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

using namespace std;

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

    int ans = 1000;
    for (int i = 0; i <= s.length() - 3; ++i) {
        ans = min(ans, abs(stoi(s.substr(i, 3)) - 753));
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define int long long int
#define FILEIO  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
#define maxn 1000000
 

using namespace std;

int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
signed main() {
//FILEIO;
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
int n , m , k;
cin>>n>>m>>k;
int a[n];
int b[m];
int pref1[n + 1];
int pref2[m + 1];
pref1[0] = 0;
pref2[0] = 0;
for (int i = 0; i < n; ++i)
{
    /* code */
    cin>>a[i];
    pref1[i + 1] = pref1[i] + a[i];
}
for (int i = 0; i < m; ++i)
{
    /* code */
    cin>>b[i];
    pref2[i + 1] = pref2[i] + b[i];
}
int ans = -1;
for(int i = 0; i <= n; i++)
{
    int temp = pref1[i];
    int remain = k - temp;
    if(remain < 0)
        break;
    int start = 0;
    int end = m;
    while(start <= end)
    {
        int mid = (start + end)/2;
        if(pref2[mid] > remain)
        {
            end = mid - 1;
        }
        else
        {
            start = mid + 1;
        }
    }
    ans = max(ans , i + end);
}
cout<<ans;










    return 0;
}


Measured memory_bytes: 9880
#include <iostream>
#include <map>
#include <vector>
#define int long long int
using namespace std;
signed main() {
  bool f;
  vector<pair<int, int> > v;
  int n, a, b, c;
  while (cin >> n && n > 0) {
    v.clear();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      f = 0;
      for (int j = 0; j < v.size(); j++) {
        if (v[j].first == a) {
          v[j].second += b * c;
          f = 1;
        }
      }
      if (!f) {
        v.push_back(pair<int, int>(a, b * c));
      }
    }
    f = 0;
    for (int i = 0; i < v.size(); i++) {
      if (v[i].second >= 1000000) {
        cout << v[i].first << endl;
        f = 1;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}

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

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

template<class T>
inline bool ChangeMin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;

    int min = 201;
    ChangeMin(min, P+Q);
    ChangeMin(min, P+R);
    ChangeMin(min, Q+R);

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    N,K=map(int,input().split())
    P=[int(i) for i in input().split()]
    PP= [i*(i+1)/2/i for i in P]
    mx = sum(PP[:K])
    sm=mx
    for i in range(K,N):
        sm+=PP[i]
        sm-=PP[i-K]
        mx=max(sm,mx)
    print(mx)





if __name__ == "__main__":
    resolve()

Measured memory_bytes: 25188
import sys
N = int(input())

dict = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for _ in range(N):
    S = input()
    if S in dict:
        i = dict.get(S)
        i += 1
        dict[S] = i

for key in dict.keys():
    print(key, 'x', dict.get(key))


Measured memory_bytes: 9112
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]){
        cout<<"Yes"<<endl;
    }else if(s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]){
        cout<<"Yes"<<endl;
    }else if(s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

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

int a, b, m;
vector<int> r, d;
vector<int> x, y, c;

int main() {
  vector<int> hoge(100000000);
    cin >> a >> b >> m;
    r.resize(a), d.resize(b);
    for (int i = 0; i < a; i++) {
        cin >> r[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> d[i];
    }
    x.resize(m);
    y.resize(m);
    c.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--, y[i]--;
    }
    int mr = *min_element(r.begin(), r.end());
    int md = *min_element(d.begin(), d.end());
    int ans = INT_MAX;
    chmin(ans, mr + md);
    for (int i = 0; i < m; i++) {
        int cand = r[x[i]] + d[y[i]] - c[i];
        chmin(ans, cand);
    }
    cout << ans << endl;
}


Measured memory_bytes: 392832
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;
const int mod = 1e9+7;

int n;
vector<vi> edges;
vector<vector<ll>> dp;

#define b first
#define w second

ll mult(ll a, ll b) {    
    ll x = ll(a * b) % mod;
    return x;
}

ll add(ll a, ll b) { 
    ll x = a + b;
    if(x >= mod) {
        x -= mod;
    }
    return x;
}


// c = 0 -> white, c = 1 -> black
ll dfs(int a, int parent, int c) {
    
    if(dp[a][c] != -1) return dp[a][c];
    
    ll ans = 1;
    
    for(int& b : edges[a]) if(b != parent) {
        
        if(c == 0) {
            ans = mult(ans, add(dfs(b, a, 0),dfs(b, a, 1))); 
        } else if(c == 1) {
            ans = mult(ans, dfs(b, a, 0));
        }
        
        ans %= mod;
    
    }
    
    ans %= mod;
    dp[a][c] = ans;
    return ans;
}

int main() {
   
    scanf("%d",&n);
    edges.resize(n+1);
    dp.assign(n+1, vector<ll>(2, -1));
    
    for(int i = 0; i < n-1; ++i) {
        int a, b;
        scanf("%d%d",&a,&b);
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    ll ans1 = dfs(1, -1, 0);
    ll ans2 = dfs(1, -1, 1);
    
    cout << add(ans1, ans2) << endl;
    
    return 0;
}




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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define e "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

#define N 5010

void solve()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<((abs(a-b)%2==0)?"Alice":"Borys");
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main(){
  string s;cin >> s;
  int count = 0;
  int ans = 0;
  rep(i,3) {
    if(s[i] == 'R') count++;
    else count = 0;
    ans = max(ans,count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	long double n, m, d;
	cin >> n >> m >> d;
	long double ans;
	if(d == 0)
		ans = (m - 1) / n;
	else
		ans = 2 * (n - d) * (m - 1) / (n * n);
	cout << fixed << setprecision(12) << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#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 1000000007LL

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

ll dp[4][3333][3333];
ll v[3333][3333];

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

	ll r, c, k;cin >> r >> c >> k;
	REP(i, k){
		ll x, y, a;cin >> x >> y >> a;
		x--;y--;
		v[x][y] = a;
	}

	REP(x, r+1){
		REP(y, c+1){
			REP(i, 4) {
				if(i < 3){
						dp[0][x+1][y] = max(dp[0][x+1][y], dp[i][x][y] + v[x][y]);
						dp[i+1][x][y+1] = max(dp[i+1][x][y+1], dp[i][x][y] + v[x][y]);
				}
				dp[0][x+1][y] = max(dp[0][x+1][y], dp[i][x][y]);
				dp[i][x][y+1] = max(dp[i][x][y+1], dp[i][x][y]);
			}
		}
	}

	ll ans = 0;
	REP(i, 4)ans = max(ans, dp[i][r+1][c]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 393920
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
pre = 100
ans = 0

for i in a:
    ans += b[i-1]
    if i == pre + 1:
        ans += c[i-2]
    pre = i
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll INF = 1000000000000000;
// a rateがa下がる
// b rateがb以上である必要あり
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl d = VV(n, 4, 0, ll);
  for(int i=0;i<n;i++){
    ll a, b, c;scanf("%lld %lld %lld", &a, &b, &c);
    d[i][0] = a, d[i][1] = b, d[i][2] = c, d[i][3] = a - (INF - b);
  }
  sort(all(d), [](vll x, vll y){return x[3] < y[3];});
  //for(auto v:d) std::cout << v[0] << " " << v[1] << '\n';

  vvl dp = VV(n+1, 10002, -INF, ll);
  dp[0][0] = 0;
  for(int i=0;i<n;i++){
    for(ll j=0;j<=10001;j++){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if(d[i][1]<j||j==10001) continue;
      ll nxt = (j+d[i][0]>10000?10001:j+d[i][0]);
      dp[i+1][nxt] = max(dp[i+1][nxt], dp[i][j] + d[i][2]);
    }
  }
  ll ans = 0;
  for(int i=0;i<=10001;i++) ans = max(ans, dp[n][i]);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 78720
N = int(input())
a = list(map(int, input().split()))
b = []
i = 0
while sum(a) != 0:
    for j in range(len(a)):
        if a[j] !=0:
            b.append(j)
            a[j] -= 1
    for k in range(len(b)-1):
        if b[k+1]-b[k] != 1:
            i += 1
    i += 1
    b = []
print(i)

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




int main()
{
	ll n;
	cin>>n;
	ll v[n];
long double x[n],y[n];
	long double sum=0.0000000;
	ll f=0;
	for(ll i=0;i<n;i++)cin>>x[i]>>y[i],v[i]=i;
	
	do
	{	f++;
		for(ll i=0;i<n-1;i++)
		{
			 long double dx = x[v[i + 1]] - x[v[i]];
            long double dy = y[v[i + 1]] - y[v[i]];
			sum+=sqrt(dx*dx+dy*dy);
			
		}
		
	}while(next_permutation(v,v+n));

cout<<setprecision(12)<<sum/f;
}

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

typedef pair<int,int> edge;
typedef vector<edge> ve;
vector<ve> graph;
int col[100000];

void dfs(int v, int c){
  ve nbor;
  col[v]=c;
//  cout << "paint " << v << " " << c << endl;
  nbor = graph[v];
  for (int i=0; i<nbor.size(); i++){
    if (col[nbor[i].first]!=-1) continue;
    dfs(nbor[i].first,(c+nbor[i].second)%2);
  }
}

int main(void){
  int n;
  
  cin >> n;
  graph = vector<ve>(n);
  for (int i=0; i<n-1; i++){
    int u,v,d; cin >> u >> v >> d;
    graph[u-1].push_back(make_pair(v-1,d));
    graph[v-1].push_back(make_pair(u-1,d));
  }
  for (int i=0; i<n; i++) col[i] = -1;
  dfs(0,0);
  for (int i=0; i<n; i++){
    cout << col[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 10496
#include <iostream>
//#include <cmath>
//#include <numeric>
#include <algorithm>
using namespace std;

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

    long long gcdlistL[N + 1];
    long long gcdlistR[N + 1];
    gcdlistL[0] = 0;
    gcdlistR[N] = 0;
    for(long long i = 0; i < N; i++) {
        gcdlistL[i + 1] = __gcd(gcdlistL[i], A[i]);
        gcdlistR[N - 1 - i] = __gcd(A[N - 1 - i], gcdlistR[N - i]);
    }
    long long gcdmax = 0;
    for(long long i = 0; i < N; i++) {
        gcdmax = max(gcdmax, __gcd(gcdlistL[i], gcdlistR[i+1]));
    }

    cout << gcdmax << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#define vi vector<int>
#define ei else if

using namespace std;
int main(void) {
	int n;
	cin >> n;
	
	vi p(n);
	
	for(int tmp = 0; tmp < n; tmp++) {
		cin >> p.at(tmp);
	}
	
	sort(p.begin(), p.end());
	
	p.at(n - 1) = p.at(n - 1) / 2;
	
	int count = 0;
	for(int tmp = 0; tmp < n; tmp++) {
		count = count + p.at(tmp);
	}
	
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) throws Exception {
        final Scanner scan = new Scanner(System.in);
        int plusCount = scan.nextInt();
        int zeroCount = scan.nextInt();
        int minusCount = scan.nextInt();
        int getCount = scan.nextInt();
        scan.close();
        int score = 0;

        if (getCount - plusCount <= 0) {
            score = getCount;
        } else {
            getCount -= plusCount;
            score += plusCount;
            if (getCount - zeroCount <= 0) {
            } else {
                getCount -= zeroCount;
                if (getCount - minusCount <= 0) {
                  score -= getCount;
                } else {
                    score -= minusCount;
                }
            }
        }

        System.out.println(score);

        
    }
}


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

int main(){
    int A, B;
    cin >> A >> B;

    if (abs(A - B) % 2 == 0) {
        cout << abs(A + B) / 2 << endl;
    }
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

int main (){
    int N, M;
    cin >> N >> M;
    int sum = 0;
    int A;
    for(int i = 0;i < M;i++){
        cin >> A;
        sum += A;
    }
    int ans = N -sum;
    if(ans >= 0){
        cout << N - sum << endl;
    }else{
        cout << -1 << endl;
    }
    
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 2001;

int n;
string s;
vector <int> v[N];
vector <ll> cnt, low, high;

void dfs(int node, int pnode){
	cnt[node] = s[node] == '1';
	for(auto &i : v[node]){
		if(i == pnode) continue;
		dfs(i, node);
		cnt[node] += cnt[i];
		high[node] += high[i] + cnt[i];
	}
	low[node] = high[node];
	ll mx = 0;
	for(auto &i : v[node]){
		if(i == pnode) continue;
		mx = max(mx, low[i] + cnt[i]);
	}
	ll sum = 0;
	for(auto &i : v[node]){
		if(i == pnode) continue;
		int cur = min(mx, high[i] + cnt[i]);
		if(cur % 2 != (high[i] + cnt[i]) % 2) cur--;
		sum += cur;
	}
	low[node] = max(sum % 2, 2 * mx - sum);
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s;
	s = ';' + s;
	for(int i = 0 ; i < n - 1 ; i++){
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	ll ans = 1e18;
	for(int i = 1 ; i <= n ; i++){
		cnt.assign(n + 1, 0);
		low.assign(n + 1, 0);
		high.assign(n + 1, 0);
		dfs(i, 0);
		if(low[i] == 0) ans = min(ans, high[i] / 2);
	}
	if(ans == 1e18) ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
ll n,sm=0,ans=-INF127;
priority_queue<ll> ft,bk;
vector<ll> md,tp,bt,mx1,mx2;
int main(){
	ll i,x,a,b,c,d,l,r;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x;
		sm+=x;
		ft.push(-x);
	}
	for(i=0;i<n;i++)
	{
		cin>>x;
		md.push_back(x);
	}
	for(i=0;i<n;i++)
	{
		cin>>x;
		sm-=x;
		bk.push(x);
	}
	tp.push_back(0);
	bt.push_back(0);
	mx1.push_back(0);
	mx2.push_back(0);
	l=0;
	r=n-1;
	for(i=0;i<n;i++)
	{
		a=-ft.top();
		b=md[l];
		c=md[r];
		d=bk.top();
		bk.pop();
		r--;
		bt.push_back(bt[bt.size()-1]+d-c);
		mx2.push_back(max(mx2[mx2.size()-1],bt[bt.size()-1]));
		bk.push(c);
		ft.pop();
		l++;
		tp.push_back(tp[tp.size()-1]+b-a);
		mx1.push_back(max(mx1[mx1.size()-1],tp[tp.size()-1]));
		ft.push(-b);
	}
	for(i=0;i<=n;i++)
	{
		ans=max(ans,sm+mx1[i]+mx2[n-i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7284
#include <iostream>
using namespace std;
bool BinarySearch(int a[],int l,int h,int key)
{
    if(l==h)
        return a[l]==key;
    int mid = (h+l)/2;
    if(a[mid]>key)
        return BinarySearch(a,l,mid,key);
    else if(a[mid]<key)
        return BinarySearch(a,mid+1,h,key);
    else
        return true;
}
int main()
{
    int s[100000];
    int n,q,i,j,c=0,t;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i];
    cin>>q;
    for(i=0;i<q;i++)
    {
        cin>>t;
        if(BinarySearch(s,0,n-1,t))
            c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3372
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N = int(input().strip())
    X = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    return N, X


@njit
def solve(N, X):
    A = np.argsort(X)
    l, r = X[A[N//2-1]], X[A[N//2]]
    mid = (l + r) / 2
    for i in range(N):
        if X[i] <= mid:
            print(r)
        else:
            print(l)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 122928
let () =
  Scanf.scanf "%d %d %d" @@ fun n a b ->
  let c = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let x = Array.fold_left (fun s v -> if v <= a then s+1 else s) 0 c in
  let y = Array.fold_left (fun s v -> if v <= b then s+1 else s) 0 c in
  min x (y-x) |> min (n-y) |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,c,d;
  cin>>a>>b;
  c=a;
  d=b;
  while(c*d){
    if(min(c%d,d-c%d)>min(d%c,c-d%c))
      d=min(d%c,c-d%c);
    else c=min(c%d,d-c%d);
  }
  cout<<a*b/(c+d)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int n;
  while(cin>>n,n){
    vector<int>in1(n);
    vector<int>in2(n);
    int count=0;
    rep(i,n)cin>>in1[i];
    while(1){
      count++;
      bool h=true;
      rep(i,in1.size()){
	int co=0;
	rep(j,in1.size()){
	  if(in1[j]==in1[i])co++;
	}
	in2[i]=co;
	//cout<<co<<endl;
	if(in1[i]!=co)h=false;
      }
      if(h)break;
      //
      count++;
      h=true;
      rep(i,in2.size()){
	int co=0;
	rep(j,in2.size()){
	  if(in2[j]==in2[i])co++;
	}
	in1[i]=co;
	if(in2[i]!=co)h=false;
      }
      if(h)break;
    }
    cout<<count-1<<endl;
    cout<<in1[0];
    rep(i,in1.size()-1)cout<<" "<<in1[i+1];
    cout<<endl;
  }
}


  /*
  while(cin>>n,n){
    int co=0;
    vector< vector<int> >in(n);
    rep(i,n)cin>>in[0][i];
    do{
      vector<int>n;
      vector<int>num;
      rep(i,in[co].size()){
	bool han=false;
	int a;
	rep(j,n.size())if(num[j]==in[co][i]){a=j;han=true;}
	if(han){
	  n[a]++;
	}else{
	  n.push_back(in[co][a]);
	  num.push_back(1);
	}
      }
      rep(i,in[co].size()){
	rep(i,num.size())if(in[co][i]==num[
	in[co+1][i]=


      bool han1=false;
      
    }while();*/

Measured memory_bytes: 1196
<?php
fscanf(STDIN, "%s", $w);
$len = strlen($w);
$warray = array();
for($i = 0; $i < $len; $i++){
    $warray[$i] = $w[$i];
}
$warray = array_count_values($warray);
foreach($warray as $k => $v){
    if($v % 2 == 1){
        $result = 'No';
        break;
    }
}
if($result == 'No'){
    print $result;
}else{
    print 'Yes';
}


Measured memory_bytes: 4856
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s[6]>52 || s[5]>48){
    cout<<"TBD"<<"\n";
  }
  else{
    cout<<"Heisei"<<"\n";
  }
  
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    map<string,int> mp_blue;
    map<string,int> mp_red;
    rep(i,n) {
        string s; cin >> s;
        mp_blue[s]++;
    }
    int m; cin >> m;
    rep(i,m) {
        string s; cin >> s;
        mp_red[s]++;
    }
    int ans = 0;
    for (auto itr = mp_blue.begin(); itr != mp_blue.end(); itr++) {
        auto &x = *itr;
        ans = max(x.second-mp_red[x.first],ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
var
        a,b:array[0..200005] of int64;
        i:longint;
        n,h,res:int64;
        check:real;
begin
        read(n,h);
        res:=0;
        for i:=1 to n do read(a[i],b[i]);
        for i:=1 to n do
        begin
                check:=0;
                check:=sqrt(sqr(a[i])+sqr(b[i]));
                if check<=h then inc(res);
        end;
        write(res);
end.


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

int main() {
  int n; cin >>n;
  vector<int> l(n);
  for (int i=0; i<n; i++) cin >>l.at(i);
  sort(l.begin(), l.end());
  string ans = "No";
  int sum = 0;
  for (int i=0; i<n-1; i++){
    sum += l.at(i);
  }
  if (l.at(n-1) < sum) ans = "Yes";
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+10,MAXM=2e6+10;
const int INF=INT_MAX,MOD=1e9+7;
const ll llINF=~(1ll<<63);

int n,a[MAXN];
ll num[MAXN];
ll ans=1;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    num[0]=3;
    for(int i=1;i<=n;i++)
    {
        (ans*=num[a[i]])%=MOD;
        num[a[i]]--;
        num[a[i]+1]++;
    }cout<<ans;
    return 0;
}


Measured memory_bytes: 1408
my $s = <STDIN>;
chomp $s;
my ($N,$M) = split(/ /,$s);
#print "$N,$K\n";
$s = <STDIN>;
chomp $s;
my @H = split(/ /,$s);
my @flag;
for(my $i=0;$i<$N;$i++){
    $flag[$i] = 0;
}
for(my $i=0;$i<$M;$i++){
    $s = <STDIN>;
    chomp $s;
    my @dat = split(/ /,$s);
    if( $H[$dat[0]-1] > $H[$dat[1]-1]  ){
        #print "low $dat[1]-1 \n";
        $flag[$dat[1]-1] = 1;
    }elsif( $H[$dat[0]-1] == $H[$dat[1]-1]  ){
        $flag[$dat[1]-1] = 1;
        $flag[$dat[0]-1] = 1;
    }else{
        #print "low $dat[0]-1 \n";
        $flag[$dat[0]-1] = 1;
    }
}
my $count =0;
for(my $i=0;$i<$N;$i++){
    if($flag[$i] == 0){
        #print "$i \n";
        $count++;
    }
}

print "$count";

Measured memory_bytes: 18672
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
    public static void main(String[] args) throws IOException {
        StringBuilder ans = new StringBuilder();
//        int t=ri();
        int t=1;
        while (t-- > 0)
        {
            long n=rl();
            String str="zabcdefghijklmnopqrstuvwxy";
            StringBuilder res=new StringBuilder();
            while(n>0)
            {
                int val= (int) (n%26);
                res.append(str.charAt(val));
                n/=26;
                if(val==0)
                {

                    n--;
                }

            }
            ans.append(res.reverse().toString()).append("\n");
        }
        out.print(ans.toString());
        out.flush();

    }
}


Measured memory_bytes: 25424
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 100011
#define ll long long
#define endl '\n'
int dp[MAX][3],a[MAX],b[MAX],c[MAX];

int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0; i < n ; i++)cin>>a[i]>>b[i]>>c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i = 1; i < n ; i++){
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0; 
} 

Measured memory_bytes: 2560
#include <iostream>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

using namespace std;

signed main() {
  IOS;
  int N, i, ans=0;
  cin >> N;

  for (i = 1; i*i <= N; i++) {
    if (N%i == 0 && (N/i-1) > i) {
      ans += N/i - 1;
    }
  }

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


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

getInt = readLn :: IO Int
getInts = map read . words <$> getLine :: IO [Int]
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y

main = do
    [n,h] <- getInts
    xs <- map (apply2 (,)) <$> replicateM n getInts
    print $ let da = maximum $ map fst xs in let fd = scanl (-) h $ sortBy (flip compare) $ filter (>=da) $ map snd xs in let r = last fd in if r>0 then length fd - 1 + r `divCeil` da else length $ filter (>0) fd


Measured memory_bytes: 155004
I, O, T, J, L, S, Z = map(int, input().split())
ans = 0

ans += O * 2

if sum([i % 2 for i in [I, J, L]]) >= 2:
    mi = min(I, J, L, 1)
    ans += mi * 6
    I -= mi
    J -= mi
    L -= mi

ans += (I // 2) * 4
ans += (J // 2) * 4
ans += (L // 2) * 4

print(ans // 2)

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

int main(){
  ull N;
  const ull mod=pow(10,9)+7;
  vector<ull> A;
  ull sum=0;
  cin >> N;

  for(int i=0;i<N;i++){
    ull input;
    cin >> input;
    A.push_back(input);
    }
  
  for(int bit=0;bit<=60;bit++){
    ull ones=0;
    vector<ull> v=A;
    for(int i=0;i<N;i++){
      ull a=v.back();
      v.pop_back();
      if(a&(1LL<<bit)) ones++;
    }
    sum = (sum+(1LL<<bit)%mod*ones%mod*(N-ones)%mod)%mod;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 6764
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}



void solve() {
	int n; cin >> n;
	modint ans = 0;
	ans = mod_pow(10, n) - mod_pow(9, n) *2 + mod_pow(8, n);
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 11832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> S(N);
    vector<int> dp(2*N,INF);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        S[i]=-a;
    }
    
    for(int i=0;i<N;i++){
        *upper_bound(all(dp),S[i])=S[i];
    }
    
    for(int i=0;i<2*N;i++){
        if(dp[i]==INF){
            cout<<i<<endl;
            break;
        }
    }
}


Measured memory_bytes: 1408
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i32; n]
    }

    let ans = if a
        .iter()
        .filter(|x| **x % 2 == 0)
        .all(|x| x % 3 == 0 || x % 5 == 0)
    {
        "APPROVED"
    } else {
        "DENIED"
    };

    println!("{}", ans);
}


Measured memory_bytes: 2184
#include <iostream>
#include <string>
#include <algorithm>
#include <deque>
using namespace std;
int main(){
    string s;
    deque<string> ss;
    int q;
    cin >> s;
    cin >> q;
    ss.push_front(s);
    int flag = 1;//flagが-1の時は後ろから1の時は前から
    for(int i = 0;i < q;i++){
        int t;
        cin >> t;
        switch(t){
            case 1:
               flag *= (-1);
               break;
            case 2:
                int f;
                string c;
                cin >> f >> c;
                switch(f){
                    case 1:
                        switch(flag){
                            case 1:
                                ss.push_front(c);
                                break;
                            case -1:
                                ss.push_back(c);
                                break;
                        }
                        break;
                    case 2:
                        switch(flag){
                            case 1:
                                ss.push_back(c);
                                break;
                            case -1:
                                ss.push_front(c);
                                break;
                        }
                        break;
                }
        }
    }
    string ans = "";
    for(auto i:ss){
        ans += i;
    }
    switch(flag){
        case 1:
            cout << ans;
            break;
        case -1:
            reverse(ans.begin(),ans.end());
            cout << ans;
            break;
    }
    return 0;
}


Measured memory_bytes: 10484
#include <iostream>
#include <algorithm>

using namespace std;

typedef struct {
	long long A;
	int B;
} drink;

bool cmp( const drink& a, const drink& b )
{
	return a.A < b.A;
}

int main()
{
	int N, M;

	cin >> N >> M;

	drink *D = new drink[N];

	for ( int i = 0; i < N; i ++ ) {
		cin >> D[i].A;
		cin >> D[i].B;
	}

	sort( D, D+N, cmp );

	long long cost = 0;
	for ( int i = 0; i < N; i ++  ) {
		if ( D[i].B < M ) {
			cost += (D[i].A * D[i].B);
			M -= D[i].B;
		} else {
			cost += (D[i].A * M );
			break;
		}
	}

	cout << cost << endl;

	return 0;

	
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint x(4);
    vint y(4);
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    cout << x[1]-(y[1]-y[0]) << " " << y[1]+(x[1]-x[0]) << " " << x[0]-(y[1]-y[0]) << " " << y[0]+x[1]-x[0] << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // int Nを受け取る
		int[] t = new int[N+1];
		int[] x = new int[N+1];
		int[] y = new int[N+1];
		// 各配列の0番目の要素に0を格納
		t[0] = 0;
		x[0] = 0;
		y[0] = 0;
		for(int i = 1; i <= N; i++) {
			t[i] = sc.nextInt(); // int t[i]を受け取る
			x[i] = sc.nextInt(); // int x[i]を受け取る
			y[i] = sc.nextInt(); // int y[i]を受け取る
		}
		sc.close(); // 標準入力を終了

		boolean can = true; // 可能フラグ

		for(int i = 0; i < N; i++) {
			int dt = t[i+1] - t[i]; // t[i+1]とt[i]の間の時間差
			int dist = Math.abs(x[i+1] - x[i]) + Math.abs(y[i+1] - y[i]);

			// dt < dist なら　canフラグをfalseにする
			if(dt < dist) can = false;

			// dt%2 != dist%2 なら　canフラグをfalseにする
			if(dt%2 != dist%2) can = false;
		}

		if (can) {
			// 可能
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 60716
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.next();
        String ans = "No";
        for (int i = 0; i < 3; i++){
            char c = s.charAt(i);
            if (c == '7'){
                ans = "Yes";
            }
        }
        System.out.println(ans);
    }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    while(true) {
        S.pop_back();
        string temp1 = S.substr(0, S.size() / 2);
        string temp2 = S.substr(S.size() / 2, S.size() / 2);
        if(temp1 == temp2) {
            cout << 2 * temp1.size() << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3468
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner c=new Scanner(System.in);
        long[] s=new long[5];
        int n=c.nextInt();
        int a;
        for(int i=0;i<n;i++){
            a=0;
            switch(c.next().charAt(0)){
                case 'M':a++;case 'A':a++;case 'R':a++;case 'C':a++;case 'H':s[a]++;
            }
        }
        long m=0;
        for(int i=0;i<3;i++)for(int j=i+1;j<4;j++)for(int k=j+1;k<5;k++)m+=s[i]*s[j]*s[k];
        System.out.println(m);
    }
}

Measured memory_bytes: 44652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;

long int findTrailingZeros(long int n) { 
  long int count = 0; 
  for (long int i = 5; n/i >= 1; i *= 5) 
    count += n/i; 

  return count; 
} 

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   

   long int n;
   cin>>n;

   if(n & 1)
      return cout<<"0",0;

  cout<<findTrailingZeros(n/2);

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  string str;
  cin>>str;
  bool ok[3] = {false};
  rep(i,str.size()){
    if('A' <= str[i] && str[i] <= 'Z'){
      ok[0] = true;
    }else if('a' <= str[i] && str[i] <= 'z'){
      ok[1] = true;
    }else if('0' <= str[i] && str[i] <= '9'){
      ok[2] = true;
    }
  }
  if(str.size()>=6 && ok[0] && ok[1] && ok[2]){
    cout<<"VALID"<<endl;
  }else{
    cout<<"INVALID"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    ll x,y;cin >> x >> y;
    ll k = x;
    ll count = 0;
    while(k<=y) {
        k*=2;
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int diff(int a, int b) {
  int d = abs(a - b);
  return min(d, 24 - d);
}

int main() {
  int n;
  cin>>n;
  vector<int> d(n);
  REP(i,n) cin>>d[i];
  vector<int> cnt(13, 0);
  ++cnt[0];
  REP(i,n) {
    ++cnt[d[i]];
  }
  bool ok = true;
  REP(i,13) {
    if (cnt[i] >= 3) ok = false;
    if ((i == 0 || i == 12) && cnt[i] >= 2) ok = false;
  }
  if (!ok) {
    cout << 0 << endl;
    return 0;
  }
  bool one = false;
  REP(i,12) {
    bool l = cnt[i] == 2 || (i == 0 && cnt[i] == 1);
    bool h = cnt[i+1] == 2 || (i+1 == 12 && cnt[i+1] == 1);
    if (l && h) one = true;
  }
  if (one) {
    cout << 1 << endl;
    return 0;
  }
  int mx = 0;
  REP(i,1<<n) {
    vector<int> t(n);
    REP(j,n) {
      if ((i>>j)&1) {
        t[j] = 24-d[j];
      } else {
        t[j] = d[j];
      }
    }
    sort(ALL(t));
    int mn = min(diff(t[0], 0), diff(t.back(), 0));
    REP(j,n-1) {
      mn = min(mn, diff(t[j], t[j+1]));
    }
    mx = max(mx, mn);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int main()
{
	int n, d,x,y,cnt=0;;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		if(pow(x,2)+pow(y,2)<=pow(d,2))
			cnt++;
	}
	
	cout<<cnt<<endl;
	
}



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

string s, t;
int letterT[26];
vector<int> c[26];
int n = 0; //終わったsの数
int idx = -1; //今のsの中でのidx
long long ans = 0;

int main() {
	cin >> s >> t;
	for (int i = 0; i < (int) s.size(); i++)
		c[s[i] - 'a'].push_back(i);
	for (int i = 0; i < (int) t.size(); i++) {
		int inf = -1, sup = c[t[i] - 'a'].size();
		if (!sup) {
			cout << -1 << endl;
			return 0;
		}
		while (sup - inf > 1) {
			int mid = (inf + sup) / 2;
			if (c[t[i] - 'a'][mid] > idx)
				sup = mid;
			else
				inf = mid;
		}
		if (sup == (int)c[t[i] - 'a'].size()) {
			n++;
			sup = 0;
		}
		idx = c[t[i] - 'a'][sup];
	}
	cout << n * s.size() + idx + 1 << endl;
}



Measured memory_bytes: 1216
package main

import "fmt"

func main() {
	var a int
	var b int
	var k int
	var a_copy int

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&k)

	a_copy = a
	a -= k
	if a < 0 {
		a = 0
	}
	k -= a_copy
	if k < 0 {
		k = 0
	}

	b -= k

	if b < 0 {
		b = 0
	}

	fmt.Println(a, b)
}


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

int road[52] = {0};

int main(){
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        road[--a]++;
        road[--b]++;
    }

    for(int i=0;i<n;++i){
        cout << road[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj] :
            minj = j
    if minj != i:
        count += 1
    A[i], A[minj] = A[minj], A[i]
        
print(*A)
print(count)
        


Measured memory_bytes: 5608