akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, H: "List[int]"):
    H.sort()

    min_hdif = float("inf")
    for i in range(N-K+1):
        min_hdif = min(min_hdif,abs(H[i]-H[i+K-1]))

    print(min_hdif)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7388
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

int main(){
    string s;
    cin >> s;
    int min = 9999;
    for(int i = 0; i < s.length()-2; i++){
        int sum = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        min = std::min(min, abs(753-sum));
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf ((ll)100000000000000)
using namespace std;
int n;
int a[310001];
ll b[110001];
ll c[110001];
priority_queue<int> ato;
priority_queue<int,vector<int>,greater<int> > mae;
int main(){
    cin>>n;
    for(int i=0;i<3*n;i++)cin>>a[i];
    ll maes=0;
    for(int i=0;i<n;i++){mae.push(a[i]);maes+=a[i];}
    b[0]=maes;
    for(int i=0;i<n;i++){
        mae.push(a[n+i]);
        maes+=a[n+i];
        maes-=mae.top();
        mae.pop();
        b[i+1]=maes;
    }
    ll atos=0;
    for(int i=3*n-1;i>=2*n;i--){
        ato.push(a[i]);
        atos+=a[i];
    }
    c[n]=atos;
    for(int i=0;i<n;i++){
        ato.push(a[2*n-1-i]);
        atos+=a[2*n-1-i];
        atos-=ato.top();
        ato.pop();
        c[n-1-i]=atos;
    }
    ll ans=-inf;
    for(int i=0;i<=n;i++){
        ans=max(ans,b[i]-c[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3960
N, M, Q = map(int, input().split())
Left = [0 for _ in range(N)]
Right = [0 for _ in range(N)]
V = [[] for _ in range(N)]
for _ in range(M):
    l, r = map(int, input().split())
    Left[l-1] += 1
    Right[r-1] += 1
    V[r-1].append(l-1)

PQ = [list(map(int, input().split())) for _ in range(Q)]

T = [[0 for _ in range(N)] for _ in range(N)]
a = M
nextl = 0
for l in range(N):
    b = a - nextl
    nextl = Left[l]
    nextr = 0
    for r in range(N-1, l-1, -1):
        T[l][r] = max(b - nextr, 0)
        nextr += Right[r]
        for li in V[r]:
            if li < l:
                nextr -= 1
    a = b


for p, q in PQ:
    print(T[p-1][q-1]) 

Measured memory_bytes: 91224
#include <bits/stdc++.h>
using namespace std;
#define BE(x) (x).begin(), (x).end()

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

    sort (BE(a));
    reverse (BE(a));
    long long x = 0, y = 0;
    for (int i = 0; i < n-1; i++) {
        if (a[i] == a[i+1]) {
            if (x == 0) x = a[i];
            else {
                y = a[i];
                break;
            }
            i++;
        }
    }
    cout << x*y << endl;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    String s = sc.next();
    
    if(a >= 3200){
      System.out.println(s);
    }else{
      System.out.println("red");
    }
  }
  
}

Measured memory_bytes: 35564
Public Class Program
  Shared x As Integer
  Shared Sub Main()
    Dim nx As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim n As Integer = nx(0)
    x = nx(1)
    Dim ls As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim ds(0 To n) As Integer
    ds(0) = 0
    For i As Integer = 1 To n
      ds(i) = ds(i - 1) + ls(i - 1)
    Next
    Dim output As Integer = Array.FindAll(Of Integer)(ds, AddressOf IsLessThan).Length
    Console.WriteLine(output.ToString())
  End Sub
  
  Shared Function IsLessThan(value As Integer) As Boolean
    Return If(value <= x, True, False)
  End Function
End Class

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int count = 0;
	int a = A;
	int b = B;
	int c = C;	
	while(1) {
		if (a%2 > 0 || b%2 > 0 || c%2 > 0) {
			break;
		}
		int a_next = b/2 + c/2;
		int b_next = c/2 + a/2;
		int c_next = a/2 + b/2;
		a = a_next;
		b = b_next;
		c = c_next;

		if (a == A && b == B && c == C) {
			count = -1;
			break;
		}

		count++;
	}
	cout << count << endl;
	return 0;
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if (A == B && B == C && A==C) {
    cout << "No";
    goto no;
  }else if(A != B && B != C && A != C) { 
    cout << "No";
    goto no;
  }else goto yes;
  
  yes:
  cout << "Yes";
  
  no:
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,r,c,sum,/*ck1,ck2,*/masu[105][105];
	scanf("%d %d",&r,&c);
	for(i=1;i<=101;i++) {
		for(j=1;j<=101;j++) {
			masu[i][j]=0;
		}
	}
	for(i=1;i<=r;i++) {
		for(j=1;j<=c;j++) {
			scanf("%d",&masu[i][j]);
		}
	}
/*	ck1=0;
	ck2=0;*/
	for(i=1;i<=r+1;i++) {
		sum=0;
		for(j=1;j<=c+1;j++) {
			if(j<=c) {
				sum+=masu[i][j];
			}
			else {
				masu[i][j]+=sum;
				//ck1+=sum;
			}
		}
	}
	for(j=1;j<=c+1;j++) {
		sum=0;
		for(i=1;i<=r+1;i++) {
			if(i<=r) {
				sum+=masu[i][j];
			}
			else {
				masu[i][j]+=sum;
//				ck2+=masu[i][j];
			}
		}
	}
//	printf("CK1=%d CK2=%d\n",ck1,ck2);
	for(i=1;i<=r+1;i++) {
		for(j=1;j<=c+1;j++) {
			if(j<=c) {
				printf("%d ",masu[i][j]);
			}
			else {
				printf("%d\n",masu[i][j]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
const ll MOD=1e9+7;
ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
   // works for neg and pos values of x.
}
vector <ll> row[300005];
multiset <ll> best;
ll col[300005];
void upd(ll pos,ll del)
{
    best.erase(best.find(col[pos]));
    col[pos]+=del;
    best.insert(col[pos]);
}
void solve()
{
    ll n,m,k,x,y;
    cin>>n>>m>>k;
    fo(i,1,m+1)
    {
        best.insert(0);
    }
    fo(i,0,k)
    {
        cin>>x>>y;
        row[x].pb(y);   
        upd(y,1);
    }
    ll ans=0;
    fo(i,1,300005)
    {
        if(row[i].size()!=0)
        {
            for( ll ele : row[i])
            {
                upd(ele,-1);
            }
            ll sum=row[i].size();
            sum+=*best.rbegin();
            ans=max(ans,sum);
            for( ll ele : row[i])
            {
                upd(ele,1);
            }
        }
    }
    cout<<ans;


}
int main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 36456
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll a, b, c, k;cin >> a >> b >> c >> k;
	ll ans = 0;
	ans += min(a, k);
	k -= min(a, k);
	k -= min(b, k);
	ans -= min(c, k);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c << endl;
  }else if (a == c){
    cout << b << endl;
  }else{
    cout << a << endl;
  }


  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

			for(int i=1;i>0; i++){
				int H = scan.nextInt();
				int W = scan.nextInt();

					if(H == 0 && W == 0)break;
						for(int j=1;j<=H; j++){
							for(int k=1; k<=W; k++){
								System.out.print("#");
							}
								System.out.println("");
							}
								System.out.println("");
							}

		}

}

Measured memory_bytes: 34460
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int r;
	cin >> r;
	cout << r * r << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
int main(){
    int x;cin>>x;
    if(x==0)cout<<1<<endl;
    else if(x==1)cout<<0<<endl;
    return 0;
}/*
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    max(a*b,max(c*d,max(a*)))
}
*/


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

int main() {
        int i, j ,l;
        int prime = 0;
        int counter = 0;
        int sq = 0;
        cin >> l;
        int *s = new int[100];
        for(i=0; i<l; i++){
                cin >> s[i];
        }
        for(i=0; i<l; i++){
                counter = 0;
                sq = sqrt(s[i]);
                for(j=2; j<sq+1; j++){
                        if(s[i] % j == 0){
                                counter ++;
                        }
                }
                if(counter == 0) 
                        { prime++;
                }
        }
        cout << prime << endl;
}





Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int a,b,sum;
scanf("%d %d",&a,&b);
	sum=a+b;
	while(sum>=24){

	sum=sum-24;
		}
	printf("%d",sum);
	
	
	
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007
const double PI=3.14159265358979323846;

int main(){
    double a;
    scanf("%lf",&a);
    a*=2;
    a*=PI;
    
    printf("%lf",a);
}

Measured memory_bytes: 3824
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const ll MOD = 1000000007;
const ll N_MAX = 100;

ll N = 0;
vector<vector<vector<vector<int>>>> dp(N_MAX+1, vector<vector<vector<int>>>(4, vector<vector<int>>(4, vector<int>(4, -1))));

ll dfs(ll n, ll a, ll b, ll now) {
  if (dp[n][a][b][now]!=-1) return dp[n][a][b][now];
  if (n==0) return dp[n][a][b][now] = (a==3&&b==3&&now==3) ? 1 : 0;
  ll result = 0;

  if (a==0 && b==1 && now==2) return dp[n][a][b][now] = 0;
  if (a==1 && b==0 && now==2) return dp[n][a][b][now] = 0;  
  if (a==0 && b==2 && now==1) return dp[n][a][b][now] = 0;

  rep(i,4) {
    if (i==0 && a==1 && b==2) continue;
    if (i==0 && a==1 && now==2) continue;    
    if (i==0 && b==1 && now==2) continue;
    if (i==1 && a==0 && b==2) continue;
    if (i==0 && a==2 && b==1) continue;
    result += dfs(n-1, i, a, b);
  }
  return dp[n][a][b][now] = result % MOD;

}

int main() {
  cin >> N;

  ll result = 0;
  rep(i, 4) rep(j, 4) rep(k, 4) result = (result+dfs(N,i,j,k))%MOD;
  // rep(i, 4) rep(j, 4) rep(k, 4) cout << i << " " << j << " " << k << " " << dfs(N,i,j,k) << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 384
var w,n,e,s:longint;
    x:char;
begin
  while not eoln do
  begin
    read(x);
    case x of
      'W':w:=1;
      'N':n:=1;
      'E':e:=1;
      'S':s:=1;
    end;
  end;
  if (w=e) and (n=s) then
    writeln('Yes')
  else
    writeln('No');
end.

Measured memory_bytes: 128
from collections import deque

S = list(input())
Q = int(input())
Query = []
cnt_re = 0
for i in range(Q):
    tmp = input().split()
    Query.append(tmp)
    if (len(tmp) == 1):
        cnt_re += 1
prev = deque()
after = deque()
if (cnt_re % 2 != 0):
    S = list(reversed(S))
for q in Query:
    if (len(q) == 3):
        if q[1] == '1':
            if (cnt_re % 2 == 0):
                prev.appendleft(q[2])
            else:
                after.append(q[2])
        else:
            if (cnt_re % 2 == 0):
                after.append(q[2])
            else:
                prev.appendleft(q[2])
    else:
        cnt_re -= 1
print(''.join(list(prev)) + ''.join(list(S)) + ''.join(list(after)))

Measured memory_bytes: 114552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define all(x)              (x).begin(), (x).end()
#define inf                 1e18

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//	ifstream cin("input.txt");
//	ofstream cout("output.txt");
	int n;
	cin >> n;
	set <ll> st;
	for (int i = 0; i < n; ++i) {
		ll x;
		cin >> x;
		st.insert(x);
	}
	cout << ((st.size() == n) ? "YES" :  "NO");
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
const int maxm=1e5+10;
const int mod=1e9+7;
typedef long long ll;
ll pre[maxn],tree[maxn];
inline int lowbit(int x){return x&-x;}
inline void update(int x,int val){
    for (int i=x; i<maxn; i+=lowbit(i)) tree[i]+=val;
}
ll query(ll x){
    ll res=0;
    for (int i=x; i>0; i-=lowbit(i)) res+=tree[i];
    return res;
}
inline void init(){
    for (int i=0; i<maxn; i++) tree[i]=0;
    pre[0]=0;
}
ll n,a[maxn],tmp;
bool check(ll x){
    init();
    for (int i=1; i<=n; i++) pre[i]=pre[i-1]+(a[i]>=x?1:-1);
    ll res=0;
    for (int i=0; i<=n; i++) {
        res+=query(maxm+pre[i]);
        update(pre[i]+maxm,1);
    }
    return res>=tmp;
}

int main(){
    while(scanf("%lld",&n)==1){
        tmp=1ll*n*(n+1)/4;
        ll l=0,r=0;
        for (int i=1; i<=n; i++) scanf("%lld",&a[i]),r=max(r,a[i]);
        while(l<=r){
            ll mid=l+r>>1;
            if(check(mid)) l=mid+1;
            else r=mid-1;
        }
        printf("%lld\n",r);
    }
    return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define HASH_SIZE 65536

struct list {
    int num;
    int cnt;
    struct list *next;
};

struct list *create_htable(void) {
    static struct list htable[HASH_SIZE];
    int i;
    for(i = 0; i < HASH_SIZE; i++) {
        htable[i].next = &htable[i];
    }
    return htable;
}

int get_key(int num) {
    return num & (HASH_SIZE-1);
}

struct list* find(struct list *htable, int num) {
    struct list *head = &htable[get_key(num)];
    struct list *elem;
    for(elem = head->next; elem != head; elem = elem->next) {
        if(elem->num == num) {
            return elem;
        }
    }
    return NULL;
}

int find_cnt(struct list *htable, int num) {
    struct list *elem = find(htable, num);
    if(!elem) return 0;
    return elem->cnt;
}

void add_elem(struct list *htable, int num) {
    struct list *elem = find(htable, num);
    if(elem) {
        elem->cnt++;
    } else {
        elem = malloc(sizeof(struct list));
        struct list *head = &htable[get_key(num)];
        elem->next = head->next;
        elem->num = num;
        elem->cnt = 1;
        head->next = elem;
    }
}

void put_elem(struct list *htable, int num) {
    struct list *elem = find(htable, num);
    if(elem) elem->cnt--;
}

#define NUM_MAX 100000

int main(void) {
    int num, multis;
    static int arr[NUM_MAX];
    get_int2(&num, &multis);
    fget_array(arr, num);
    int i;
    for(i = 0; i < num; i++) arr[i] = (arr[i]%multis);

    struct list *htable = create_htable();
    int sum = 0;
    for(i = 0; i < num; i++) {
        sum = (sum + arr[i])%multis;
        add_elem(htable, sum);
    }

    // remove
    int offset = 0;
    int64_t ans = find_cnt(htable, offset);

    for(i = 0; i < num-1; i++) {
        // arr[i]-offset: indexer
        put_elem(htable, (arr[i]-offset+multis)%multis);
        offset = (offset -arr[i]+multis)%multis;
        ans += find_cnt(htable, (multis-offset)%multis);
#ifdef DEBUG
        printf("%d: %d -> %lld\n", i, offset, ans);
#endif
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.size(),c=0;
    for(int i=0;i<l/2;i++)
    {
        if(s[i]!=s[l-1-i])
            c++;
    }
    printf("%d\n",c);
    return 0;
}


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

int calculate(int first, int second, string ope){
    if(ope == "+"){
        return first + second;
    }else if(ope == "-"){
        return first - second;
    }else if(ope == "*"){
        return first * second;
    }
}

bool is_operator(string &s){
    if(s == "+" || s == "-" || s == "*"){
        return true;
    }else{
        return false;
    }
}

int main(){
    stack<string> formula;
    bool flag = true;
    string s;
    while(cin >> s){
        if(is_operator(s)){
            string str_second = formula.top();
            formula.pop();
            string str_first = formula.top();
            formula.pop();
            int second = stoi(str_second);
            int first = stoi(str_first);
            int result = calculate(first,second,s);
            string str_result = to_string(result);
            formula.push(str_result);

        }else{
            formula.push(s);
        }
    }
    cout << formula.top() << endl;
}


Measured memory_bytes: 3256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = list(range(n))
        self.ranks = [0 for _ in range(n)]

    def get_root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.get_root(self.parents[x])
        return self.parents[x]

    def merge(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x != y:
            if self.ranks[x] < self.ranks[y]:
                self.parents[x] = y
            else:
                self.parents[y] = x
                if self.ranks[x] == self.ranks[y]:
                    self.ranks[x] += 1


n, m = ril()
uf = UnionFind(n)
for _ in range(m):
    x, y, z = ril()
    uf.merge(x - 1, y - 1)
for i in range(n):
    uf.get_root(i)
print(len(set(uf.parents)))

Measured memory_bytes: 13992
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)
#define meax 100507
 vll a(meax,LONG_MAX);
  vll b(meax,LONG_MAX);
  ll sum1=0;
  ll k=0;
ll maximize(ll i,ll n,ll prev){

    if(b[i]!=LONG_MAX){
        return b[i];
    }
    if(i>=n){
        return LONG_MAX;
    }

    if(i==n-1){
            b[i]=0;
        return b[i];
    }
    ll d2=LONG_MAX;
    for(ll j=1;j<=k;j++){
        ll d1=maximize(i+j,n,a[i]);
        if(i+j<n)
        d2=min(d2,abs(a[i+j]-a[i])+d1);
    }
    b[i]=d2;
    return b[i];


}
int main(){
    ll n;
    cin>>n>>k;


    rep(i,0,n,1){
        cin>>a[i];
    }
    ll d=maximize(0,n,a[0]);
    cout<<d<<endl;
}


Measured memory_bytes: 11124
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,a[8],b[8],c[8],a1,b1;

bool f(bool q){
	if (q){
		for (int i=0;i<n;i++)
			if (a[i]!=c[i])
				return false;
		return true;
	}
	else {
		for (int i=0;i<n;i++)
			if (b[i]!=c[i])
				return false;
			return true;
	}
}

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>a[i];
	for (int i=0;i<n;i++)
		cin>>b[i];
	for (int i=1;i<=n;i++)
		c[i-1]=i;
	int k=0;
	do{
		k++;
		if (f(true))
			a1=k;
		if (f(false))
			b1=k;
	}while (next_permutation(c,c+n));
	cout<<abs(a1-b1);
	return 0;
}

Measured memory_bytes: 896
A=[0]*1000
A[0]=11111
A[1]=111111
def a(i,j,k,l=0):
    print("+<"[l],i,j,k)
    A[k] = int(A[i] < A[j]) if l else A[i] + A[j]


r=range
print(6484)
a(0,1,3)
a(2,3,3,1)
for x in 0,1:
    a(x,3,x)
    for t in r(30):a(v:=x+4,v,v);a(v,3,6);exec('a(6,6,6);'*(29-t));a(6,x,T:=x*60+9+t,1);a(v,T,v)
for t in r(60):a(2,2,2);[(a(8+t-s,69+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]


assert((A[0]-1) * (A[1]-1) == A[2])

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(vector<int>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{  
  int A,B;
  cin>>A>>B;
  if((A*B)%2 == 0)
  {
    cout<<"Even"<<endl;
  }
  else
  {
    cout<<"Odd"<<endl;
  }
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, k; cin >> n >> k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    vector<int> prev;
    while (k--) {
        vector<int> diff(n + 2);
        for (int i = 1; i <= n; i++) {
            diff[max(0ll, i - a[i])]++;
            diff[min(n + 1, i + a[i] + 1)]--;
        }
        for (int i = 1; i <= n; i++) {
            diff[i] += diff[i - 1];
            a[i] = diff[i];
        }
        if (prev.empty() || prev != a)
            prev = a;
        else
            break;
    }
    for (int i = 1; i <= n; i++)
        cout << a[i] << ' ';
}


Measured memory_bytes: 7948
class Main{
	public static void main(String[] args){
		output();
	}
	private static void output (){
		for (int i = 1; i <= 9; i++){
			for (int j = 1; j <= 9; j++){
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}

Measured memory_bytes: 24180
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int num[]=new int[3];
    int sum=0,max=5,min=7;
    for(int i=0;i<3;i++){
      num[i]=sc.nextInt();
      sum+=num[i];
      max=Math.max(max,num[i]);
      min=Math.min(min,num[i]);
    }    
    if((sum==17)&&(max==7)&&(min==5)){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21972
import sys
def getpar(Edge, p = 0):
    N = len(Edge)
    par = [0]*N
    par[p]  -1
    stack = [p]
    visited = set([p])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            stack.append(vf)
    return par

mod = 10**9+7
N = int(input())
Dim = [0]*N
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a] += 1
    Dim[b] += 1

Dim[0] += 2
Leaf = [i for i in range(N) if Dim[i] == 1]

par = getpar(Edge)
dpw = [1]*N
dpb = [1]*N
stack = Leaf[:]
while stack:
    vn = stack.pop()
    vp = par[vn]
    dpw[vp] = (dpw[vp]*(dpw[vn] + dpb[vn])) % mod
    dpb[vp] = dpb[vp]*dpw[vn] % mod
    Dim[vp] -= 1
    if Dim[vp] == 1:
        stack.append(vp)
print((dpw[0] + dpb[0])%mod)


Measured memory_bytes: 72304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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


int main() {

	int n, a, b;
	cin >> n >> a >> b;

	int ans = inf;
	ans = min(b, a * n);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
int main(void){
  ll n,x;
  cin >> n >> x;
  vector<int> child(n);
  rep(i,n){
    cin >> child.at(i);
  }
  sort(child.begin(),child.end());
  int ans = 0;
  rep(i,n){
    x -= child.at(i);
    if(x >= 0){
      ans++;
    }
  }
    if(x > 0){
      ans--;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class t,class u>
ostream& operator << (ostream& os,pair<t,u> p){
	return os << p.fi << ',' << p.sec;
}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
int N,K;
string s;
int main(){
	cin >> N;
	cin >> s;
	cin >> K;
	K--;
	for(int i=0;i<s.size();i++){
		if(s[i]!=s[K])s[i] = '*';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int N;
int cnt[26];
string S;
int main(){
  cin>>N;
  FOR(i,0,26){
    cnt[i]=INF;
  }
  FOR(i,0,N){
    cin>>S;
    int p[26];
    fill(p,p+26,0);
    FOR(j,0,(int)S.size()){
      p[S[j]-'a']++;
    }
    FOR(j,0,26){
      cnt[j]=min(cnt[j],p[j]);
    }
  }
  FOR(i,0,26){
    FOR(j,0,cnt[i]){
      char c='a'+i;
      cout<<c;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N,M,X,Y = [int(x) for x in input().split()]

xl = [int(x) for x in input().split()]
yl = [int(x) for x in input().split()]

xl.sort()
yl.sort()

xmax = xl[-1]
ymin = yl[0]

war = 'War'
nowar = 'No War'

kyokai = xmax + 1

isOk = False

if xmax < ymin:
    isOk = True
else:
    print(war)
    exit()

if kyokai <= ymin:
    pass
else:
    print(war)
    exit()

if X < kyokai:
    pass
else:
    print(war)
    exit()

if kyokai <= Y:
    pass
else:
    print(war)
    exit()


print(nowar)

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

int main(){
    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;
    int64_t max = 0;
    int64_t ans = 0;
    if(a >= k){
        cout << k << endl;
    }
    else if(k > a+b){
        cout << a-(k-(a+b)) << endl;
    }
    else{
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<bitset<101> > know(n);
        for(int i=0; i<n; ++i){
            int m;
            cin >> m;
            for(int j=0; j<m; ++j){
                int p;
                cin >> p;
                know[i][p] = true;
            }
        }

        int k;
        cin >> k;
        bitset<101> bs;
        for(int i=0; i<k; ++i){
            int l;
            cin >> l;
            bs[l] = true;
        }

        int ret = -1;
        for(int i=0; i<n; ++i){
            if((bs & ~know[i]).none()){
                if(ret == -1){
                    ret = i + 1;
                }else{
                    ret = -1;
                    break;
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 908
#include<stdio.h>
#include<algorithm>
#include<map>
#include<math.h>
using namespace std;
int n, p[2500], cnt;
long long w[101000], G1[101000], G2[101000], Res;
map<long long,int>Map;
int main(){
    int i, j;
    for(i=2;i<=2500;i++){
        for(j=2;j*j<=i;j++){
            if(i%j==0)break;
        }
        if(j*j>i)p[++cnt] = i;
    }
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%lld",&w[i]);
        G1[i]=G2[i]=1;
        for(j=1;j<=cnt;j++){
            if(w[i]%p[j] == 0){
                while(w[i]%(p[j]*p[j]*p[j]) == 0){
                    w[i]/=(p[j]*p[j]*p[j]);
                }
                if(w[i]%(p[j]*p[j]) == 0){
                    G2[i]*=p[j];
                    w[i]/=(p[j]*p[j]);
                }
                else if(w[i]%p[j] == 0){
                    G1[i]*=p[j];
                    w[i]/=p[j];
                }
            }
        }
        int t = (int)sqrt(1.0*w[i]);
        for(j=t-1;j<=t+1;j++){
            if(1ll*j*j == w[i])break;
        }
        if(j!=t+2){
            G2[i]*=j;
        }
        else G1[i]*=w[i];
        Map[G1[i]*G2[i]*G2[i]]++;
    }
    for(i=1;i<=n;i++){
        long long a = G2[i]*G1[i]*G1[i], b = G1[i]*G2[i]*G2[i];
        if(a==1){
            if(Map[a])Res++;
        }
        else{
            Res += max(Map[a],Map[b]);
        }
        Map[a]=Map[b]=0;
    }
    printf("%lld\n",Res);
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
using Long = long long;


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);

    for(int i =  0 ; i < n ; ++i ) cin>> v[i];
    sort(v.begin(),v.end());
    int s = 0;
    for( int i = 0  ; i < k ; ++i ){
        s += v[i];
    }
    cout << s ;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<bitset>
#define DEBUG
using namespace std;
int main(){
  int n;
  while(cin >> n && n) {
    int num[n];
    for (int i = 0; i < n; i++) {
      cin >> num[i];
    }
    int min = 1000000;
    for (int i = 0; i < n; i++) {
      for (int j = i+1; j < n; j++) {
	if (min > abs(num[i]-num[j])) {
	  min = abs(num[i]-num[j]);
	}
      }
    }
    cout << min << endl;
  }




  return 0;
}


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

int main() {
  int h,a;
  int ans = 0;
  cin >> h >> a;
  while (h>0) {
    h -= a;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

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

int main(void){
	int p=10000;
	int ju=10000;
	
	for(int i = 0; i < 3; i++){
		int t;
		scanf("%d", &t);
		if(p>t)p = t;
	}
	
	for(int i = 0; i < 2; i++){
		int t;
		scanf("%d", &t);
		if(ju>t)ju = t;
	}
	
	printf("%d\n", ju+p-50);
	return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	//string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	map<string,int>blue,red;

	cin>>n;

	f(i,0,n-1){
	    string s1;
        cin>>s1;

        blue[s1]++;

	}

	cin>>m;

	f(i,0,m-1){
        string s1;
        cin>>s1;

        red[s1]++;

	}

	int sum=0;

	for(auto it=blue.bb;it!=blue.ee;it++){

            //cout<<it->se<<endl;

        if(red[it->fi]){
            maxi=max(maxi,((it->se)-red[it->fi]));
        }
        else{
            maxi=max(it->se,maxi);
        }




	}

	cout<<max(maxi,0)<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict

def inside(x, y):    
    return 0 <= x <= h - 3 and 0 <= y <= w - 3

h, w, n = (int(_) for _ in input().split())
black = defaultdict(int)
for i in range(n):
    a, b = (int(_) - 1 for _ in input().split())
    for j in range(3):
        for k in range(3):
            x, y = a - j, b - k
            if not inside(x, y):
                continue
            black[(x, y)] += 1
ans = [0 for i in range(10)]
ans[0] = (h-2)*(w-2) - len(black)
for k in black:
    ans[black[k]] += 1
for i in range(10):
    print(ans[i])


Measured memory_bytes: 140576
N, M, L = map(int, input().split())

A=[]
B=[]

for i in range(N):
  A.append(list(map(int, input().split())))

for j in range(M):
  B.append(list(map(int, input().split())))
  
BT = list(map(list, zip(*B)))


C =[[0 for k in range(L)] for i in range(N)]

for i in range(N):
    for j in range(L):
        for k in range(M):
            C[i][j] += A[i][k]*B[k][j]
for c in C:
    for i in range(len(c)):
        if i+1 == len(c):
            print(c[i])
        else:
            print(c[i], end=" ")


Measured memory_bytes: 7176
#include<stdio.h>

int def(int a, int b);
int main(void){
    int a, b, c, d;
    int flag = 0;

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

    if(def(a, b)>d || def(b, c)>d) flag++;
    if(def(a, c)<=d) flag = 0;

    if(!flag){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

int def(int a, int b){
    return (a<b) ? b-a : a-b;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
const double PI=3.14159265358979323846; 
using namespace std;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a>=k) cout << k << endl;
  else if(a+b>=k) cout << a << endl;
  else if(a+b+c>=k) cout << a-(k-a-b) << endl;
}


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

int main(){
    ll n,ans=1;
    cin>>n;
    for(int i=2;i<=n;i++){
        ll j=i;
        while(j<=n){
            j*=i;
        }
        j/=i;
        if(j!=i){
            ans=max(ans,j);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
ll MOD = 1e9 + 7;
//vector<ld> vec;
ll INT_MAX=pow(2,31)-1;
//#define int long long
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketSum;
  SqrtDecomposition(int n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucketSum.assign(K, 0);
  }
  void add(int x, int y) {
    int k = x / sqrtN;
    data[x] += y;
    int sum = 0;
    for (int i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
      sum += data[i];
    }
    bucketSum[k] = sum;
  }
  // [x, y)
  int getSum(int x, int y) {
    int sum = 0;
    for (int k = 0; k < K; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        sum += bucketSum[k];
      } else {
        for (int i = max(x, l); i < min(y, r); ++i) {
          sum += data[i];
        }
      }
    }
    return sum;
  }
};
	
int main(){
    int n,q;
    cin>>n>>q;
    SqrtDecomposition seg(n);
    for(int i=0;i<q;i++){
        int k;
        cin>>k;
        int x,t;
        cin>>x>>t;
        if(k==0){
            seg.add(x,t);
        }else{
            cout<<seg.getSum(x,t+1)<<endl;
        }
    }
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int sum=0;
	for(int i=0; i<=s.length(); i++)
	{
		if(s[i]!=t[i])
		{
			sum=sum+1;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 3888
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    ans = 0
    L = [0]
    for i in range(N):
        num = int(input())
        if L[-1] == 0:
            ans += (num//2)
            L.append(num%2)
        else:
            if num == 0:
                L.append(num)
                continue
            else:
                num -= 1
                ans += (num//2+1)
                L.append(num%2)
                
    print(ans)
            
if __name__ == "__main__":
    main()


Measured memory_bytes: 3928
def main(n, ns):
    if len(set(ns)) == 1:
        return 0
    
    min_v  = min(ns)
    max_v  = max(ns)
    answer = pow(100, 3)
    for i in range(min_v, max_v + 1):
        cost = 0
        for j in ns:
            if i == j:
                continue
            cost += pow((j - i), 2)
        answer = min(answer, cost)
    return answer
 
 
if __name__ == '__main__':
    n = int(input())
    ns = [int(e) for e in input().split()]
    print(main(n, ns))




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

using namespace std;

int main()
{
	int32_t h, w;
	cin >> h >> w;

	vector<string> image(h);;
	for(auto& slice : image) {
		cin >> slice;
	}

	for(auto i = 0; i < h; ++i) {
		cout << image[i] << '\n' << image[i] << endl;
	}
}

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

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

    int N,M;
    cin>>N>>M;

    vector<int> A(M);
    for(int i=0;i<M;i++)
        cin >> A[i];

    int sum = 0;
    for(int a : A)
        sum += a;

    int ans = N-sum;
    printf("%d\n",ans<-1?-1:ans);

    return 0;
}



Measured memory_bytes: 3740
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = [0]

for i in range(N):
    D.append(D[-1] + L[i])

flag = True
for i in range(len(D)):
    if D[i] > X:
        print(i)
        flag = False
        break

if flag:
    print(N+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

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

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

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

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

    int ans = 1;
    
    set<int> s;
    for(int i = 0; i < n; ++i)
        s.insert(b[i]);
    
    auto many = [&] (int x, int y) -> int {
        auto lf = lower_bound(a.begin(), a.end(), x);
        if(lf == a.end())
            return 0;
        auto rt = upper_bound(a.begin(), a.end(), y);
        rt--;
        return (rt - lf + 1);
    };

    for(int i = 0; i < n; ++i) {
        int x = *(s.begin());
        s.erase(s.begin());
        ans = 1LL * ans * (many(min(x, a[i]), max(x, a[i]))) % MOD;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i'|| c == 'u' || c == 'e' || c == 'o')cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 764
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    int m = (n + 1000 - 1) / 1000 * 1000;
    int res = m - n;

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3648