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

void mergeSort(int[], int, int, int);
void merge(int[], int, int, int);

#define inf 1000000000

int R[250001],L[250001];
int cnt = 0;

int main(){
	int n;
	int S[500002];
	
	cin >> n;
	
	for(int i = 0 ; i < n ; i++){
		cin >> S[i];
	}
	
	mergeSort(S, 0, n, n);
	
	for(int i = 0 ; i < n-1 ; i++){
		cout << S[i] << " ";
	}
	cout << S[n-1] << endl;
	cout << cnt << endl;
	return 0;
}

void merge(int S[], int left, int mid, int right, int n){
	int n1, n2;
	n1 = mid - left;
	n2 = right - mid;
	
	for(int i = 0 ; i < n1 ; i++){
		L[i] = S[left + i];
	}
	
	for(int i = 0 ; i < n2 ; i++){
		R[i] = S[mid +i];
	}
	
	L[n1] = inf;
	R[n2] = inf;
	
	int i = 0;
	int j = 0;
	
	for(int k = left ; k < right ; k++){
		cnt++;
		if(L[i] <= R[j]){
			S[k] = L[i];
			i = i + 1;
		}else{
			S[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(int S[], int left, int right, int n){
	if(left + 1 < right){
		int mid = (left + right) / 2;
		mergeSort(S, left, mid, n);
		mergeSort(S, mid, right, n);
		merge(S, left, mid, right, n);
	}
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,K;cin>>N>>K;
	int cnt[N] = {};
	int a,d;
	rep(i,0,K){
		cin>>d;
		rep(j,0,d){ cin>>a; cnt[a-1]++; }
	}
	int ans = 0;
	rep(i,0,N)if(cnt[i] == 0) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>
#include<vector>

int main(){
    string S;
    cin >> S;
    long long int K;
    cin >> K;
    int res;
    int L=S.length();
    for(int i=0;i<min((long long)S.size(),K);++i){
        if(S[i]>='2'){
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << '1' <<endl;
    return 0;
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end(), std::less<>()); }
template<typename Type> inline void rsort(Type& arr) { std::sort(arr.begin(), arr.end(), std::greater<>()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    vector<ll> H(N);
    ll pre = INF_I;
    ll cur = -1;
    ll maxh = 0;
    rep(i, N)
    {
        ll h;
        cin >> h;
        // リセット
        if (pre < h)
        {
            chmax(maxh, cur);
            cur = 0;
        }
        else
        {
            ++cur;
        }
        pre = h;
    }
    chmax(maxh, cur);
    cout << maxh;
    //
    return 0;
}

Measured memory_bytes: 3528
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll ans;
    ans = ((n - (ll)1) * n) / (ll)2;
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <fstream>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

vector<ll> array2;

P bino(ll s, ll e){
  ll a = s;
  ll b = e;
  ll base = s == 0 ? 0 : array2[s-1];
  if (e - s == 1) {
    return P(array2[s] - base, array2[e] - array2[s]);
  }
  while(b - a > 1){
    ll i = (a + b) / 2;
    ll tmp = array2[e] - 2 * array2[i] + base;
    if (tmp >= 0){
      a = i;
    }else{
      b = i;
    }
  }

  if (abs(array2[e] - 2 * array2[a] + base) < abs(array2[e] - 2 * array2[b] + base)){
    return P(array2[a] - base, array2[e] - array2[a]);
  }else{
    return P(array2[b] - base, array2[e] - array2[b]);
  }
}

int main() {
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  ll n;
  cin >> n;
  vector<ll> array1(n);
  array2.resize(n);
  REP(i, n) {
    cin >> array1[i];
    if (i != 0) array2[i] = array2[i-1] + array1[i];
    else array2[i] = array1[i];
  }

  ll j = 0;
  ll l = 2;
  ll ans = 1e9 + 5;
  vector<ll> tmp(4);
  for(ll i = 1; i < n - 2; i++) {

    P p = bino(0, i);
    P q = bino(i+1, n-1);
    //if (i > 1e4)cout << i << endl;
    /*
    tmp[0] = p.first;
    tmp[1] = p.second;
    tmp[2] = q.first;
    tmp[3] = q.second;
    */
    ll big = max(max(p.first, p.second), max(q.first, q.second));
    ll small = min(min(p.first, p.second), min(q.first, q.second));
    //sort(tmp.begin(), tmp.end());
    ans = min(ans, big - small);

  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3328
N = int(input())
plan = []

for j in range(0,N):
    t,x,y = map(int,input().split())
    plan.append(t)
    plan.append(x)
    plan.append(y)

if (plan[0] < plan[1] + plan[2]) or ((plan[0] % 2) != ((plan[1] + plan[2]) % 2)):
    print("No")
    exit()

for i in range(0,N-1):
    time_dis = plan[i*3 +3] - plan[i*3]
    x_dis = abs(plan[i*3+1] - plan[i*3+1 +3])
    y_dis = abs(plan[i*3+2] - plan[i*3+2 +3])
    
    if (time_dis < x_dis + y_dis) or ((time_dis % 2) != ((x_dis + y_dis) % 2)):
        print("No")
        exit()
        
print("Yes")


Measured memory_bytes: 11816
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,j,n,m,a[101][101],b[101],x,c[101];
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)	{
		for(j=1;j<=m;j++)	{
			scanf("%d",&a[i][j]);
		}
	}
	for(j=1;j<=m;j++)	scanf("%d",&b[j]);
	for(i=1;i<=n;i++)	{
		c[i]=0;
		for(j=1;j<=m;j++)	{
			c[i]+=a[i][j]*b[j];
		}
	}
	for(i=1;i<=n;i++)	printf("%d\n",c[i]);
	return 0;
}


Measured memory_bytes: 2732
import std.stdio;
import std.string;
import std.algorithm;

void main() {
	int n;
	scanf("%d\n", &n);
	int incl, lb, ra, half;
	for(size_t i;i < n; ++i){
		auto l = readln.chomp;
		incl += l.count("AB");
		auto b = l[0] == 'B';
		auto a = l[$-1] == 'A';
		if (a) ++ra;
		if (b) ++lb;
		if ((a || b) && (a != b)) ++half;
	}
	if (min(ra,lb) > 0 && half == 0) --incl;
	write(incl + min(lb, ra));
}


Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll a[3][3],c[3][3];
	ll i,j,z;
	for(i=0;i<3;i++)
		for(j=0;j<3;j++){
			cin>>a[i][j];
			c[i][j]=0;
		}
	ll n;
	ll b[100];
	cin>>n;
	for(z=0;z<n;z++){
		cin>>b[z];
		for(i=0;i<3;i++)
			for(j=0;j<3;j++)
				if(b[z]==a[i][j])
					c[i][j]=1;
	}
	ll t=0;
	for(i=0;i<3;i++){
		ll f=1,ff=1;
		for(j=0;j<3;j++){
			if(c[i][j]!=1)
				f=0;
		}
		for(j=0;j<3;j++){
			if(c[j][i]!=1)
				ff=0;
		}
		if(f||ff){
			cout<<"Yes";
			t=1;
			break;
		}
	}
	if(t==1)
		return 0;
	if((c[0][0]==1&&c[1][1]==1&&c[2][2]==1)||(c[2][0]==1&&c[1][1]==1&&c[0][2]==1))
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll a;
    cin>>a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll N, M, t1, t2, t;
  vector<ll> H, ind; 
  cin >> N >> M;
  rep(i, N){
    cin >> t;
    H.push_back(t);
    ind.push_back(i);
  }
  
  /*sort(ind.begin(), ind.end(), [&H](size_t i1, size_t i2) {
        return H[i1] < H[i2];
  });*/
  
  /*rep(i, ind.size()){
    cout << ind[i] << endl;
  }*/
  
  vector<vector<ll>> G(N);
  rep(i, M){
    cin >> t1 >> t2;
    G[t1-1].push_back(t2-1);
	G[t2-1].push_back(t1-1);
  }
  
  ll mem;
  ll ans = 0;
  
  rep(i, N){
    if(G[i].size()==0){
      ans++;
      //cout << "Yes" << i << endl;
      continue;
    }
    
    mem = 0;
    rep(j, G[i].size()){
      if(H[i]<=H[G[i][j]]){
        break;
      }
      mem++;
    }
    //cout << mem << G[i].size() << endl;
    if(mem == (G[i].size())){
	    ans++;
    }
    /*for(int j=ind.size()-1; j>=0; j--){
      auto itr = find(G[i].begin(), G[i].end(), ind[j]);
      size_t index = distance(G[i].begin(), itr);
  	  if (index != G[i].size()) {
        mem = ind[j];
        break;
      }
    }
    if(H[i]>H[mem]){
      ans++;
    }*/
    
  }
  
  cout << ans << endl;
}

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

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

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

int N, pre[202], visit[202];
vi x, y[2];
set<int> adj[202];

bool oddprime(int x) {
    x = abs(x);
    if (x <= 2) return 0;
    for (int i = 2; i*i <= x; ++i) if (x % i == 0) return 0;
    return 1;
}

int calc(int flow) {
    return flow+2*((y[0].size()-flow)/2+(y[1].size()-flow)/2)+3*((y[0].size()-flow)%2);    
}

void dfs(int x) {
    visit[x] = 1;
    for (int i: adj[x]) if (!visit[i]) {
        if (visit[201]) break;
        pre[i] = x;
        dfs(i);
    }
}

void backtrack(int x) {
    if (x == 0) return;
    int x1 = pre[x];
    adj[x1].erase(x);
    adj[x].insert(x1);
    backtrack(x1);
}

int main() {
    cin >> N; x.resize(N); 
    F0R(i,N) cin >> x[i];
    F0R(i,N) {
        if (i == 0 || x[i-1]+1 != x[i]) y[(x[i]-1)%2].pb(x[i]-1);
        if (i == N-1 || x[i]+1 != x[i+1]) y[x[i]%2].pb(x[i]);
    }
    
    F0R(i,y[0].size()) adj[0].insert(i+1);
    F0R(i,y[1].size()) adj[i+y[0].size()+1].insert(201);
    F0R(i,y[0].size()) F0R(j,y[1].size()) 
        if (oddprime(y[0][i]-y[1][j])) adj[i+1].insert(j+1+y[0].size());
        
    int flow = 0;
    while (1) {
        memset(visit,0,sizeof visit);
        dfs(0);
        if (!visit[201]) {
            cout << calc(flow);
            return 0;
        }
        flow++;
        backtrack(201);
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

ll N,M,Q;
ll ma;
vector<vector<ll>> vec;
vector<ll> x;

void  judge(ll index ,ll value) {
   if(index==N) {
ll point=0;
    for(ll i=0;i<Q;i++) {
      if(x[vec[i][1]-1]-x[vec[i][0]-1]==vec[i][2]) {
point+=vec[i][3];
      }
    }
 ma=max(ma,point);
    return;
  }
  ll i=0;
 
  while(i+value<=M) {
    x[index]=i+value;
   
    judge(index+1,i+value);
  i++;
}
return;
}
  

 
int main() {
  cin>>N>>M>>Q;
ma=0;
  x=vector<ll>(N,0);
  vec=vector<vector<ll>>(Q,vector<ll>(4));
for(ll i=0;i<Q;i++) {
for(ll j=0;j<4;j++) {
cin>>vec[i][j];
}
}
  judge(0,1);
  cout<<ma<<endl;
  

}

              
              
              
              
              
              
              


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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e18+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');
    cerr.write(names, name-names) << " = " << arg1 << endl;
    _F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}


void solve(){
    int n, w;
    cin >> n >> w;
    int dp[n+1][w+1];
    int W[n+1], V[n+1];
    for(int i = 1; i <= n; i++){
        cin >> W[i] >> V[i];
    }
    memset(dp, 0, sizeof(dp));
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= w; j++){
            dp[i][j] = dp[i-1][j];
            if(j >= W[i])
                dp[i][j] = max(dp[i][j], dp[i-1][j-W[i]]+V[i]);
        }
        //cout << dp[i][n] << endl;
    }
    cout << dp[n][w] << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(12);

   // #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);
    //#endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 79232
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		double x[]=new double[3];
		double y[]=new double[3];
		double xp,yp;
		while(in.hasNextDouble()){
			for(int i=0;i<3;i++){
				x[i]=in.nextDouble();
				y[i]=in.nextDouble();
			}
			xp=in.nextDouble();
			yp=in.nextDouble();
			boolean left=false;
			boolean right=false;
			for(int i=0;i<3;i++){
				int a=i%3,b=(i+1)%3;
				double xx=x[a]-x[b];
				double yy=y[a]-y[b];
				double px=xp-x[a];
				double py=yp-y[a];
				left|=(xx*py<yy*px);
				right|=(xx*py>yy*px);
			}
			if(left&right)
				System.out.println("NO");
			else
				System.out.println("YES");
		}
		in.close();
	}
}

Measured memory_bytes: 30776
#XXOR
n,k=map(int,input().split())
a=list(map(int,input().split()))
data0=[0]*40
data1=[0]*40
for u in a:
    for j in range(40):
        if (u>>j)&1==1:
            data1[j]+=1
        else:
            data0[j]+=1
data=[]
for i in range(40):
    if data0[i]-data1[i]>0:
        data.append([(data0[i]-data1[i])*(2**i),i])
data.sort(reverse=True)
lst=[]
for i in range(40):
    if data1[i]<data0[i]:
        lst.append(i)
m=len(lst)
dp=[[]]
x=0
for h in data:
    i=h[0]
    j=h[1]
    if x+2**j<=k:
        x+=2**j
ans=0
for u in a:
    ans+=x^u
print(ans)

Measured memory_bytes: 14620
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    int m = 1e9;
    while (t--) {
        int x;
        cin >> x;
        int a, b;
        cin >> a >> b;
        if (b / x - (a-1) / x > 0) {
            cout << "OK\n";
        }
        else
            cout << "NG\n";
    }
    return 0;
}


Measured memory_bytes: 3560
R, G, B, N = map(int, input().split())
r = N//R
ans = 0
for i in range(r + 1):
  g = (N - i*R)//G
  for j in range(g + 1):
    if (N - i*R - j*G) % B == 0:
      ans += 1
print(ans)

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

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

    if (H >= W){
        if (N % H == 0) cout << N / H << endl;
        else cout << N / H + 1<< endl;
    }else{
        if (N % W == 0) cout << N / W << endl;
        else cout << N / W + 1<< endl;
    }

//    printf("%c\n", C+1);

  
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        if (A * B <= C * D) {
            System.out.println(C * D);
        } else {
            System.out.println(A * B);
        }
    }
}

Measured memory_bytes: 21844
N = int(input())

s = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        s[i].append((x - 1, y))

result = 0
for i in range(1, 2 ** N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in s[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)


Measured memory_bytes: 3064
from collections import defaultdict as dd
from collections import deque
N = int(input())
D =dd(list)
for i in range(N-1):
  a, b, c = map(int, input().split())
  D[a-1].append((b-1, c))
  D[b-1].append((a-1, c))

Q, K = map(int, input().split())
K -= 1
L = [0 for _ in range(N)]
q = deque([])
q.append(K)
while len(q) > 0:
  a = q.pop()
  for b, c in D[a]:
    if L[b] == 0:
      L[b] = L[a] + c
      q.append(b)

for i in range(Q):
  x, y = map(int, input().split())
  print (L[x-1] + L[y-1])


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

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

	vector<string> ai(H);
	for (int i = 0; i < H; i++) {
		cin >> ai.at(i);
	}
	string dummy = "##";
	for (int j = 0; j < W; j++) {
		dummy += '#';
	}
	cout << dummy << endl;
	for (int i = 0; i < H; i++) {
		cout << '#' << ai.at(i) << '#' << endl;
	}
	cout << dummy << endl;
}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
XYs = readlines.map{|l| l.split.map(&:to_i)}

xs, ys = XYs.transpose.map(&:sort)
c = Array.new(N + 1){Array.new(N + 1, 0)}
[*0 ... N].repeated_permutation(2) do |i, j|
  c[i + 1][j + 1] = XYs.count{|x, y| x <= xs[i] && y <= ys[j]}
end
ans = 1e20.to_i
[*[*0 ... N].combination(2)].repeated_permutation(2) do |(i1, i2), (j1, j2)|
  next unless c[i2 + 1][j2 + 1] - c[i2 + 1][j1] - c[i1][j2 + 1] + c[i1][j1] >= K
  s = (xs[i2] - xs[i1]) * (ys[j2] - ys[j1])
  ans = s if s < ans
end
puts ans

Measured memory_bytes: 3836
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
#include<time.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ")
#define pdd(a,n,m)for(int i=0;i<m;i++)pd(a,m)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
int a[11111];

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

  rep(i,n){
    if(a[i]%2==0)
    if(a[i]%3!=0&&a[i]%5!=0){
      cout<<"DENIED"<<endl;
      return 0;
    }
  }

  cout<<"APPROVED"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import os

OK = 'APPROVED'
NG = 'DENIED'


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C, D = list(map(int, sys.stdin.buffer.readline().split()))

    print('Yes' if abs(A - B) <= D and abs(B - C) <= D or abs(A - C) <= D else 'No')


if __name__ == '__main__':
    main()


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

ll length(ll n) {
  if (n == 0) {
    return 0;
  }
  ll k = 1, d = 1;
  while (10 * k <= n) {
    k *= 10;
    d++;
  }
  k--;
  ll n3 = n / 3 - k / 3;
  ll n5 = n / 5 - k / 5;
  ll n15 = n / 15 - k / 15;
  return length(k) + 4 * (n3 + n5) + d * (n - k - n3 - n5 + n15);
}

int main() {
  ll s;
  cin >> s;

  ll ok = 1, ng = 1e17, m;
  while (ng - ok > 1) {
    m = (ok + ng) / 2;
    ll l = length(m - 1);
    if (l <= s - 1) {
      ok = m;
    } else {
      ng = m;
    }
  }

  string r;
  for (ll i = ok; r.size() < 100; i++) {
    if (i % 15 == 0) {
      r += "FizzBuzz";
    } else if (i % 3 == 0) {
      r += "Fizz";
    } else if (i % 5 == 0) {
      r += "Buzz";
    } else {
      r += to_string(i);
    }
  }
  cout << r.substr(s - 1 - length(ok - 1), 20) << endl;
}



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

using namespace std;

#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int N = 1e5+5;

int arr[N][3],dp[N][3];
int n;

int f(int ind,int key){
    if(ind==n)
        return dp[ind][key]=0;
    if(key>=0 && dp[ind][key]!=-1){
        return dp[ind][key];
    }
    int ans = 0;
    if(key==0){
        dp[ind][0] = max(arr[ind][1]+f(ind+1,1),arr[ind][2]+f(ind+1,2));
        ans = max(ans,dp[ind][0]);
    }
    else if(key==1){
        dp[ind][1] = max(arr[ind][0]+f(ind+1,0),arr[ind][2]+f(ind+1,2));
        ans = max(ans,dp[ind][1]);
    }
    else if(key==2){
        dp[ind][2] = max(arr[ind][1]+f(ind+1,1),arr[ind][0]+f(ind+1,0));
        ans = max(ans,dp[ind][2]);
    }
    return ans;
}


void solve(){
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin>>arr[i][j],dp[i][j]=-1;
    cout<<max(max(f(0,0),f(0,1)),f(0,2))<<endl;
}

int main()
{
    FASTIO
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}




Measured memory_bytes: 12208
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    ll len,sum = 0;
    for(ll i=1;i<13;i++){
        if(sum <= n && n <= sum + pow(26,i)){
            len = i;
            break;
        }
        sum += pow(26,i);
    }

    string ans;
    for(ll i=0;i<len;i++){
        char a = 'a' + (n-1)%26;
        ans.push_back(a);
        n = (n-1)/26;
    }

    for(ll i=len-1;i>=0;i--) cout<<ans[i];
    cout<<endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include<string>
#include<cstdio>
#include<string.h>
#include<vector>
#include<cmath>
using namespace std;
const int N=110;

int main ()
{
    int k;
    cin>>k;
    int ret=1;
    if(k%2==0){
        cout<<"-1"<<endl;
    }
    else{
        int a=7;
        int p=0;
        for(;ret<8000000;ret++){
            if(a%k==0){
                p=1;
                break;
            }
            else{
                a%=k;
                a=a*10+7;
            }
        }
        if(p){
            cout<<ret<<endl;
        }
        else{
            cout<<"-1"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int n;
string s;

int main() {
	cin >> n;
	map<string, int> x{};
	rep(i, n) {
		cin >> s;
		x[s]++;
	}

	int MAX = -1;
	for (auto i : x) {
		int y = i.second;
		if (y > MAX) {
			MAX = y;
		}
	}

	//map型はfirstでKeyを、secondで値を取得できる
	//itrはx.begin()からx.end()でxのイテレータを取得している
	//イテレータであるitrを操作するためには->(アロー演算子)を使う
	for (auto itr = x.begin(); itr != x.end(); itr++) {
		if (itr->second == MAX) {	
			cout << itr->first << endl;
		}
	}

	return 0;
}

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

int main(){
    int n,a[200000]={0};
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a[i];
    }
    int b[200000]={0};
    
    for(int i=0;i<n-1;i++){
        b[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<b[i]<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;cin>>n>>k;
    vector<pair<long long, long long > >nos(n);
    long long a,b;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        nos[i]=make_pair(a,b);
    }
    sort(nos.begin(),nos.end());
    int i=0;
    while(k!=0){
        if(k<=nos[i].second){cout<<nos[i].first;break;}
        k-=nos[i].second;
        i++;
    }
}

Measured memory_bytes: 4792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  string S;
  cin >> S;
  int ans = 0;

  if(S == "RRR") ans = 3;
  else if(S == "RRS" || S == "SRR") ans = 2;
  else if (S == "RSS" || S == "SRS" || S == "SSR" || S == "RSR") ans = 1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    vector<string> S;
    void input() {
        cin >> N;
        S.resize(N);
        REP(i, N) {
            cin >> S[i];
        }
    }
    void output() {
        ll res = 0;
        REP(b, N) {
            bool ok = true;
            REP(i, N) {
                REP(j, N) {
                    if (S[i][(j + b) % N] != S[j][(i + b) % N]) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) break;
            }
            if (ok) res += N;
        }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3720
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    h, w = LI()
    ch, cw = LI_()
    dh, dw = LI_()
    s = [None] * h
    c = [None] * h
    for i in range(h):
        s[i] = S()
        c[i] = [inf] * w
    q = deque()
    q.append((ch, cw))
    c[ch][cw] = 0
    nq = deque()
    mv = [(0, 1), (1, 0), (-1, 0), (0, -1)]
    mij = [(i, j) for i in range(-2, 3) for j in range(-2, 3)]
    while 1:
        while q:
            nh, nw = q.popleft()
            now = c[nh][nw]
            nq.append((nh, nw))
            for mh, mw in mv:
                mh += nh
                mw += nw
                if 0 <= mh < h and 0 <= mw < w and c[mh][mw] > now and s[mh][mw] == ".":
                    c[mh][mw] = now
                    q.appendleft((mh, mw))
        while nq:
            nh, nw = nq.popleft()
            now = c[nh][nw]
            for mi, mj in mij:
                mi += nh
                mj += nw
                if 0 <= mi < h and 0 <= mj < w and c[mi][mj] > now + 1 and s[mi][mj] == ".":
                    c[mi][mj] = now + 1
                    q.append((mi, mj))
        if len(q) == 0:
            break
    print(-1 if c[dh][dw] == inf else c[dh][dw])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 102108
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
} 
const int N = 1e6 + 100;
const ll mod = 998244353;
const ll mod2 = 1e9 + 7;
 
ll mul(ll a, ll b) {
	return (a * b) % mod;
}
ll binpow (ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)
			res *= a;
		a *= a;
		n >>= 1;
		res %= mod;
		a %= mod;
	}
	return res;
}
ll kol[N];
int main () 
{
    data();      
	int n;
	cin >> n;
	int a[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		kol[a[i]]++;
	}
	if (kol[0] != 1 || a[1])
	{
		cout << 0;
		return 0;
	}
	while (kol[n] == 0)
	{
		n--;
	}
	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= kol[i + 1]; j++)
		{
			ans = mul(ans, kol[i]);
		}	
	//	cout << ans << '\n';
	}
	cout << ans;
}
//Timus:295965SY              

Measured memory_bytes: 4716
#include <iostream>

using namespace std;

int const NMAX = 1e6;

bool ciur[1 + NMAX];

void computeCiur(){
  for(long long i = 2;i * i <= NMAX;i++){
    if(ciur[i] == 0){
      for(long long j = i * i;j <= NMAX;j+=i){
        ciur[j] = 1;
      }
    }
  }
}

int main() {

  int n;
  cin >> n;
  computeCiur();
  while(ciur[n] == 1){
    n++;
  }
  cout << n;
  return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int n, x;
	cin >> n >> x;
	if (n < x)
		puts("0");
	else
		cout << n - x << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

m,d = map(int,stdin.readline().rstrip().split())
day = 0
for s in range(1,m+1):
    for i in range(1,d+1):
        if i > 9:
            k = str(i)
            ten = int(k[0])
            one = int(k[1])
            if ten>1 and one>1:
                if ten*one == s:
                    day += 1
print(day)

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

int main(){
  int M, D;
  cin >> M >> D;
  int ans = 0;
  for(int i = 1; i <= M; ++i){
    for(int j = 1; j <= D; ++j){
      int d1 = j%10, d2 = j/10;
      if(d1 >= 2 and d2 >= 2 and d1*d2 == i)
        ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
しゃくとり法
・前にやったのとか参考にして自力実装
"""
 
N = int(input())
aN = list(map(int, input().split()))

l,r,ans = 0,0,0
sm = xor = 0
# 外ループで左を動かす
while l < N:
    # 内ループは条件を満たす限り右を動かす
    while r < N and sm + aN[r] == xor ^ aN[r]:
        sm += aN[r]
        xor ^= aN[r]
        r += 1
    # 左右の差分が、今の左位置からうまくいった合計になる
    ans += r - l
    # ※今回はl==rの時whileの条件を確実に満たすので、
    # 　ここでl==rになることはなく、このif文は本当は必要ないはず。
    if l == r:
        # 左が右に追いついたら、右も左に合わせて+1する
        r += 1
    else:
        # 左を動かす分、合計から引く
        sm -= aN[l]
        xor ^= aN[l]
    l += 1
print(ans)


Measured memory_bytes: 24840
#include<iostream>
using namespace std;
int main (){
	int j,k,H,W;
	while(1){
		cin>>H>>W;

		for(j=1;j<=H;j++){

			for(k=1;k<=W;k++){

				if((j+k)%2==0){
					cout<<"#";
				}
				else{
					cout<<".";
				}
			}
			cout<<endl;



		}    if(H==0&&W==0){
			break;
		}cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
#define mod 100003
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define piiii pair<int,piii>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define no {cout<<"REBEL"<<endl;return;}
#define yes {cout<<"OBEY"<<endl;return;}
#define exit_now {cout<<-1<<endl;return;}




void solve(){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0) x*=-1;
    if(x==0){
        cout<<(k%2)*d;
        return;
    }
    else{
        ll m=x/d;
        if(m>=k){
            cout<<x-k*d;
        }
        else{
            x-=m*d;
            k-=m;
            if(k%2) cout<<min(abs(x-d),abs(x+d));
            else cout<<x;

        }
    }




    return;
}
int main(){
    IO
    //TEST
    solve();

    return(0);
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<ll> A(N); cin >> A;
        vector<pair<ll, ll>> BC(M); rep(i, M) cin >> BC[i].second >> BC[i].first;
        sort(all(BC));
        reverse(all(BC));
        sort(all(A));
        int pos = 0;
        rep(i, M) {
            rep(j, BC[i].second) {
                if(pos < N and A[pos] < BC[i].first) A[pos++] = BC[i].first;
                else goto FAA;
            }
        }
  FAA:
        cout << accumulate(all(A), 0ll) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 2560
n = gets.to_i
i = 1
while i <= n
	x = i
	if x % 3 == 0
		print( " #{i}" )
	else
		while x != 0
			if x % 10 == 3
				print( " #{i}" )
				break
			else
				x /= 10
			end
		end
	end
	i += 1
end
print( "\n" )

Measured memory_bytes: 6092
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int[][] a = new int[C][100000];
		for (int i = 0; i < N; ++i) {
			int s = sc.nextInt() - 1;
			int t = sc.nextInt() - 1;
			int c = sc.nextInt() - 1;
			for (int j = s; j <= t; ++j)
				if (a[c][j] == 0)
					a[c][j]++;
		}

		int ans = 0;
		for (int i = 0; i < 100000; ++i) {
			int tmp = 0;
			for (int j = 0; j < C; ++j) {
				tmp += a[j][i];
			}
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 109352
def play(S, i):
    if S[i] == "L": return i - 1
    else: return i + 1

def solve():
    S = input()
    N = len(S)
    move = 10 ** 100
    
    leftL, rightR = [N-1] * N, [0] * N
    for i in range(1, N):
        if S[i] == "R": rightR[i] = i
        else: rightR[i] = rightR[i-1]
        if S[N-i-1] == "L": leftL[N-i-1] = N-i-1
        else: leftL[N-i-1] = leftL[N-i]

    #print(leftL)
    #print(rightR)
    count =[0] * N

    for i in range(N):
        if S[i] == "R":
            moved = leftL[i] - i
            #print(moved)
            if moved % 2 == 0: count[leftL[i]] += 1
            else: count[leftL[i] - 1] += 1
        else:
            moved = i - rightR[i]
            #print(moved)
            if moved % 2 == 0: count[rightR[i]] += 1
            else: count[rightR[i] + 1] += 1

    print(" ".join(map(str, count)))
    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 15276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
      
      long n = Integer.parseInt(in.readLine());

      long p,q;
      for(long x=1; x<3501; x++) {
        for(long y=1; y<3501; y++) {
          p = ((x*y)<<2) - n*x - n*y;
          q = n*x*y;
          if(p > 0 && q % p == 0) {
            System.out.println(x + " " + y + " " + q/p);
            return;
          }
        }
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - (x + y);
            if (z >= 0 && z <= k) ans++;
        }
    }

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


Measured memory_bytes: 3604
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))

struct node {
	int id;
	int state;
	bool done;
	vector<int> to;
};
int N,M;
vector<node> nod;
int dfs(int ind, int dep = 1) {
	if (dep == 1) {
		nod[ind].state = 1;
		++dep;
	}

	nod[ind].done = true;
	int hon = -1;
	for (int c : nod[ind].to) {
		if (nod[c].state > 0) MAXS(hon, nod[c].state);
		else if (nod[c].state == 0) nod[c].state = -dep;
	}
	if (hon != -1) return hon;
	for (int c : nod[ind].to) {
		if (nod[c].state != -dep)continue;
		nod[c].state = dep;
		int ret = dfs(c, dep + 1);
		if (ret != -1)return ret;
		nod[c].state = -dep;
	}

	for (int c : nod[ind].to) {
		if (nod[c].state == -dep) nod[c].state = 0;
	}

	if (dep == 2) {
		nod[ind].state = 0;
	}
	return -1;
}
int main() {
	cin >> N >> M;
	if (N == 1) {
		PRI(-1);
		return 0;
	}
	nod.resize(N);
	REP(i, 0, N) {
		nod[i].id = i+1;
		nod[i].state = 0;
		nod[i].done = false;
	}
	REP(i, 0, M) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		nod[a].to.push_back(b);
	}
	int ret;
	REP(i, 0, N) {
		if (!nod[i].done) {
			ret = dfs(i);
			if (ret != -1) break;
		}
	}
	if (ret == -1) {
		PRI(-1);
		return 0;
	}
	vector<int> ans;
	REP(i, 0, N) {
		if (nod[i].state >= ret)ans.push_back(nod[i].id);
	}
	PRI(ans.size());
	for (int i : ans)PRI(i);
	return 0;
}




Measured memory_bytes: 3732
#include<stdio.h>
int main(){
    long long n, count = 0;
    scanf("%lld",&n);
    if(n % 2 == 1)
        puts("0");
    else{
        long long d = 2;
        for(long long i = 1; (d * 5) <= n; i++){
            d *= 5;
            count += n / d;
        }
        printf("%lld\n",count);
    }
    return 0;
}

Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

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

n, k = na()
if n % k == 0:
    print(0)
else:
    print(min(abs((n//k)*k - n), abs((n//k + 1)*k - n)))


Measured memory_bytes: 6692
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>
using namespace std;
#define LL long long
const int maxn = 1e6+33;
const int mod = 1e9+7;

int main()
{
    int a[4];
    for(int i=1;i<=3;i++)
        scanf("%d",&a[i]);
    int ans=123123;
    do
    {
        ans=min(ans,abs(a[3]-a[2])+abs(a[1]-a[2]));
    }while(next_permutation(a+1,a+1+3));
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
p=list(s[0])[0]
from collections import Counter
c=Counter(s)
if [1 for i in range(n)]!=list(c.values()):
    print("No")
    exit()
else:
    for i in s:
        a=list(i)[0]
        b=list(i)[-1]
        if p==a:
            p=b
        else:
            print("No")
            exit()
print("Yes")
        

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> m{};
	map<int, int>::iterator itr;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		itr = m.find(A[i]);
		if (itr != m.end()) {
			m[A[i]] += 1;
		}
		else {
			m[A[i]] = 1;
		}
	}
	
	map<int, int> check{};
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int ter = A[i];
		itr = check.find(ter);
		if (itr != check.end()) {
			continue;
		}
		else {
			check[ter] = 1;
			int val = m[ter];
			if (val < ter) {
				ans += val;
			}
			else {
				ans += val - ter;
			}
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 9728