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

using ll = long long;

ll bs[100010],cs[100010];

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

    int n;cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    int pos=0;
    for(int i=0;i<=n;i++)
    {
        for(;pos<n;pos++)if(a[pos]>=b[i])break;
        bs[i+1]=bs[i]+pos;
    }

    pos=0;
    for(int i=0;i<n;i++)
    {
        for(;pos<n;pos++)if(b[pos]>=c[i])break;
        cs[i]=pos;
    }

    ll ans=0;

    for(int i=0;i<n;i++)
    {
        ans+=bs[cs[i]];
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 6084
import sys
input = sys.stdin.readline
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True
    
def same(x,y):
    return find(x) == find(y)

def size(x):
    return -par[find(x)]
def func(a):
    return int(a)-1
n,m = map(int,input().split())
par = [-1]*n
ab = [list(map(func,input().split()))for i in range(m)]
ans = 0
for i in range(m):
    par = [-1]*n
    for j in range(m):
        if i != j:
            unite(ab[j][0],ab[j][1])
    for k in range(m):
        if not(same(ab[k][0],ab[k][1])):
            #print(k,ab[k][0]+1,ab[k][1]+1)
            ans += 1
            break

print(ans)

Measured memory_bytes: 42224
from sys import stdin
L,R = [int(x) for x in stdin.readline().rstrip().split()]
ans = 2019
#if L + 2019 >= R:
#    ans = 0
#else:
for i in range(L,R):
    for j in range(L+1,R+1):
        ans = min((i*j % 2019,ans))
        if ans == 0:
            break
    else:
        continue
    break
        
        
print(ans)

Measured memory_bytes: 40284
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n, d; scan(n, d);
    int r = 2 * d + 1;
    writeln(ceil(1.0 * n / r));
}


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

int main(){
    int n,m,sum=0,ans=0; cin >>n >>m;
    vector<int>a(n);

    for(int i=0; i<n; i++){cin >>a[i]; sum+=a[i];}
    for(int i=0; i<n; i++){if(a[i]*4*m>=sum){ans++;}}

    if(ans>=m){cout <<"Yes";}
    else{cout <<"No";}

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N, i, j;
  	double temp;
    double v[51];
  	double x = 0;
  	
  	scanf("%d", &N);
  	for(i=0;i<N;i++)
      	scanf("%lf", &v[i]);
    
	for(i=0;i<N;i++){
    	for(j=N-1;j>i;j--){
        	if(v[j]<v[j-1]){
          		temp = v[j];
          		v[j] = v[j-1];
          		v[j-1] = temp;
            }
        }
    }
  	
  	for(i=0;i<N-1;i++){
    	v[i+1] = (v[i]+v[i+1])/2.0; 
    }
    printf("%lf", v[N-1]);
      
  	return 0;
}

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

using namespace std;

// a - splits at 37 mins

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


int main()
{
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
    int five = 0, seven = 0;
    rep(i, 3)
    {
        int x;
        cin >> x;
        if (x == 5)
            five++;
        else if (x == 7)
            seven++;
    }
    if (five == 2 && seven == 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m,l=0,r=2*1e5,num=0,mid=0,k=0;cin>>n>>m;
  vector<ll> a(n),s(n);rep(i,n) cin>>a[i];
  sort(a.begin(),a.end(),greater<ll>());
  s[0]=a[0];for(ll i=1;i<n;++i) s[i]=s[i-1]+a[i];
  while(r-l>1) {
    mid=(l+r)/2;num=0;k=n-1;
    for(ll i=0;i<n;++i) {
      for(ll j=k;j>-1;--j) {
        if(a[j]>mid-a[i]) break;
        k-=1;
      }
      num+=k+1;
    }
    if(num>m) l=mid;else r=mid;
  }
  ll ans=0;num=0;k=n-1;
  for(ll i=0;i<n;++i){
    for(ll j=k;j>-1;--j){
      if(a[j]>r-a[i]) break;
      k-=1;
    }
    if(k!=-1) ans+=s[k]+(k+1)*a[i];
    num+=k+1;
  }
  ans+=(m-num)*r;print(ans);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}

ll extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;
    y=0;
  }
  return d;
}

ll mod_inverse(ll a,ll m){
  ll x,y;
  ll z=extgcd(a,m,x,y);
  return(m+x%m)%m;
}

pair<ll,ll> linear_congruence(const vector<ll> &A,const vector<ll> &B,
                              const vector<ll> &M){
  ll x=0,m=1;

  for(int i=0;i<A.size();i++){
      ll a=A[i]*m,b=B[i]-A[i]*x,d=gcd(M[i],a);
      if(b%d!=0) return make_pair(-1,-1);

      ll t=(b/d)*mod_inverse(a/d,M[i]/d)%(M[i]/d);
      x=x+m*t;
      m*=M[i]/d;

      x=(x%m+m)%m;
  }
  return make_pair(x,m);
}

pair<ll, ll> crt(ll b1, ll m1, ll b2, ll m2){
    ll p, q;
    ll d = extgcd(m1, m2, p, q);
    if((b2-b1) % d != 0) return make_pair(-1, -1);
    ll m = m1 * (m2/d);
    ll tmp = (b2 - b1) / d * p % (m2/d);
    ll r = b1 + m1 * tmp;
    r = (r%m+m) % m;
    return make_pair(r, m);
}


int main(){
  int N;
  cin>>N;
  vector<int> P(N),Q(N);
  rep(i,N) cin>>P[i];
  rep(i,N) cin>>Q[i];

  rep(i,N){
    P[i]--;
    Q[i]--;
  }

  vector<vector<int>> app(N);
  vector<int> nowp=P;
  rep(k,2*N+2){
    vector<int> nexp(N);
    for(int i=0;i<N;i++){
      if(nowp[i]==i) app[i].push_back(k);
      nexp[i]=Q[nowp[i]];
    }
    nowp.swap(nexp);
  }

  pair<ll,ll> ans={0,1};
  for(int i=0;i<N;i++){
    if(app[i].size()<2){
      cout<<-1<<endl;
      return 0;
    }

    ans=crt(ans.first,ans.second,app[i][0],app[i][1]-app[i][0]);
    if(ans.first==-1){
        cout<<-1<<endl;
        return 0;
    }
  }

  cout<<ans.first<<endl;

  return 0;
}



Measured memory_bytes: 3280
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define fir fisrt
#define sec second

int n, x[105], y[105], h[105];
bool vis[105][105];

int main(){
	scanf(" %d", &n);
	int ert = 1;
	for(int i = 1; i <= n; i ++){
		scanf(" %d %d %d", &x[i], &y[i], &h[i]);
		if(h[i] > 0) ert = i;
		vis[x[i]][y[i]] = 1;
	}
	bool VIS = 0;
	int H;
	int pos = 0;
	int resx = -1, resy = -1, resh = -1;
	for(int i = 0; i <= 100; i ++){
		for(int j = 0; j <= 100; j ++){
			H = h[ert] + abs(i - x[ert]) + abs(j - y[ert]);
			VIS = 0;
			pos = 0;
			for(int k = 1; k <= n; k ++){
				if(h[k] - max(H - abs(i - x[k]) - abs(j - y[k]), 0) != 0){
					VIS = 1;
					break;
				}
			}
			if(VIS == 0){
				pos = 1;
				resx = i;
				resy = j;
				resh = H;
				break;
			}
		}
		if(VIS == 0 && pos == 1) break;
	}
	/*if(resx == -1){
	  for(int i = 1; i <= n; i ++){
	  VIS = 0;
	  for(int j = 1; j <= n; j ++){
	  if(h[i] < h[j]){
	  VIS = 1;
	  break;
	  }
	  if(h[i] - h[j] - abs(x[i] - x[j]) - abs(y[i] - y[j]) != 0){
	  VIS = 1;
	  break;
	  }
	  }
	  if(VIS == 0){
	  resx = x[i];
	  resy = y[i];
	  resh = h[i];
	  break;
	  }
	  }
	  }*/
	printf("%d %d %d\n", resx, resy, resh);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e2+50;
int arr[N];
int main(){
    int n;scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    int temp1=sum/n;
    int temp2=sum/n+1;
    int ans1=0;
    int ans2=0;
    for(int i=0;i<n;i++){
        ans1+=(arr[i]-temp1)*(arr[i]-temp1);
        ans2+=(arr[i]-temp2)*(arr[i]-temp2);
    }
    printf("%d\n",min(ans1,ans2));
    //system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n, k;
  cin >> n >> k;
  int mx = (n-1)*(n-2)/2;
  if(mx < k){
    cout << -1 << endl;
    return 0;
  }
  vector<P> ans;
  REP(i, n-1){
    ans.emplace_back(P(i+1, n));
  }
  int add = mx - k;
  vector<P> edge;
  REP(i, n-1)REP(j, i) edge.emplace_back(P(i+1, j+1));
  REP(i, add)ans.emplace_back(edge[i]);
  cout << ans.size() << endl;
  REP(i, ans.size()){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF=1e9;

int main(){
  int k,n;
  cin >>k>>n;
  vector<int> a(n);
  int dmin=INF;
  rep(i,n){
    cin >>a[i];
    if(i>=1){
      dmin=min(dmin, k-(a[i]-a[i-1]));
    }
  }
  dmin=min(dmin,a[n-1]-a[0]);
    
  cout<<dmin<<endl;
 
  
    
 
}

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

int selection_sort(int A[], int n) {
    int minj, sw = 0;
    rep(i, n) {
        minj = i;
        for (int j = i; j < n; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (minj != i) {
            swap(A[i], A[minj]);
            ++sw;
        }
    }
    return sw;
}

void Main() {
    int n;
    cin >> n;
    int A[100];
    rep(i, n) cin >> A[i];
    int ans;
    ans = selection_sort(A, n);
    rep(i, n) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << "\n" << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 3140
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#define mod 1000000007
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod

ll n,a[110],cnt[110];
bool solve(){
    cin>>n;
    for(int i=1;i<n;i++)cnt[i]=0;
    ll ma=-1;
    for(int i=0;i<n;i++){
	cin>>a[i];
	cnt[a[i]]++;
	chmax(ma,a[i]);
    }
    for(int i=0;i<(ma+1)/2;i++){
	cnt[ma-i]-=2;
    }
    if(ma%2==0)cnt[ma/2]--;
    for(int i=1;i<=(ma+1)/2;i++)if(cnt[i]>0)return 0;
    for(int i=1;i<n;i++)if(cnt[i]<0)return 0;
    return 1;
}
int main(){
    if(solve()==0)cout<<"Impossible"<<endl;
    else cout<<"Possible"<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<functional>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
using namespace std;
int main()
{
  string s;
  cin >> s ;
  int n = s.size();
  REP(i, n){
    if(i%2 == 0){
      if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
	//	cout << s[i] << endl;
	cout << "No" << endl;
	return 0;
      }
    }else{
      if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
	//	cout << s[i] << endl;
	cout << "No" << endl;
	return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
require "prime"

ary = []
STDIN.each do |l|
  ary << l.split(" ").map(&:to_i)
end
ary.each do |a,d,n|
  break if (a == 0) && (d == 0) && (n == 0)
  count = 0
  res = a
  count += 1 if Prime.prime? res
  begin
    res += d
    count += 1 if Prime.prime? res
  end while count < n
  puts res
end

Measured memory_bytes: 6220
import java.util.Scanner;
 
public class Main {
 
    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
 
        int x = Math.min(n, m);
        int y = Math.max(n, m);
 
        k = Math.min(k, x * y - k);
 
        boolean found = false;
        for (int i = 0; i < (x + 1) / 2 && !found; i++) {
            int count = i * y;
            if(count == k) {
                found = true;
                break;
            }
            for (int j = 0; j < y; j++) {
                count += x - 2 * i;
                if(count == k) {
                    found = true;
                    break;
                }
            }
        }
 
        if(found) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23892
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
      Scanner input=new Scanner(System.in);
      int hour1=input.nextInt();
      int minute1=input.nextInt();
      int hour2=input.nextInt();
      int minute2=input.nextInt();
      int k=input.nextInt();
      int result=(hour2-hour1)*60+minute2-minute1;
      System.out.println(result-k);
    }
}

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

#define int long long

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

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
const int MOD=1e9+7;
signed main(){
	string s;
	cin>>s;
	int n=s.size();
	int ans=0;
	vector<char> k;
	rep(i,n){
		if(s[i]=='E')continue;
		if(s[i]=='B'&&i+1<n&&s[i+1]=='C'){
			s[i]='D';
			s[i+1]='E';
		}
		if(s[i]=='A'||s[i]=='D')k.push_back(s[i]);
		else {
			int cnt=0;
			int sum=0;
			rep(j,k.size()){
				if(k[j]=='A'){
					cnt++;
					sum+=j;
				}
			}
			ans+=((k.size()-1)+(k.size()-cnt))*cnt/2-sum;
			k.clear();
		}
	}
	int cnt=0;
	int sum=0;
	rep(j,k.size()){
		if(k[j]=='A'){
			cnt++;
			sum+=j;
		}
	}
	ans+=((k.size()-1)+(k.size()-cnt))*cnt/2-sum;
	cout<<ans<<endl;
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair
# define int long long

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int n, k, a[N], pref[N], t[N * 4], b[N], cnt, s, ans;
map <int, int> mp;
vector <int> vec;

void update(int pos, int x, int v = 1, int tl = 1, int tr = cnt)
{
      if(tl == tr)
      {
            t[v] += x;
      }
      else
      {
            int tm = (tl + tr) >> 1;
            if(pos <= tm)
                  update(pos, x, v << 1, tl, tm);
            else
                  update(pos, x, (v << 1) | 1, tm + 1, tr);
            t[v] = t[v << 1] + t[(v << 1) | 1];
      }
}

int get(int l, int r, int v = 1, int tl = 1, int tr = cnt)
{
      if(l > tr || tl > r) return 0;
      if(l <= tl && tr <= r) return t[v];
      int tm = (tl + tr) >> 1;
      return get(l, r, v << 1, tl, tm) +
                  get(l, r, (v << 1) | 1, tm + 1, tr);
}

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

      for(int i = 1; i <= n; i ++)
      {
            cin >> a[i];
            a[i] -= k;
            pref[i] = pref[i - 1] + a[i];
            b[i] = pref[i];
            vec.pb(pref[i]);
      }

      sort(vec.begin(), vec.end());
      sort(b + 1, b + n + 1);

      for(int i : vec)
      {
            if(!mp[i])
                  mp[i] = ++ cnt;
      }

      for(int i = 1; i <= n; i ++)
            pref[i] = mp[pref[i]];

      for(int i = 1; i <= n; i ++)
            update(pref[i], 1);

      for(int i = 1; i <= n; i ++)
      {
            int l = 1, r = n;
            while(r - l > 1)
            {
                  int md = (l + r) >> 1;
                  if(b[md] >= s)
                        r = md;
                  else
                        l = md;
            }
            if(b[l] >= s) r = l;
            if(b[r] >= s)
                  ans += get(mp[b[r]], cnt);
            update(pref[i], -1);
            s += a[i];
      }

      cout << ans << endl;
}


Measured memory_bytes: 28144
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int n,k,h[200007];
long long ans=0;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for (int i=1; i<=n; i++) cin>>h[i];
	sort(h+1,h+n+1);
	long long num=max(0,n-k);
	for (long long i=1; i<=num; i++) ans+=h[i];
	cout<<ans<<endl; 
	return 0;
} 

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
N = int(input())
m, a, r, c, h = [0, 0, 0, 0, 0]
for _ in range(N):
    s = input()
    if s[0] == "M":
        m += 1
    elif s[0] == "A":
        a += 1
    elif s[0] == "R":
        r += 1
    elif s[0] == "C":
        c += 1
    elif s[0] == "H":
        h += 1
print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)


Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {-1,0,1,0};
const int ty[] = {0,1,0,-1};

char stage[20][20];

int main(){
	int N;

	while(~scanf("%d",&N)){
		if(N==0) break;
		map<int,P> rect;
		int min_x=0,min_y=0,max_x=0,max_y=0;
		rect[0] = P(0,0);
		for(int i=1;i<N;i++){
			int n,d;
			scanf("%d %d",&n,&d);
			rect[i].first = rect[n].first + tx[d];
			rect[i].second = rect[n].second + ty[d];
			min_x = min(min_x,rect[i].first);
			max_x = max(max_x,rect[i].first);

			min_y = min(min_y,rect[i].second);
			max_y = max(max_y,rect[i].second);
		}

		printf("%d %d\n",max_x-min_x+1,max_y-min_y+1);
	}


}

Measured memory_bytes: 0
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;


int a[105];
int main()
{
    int x,y,z,ans=0,cnt=0,sum=0;
    cin>>x>>y>>z;
    for(int i=0;i<y;i++)
    {cin>>a[i]; 
    if(a[i]<z)
    ans++;
    if(a[i]>z)
    cnt++;
    sum=min(ans,cnt);
    }
    cout<<sum;
 
    return 0;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

int n;
vector<int> pos;

vector<int> l[maxn];
pair<int,int> seg[maxn];

int dp[maxn];

struct node
{
	int l,r;
	int max_val;
} seg_tree[maxn<<2];

void push_up(int root)
{
	seg_tree[root].max_val=max(seg_tree[root<<1].max_val,seg_tree[root<<1|1].max_val);
}

void build(int root,int l,int r)
{
	seg_tree[root].l=l;
	seg_tree[root].r=r;
	if(l==r)
	{
		seg_tree[root].max_val=0;
		return;
	}
	int mid=(l+r)>>1;
	build(root<<1,l,mid);
	build(root<<1|1,mid+1,r);
	push_up(root);
}

void update(int root, int pos, int val)
{
	if(seg_tree[root].l>pos || seg_tree[root].r<pos)
		return;
	if(seg_tree[root].l== pos && seg_tree[root].r== pos)
	{
		seg_tree[root].max_val=val;
		return;
	}
	int mid=(seg_tree[root].l + seg_tree[root].r)>>1;
	if(pos<=mid)
		update(root<<1,pos,val);
	if(pos>mid)
		update(root<<1|1,pos,val);
	push_up(root);
}

int query(int root,int l,int r)
{
	if(l <= seg_tree[root].l && seg_tree[root].r <= r)
		return seg_tree[root].max_val;
	int res=0;
	int mid=(seg_tree[root].l + seg_tree[root].r)>>1;
	if(l<=mid)
		res=max(res,query(root<<1,l,r));
	if(r>mid)
		res=max(res,query(root<<1|1,l,r));
	return res;
}

int main()
{
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	build(1,1,200000);

	for(int i=1;i<=n;i++)
	{
		int x,l;
		scanf("%d%d",&x,&l);
		seg[i].first=x-l;
		seg[i].second=x+l;
		pos.push_back(x-l);
		pos.push_back(x+l);
	}
	
	sort(pos.begin(),pos.end());
	
	for(int i=1;i<=n;i++)
	{
		seg[i].first=lower_bound(pos.begin(),pos.end(),seg[i].first) - pos.begin() + 1;
		seg[i].second=lower_bound(pos.begin(),pos.end(),seg[i].second)-pos.begin() + 1;
	}
	
	for(int i=1;i<=n;i++)
		l[seg[i].second].push_back(seg[i].first);

	for(int i=1;i<=200000;i++)
	{
		dp[i]=dp[i-1];
		if(!l[i].empty())
		{
			for(int x:l[i])
			{
				dp[i]=max(dp[i],query(1,1,x)+1);
			}
		}
		update(1,i,dp[i]);
	}
	printf("%d\n",dp[200000]);
	return 0;
}


Measured memory_bytes: 20596
#include<bits/stdc++.h>
#define vi vector<int>
#define ALL_UP_WITH return 0
using namespace std;




int main()
{
    int n;
int a[200000];
int b[200000];
int re[200000];

     scanf("%d",&n);

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

     copy(begin(a), end(a), begin(re));

     sort (re,re + n);
     int counter = 0;
     int aa = 0;
     int bb = 0;
  do {
    bool oka = true;
    bool okb = true;
    for(int i =0;i<n;i++){
        if(re[i] != a[i]){
            oka = false;
        }
        if(re[i] != b[i])
            okb = false;
    }
    if(oka == true)
        aa=  counter;

    if(okb == true)
        bb=  counter;

    counter++;
  } while ( next_permutation(re,re+n) );

    cout << abs(aa - bb);

    return 0;
}


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

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int l = 0;
    ll seg = 0;
    ll res = 0;
    rep(r,n){
        if(seg+a[r] == (seg^a[r])){
        }else{
            while(l<r){
                seg -= a[l];
                l++;
                if(seg+a[r] == (seg^a[r]))break;
            }
        }
        seg += a[r];
        res += r-l+1;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1920
n,k = map(int,input().split())

h = list(map(int,input().split()))
h.sort()
s=0
t=0

if k == 0:
  for i in h:
    s += i
  print(s)
elif k >= n:
  print(0)

  
else:
  k= k*(-1)
  h = h[:k]
  for j in h:
    t += j
  print(t)

Measured memory_bytes: 26024
#include <iostream>

#include <vector>

#include <algorithm>

#include <sstream>

#include <string>

#include <cmath>

using namespace std;



template <typename T> class SegTree

{

public:

	int n;

	T T_max;

	vector<T> dat;

	SegTree(int n_, T t_max)

	{

		int n = 1;

		T_max = t_max;

		while (n < n_)n *= 2;

		for (int i = 0; i < 2 * n - 1; i++)dat.push_back(t_max);

	}

	void update(int k, T a)

	{

		k += n - 1;

		dat[k] = a;

		while (k > 0)

		{

			k = (k - 1) / 2;

			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);

		}

	}



	//[a,b)

	T query(int a, int b)

	{

		return _query(a, b, 0, 0, n);

	}



private:

	T _query(int a, int b, int k, int l, int r)

	{

		if (r <= a || b <= l)return T_max;

		if (a <= l && r <= b)return dat[k];

		else

		{

			T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);

			T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);

			return min(vr, vl);

		}

	}

};





int main()

{

	double a;

	while (cin >> a && a >= 0.0)

	{

		int A;

		double B;

		string ans;



		A = a;

		B = a - A;



		for (int i = 0; i < 8; i++)

		{

			ans += (A % 2) + '0';

			A /= 2;

		}



		if (A > 0)

		{

			cout << "NA" << endl;

			continue;

		}



		reverse(ans.begin(), ans.end());

		ans += ".";



		for (int i = 1; i <= 4; i++)

		{

			if (B >= pow(2, i * -1))

			{

				ans += "1";

				B -= pow(2, i * -1);

			}

			else

			{

				ans += "0";

			}

		}



		if (B != 0.0)

		{

			cout << "NA" << endl;

			continue;

		}



		cout << ans << endl;



	}

}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, c, k;
    cin>>n>>c>>k;
    vector<ll> t(n);
    for(ll i=0;i<n;++i){
        cin>>t[i];
    }
    sort(t.begin(), t.end());

    ll count = 0;
    ll ans = 0;
    while(count < n){
        ll num = t[count];
        ll sum = 1;
        for(ll i=1;i<c;++i){
            if(count + i >= n){
                break;
            }
            if(t[count + i] - num <= k){
                sum++;
            }else{
                break;
            }
        }
        count += sum;
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

struct BIT {
    int n;
    vector<ll> bit;
    BIT(int sz) { 
        n=1; while(n < sz) n*=2;
        bit.assign(n+1, 0); 
    }
    void update(int i, ll w) {
        for(int x=i+1; x<(int)bit.size(); x += x&-x) bit[x] += w;
    }
    // [0,i]
    ll query(int i) {
        ll ret = 0;
        for(int x=i+1; x>0; x -= x&-x) ret += bit[x];
        return ret;
    }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll,PII>> p(n);
    REP(i, n) {
        cin >> p[i].second.first >> p[i].second.second;
        p[i].first = p[i].second.second - p[i].second.first + 1;
    }
    sort(ALL(p));
    vector<ll> l(n), r(n);
    REP(i, n) l[i] = p[i].second.first, r[i] = p[i].second.second;

    BIT bit(m+1);
    ll num = n, idx = 0;
    FOR(d, 1, m+1) {
        // 区間長がd未満のものの分を加算
        while(idx < n && r[idx]-l[idx]+1 < d) {
            bit.update(l[idx], 1);
            if(r[idx]+1<=m) bit.update(r[idx]+1, -1);
            idx++;
            num--;
        }
        // bitでdの倍数を参照
        ll ret = 0;
        for(ll i=d; i<=m; i+=d) ret += bit.query(i);
        cout << ret + num << "\n";
    }
    cout << flush;

    return 0;
}

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

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

int main(){
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3620
using System;
public class Hello{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int cnt = 0;
        for (int i=1;i<=n;i++){
            string s = i.ToString();
            if ( s.Length%2==1){
                cnt++;
            }
        }
        System.Console.WriteLine(cnt);
    }
}


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

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

    int ans = 0;

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            ans += d[i] * d[j];
        }
    }

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


Measured memory_bytes: 256
n= int(input())
cnt = 0
l = list(map(int,input().split()))
for i in range(n-2):
    for j in range (i+1,n-1):
        for k in range (j+1,n):
            if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                long = max(l[i],l[j],l[k])
                if l[i]+l[j]+l[k] > 2*long:
                    cnt += 1
print(cnt)

Measured memory_bytes: 9204
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=998244353;
#define INF 2*1e9
#define N 210000
using namespace std;

main(){
    int n,k;
    cin>>n>>k;
    int x[N];
    rep(i,n){
        cin>>x[i];
    }
    int t=INF;
    rep(i,n){
        if(x[i]>=0){
            t=i;break;
        }
    }
    if(t==INF){
        cout<<-x[n-k];return 0;
    }
    int ans=INF;
    rep(i,n){
        if(i+k-1<n)
        ans=min(ans,abs(x[i])+(x[i+k-1]-x[i]));
    }
    rep(i,n){
        if(i-k+1>=0)
        ans=min(ans,abs(x[i])-(x[i-k+1]-x[i]));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int X = scan.nextInt();
			int Y = scan.nextInt();
			
			Map<Integer,Integer>map = new TreeMap<Integer,Integer>();
			int[] m = new int[2000];
			
			
			for(int i =1;i<=N-1;i++) {
				for(int j =i+1;j<=N;j++) {
					if(i<=X&&Y<=j) {
						int dist = (X-i)+1+(j-Y);
						m[dist]++;
						//System.out.println(dist+" "+i+" "+j+" ");
						
					}else if(i>X&&Y<=j){
						int dist  =j-i;
						int xydist = i-X+1+j-Y;
						int d = dist<xydist?dist:xydist;
						m[d]++;
						//System.out.println(dist+" "+i+" "+j+" ");	
					}else if(i<=X&&Y>j) {
						int dist  =j-i;
						int xydist = X-i+1+Y-j;
						int d = dist<xydist?dist:xydist;
						m[d]++;
						//System.out.println(dist+" "+i+" "+j+" ");	
					}else if(i>X&&Y>j){
						int dist  =j-i;
						int xydist = i-X+1+Y-j;
						int d = dist<xydist?dist:xydist;
						m[d]++;
						//System.out.println(dist+" "+i+" "+j+" ");	
					}
				}
				
			}
			
		
			
			for(int i = 1;i<N;i++) {
				System.out.println(m[i]);
			}
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 24532
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
   string S;
   cin>>S;
   int N = S.size();
   int ans = 999;
   for(int i = 0;i<=N-3;++i){
      int num = (S[i]-'0')*100 + (S[i+1]-'0')*10 + S[i+2]-'0';
      ans = min(ans,abs(num-753));
   }
   cout<<ans<<endl;
}

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

long long s, n, t;
long long w[100100], v[100100], dp[1001000];

int main () {
    cin >> n >> s;
    for ( int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    for ( int i = 0; i <= s; i++) {
        dp[i] = -pow(10, 10);
    }
    dp[0] = 0;
    for ( int i = 1; i <= n; i++) {
        for ( int j = s; j >= w[i]; j--) {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    for ( int i = 1; i <= s; i++) {
        t = max(t, dp[i]);
    }
    cout << t;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node * find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
    	if(com[0]=='f'){
    		scanf("%d",&x);
    		Node *t=find(root,x);
    		if(t!=NIL){
    			printf("yes\n");
    		}else{
    			printf("no\n");
    		}
    	}else if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 20540
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

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

const int MAXN = 1e5+5;

int n, p[MAXN];
int a[MAXN];
char s[MAXN];

int main(){
	scan(s);
	n = strlen(s);
	FOR(i,0,n) a[i+1] = s[i]-'0';
	if(a[1]!=1 || a[n]==1){
		printf("-1\n");
		return 0;
	}
	FOR(i,1,n){
		if(a[i] != a[n-i]){
			printf("-1\n");
			return 0;
		}
	}
	stack<int> stk;
	stk.push(n);
	int v = -1;
	FOR(i,2,n){
		if(a[i] == 0){
			stk.push(n-i+1);
		}else{
			v = n-i+1;
			while(!stk.empty()){
				int u = stk.top(); stk.pop();
				p[u] = v;
			}
			stk.push(v);
		}
	}
	v = 1;
	while(!stk.empty()){
		int u = stk.top(); stk.pop();
		p[u] = v;
	}
	FOR(i,2,n+1) printf("%d %d\n",p[i],i);

}


Measured memory_bytes: 2380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    vector<pair<int, int>> ps(n);

    string s;
    int c = 0;
    for (int i = 0; i < n; i++) {
        cin >> s >> ps[i].first;
        if (mp.find(s) == mp.end()) {
            mp[s] = c++;
        }
        ps[i].second = mp[s];
    }
    int m;
    cin >> m;

    vector<int> req(m);
    for (int i = 0; i < m; i++) {
        cin >> s;
        if (mp.find(s) == mp.end()) {
            cout << "No" << endl;
            return 0;
        }
        req[i] = mp[s];
    }

    sort(ps.begin(), ps.end());
    int reqmax = 0;
    for (int i = 0; i < ps.size() && reqmax < m; i++) {
        if(ps[i].second == req[reqmax]) {
            reqmax++;
            while(i + 1 < ps.size() && ps[i].first >= ps[i + 1].first) i++;
        }
    }

    if (reqmax == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 18196
import qualified Data.Map as MP
import Data.Bits
import Data.List
import Control.Monad

update m s 
    | h  `elem` "MARCH" = MP.adjust (+1) h m
    | otherwise = m
    where
        h = head s

enum n l
    | l == 0 = []
    | otherwise = (n .&. 1) : enum (shiftR n 1) (l - 1)

solve es = sum $ map (\i -> comb es (enum i 5)) [0..31]
    where
        comb :: [Int] -> [Int] -> Int
        comb es ens 
            | (length $ elemIndices 1 ens) /= 3 = 0
            | otherwise = foldl' step 1 $ zip es ens
                where
                    step acc (v, b)
                        | b == 1 = acc * v
                        | otherwise = acc

main = do
    n <- readLn :: IO Int
    names <- replicateM n getLine
    let m = foldl' (\m i -> MP.insert i 0 m) MP.empty "MARCH"
    let es = MP.elems $ foldl' update m names
    print $ solve es

Measured memory_bytes: 48508
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[100],b[100],u[100];
    cin>>a>>b;
    int A,B;
    cin>>A>>B;
    cin>>u;
    if(strcmp(a,u)==0)
    {
     A--;
    }
    else B--;
    cout<<A<<" "<<B<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main (){

  int N = 0;

  scanf("%d",&N);

  double x[N];
  char tanni[100];

  double sum = 0;

  int i = 0;
  for( i = 0; i < N; i++ ){
    scanf("%lf %s",&x[i], tanni);

    if( tanni[0] == 'B' ){
      x[i] = x[i] * 380000;
    }

    sum = sum + x[i];
  }

  printf("%lf", sum);

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();
		
		int ans = 0;
		for (int i = 0; i < n - 1; i++) {
			if (a[i] == a[i + 1]) {
				ans++;
				i++;
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n%1000)
    {  int i = n/1000;
        while(n>i*1000)
        {
            i++;
        }
        cout<<i*1000-n<<endl;
    }
    else
    cout<<0<<endl;
    return 0;
}

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

#define endl '\n'
#define PI acos(-1.0)
#define F first
#define S second

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	ll n, m, a = 0, x;
	cin >> n >> m;
	
	for(int i = 0; i < m; ++i) {
		cin >> x;
		a += x;
	}
	
	if(a > n) {
		cout << -1 << endl;
	} else {
		cout << n - a << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3664
a,b,c,d = map(int,input().split())
t = b//c-(a-1)//c
u = b//d-(a-1)//d
def gcd(p,q):
    if p%q != 0:
        return gcd(q,p%q)
    else:
        return q
k = c*d//gcd(c,d)
v = b//k-(a-1)//k
print(b-a+1-t-u+v)


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

int main() 
{
	int x,a,b,max;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b))
	{
		cout<<'B'<<endl;
		return 0;
	}
	else
	{
		cout<<'A'<<endl;
		return 0;
	}
}


Measured memory_bytes: 256
def inserts(N):
    k = 1
    for n in N:
        print(n, end='')
        if k < len(N):
            print(' ', end='')
        k += 1
 
    print('')
    for i in range(1,len(N)):
        v = N[i]
        j = i - 1
        while j >= 0 and N[j] > v:
            N[j + 1] = N[j]
            j -= 1
        N[j + 1] = v
        k = 1
        for n in N:
            print(n, end='')
            if k < len(N):
                print(' ', end='')
            k += 1
        print('')
 
 
n = int(input())
numbers = list(map(int, input().split()))
 
inserts(numbers)


Measured memory_bytes: 6316
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int N;
cin >> N;
if(1000-N%1000==1000){
cout << 0;
}
else{
cout << 1000-N%1000;
}










	return 0;

}



Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int a,a1=1,b,sum=0,i,c;
    scanf("%d %d",&a,&b);
    for(i=1;i<=a;i++)
    {
        if(a1<b){
        a1=a1*2;
        }
        else
        a1=a1+b;
    }
    printf("%d\n",a1);
    return 0;
}


Measured memory_bytes: 128
import math
a, b, C = map(int, input().split())
h = b * math.sin(math.radians(C))
S = a * h * 0.5
L = a + b + math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b *math.cos(math.radians(C)))
print(S)
print(L)
print(h)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a >= b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, t;
	cin >> n >> t;
	vector<int> a(n), b(n);
	int c = 0;
	REP(i, n) {
		cin >> a[i] >> b[i];
		chmax(c, a[i]);
	}
	vector<vector<int>> dp(n + 1, vector<int>(t + 1));
	vector<vector<int>> dp2(n + 1, vector<int>(t + 1));
	REP(i, t + 1) {
		dp[0][i] = 0;
	}
	REP(i, n) {
		REP(j, t + 1) {
			if (j >= a[i]) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - a[i]] + b[i]);
			} else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	REP(i, t + 1) {
		dp2[n][i] = 0;
	}
	RREP(i, n) {
		REP(j, t + 1) {
			if (j >= a[i]) {
				dp2[i][j] = max(dp2[i + 1][j], dp2[i + 1][j - a[i]] + b[i]);
			} else {
				dp2[i][j] = dp2[i + 1][j];
			}
		}
	}
	ll res = 0;
	REP(i, n) {
		ll temp = 0;
		REP(j, t) {
			chmax(temp, dp[i][j] + dp2[i + 1][t - 1 - j]);
		}
		chmax(res, temp+b[i]);
	}
	put(res);
 	return 0;
}

Measured memory_bytes: 70912
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x, y;
    
    while(1){
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) {
            break;
        }
        if (x>y) {
            printf("%d %d\n", y, x);
        }else
            printf("%d %d\n", x, y);
    }
        return 0;
}



Measured memory_bytes: 1916
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;

string S;
int S_size;

i64 dfs(int i, i64 value, i64 sum){
    if(i==S_size){
        return sum + value;
    }
    return dfs(i+1, 10*value+S[i]-'0', sum) + dfs(i+1, S[i]-'0', sum+value);
}

int main(){
    cin >> S;
    S_size = S.size();
    i64 ans = dfs(1,S[0]-'0',0);
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n; cin >> n; long long res = 100;
    for(int i = 1 ; ;i ++)
    {
        res += res /100;
        if(res >= n)
        {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3596
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import sqrt

def main():
  n = int(input())
  
  min = 10**12
  for i in range(1, int(sqrt(n))+1):
    if n % i != 0:
      continue
    x = n//i + i
    if min > x:
      min = x
  print(min - 2)
      

if __name__=='__main__':
  main()



Measured memory_bytes: 3060
N = int(input())
S = input()


def create_map(s):
    m = {}
    for c in s:
        if c in m:
            m[c] += 1
        else:
            m[c] = 1
    return m


def common(m1, m2):
    c = 0
    # print(m1)
    # print(m2)
    for key in m1.keys():
        if key in m2:
            c += 1
    # print('commmon = ' + str(c))
    return c


m = 0
for i in range(1, len(S)):
    # print(S[:i])
    # print(S[i:])
    m1 = create_map(S[:i])
    m2 = create_map(S[i:])
    com = common(m1, m2)
    if com > m:
        m = com

print(m)

Measured memory_bytes: 3064