akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long ans=0;
    for(long long i=2;i*i<=n;i++) {
        if(n%i!=0)
        	continue;
        long long num=0;
        while(n%i==0){
            n/=i;
            num++;
        }
        for(long long j=1;;j++){
            if(num>=j){
                num-=j;
                ans++;
            }
        	else
            	break;
        }
    }
    if(n!=1)
    	ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll b[n];
    for(i=0;i<n-1;i++){
        cin>>b[i];
    }
    ll ans=0;
    for(i=0;i<n;i++){
        if(i==0) ans+=b[i];
        else if(i==n-1) ans+=b[i-1];
        else ans+=min(b[i],b[i-1]);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 0
for j in range(n + 1):
    ass = []
    for i in range(1, int(j**0.5)+1):
        if j % i == 0:
            ass.append(i)
            if i**2 == j:
                continue
            ass.append(j//i)
    if j % 2 == 1 and len(ass) == 8:
        ans += 1
print(ans)

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 1; i < n; ++i) {
        vector<int> a(26), b(26);
        for(int j = 0; j < i; ++j) {
            a[s[j] - 'a']++;
        }
        for(int j = i; j < n; ++j) {
            b[s[j] - 'a']++;
        }
        int tmp = 0;
        for(int j = 0; j < 26; ++j) {
            tmp += a[j] > 0 && b[j] > 0;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    string s;cin>>s;
    rep(i,2){
        if(s.at(i)=='9'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


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

using namespace std;

#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int, int>

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

  long long x, k, d;
  cin >> x >> k >> d;
  if (x < 0) x *= -1;
  if (x / d >= k) {
    cout << x - k * d << "\n";
    return 0;
  }
  k -= x / d;
  x %= d;
  if (k % 2 == 0)
    cout << x << "\n";
  else
    cout << (long long)abs(x - d) << "\n";

  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int a,b;
	int ta,tb;

	while (cin >> n) {
		if (n == 0) {
			break;
		}
		ta = 0;
		tb = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			if (a > b) {
				ta += (a + b);
			} else if (a < b) {
				tb += (a + b);
			}else {
				ta += a;
				tb += b;
			}
		}
		cout << ta << " " << tb << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from bisect import bisect
mod = 10**9+7
n,k = map(int,input().split())
*a,= map(int,input().split())
b = []
ans = 0
for j,x in enumerate(a):
	i = bisect(b,x)
	ans += (j-i)*k
	b.insert(i,x)
a.sort(reverse=True)
bef = a[-1]
j=0
for i,cur in enumerate(a):
	if cur==bef:
		ans += k*(k-1)*j//2
	else:
		ans += k*(k-1)*i//2
		j = i
		bef = cur
print(ans%mod)

Measured memory_bytes: 40944
// Created by  Ambesh kumar
#include "bits/stdc++.h"

#define  ll  long long  
# define  loop(x,n)  for(int x = 0; x < n; ++x)  
#define   constloop(x,a,n) for(int x = a; x < n; ++x)  
#define  revloop(x,a,n)  for(int x = a; x > n; x--) 

using namespace std;

int main()
{

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


    ios::sync_with_stdio(0);
    cin.tie(0);
        int n,k;
        cin>>n>>k;
        set<int> s;
        
        loop(i,k)
       {

        int d;
        cin>>d;
       	loop(j,d)
       	{
         int p;
         cin>>p;
         s.insert(p);

       } 
       }




 int res=n-s.size();
   cout<<res<<"\n";

        
    return 0;
}

Measured memory_bytes: 3668
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod;
int n;
ll dp[5001][5001];
ll dp2[5001][5001];
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> mod;
	dp[0][0]=dp2[0][0]=1;
	for(int i=(n-1)/2 ;i>=1 ;i--){
		for(int k=1; i*k<=n ;k++){
			for(int j=i; j<=n ;j++){
				dp2[k][j]+=dp2[k-1][j-i];
				if(dp2[k][j]>=mod) dp2[k][j]-=mod;
			}
		}
	}
	for(int j=0; j<=n ;j++){
		for(int k=j; k<=n ;k++){
			swap(dp2[j][k],dp2[k][j]);
		}
	}
	if(n%2==0){
		for(int j=0; j<=n ;j++){
			for(int k=0; k<=n ;k++){
				dp[j][k]=dp2[j][k];
			}
		}
		for(int j=n/2; j<=n ;j++){
			for(int k=1; k<=n ;k++){
				dp[j][k]+=dp[j-(n/2)][k-1];
				if(dp[j][k]>=mod) dp[j][k]-=mod;
			}
		}
	}
	else{
		for(int j=0; j<=n ;j++){
			for(int k=0; k<=n ;k++){
				dp[j][k]=dp2[j][k];
			}
		}
	}
	for(int j=0; j<=n ;j++){
		for(int k=1; k<=n ;k++){
			dp[j][k]=(dp[j][k]+dp[j][k-1]);
			dp2[j][k]=(dp2[j][k]+dp2[j][k-1]);
			if(dp[j][k]>=mod) dp[j][k]-=mod;
			if(dp2[j][k]>=mod) dp2[j][k]-=mod;
		}
	}
	for(int k=0; k<=n ;k++){
		for(int j=1; j<=n ;j++){
			dp2[j][k]=(dp2[j][k]+dp2[j-1][k]);
			if(dp2[j][k]>=mod) dp2[j][k]-=mod;
		}
	}
	ll ans=0;
	for(int i=1; i<=n ;i++){//mid = n
		for(int j=0; j<i ;j++){//lhs sum = i
			ans=(ans+dp[j][i-1]*dp2[i-j-1][n-i])%mod;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 391040
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 100000;
const int INF = int(1E9);
int arr[MAXN + 5], sum[MAXN + 5], temp[MAXN + 5];
long long tot1 = 0, tot2 = 0;
int N;
void MergeSort(int le, int ri) {
    if( le == ri ) return ;
    int mid = (le + ri) >> 1;
    MergeSort(le, mid);
    MergeSort(mid+1, ri);
    int p = le, q = mid+1, r = le;
    while( p <= mid && q <= ri ) {
        if( sum[p] < sum[q] ) {
            temp[r++] = sum[p++];
        }
        else {
            tot1 += (p-le);
            temp[r++] = sum[q++];
        }
    }
    while( p <= mid ) {
        temp[r++] = sum[p++];
    }
    while( q <= ri ) {
        tot1 += (p-le);
        temp[r++] = sum[q++];
    }
    for(int i=le;i<=ri;i++)
        sum[i] = temp[i];
}
bool Check(int x) {
    tot1 = 0;
    for(int i=1;i<=N;i++)
        sum[i] = (arr[i] <= x ? 1 : -1);
    for(int i=1;i<=N;i++)
        sum[i] += sum[i-1];
   // for(int i=1;i<=N;++i) printf("%d ",sum[i]);
  //  puts("");
    MergeSort(0, N);
 /*   for(int i=1;i<=N;++i) printf("%d ",sum[i]);
 	printf("\n%d %lld %lld\n",x,tot1,tot2);*/
    return tot1 >= (tot2/2 + 1);
}
int main() {
    int le = INF, ri = -INF;
    scanf("%d", &N);
    for(int i=1;i<=N;i++) { 
        scanf("%d", &arr[i]);
        le = min(le, arr[i]);
        ri = max(ri, arr[i]);
        tot2 += i;
    }
    while( le < ri ) {
        int mid = (le + ri) >> 1;
        if( Check(mid) ) ri = mid;
        else le = mid + 1;
    }
    printf("%d\n", ri);
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
	public static void main(String[] args) {	
		Integer a[] = new Integer[5];
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a, Collections.reverseOrder());
		System.out.print(a[0]);
		for(int i = 1; i < 5; i++) {
			System.out.printf(" %d", a[i]);
		}
		System.out.println();
	}
}

Measured memory_bytes: 17184
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
      
        String S = sc.next();
        int count = 0;
        
        for(int i = 0; i < 4; i++){
            if(S.charAt(i) == '+') count++;
            if(S.charAt(i) == '-') count--;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23764
while True:
    n=input()
    if n=='END OF INPUT':
        break
    
    n=list(n)
    m=[]
    sum=0
    for i in range(len(n)):
        if n[i]==' ':
            m.append(sum)
            sum=0
        else:
            sum+=1
    print(*m,sum,sep='')


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n,x,y;
    cin>>n>>x>>y;
    x--,y--;
    vector<int> ans(n);
    rep(sv,n){
        vector<int> dist(n,INF);
        queue<int> q;
        auto push=[&](int v,int d){
            if(dist[v]!=INF) return;
            dist[v]=d;
            q.push(v);
        };
        push(sv,0);
        while(!q.empty()){
            int v=q.front();q.pop();
            int d=dist[v];
            if(v-1>=0) push(v-1,d+1);
            if(v+1<n) push(v+1,d+1);
            if(v==x) push(y,d+1);
            if(v==y) push(x,d+1);
        }
        rep(i,n) ans[dist[i]]++;
    }
    rep(i,n) ans[i]/=2;
    for(int i=1;i<n;i++) cout<<ans[i]<<endl;
}

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

int main(){
  int h, w;
  string s[50];
  cin >> h >> w;

  for(int i=0; i<h; ++i) cin >> s[i];
  
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1,};
  for(int i=0; i<h; ++i){ 
    for(int j=0; j<w; ++j){
      if(s[i][j] == '#') continue;

      int num = 0;
      for(int d=0; d<8; ++d){
        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if(ni<0 or h<=ni) continue;
        if(nj<0 or w<=nj) continue;
        if(s[ni][nj] == '#') num++;
      }
      s[i][j] = char(num + '0');
    }
  }

  for(int i=0; i<h; ++i) cout << s[i] << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B; string S;
  cin >> A >> B >> S;
  int N= A+1;
  int M= A+B+1;
  bool ans=true;
  
  for(int i=0; i<A; i++) {
    if(S[i]=='-') ans =false;
  }
  for(int i=N; i<M; i++) {
    if(S[i]=='-') ans =false;
  }
  if(S[A]!='-') ans=false;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

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

typedef long long ll;

map<ll, ll> prime_facto(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            n /= i;
            res[i]++;
        }
    }

    if (n != 1)
    {
        res[n] = 1;
    }

    return res;
}

void solve1()
{
    ll n, p;
    cin >> n >> p;

    map<ll, ll> num;
    num = prime_facto(p);

    ll maxnum = 1;
    for (auto itr = num.begin(); itr != num.end(); itr++)
    {
        if (itr->second >= n)
        {
            maxnum *= pow(itr->first, (itr->second / n));
        }
    }

    cout << maxnum << endl;
}

int main()
{
    solve1();
}


Measured memory_bytes: 3980
<?php
fscanf(STDIN, "%d", $N);
$a = array_map('intval', explode(" ", trim(fgets(STDIN))));

$c = $a[0];
for ($i = 1; $i < $N; $i++) {
    $c ^= $a[$i];
}

echo $c === 0 ? 'Yes' : 'No';


Measured memory_bytes: 16884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    string s; cin >> s;
    int n = s.size();
    vector<int> a(n,0);
    int odd = 0,even = 0;
    int through = 0;
    //Rを見ていく
    for(int i = 0; i < n; i++){
        if(s[i] == 'L' && through == 0){
            if(i % 2){
                a[i] += odd;
                a[i-1] += even;
            }else{
                a[i] += even;
                a[i-1] += odd;
            }
            odd = 0;
            even = 0;
            through = 1;
        }else if(s[i] == 'L' && through == 1){
            continue;
        }else{
            if(i%2) odd++;
            else even++;
            through = 0;
        }
    }

    //Lを見ていく
    odd = 0;
    even = 0;
    for(int i = n-1; i >= 0; i--){
        if(s[i] == 'R' && through == 0){
            if(i % 2){
                a[i] += odd;
                a[i+1] += even;
            }else{
                a[i] += even;
                a[i+1] += odd;
            }
            odd = 0;
            even = 0;
            through = 1;
        }else if(s[i] == 'R' && through == 1){
            continue;
        }else{
            if(i%2) odd++;
            else even++;
            through = 0;
        }
    }
    rep(i,n) cout << a[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem0560 : Planetary Exploration **/
typedef vector<int> v;
int main()
{
	int M, N, K;
	cin>>M>>N>>K;
	vector<string> field(M);
	rep(i, M) cin>>field[i];
	
	vector<v> j(N+1, v(M+1)), o(N+1, v(M+1)), i(N+1, v(M+1));
	for (int y=1; y<M+1; y++) {
		for (int x=1; x<N+1; x++) {
			j[x][y] = j[x-1][y] + j[x][y-1] - j[x-1][y-1] + (field[y-1][x-1]=='J'?1:0);
			o[x][y] = o[x-1][y] + o[x][y-1] - o[x-1][y-1] + (field[y-1][x-1]=='O'?1:0);
			i[x][y] = i[x-1][y] + i[x][y-1] - i[x-1][y-1] + (field[y-1][x-1]=='I'?1:0);
		}
	}
	
	for (int k=0; k<K; k++) {
		int a, b, c, d; cin>>b>>a>>d>>c;
		cout << j[c][d] - j[a-1][d] - j[c][b-1] + j[a-1][b-1] << " ";
		cout << o[c][d] - o[a-1][d] - o[c][b-1] + o[a-1][b-1] << " ";
		cout << i[c][d] - i[a-1][d] - i[c][b-1] + i[a-1][b-1] << endl;
	}
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(n, a, b);
    cout << min(a * n, b) << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
sa = sorted(a)
maxi = sa.count(sa[-1])
ans = sa[-1]
max_index = a.index(sa[-1])
if maxi == 1:
    for i in range(n):
        if i == max_index:
            print(sa[-2])
        else:
            print(ans)
else:
    for i in range(n):
        print(ans)

Measured memory_bytes: 14152
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 105;
const int maxw = 1e5+5;

int w[maxn], v[maxn];

int n, W;

ll dp[maxw];

int main()
{
	scanf("%d %d", &n, &W);
	int sum = 0;
	for(int i = 1; i<= n; i++) scanf("%d %d", &w[i], &v[i]);
	for(int i = 1; i<= n; i++) sum += v[i];
	for(int i = 1; i<= sum; i++) dp[i] = 1e9;
	for(int i = 1; i<= n; i++)
	{
		for(int j = sum; j>= v[i]; j--)
		{
			dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
		}
	}
	for(int i = sum; i>= 0; i--)
	{
		if(dp[i]<= W)
		{
			printf("%d\n", i);
			return 0;
		}
	}
}

Measured memory_bytes: 1024
T = gets.to_i
H = gets.split.map(&:to_i)

pre = 0
ans = 0

H.reverse!

1.upto(H.size - 1) do |i|
  if H[i-1] <= H[i]
    pre += 1
  else
    pre = 0
  end

  ans = [ans, pre].max
end

puts ans


Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define int             ll
#define ff              first
#define ss              second
#define pb              emplace_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define dor(i, a, b)    for(int i =(a);i<=(b);i++)
#define mem(a,val)      memset((a),(val),sizeof((a))); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
    template <typename Arg1>
     void __f(const char* name,Arg1&& arg1){
        cout<<name<<" : "<<arg1<<std::endl;
     }
     template <typename Arg1, typename... Args>
     void __f(const char* names,Arg1&& arg1,Args&&... args){
        const char* comma = strchr(names+1 ,',');
        cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
     }
#else
#define trace(...)
#endif
/*     
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
*/
double pi = 2.0*acos(0);
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}

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



void solve()
{
  int k;cin>>k;
   string s;
   cin>>s;

   int n = s.length();
   if(n<=k)
   cout<<s<<endl;
   else
   {
      cout<<s.substr(0,k)<<"..."<<endl;
   } 
}

signed main(void)
{
      fast();
      //w(t)
      solve();

}


Measured memory_bytes: 3656
input_line = [int(i) for i in input().split()]
n = input_line[0]
m = input_line[1]

input_line = [int(i) for i in input().split()]
thr = sum(input_line) / (4 * m)
input_line.sort(reverse=True)
if input_line[m - 1] < thr:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
N, Y = map(int, input().split())
res10000 =res5000 = res1000 = -1

for x in range(N+1):
    for y in range(N+1-x):
        z = N-x-y
        if 10000*x + 5000*y + 1000*z == Y:
            res10000 = x
            res5000 = y
            res1000 = z

print(res10000, res5000, res1000)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


#define H 0
#define V 1


bool feasible(const int x, const std::vector<int>& a)
{
  if (a.empty())
    return x == 0;
  
  bool dp[2][20000], *curr = dp[0], *next = dp[1];

  memset(dp, 0, sizeof(dp));

  curr[10000] = true;

  for (const auto& i : a) {
    memset(next, 0, sizeof(dp[0]));
    
    for (int j = 0; j < 20000; j ++)
      if (curr[j]) {
        assert(0 <= j - i && j + i < 20000);
        
        next[j - i] = next[j + i] = true;
      }

    std::swap(curr, next);
  }

  return curr[x + 10000];
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string s;

  int x, y, size;

  std::cin >> s >> x >> y;

  size = s.size();

  std::reverse(ALL(s));

  while (! s.empty()) {
    char c = s.back();

    if (c == 'T')
      break;

    x --;

    s.pop_back();
  }

  int d = H;

  std::vector<int> h, v;

  while (! s.empty()) {
    char c = s.back();

    int n = 1;

    s.pop_back();

    while (! s.empty() && s.back() == c) {
      s.pop_back();

      n ++;
    }

    if (c == 'T') {
      if (n % 2)
        d = 1 - d;
    }
    else {
      (d == H ? h : v).push_back(n);
    }
  }

  std::cout << (feasible(x, h) && feasible(y, v) ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
#define STR_SIZE 100
#define LIMIT_LEN 80
const char *add_bignum(char a[], char b[]) {
	static char buf[STR_SIZE];
	memset(buf, 0, 100);

	int alen = strlen(a);
	int blen = strlen(b);
	if (alen > LIMIT_LEN || blen > LIMIT_LEN) {
		return "overflow";
	}
	--alen;
	--blen;
	int i, digit, tmp = 0;
	for (i = 98; i > 0; i--) {
		if (alen >= 0 && blen >= 0)
			digit = (int)a[alen] + (int)b[blen] - '0' - '0';
		else if (alen >= 0 && blen < 0)
			digit = a[alen] - '0';
		else if (alen < 0 && blen >= 0)
			digit = b[blen] - '0';
		digit += tmp;

		buf[i] = (char)((digit % 10) + '0');
		tmp = (char)(digit / 10) & 1;

		--alen;
		--blen;
		if (alen < 0 && blen < 0)
			break;
	}
	if (tmp) {
		buf[--i] = '1';
	}
	const char *result = buf + i;
	if (strlen(result) > LIMIT_LEN) {
		return "overflow";
	}
	return result;
}
int main() {
	int n;
	char a[STR_SIZE], b[STR_SIZE];
	scanf("%d", &n);
	for (; n; n--) {
		scanf(" %100s %100s", a, b);
		puts(add_bignum(a, b));
	}
	return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    vector<int> a(3);
    rep(i, 3) {
        cin >> a[i];
    }
    sort(all(a));
    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
set <int> s;
bool ar[100001];
void seive() {
	ar[0] = ar[1] = true;

	for(int p=2; p*p<=100001; p++) {
		if(ar[p] == false) {
			for(int i=p*p;i<=100001;i+=p)
				ar[i] = true ;
		}
	}

	for(int p=2;p<=100001;p++) {
		if(ar[p] == false)
			s.insert(p);
	}
}
void solve() {
	string s, t; 
	cin >> s >> t;
    int a, b; 
    cin >> a >> b;
    string r; 
    cin >> r;
    (r == s ? a : b)--;
    cout << a << ' ' << b << endl;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		String t = sc.next();
		
		// 計算
		String result = "";
		int[][] dp = new int[s.length()+1][t.length()+1];
		for(int i = 1; i <= s.length(); i++){
		    for(int j = 1; j <= t.length(); j++){
		        if(s.charAt(i-1) == t.charAt(j-1)){
		            dp[i][j] = dp[i-1][j-1] + 1;
		        }else{
		            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		        }
		    }
		}
		int len = dp[s.length()][t.length()];
		char[] a = new char[len];
		int i = s.length();
		int j = t.length();
		while(len > 0){
		    if(s.charAt(i-1) == t.charAt(j-1)){
		        a[len-1] = s.charAt(i-1);
		        i--;
		        j--;
		        len--;
		    }else if(dp[i][j] == dp[i-1][j]){
		        i--;
		    }else{
		        j--;
		    }
		}
		result = String.valueOf(a);
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 84940
#include<bits/stdc++.h>
using namespace std;
long long int pre[2*100000+7];
long long int sum=0;

long long factorial(int m, int n)
{
    long long ans = 1;
    if(m < n-m)
        m = n-m;
    for(int i = m+1; i <= n; i++)
        ans *= i;
    for(int j = 1; j <= n - m; j++)
        ans /= j;
    return ans;
}
int main()
{
    int n;
    long long int ans=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        long long int x;
        scanf("%lld",&x);
        sum+=x;
        pre[i]=sum;
    }
    sort(pre,pre+1+n);
    int cnt=1;
    for(int i=1;i<=n;i++)
    {
        if(pre[i]==pre[i-1]) cnt++;
        else
        {
            if(cnt!=1) ans+=factorial(2,cnt);
            cnt=1;
        }
    }
    if(cnt!=1) ans+=factorial(2,cnt);
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            int ans = 0;

            if(op.equals("+")){
                ans = a + b;
            }else if(op.equals("-")){
                ans = a - b;
            }else if(op.equals("*")){
                ans = a * b;
            }else if(op.equals("/")){
                ans = a / b;
            }else if(op.equals("?")){
                break;
            }
            
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 26140
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        dis = 0
        for d in range(D):
            dis += (X[i][d] - X[j][d])**2
        if math.sqrt(dis) == int(math.sqrt(dis)):
            cnt += 1
print(cnt)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 311

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int dp[maxn][maxn][maxn]; // dp[from][to][x changes left] - longest subsequence palindrome in range [from, to] with x changes left
char str[maxn];

int main(){
	int n, k;
	scanf("%s", str + 1);
	scanf("%d", &k);
	n = strlen(str + 1);

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= k; j++)
			dp[i][i][j] = 1;
	}

	for(int len = 2; len <= n; len++){
		for(int l = 1; l + len - 1 <= n; l++){
			int d = l + len - 1;

			for(int j = 0; j <= k; j++){
				if(j > 0)
					dp[l][d][j] = max(dp[l][d][j], dp[l][d][j - 1]);

				dp[l][d][j] = max(dp[l][d][j], dp[l + 1][d][j]);
				dp[l][d][j] = max(dp[l][d][j], dp[l][d - 1][j]);

				if(j > 0)
					dp[l][d][j] = max(dp[l][d][j], dp[l + 1][d - 1][j - 1] + 2);

				if(str[l] == str[d])
					dp[l][d][j] = max(dp[l][d][j], dp[l + 1][d - 1][j] + 2);
			}
		}
	}

	printf("%d\n", dp[1][n][k]);
	return 0;
}

Measured memory_bytes: 114560
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	dayMapping := map[string]int{
		"SUN": 7,
		"MON": 6,
		"TUE": 5,
		"WED": 4,
		"THU": 3,
		"FRI": 2,
		"SAT": 1,
	}
	fmt.Println(dayMapping[s])
}

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

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

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  int N,M;
  cin>>N>>M;
  if(N==M) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W; cin >> H >> W;
	VS S(H);
	REP(i, H)cin >> S[i];


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

	REP(i, H) {
		REP(j, W) {
			int cnt = 0;
			if (S[i][j] == '#')continue;
			REP(k, 8) {
				if (i + dx[k] >= 0 && i + dx[k] < H&&j + dy[k] >= 0 && j + dy[k] < W) {
					if (S[i + dx[k]][j + dy[k]] == '#')cnt++;
				}
			}



			S[i][j] = cnt + '0';
		}
	}
	REP(i, H) {
		REP(j, W)cout << S[i][j];
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define max_n 100000
using namespace std;
char s[max_n+1];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1'){
		puts("-1");
		return 0;
	}
	for(int i=n; --i; )
		if(s[i]!=s[n-i]){
			puts("-1");
			return 0;
		}
	for(int i=1,r=1; ++i<=n; s[i-1]=='1'&&(r=i))
		printf("%d %d\n",r,i);
	return 0;
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int a, b;
    cin >> a >> b;
    for (int v = 1; v <= 100000; ++v) {
        int x = v * 8 / 100;
        int y = v * 1 / 10;
        if (a == x and b == y) {
            cout << v << '\n';
            return 0;
        }
    }

    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
p = []
cnt = 0

for v in itertools.permutations(xy, N):
    p.append(v)

for i in range(len(p)):
    for j in range(N-1):
        cnt += ((p[i][j][0] - p[i][j+1][0])**2 + (p[i][j][1] - p[i][j+1][1])**2) ** 0.5

ans = cnt / len(p)

print(ans)

Measured memory_bytes: 8052
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
      	Integer a[] = new Integer[n];
        int i;
        long count = 0;
      	for(i = 0;i < n;i++){
          a[i] = sc.nextInt();
        }
      Arrays.sort(a, Collections.reverseOrder()); 
      
      	for(i = 1;i < n;i++){
			count += a[i/2];
        }
 			System.out.println(count);
    }
}

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

int n, p, c;

int main(){
	cin >> n;
	c = 0;
	for (int i = 1; i <= n; ++i){
		cin >> p;
		if (i != p) c++;
		if (c > 2) break;
	}
	cout << (c <= 2 ? "YES" : "NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
using namespace std;

typedef long long ll;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	string s, t;
	cin >> s >> t;
	int res = 0;
	for(int i = 0; i <= 2; i ++){
		res += s[i] == t[i];
	}
	cout << res << endl;
	return 0;
}

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

int main(void){
    int room[8] = {0,1,2,3,5,7,8,9},n;
    int newroom[10],i;
    
    while(cin >> n ,n){
        for(i = 0 ;; i++){
            int nn = n / 8;
            newroom[i] = n % 8;
            n = nn;
            if(!n) break;
        }
        
        for(int j = i ; j >= 0 ; j--) cout << room[newroom[j]];
        cout << endl;
    }
    
    return 0;
}

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

int main()
{
int n,b,f,r,r1[4][11],r2[4][11],r3[4][11],r4[4][11],k,p,i,j;

cin>>n;
for(k=1;k<=4;k++)
{

 for(i=1;i<=3;i++)
    {
        for(j=1;j<=10;j++)
    {
        if(k==1)
            r1[i][j]=0;
        else if(k==2)
            r2[i][j]=0;
        else if(k==3)
            r3[i][j]=0;
        else if(k==4)
            r4[i][j]=0;
    }

    }

}

for(k=0;k<n;k++)
{
    cin>>b>>f>>r>>p;

        if(b==1)
            r1[f][r]=r1[f][r]+p;
        else if(b==2)
            r2[f][r]=r2[f][r]+p;
        else if(b==3)
            r3[f][r]=r3[f][r]+p;
        else if(b==4)
            r4[f][r]=r4[f][r]+p;

}



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

 for(i=1;i<=3;i++)
    {
        for(j=1;j<=10;j++)
    {
        if(k==1)
            cout<<" "<<r1[i][j];
        else if(k==2)
            cout<<" "<<r2[i][j];
            else if(k==3)
            cout<<" "<<r3[i][j];
            else if(k==4)
            cout<<" "<<r4[i][j];
    }
    cout<<endl;
    }
    if(k!=4)
    cout<<"####################"<<endl;
}





}









Measured memory_bytes: 3096
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

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

    int a[n];
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    int count = 0;
    float threshould = sum / (4.0 * m);
    rep(i, n) {
        if (a[i] >= threshould) count++;

        if (count == m) {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N;
    cin >> N;
    ll ans = 0;
    map<string, ll>cnt;
    for(ll i = 0; i < N; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ans += cnt[s];
        cnt[s]++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;

//Finite Field Calculator
public class Main{

	String s;
	int idx, mod;
	boolean ng;
	
	char get(){
		if(idx==s.length())return '$';
		return s.charAt(idx++);
	}
	
	int[] exgcd(int x, int y){
		int r0 = x, r1 = y, a0 = 1, a1 = 0, b0 = 0, b1 = 1;
		int q1, r2, a2, b2;
		while(0 < r1){
			q1 = r0/r1;
			r2 = r0%r1;
			a2 = a0-q1*a1;
			b2 = b0-q1*b1;
			r0 = r1; r1 = r2;
			a0 = a1; a1 = a2;
			b0 = b1; b1 = b2;
		}
		return new int[]{a0, b0, r0};
	}
	
	int modInverse(int a, int m){
		int[] r = exgcd(a, m);
		return r[2]==1?(m+r[0])%m:-1;
	}
	
	int exp(){
		if(ng)return 0;
		int res = term();
		for(;;){
			char c = get();
			if(c=='+'){
				res += term();
				if(mod <= res)res-=mod;
			}
			else if(c=='-'){
				int ope = term();
				ope = mod-ope;
				res+=ope;
				if(mod <= res)res-=mod;
			}
			else break;
		}
		idx--;
		return res;
	}
	
	int term(){
		if(ng)return 0;
		int res = fact();
		for(;;){
			char c = get();
			if(c=='*'){
				res *= fact();
				res%=mod;
			}
			else if(c=='/'){
				int ope = fact();
				if(ope==0){
					ng = true; return 0;
				}
				ope = modInverse(ope, mod);
				if(ope==-1){
					ng = true; return 0;
				}
				res *= ope;
				res%=mod;
			}
			else break;
		}
		idx--;
		return res;
	}
	
	int fact(){
		if(ng)return 0;
		char c = get();
		if(c=='('){
			int res = exp();
			get();
			return res;
		}
		if(c=='-'){
			int res = exp();
			res%=mod;
			return mod-res;
		}
		int res = c-'0';
		for(;;){
			c = get();
			if(!Character.isDigit(c))break;
			res = res*10 + c-'0';
		}
		idx--;
		return res;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			String[] t = sc.nextLine().split(":");
			mod = Integer.parseInt(t[0]);
			if(mod==0)break;
			s = t[1].replace(" ", "");
			idx = 0;
			ng = false;
			int res = exp();
			if(ng)System.out.println("NG");
			else System.out.printf("%s = %d (mod %d)\n", s, res, mod);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define pb(a) push_back(a)

const int MOD = 998244353;
const ll MAX_VAL = 1000000;

ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}


ll inv[1000010];//逆元
vector<ll>divisors[1000010];//約数の集合
ll sum1[1000010];//sum1[d]=dの倍数の和
ll sum2[1000010];//sum2[d]=dの倍数の2乗の和
ll A[200020];
ll f[1000010];
ll g[1000010];
//逆元の前計算
void inverse_init() {
	inv[1] = 1;
	for (int i = 2; i <= MAX_VAL; i++) {
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
	}
}
//約数列挙
void divisors_init() {
	for (int d = 1; d <= MAX_VAL; d++) {
		for (int x = d; x <= MAX_VAL; x += d) {
			divisors[x].pb(d);
			//divs[x].insert(d);
		}
	}
}
//g(d)の計算
void calc_g() {
	for (int d = 1; d <= MAX_VAL; d++) {
		ll tmp = 0;
		tmp = add(tmp, mult(sum1[d], sum1[d]));
		tmp = sub(tmp, sum2[d]);
		tmp = mult(tmp, inv[2]);
		g[d] = tmp;
	}
}

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

	divisors_init();//約数列挙
	inverse_init();//逆元の前計算
	int N; cin >> N;
	REP(i, N) {
		cin >> A[i];
		for (auto x : divisors[A[i]]) {
			sum1[x] = add(sum1[x], A[i]);
			sum2[x] = add(sum2[x], mult(A[i], A[i]));
		}
	}
	calc_g();//g(d)の計算
	ll ans = 0;
	for (int d = MAX_VAL; d >= 1; d--) {
		ll tmp = g[d];
		for (int k = 2; k*d <= MAX_VAL; k++) {
			tmp = sub(tmp, f[k*d]);
		}
		f[d] = tmp;
		ans = add(ans, mult(f[d],inv[d]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 221440
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
static const ll MAX_L = (ll)1 << 62;

ll a[100] = {};
ll aa[100] = {};
ll b[100] = {};
bool red[100] = {};
ll c[100] = {};
ll d[100] = {};
bool blue[100] = {};
int main() {
	ll n; cin >> n;

	rep(i, 0, n) {
		ll A, B; cin >> A >> B;
		a[i] = A;
		aa[i] = A;
		b[i] = B;
	}
	sort(aa, aa + n);
	reverse(aa, aa + n);

	rep(i, 0, n) cin >> c[i] >> d[i];

	ll cnt = 0;
	rep(i, 0, n) {
		ll r_index = 0;
		rep(k, 0, n) {
			if (a[k] == aa[i]) {
				r_index = k;
			}
		}

		if (!red[r_index]) {
			ll rx = a[r_index]; ll ry = b[r_index];
			ll b_index;
			ll minBy = MAX_L;
			rep(j, 0, n) {
				if (!blue[j]) {
					if (rx < c[j] && ry < d[j]) {
						if (d[j] < minBy) {
							minBy = d[j];
							b_index = j;
						}
					}
				}
			}

			if (minBy != MAX_L) {
				cnt++;
				blue[b_index] = true;
				red[r_index] = true;
			}
		}
	}

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

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

void solve() {
	int ans[100000] = {};
	int n, m, t;
	cin >> n >> m >> t;
	REP(i, n) {
		int a;
		cin >> a;
		ans[a - m]++;
		ans[a + m]--;
	}
	int now = 0;
	REP(i, t) {
		ans[i + 1] += ans[i];
		if (ans[i] == 0) now++;
	}
	cout << now << endl;
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
      int n,h,w,i = 0,j = 0;
      scanf("%d %d %d",&n,&h,&w);
//      printf("%d\n",n);
      int a[n],b[n];      

      for(i=0;i < n;i++) {
            scanf("%d %d",&a[i],&b[i]);
//            printf("%d %d\n",a[i],b[i]);

            if(a[i] >= h && b[i] >= w) {
//                  printf("ok\n");
                  j++;
            }

      }

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

      return 0;
}

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

int N;
int a[100010];

void swap( int& a, int& b ){
  int tmp = a;
  a = b;
  b = tmp;
}

int partition( int p, int r ){
  int x = a[r];
  int i = p - 1;
  for( int j = p; j < r; j++ ){
    if( a[j] <= x ){
      i++;
      ::swap( a[i], a[j] ); 
    }
  }
  ::swap( a[i + 1], a[r] );

  return i + 1;
}


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

  int tmp = partition( 0, N - 1 );

  for( int i = 0; i < N; i++ ){
    if( i == tmp ){
      cout << "[" << a[i] << "]";
    }else{
      cout << a[i];
    }

    if( i == N - 1 ) cout << endl;
    else cout << " ";
  }


    
}



Measured memory_bytes: 3384
from fractions import gcd
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
kyori_list = [abs(X-i) for i in x_list]
ans_gcd = kyori_list[0]
for i in kyori_list[1:]:
    ans_gcd = gcd(ans_gcd, i)
print(ans_gcd)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
using ll=long long;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int r; cin >> r; END(3*r*r);
}



Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main(void) {
    int N;
    std::vector<pair<int,int>> X;
    std::vector<int> rawX;
    
    cin >> N;
    X.reserve(N);
    rawX.reserve(N);
    
    for(int i=0; i< N; i++) {
        int x;
        cin >> x;
        X.push_back(make_pair(x,i));
        rawX.push_back(x);
    }
    std::sort(X.begin(), X.end(), [](pair<int,int>& x, pair<int,int>& y) -> int {
                                        return ( x.first < y.first );
                                    });

    int mi1 = X[N/2-1].second;
    int mi2 = X[N/2].second;
    double mean = (rawX[mi1] + rawX[mi2])/2.0;
    for(int i=0; i< N; i++) {
        if( rawX[i] < mean ) {
            cout << rawX[mi2] << endl;
        }else {
            cout << rawX[mi1] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4480
kosuu = int(input())
hairetu = list(map(int, input().split()))
count = 0
step = kosuu - 2
for a in range(step):
    if hairetu[a] < hairetu[a + 1] < hairetu[a + 2]:
        count += 1
    if hairetu[a + 2] < hairetu[a+1] < hairetu[a]:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

int f(int b,int n){
  if(n<b)return n;
  return f(b,n/b)+n%b;
}

signed main(){
  int n,s;
  cin>>n>>s;
  if(n==s){
    cout<<n+1<<endl;
    return 0;
  }
  int ans=INF;

  for(int b=2;b*b<=n;b++)if(f(b,n)==s)cmin(ans,b);
  if(ans!=INF){
    cout<<ans<<endl;
    return 0;
  }

  vector<int> divisor;
  for(int p=1;p*p<=n-s;p++){
    if((n-s)%p==0)divisor.push_back((n-s)/p+1);
  }
  sort(all(divisor));
  for(auto x:divisor){
    if(f(x,n)==s){
      ans=x;
      break;
    }
  }
  cout<<(ans==INF?-1:ans)<<endl;


  return 0;
}


Measured memory_bytes: 256