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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
	int n; cin >> n;
	vector<int> mp(n+1, 0);

	rep (i, 2, n) {
		int x; cin >> x;
		mp[x]++;
	}

	rep (i, 1, n) {
		cout << mp[i] <<"\n";
	}
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3988
#!/usr/bin/env python3

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
total = sum(a_list)
b_list = [a for a in a_list if a >= total * (1 / (4 * M))]
ans = "Yes" if len(b_list) >= M else "No"

print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> ans(n + 1, 0);
  rep(i, n - 1) {
    int tmp;
    cin >> tmp;
    ans.at(tmp - 1)++;
  }
  rep(i, n) { cout << ans.at(i) << endl; }
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;

typedef const pair<string, int> PSI;

bool cmpCount(PSI &T1, PSI &T2) {
	return T1.second < T2.second;
}

bool cmpLength(PSI &T1, PSI &T2) {
	return T1.first.length() < T2.first.length();
}

int main() {
	string str;
	map<string, int> M;

	while(cin >> str) {
		M[str]++;
	}

	PSI maxCount = *max_element(M.begin(), M.end(), cmpCount);
	PSI maxLength = *max_element(M.begin(), M.end(), cmpLength);

	cout << maxCount.first << " " << maxLength.first << endl;

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
int main(void){
int a,b,c;
bool OK = false;
    scanf("%d %d %d",&a,&b,&c);
    if((a == b && a != c) || (b == c && c != a) || (c == a && a != b))OK = true;
  if(OK == true)printf("Yes");
  else printf("No");
       return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int a[4], b[4];
	int al[10];
	int hit, blow;
	while(scanf("%d %d %d %d", a, a+1, a+2, a+3) != EOF){
		scanf("%d %d %d %d", b, b+1, b+2, b+3);
		hit = blow = 0;
		for(int i=0; i<10; ++i){
			al[i] = -1;
		}
		for(int i=0; i<4; ++i){
			al[a[i]] = i;
		}
		for(int i=0; i<4; ++i){
			if(al[b[i]] == -1){ continue; }
			if(al[b[i]] == i ){ hit++; }
			else { blow++;}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <vector>
#include <set>
#include <queue>
using namespace std;

bool terminal(string& worm){
  for(int i = 1; i < (int)worm.size(); i++)
    if(worm[i] != worm[i - 1])
      return false;
  return true;
}


char othercolor(char a, char b){
  if(a != b){
    if(a != 'r' && b != 'r'){ return 'r'; }
    if(a != 'g' && b != 'g'){ return 'g'; }
    if(a != 'b' && b != 'b'){ return 'b'; }
  }
  return -1;
}


int main(void){
  while(true){
    string initworm;
    cin >> initworm;
    if(initworm == "0"){ break; }

    queue<pair<int, string> > wait;
    set<string> used;
    wait.push(make_pair(0, initworm));
    used.insert(initworm);
    
    int ans = -1;
    while(!wait.empty()){
      int nowcost = wait.front().first;
      string nowworm = wait.front().second;
      wait.pop();

      if(terminal(nowworm)){
        ans = nowcost;
        break;
      }

      // ??£??\??¶???
      for(int i = 1; i < (int)nowworm.size(); i++){
        char c = othercolor(nowworm[i], nowworm[i - 1]);
        // ???????????????????????????????????§???????????????
        if(c != -1){
          string next = nowworm;
          next[i] = next[i - 1] = c;
          // ????????¶???????????¢?´¢?????£?????´???
          if(used.count(next) == 0){
            used.insert(next);
            wait.push(make_pair(nowcost + 1, next));
          } 
        }
      }      
    }
    
    // ??????
    if(ans == -1){ cout << "NA" << endl; }
    else{ cout << ans << endl; }
  }
  return 0;
}

Measured memory_bytes: 4556
N, u, v = map(int, input().split())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)


def dfs(v):
    dist = [-1 for _ in range(N+1)]
    stack = [v]
    dist[v] = 0
    while stack:
        v = stack.pop()
        dist_x = dist[v] + 1
        for child in graph[v]:
            if 0 <= dist[child]:
                continue
            dist[child] = dist_x
            stack.append(child)
    return dist


def solve():
    dist_u, dist_v = dfs(u), dfs(v)
    
    ans = 0
    for a, b in zip(dist_u[1:], dist_v[1:]):
        if a < b:
            ans = max(ans, b-1)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 69740
import heapq,sys


def main():
    input = sys.stdin.readline
    X, Y, Z, K = map(int, input().split())
    #tupleはlistの速いver. 但し値変更なし
    A = tuple(map(int,input().split()))
    B = tuple(map(int,input().split()))
    C = tuple(map(int,input().split()))
    
    #A+Bでのベスト枠K個求めるO(XYlogK)
    AandB = []
    for x in A:
        for y in B:
            heapq.heappush(AandB,x+y)
            #要素がK+1個以上なら一々はじく！！！ことでO(logK)
            if len(AandB) > K:
                heapq.heappop(AandB)
    #上のとCでのベスト枠K個を求める(ZKlogK)
    heap_queue = []
    for z in C:
        for elt in AandB:
            heapq.heappush(heap_queue,z+elt)
            if len(heap_queue) > K:
                heapq.heappop(heap_queue)
    heap_queue.sort(reverse = True)
    for e in heap_queue:
        print(e)
if __name__ == '__main__':
    main()

Measured memory_bytes: 55772
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

long double a,b,c,d1,x[1005],y[1005],r[1005],d[1005];
int n;
vector<pair<int,long double> > v[1005];

long double dis(long double a,long double b,long double c,long double d)
{
	return sqrt((a-c)*(a-c)+(b-d)*(b-d));
}

int main()
{ios_base::sync_with_stdio(false);
cin>>a>>b>>c>>d1>>n;
rep(i,1,n)
{
	cin>>x[i]>>y[i]>>r[i];
	long double kk=dis(a,b,x[i],y[i])-r[i];
	if(kk<0)kk=0;
	v[0].pb(mp(i,kk));
	v[i].pb(mp(0,kk));
	kk=dis(c,d1,x[i],y[i])-r[i];
	if(kk<0)kk=0;
	v[n+1].pb(mp(i,kk));
	v[i].pb(mp(n+1,kk));
}
v[0].pb(mp(n+1,dis(a,b,c,d1)));
v[n+1].pb(mp(0,dis(a,b,c,d1)));
rep(i,1,n)
{
	rep(j,i+1,n)
	{
		long double dd=dis(x[i],y[i],x[j],y[j])-r[i]-r[j];
		if(dd<0)dd=0;
		v[i].pb(mp(j,dd));
		v[j].pb(mp(i,dd));
	}
}

rep(i,0,n+1)d[i]=1e18+7;

d[0] = 0;
	priority_queue < pair<long double,int> > q;
	q.push (make_pair (0, 0));
	while (!q.empty()) 
	{
		int at = q.top().second;long double  cur_d = -q.top().first;
		q.pop();
		if (cur_d > d[at])  continue;
 
		for (size_t j=0; j<v[at].size(); ++j) 
		{
			int to = v[at][j].first;
			long double	len = v[at][j].second;
			if (d[at] + len < d[to]) 
			{
				d[to] = d[at] + len;
				q.push (make_pair (-d[to], to));
			}
		}
	}
cout<<fixed<<setprecision(10)<<d[n+1];
return 0;
}


Measured memory_bytes: 41008
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

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

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

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

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

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

int calCost(pair<int,int> A,pair<int,int> B){
	return abs(A.first-B.first)+abs(A.second-B.second);
}
void solve(){
	int H,W,D;
	cin >> H >>W>>D;
	vector<vector<int> > A(H,vector<int>(W));
	vector<pair<int,int> > pos(H*W);
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			cin>>A[h][w];
			A[h][w]--;
			pos[ A[h][w] ].first = h;
			pos[ A[h][w] ].second = w;
		}
	}
	////
	vector<LL> cost(H*W,0);
	for(int i=0;i<D;++i){
		for(int j=1;i+j*D<H*W;++j){
			LL res = calCost(pos[i+(j-1)*D],pos[i+j*D]);
			cost[i+j*D] = cost[i+(j-1)*D] + res;
		}
	}
	////
	int Q;
	cin >> Q;
	int L,R;
	while(Q--){
		cin >> L>>R;
		--L;
		--R;
		cout << cost[R]-cost[L] << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    int cnt = ceil(n * 1.0 / x);
    cout << cnt * t;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>

typedef long long ll;
using namespace std;

struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main(void) {
	int i, n, m, x, y, z;
	
	cin >> n >> m;
	UnionFind tree(n);
	for (i = 0;i < m;i++) {
		cin >> x >> y >> z;
		x--, y--;
		tree.unite(x, y);
	}

	int ans = n;
	for (i = 0;i < n;i++) {
		if (tree.root(i) != i) {
			ans--;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    char c;
    cin>>a;
    cin>>c;
    cin>>b;
    if(c=='+')
        cout<<a+b<<endl;
    else
        cout<<a-b<<endl;
    
    return 0;   
}




 
 


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

int main(){
    while(1){
        int l;
        cin >> l;
        if(l == 0)  break;

        int m[12], n[12];
        for(int i = 0; i < 12; i++){
            cin >> m[i] >> n[i];
        }

        int sum = 0, month;
        for(month = 0; month < 12; month++){
            sum += m[month] - n[month];
            if(sum >= l)    break;
        }

        if(month == 12) cout << "NA" << endl;
        else            cout << month+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3060
N, K = [int(s) for s in input().split()]
R, S, P = [int(s) for s in input().split()]
T = list(input())

def get_winpos(dealer):
  if dealer == 'r':
    return 'p'
  elif dealer == 's':
    return 'r'
  else:
    return 's'
def calc_point(rsp):
  if rsp == 'r':
    return R
  elif rsp == 's':
    return S
  else:
    return P
  
winpos = [get_winpos(s) for s in T]
point = 0
check = 'any'
for i, pos in enumerate(winpos):
  if i-K >= 0:
    check = winpos[i-K]
  if winpos[i] == check:
    winpos[i] = 'any'
  else:
    point += calc_point(winpos[i])
print(point)

Measured memory_bytes: 4796
import std.stdio,std.string,std.conv;

int main()
{
	string[] s = readln.chomp.split(" ");
	string len_max = s[0],ans = s[0];
	int[string] map;
	int count_max = 1;

	foreach(i;0..(s.length))
	{
		if(len_max.length < s[i].length)
		{
			len_max = s[i];
		}
		map[s[i]]++;

		if(map[s[i]] > count_max)
		{
			count_max = map[s[i]];
			ans = s[i];
		}
	}
	writeln(ans," ",len_max);
	return 0;
}

Measured memory_bytes: 1052
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1000;
vector<vector<int>> G(N,vector<int>(N,0));

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

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    int u,k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int v; cin >> v;
      G[u][v] = 1;
    }
  }

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(j != 1) cout << " ";
      cout << G[i][j];
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 11024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int solve(int n,vi& memo)
{
	if(memo[n]!=-1) return memo[n];
	if(n==6174) return memo[n]=0;
	
	char s1[5]; sprintf(s1,"%04d",n); sort(s1,s1+4);
	char s2[5]; rep(i,4) s2[i]=s1[3-i];
	if(atoi(s1)==atoi(s2)) return -1;
	return memo[n]=1+solve(atoi(s2)-atoi(s1),memo);
}

int main()
{
	vi memo(10000,-1);
	for(int n;cin>>n,n;){
		int res=solve(n,memo);
		if(res==-1) cout<<"NA"<<endl;
		else cout<<solve(n,memo)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1300
#include<cstdio>

int main(){
	int a[5];
	int t;
	scanf("%d %d %d %d %d", &a[0],&a[1],&a[2],&a[3],&a[4]);
	for(int i = 0; i < 4; i++){
		for(int j = 0; j <= i; j++){
			if(a[i - j] < a[i - j + 1]){
				t = a[i - j];
				a[i - j] = a[i - j + 1];
				a[i - j + 1] = t;
			}
		}
	}
	printf("%d %d %d %d %d\n", a[0],a[1],a[2],a[3],a[4]);
	return 0;
}

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

signed main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    char lc = ' ';

    int ans = 0;

    REP(i, N) {
        if (lc != S[i]) ans++;
        lc = S[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

int MOD = 998244353;
ll dp[200010][2] = {0};

signed main(){

   
    string s;
    cin >> s;

    ll n = s.size();

    dp[1][0] = 1;
    dp[1][1] = 0;
    for(int i = 2;i <= n;i++){
        // 2コ使う
        if(i < 4 || (s[i-1] == s[i-3] && s[i-2] == s[i-4])){
            dp[i][1] = dp[i-2][0]+1;
        }else{
            dp[i][1] = max(dp[i-2][0],dp[i-2][1]) + 1;
        }
        if(s[i-1] == s[i-2]){
            dp[i][0] = dp[i-1][1]+1;
        }else{
            dp[i][0] = max(dp[i-1][0],dp[i-1][1])+1;
        }
    }
    
    cout << max(dp[n][0],dp[n][1]) << endl;


    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc037.contest.atcoder.jp/tasks/agc037_a

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

int main(int argc, char **argv) {
	int h, w;
	cin >> h >> w;
	vector<vector<string>> str(h, vector<string>(w));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> str[i][j];
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if(str[i][j] == "snuke") {
				cout << char(j + 'A') << i + 1 << endl;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, m, sum = 0;
  cin >> n >> m;
  priority_queue<ll> a;
  for (ll i = 0; i < n; i++) {
    ll x;
    cin >> x;
    sum += x;
    a.push(x);
  }
  
  for (ll i = 0; i < m; i++) {
    ll y = a.top();
    sum -= y - y/2;
    y /= 2;
    a.pop();
    a.push(y);
  }
  
  cout << sum << endl;
}

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

int main(){
    int n, q;
    cin >> n >> q;
    atcoder::dsu d{n};
    for(int i=0;i<q;++i){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) d.merge(u, v);
        else cout << d.same(u, v) << endl;
    }

    return 0;
}

Measured memory_bytes: 3936
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<complex>
using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) begin(v),end(v)

#define X real()
#define Y imag()
typedef complex<double> P;
const double EPS=1e-9;

bool P_compX(const P &a,const P &b){
  return a.X!=b.X ? a.X<b.X : a.Y<b.Y;
}

bool P_compY(const P &a,const P &b){
  return a.Y!=b.Y ? a.Y<b.Y : a.X<b.X;
}

//??????
double cross(P a,P b){
  return (a* conj(b)).imag();
}

//??????
double dot(P a,P b){
  return (a* conj(b)).real();
}

int ccw(P a,P b,P c){
  P ab = b-a;
  P ac = c-a;
  if(cross(ab,ac)>0)   return 1;  //???????¨???????
  if(cross(ab,ac)<0)   return -1; //????¨???????
  //??´??????
  if(dot(ab,ac)<0)     return 2;  //c-a-b
  if(norm(ab)<norm(ac))return -2; //a-b-c
  return 0;                       //a-c-b or b==c
}

vector<P> ConvexHull(vector<P> ps){
  int n=ps.size(),k=0;
  vector<P> ret(2*n);
  sort(all(ps),P_compX);

  //?????????
  for(int i=0;i<n;ret[k++]=ps[i++]){
    while(k>=2 && ccw(ret[k-2],ret[k-1],ps[i]) ==-1) k--; 
  }
  //?????????
  for(int i=n-2,t=k+1;i>=0;ret[k++]=ps[i--]){
    while(k>=t && ccw(ret[k-2],ret[k-1],ps[i]) ==-1) k--;
  }
  ret.resize(k-1);
  return ret;
}

int main()
{
  int n;
  cin>>n;
  vector<P> ps(n);
  rep(i,n){
    double x,y;
    cin>>x>>y;
    ps[i]=P(x,y);
  }
  vector<P> ans=ConvexHull(ps);
  cout<<ans.size()<<endl;

  reverse(all(ans));
  
  int st_i=0;
  rep(i,ans.size()){
    if(P_compY(ans[i],ans[st_i]))st_i=i;
  }
  
  rep(i,ans.size()){
    cout<<ans[(st_i+i)%ans.size()].X<<" "<<ans[(st_i+i)%ans.size()].Y<<endl;
  }
  return 0;
}

Measured memory_bytes: 7264
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int ans = 0;
        
        for(int i=0; i<S.length(); i++){
            if(S.charAt(i) != T.charAt(i)){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 41144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
    
    int A,B,H,M;
    cin>>A>>B>>H>>M;
    double angle;
    if(6*M<=30*H+0.5*M){
        angle=30*H+0.5*M - 6*M;
    }else{
        angle=6*M - (30*H+0.5*M);
    }
    angle=min(360-angle, angle);
    double ans=sqrt(A*A+B*B-2*A*B*cos(angle*PI/180));
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

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

int main() {
    double a,b,c,C,s,l,h,p=3.141592653589; cin>>a>>b>>C;
    s = a*b*sin(C*p/180)/2;
    c = a*a+b*b-(2*a*b*cos(C*p/180));
    c = pow(c,0.5);
    l = a+b+c;
    h = s*2/a;
    cout<<setprecision(12)<<s<<" "<<l<<" "<<h<<endl;
}


Measured memory_bytes: 3576
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] info = new int[12][40];
        int b,f,r,v;
        for(int i = 0;i<n;i++){
            b = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
            v = sc.nextInt();
            info[(b-1)*3+f-1][r-1] += v;
        }
        for(int i = 0;i<4;i++){
            for(int j = 0;j<3;j++){
                for(int k = 0;k<10;k++){
                    System.out.printf(" %d",info[i*3+j][k]);
                }
                System.out.println();
            }
            if(i !=3)
                System.out.printf("####################%n");
        }
        sc.close();
    }
}


Measured memory_bytes: 30360
# ITP1_5_B
# フレームの描画

while  1:
	H, W = map(int, input().split())
	if H == W == 0:
		break
	for i in range(H):
		if i == 0 or i == H - 1:
			print("#" * W)
		else:
			for j in range(W):
				if j == 0 or j == W - 1:
					print("#", end="")
				else:
					print(".", end="")
			print()
	print()


Measured memory_bytes: 7004
#include <stdio.h>
int main(void) {
	int l, r, lmod, rmod, min;
	scanf("%d %d", &l, &r);
	lmod = l % 2019;
	rmod = r % 2019;
	min = 2018;
	if (r - l >= 2018)
		min = 0;
	int temp;
	for (int i = lmod; i < rmod; i++) {
		for (int j = i + 1; j <= rmod; j++) {
			temp = (i * j) % 2019;
			if (min >= temp)
				min = temp;
		}
	}
	printf("%d\n", min);
	return 0;
}

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
const int mxN=1000, M=1e9+7;
int h, w, dp[mxN][mxN]={0};
string g[mxN];
 
bool ie(int i, int j) {
	return i>=0&&j>=0&&g[i][j]=='.';
}
 
int main()
 {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> h >> w;
	for(int i=0; i<h; ++i)
		cin >> g[i];

	dp[0][0]=1;
	for(int i=0; i<h; ++i) 
    {
		for(int j=0; j<w; ++j)
         {
			if(ie(i-1, j))
				dp[i][j]+=dp[i-1][j];
			if(ie(i, j-1))
				dp[i][j]+=dp[i][j-1];
			dp[i][j]%=M;
		}
	}
	cout << dp[h-1][w-1];
}


Measured memory_bytes: 8572
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const double PI = acos(-1.0);

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  double a, b, c;
  cin >> a >> b >> c;

  double th = PI * c / 180;

  double h = b * sin(th);
  double s = 0.5 * a * h;
  double l = sqrt(a * a + b * b - 2.0 * a * b * cos(th)) + a + b;

  printf("%.8lf\n", s);
  printf("%.8lf\n", l);
  printf("%.8lf\n", h);

  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <time.h>

using namespace std;

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, k;
  P susi[100001];
  map<int, int> s;
  cin >> n >> k;
  rep(i, 0, n) cin >> susi[i].second >> susi[i].first;

  sort(susi, susi + n);

  int tb = 0;
  int sc = 0;
  priority_queue<int, vector<int>, greater<int> > q;
  int mx = 0;
  int sum = 0;
  dep(i, n - 1, 0) {
    tb++;
    if(s[susi[i].second]) {
      if(tb > k) continue;
      q.push(susi[i].first);
    }else {
      if(tb > k) {
        if(q.empty()) {
          break;
        }
        sum -= q.top();
        q.pop();
      }
      s[susi[i].second] = true;
      sc++;
    }
    sum += susi[i].first;
    mx = max(mx, sum + sc * sc);
  }
  cout << mx << endl;
}


Measured memory_bytes: 6140
'use strict';
function main(input) {
  const
    arr = input.trim().split('\n'),
    a = Number(arr[0]),
    b = arr[1].split(' ').map(x => Number(x));
  let 
    isPossible = false;

  for (let i = b[0]; i <= b[1]; i ++) {
    if (i % a === 0) {
      isPossible = true;
      break;
    }
  }
  
  console.log(isPossible ? 'OK' : 'NG');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll n,m,q;
    cin >> n >> m >> q;
    vector<int> a(q),b(q),c(q),d(q);
    rep(i,q){
        int a1,b1,c1,d1;
        cin >> a1 >> b1 >> c1 >> d1;
        a1--; b1--;
        a[i] = a1;
        b[i] = b1;
        c[i] = c1;
        d[i] = d1;
    }
    vector<ll> A(10);
    ll res=0;
    for(int k1=1;k1<=m;k1++){
        for(int k2=k1;k2<=m;k2++){
            for(int k3=k2;k3<=m;k3++){
                for(int k4=k3;k4<=m;k4++){
                    for(int k5=k4;k5<=m;k5++){
                        for(int k6=k5;k6<=m;k6++){
                            for(int k7=k6;k7<=m;k7++){
                                for(int k8=k7;k8<=m;k8++){
                                    for(int k9=k8;k9<=m;k9++){
                                        for(int k10=k9;k10<=m;k10++){
                                            A[0] = k1;
                                            A[1] = k2;
                                            A[2] = k3;
                                            A[3] = k4;
                                            A[4] = k5;
                                            A[5] = k6;
                                            A[6] = k7;
                                            A[7] = k8;
                                            A[8] = k9;
                                            A[9] = k10;
                                            
                                            ll ans=0;
                                            for(int j=0;j<q;j++){
                                                if(A[b[j]]-A[a[j]]==c[j]) ans += d[j];
                                            }
                                            res = max(res,ans);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    char x;
        cin >> H >> W;
    for(int i=1;i<=H+2;i++){
        for(int j=1;j<=W+2;j++){
            if(i==1||i==H+2){
                cout << "#";
            }else{
                if(j==1||j==W+2){
                    cout << "#";
                }else{
                    cin >> x;
                        cout << x;
                }
                    //cout << endl;
            }
                //cout << endl;
        }
            cout << endl;
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum =0,add =0,add2,sum2=0;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        add = add + a[i];
    }
    add = add/n;
    add2=add+1;
    for(int i=0;i<n;i++)
    {
        sum= sum + (a[i]-add)* (a[i]-add);
        sum2 = sum2 + (a[i]-add2)* (a[i]-add2);
    }
    cout<<min(sum,sum2);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int a[100001];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    std::sort(a,a+n);
    a[n]=1e8;
    int sum[2]={},l=0,r=0;
    while(r<n){
        while(a[l]==a[r])r++;
        sum[(r-l)%2]++;
        l=r;
    }
    printf("%d",sum[0]+sum[1]-(sum[0]%2));
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n,m;
    while(cin >> n >> m,n){
        vector<int> a(n),w(m);
        for (int i = 0; i < n; i++) {
            cin >> a[i]; 
        }
        for (int i = 0; i < m; i++) {
            cin >> w[i];
        }
        vector<int> sum(1<<m,0);
        for (int i = 0; i < 1<<m; i++) {
            for (int j = 0; j < m; j++) {
                if(i&(1<<j)) sum[i]+=w[j];
            }
        }
        vector<vector<int>> dp(n);
        for (int mask = 0; mask < 1<<m; mask++) {
            int tmask=((1<<m)-1)^mask;
            for(int i=tmask;;i=(i-1)&tmask) {
                for (int j = 0; j < n; j++) {
                    dp[j].push_back(abs(sum[mask]+a[j]-sum[i]));
                }
                if(i==0) break;
            }
        }
        vector<bool> s(n);
        int cnt=0;
        for (int i = 0; i < n; i++) {
            sort(ALL(dp[i]));
            if(dp[i][0]==0){
                cnt++;
                s[i]=true;
                continue;
            }
            dp[i].erase(unique(ALL(dp[i])),dp[i].end());
        }
        if(cnt==n){
            cout << 0 << endl;
            continue;
        }
        bool f=false;
        for (int i = 0; i < n; i++) {
            if(s[i]) continue;
            for (int j = 0; j < dp[i].size(); j++) {
                bool ff=false;
                for (int k = i+1; k < n; k++) {
                    if(s[k]) continue;
                    auto p = lower_bound(ALL(dp[k]),dp[i][j]);
                    if(*p!=dp[i][j]){
                        ff=true;
                        break;
                    }
                }
                if(!ff){
                    cout << dp[i][j] << endl;
                    f=true;
                    break;
                }
            }
            break;
        }
        if(!f) cout << -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 25492
#include<iostream>
using namespace std;
int main()
{
    int n,s,m;
    cin>>n;
    if(n%1000==0)
        cout<<"0\n";
    else if(n%1000!=0)
    {
        s=n%1000;
        m=1000-s;
        cout<<m<<endl;
    }
    return 0;
}


Measured memory_bytes: 3524
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    loop {
        let n: usize = sc.read();
        if n == 0 { break; };
        let mut g = vec![vec![0; 21]; 21];
        for _ in 0..n {
            let x: usize = sc.read();
            let y: usize = sc.read();
            g[y][x] += 1;
        }
        let m: usize = sc.read();
        let mut cx = 10;
        let mut cy = 10;
        let mut cnt = 0;
        cnt += g[cy][cx];
        g[cy][cx] = 0;
        for _ in 0..m {
            let s: String = sc.read();
            let d: usize = sc.read();
            for _ in 0..d {
                match &*s {
                    "N" => { cy += 1; },
                    "E" => { cx += 1; },
                    "W" => { cx -= 1; },
                    "S" => { cy -= 1; },
                    _ => (),
                };
                cnt += g[cy][cx];
                g[cy][cx] = 0;
            }
        }
        println!("{}", if cnt == n { "Yes" } else { "No" });
    }
}



Measured memory_bytes: 5044
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define pr pair<int, int>

using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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;
}

// int a[10010][10010], b[1000];
// int dp[10010][3];

int main() {
    ll n,m; cin >> n >> m;
    cout << ((n > m )?"safe":"unsafe") << endl; 

return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

int count(int v)
{
	if (v == 0)
	{
		return 0;
	}
	int popcount = 0;
	auto u = v;
	while (u)
	{
		popcount += u % 2 == 1;
		u /= 2;
	}
	return count(v % popcount) + 1;
}

void Main()
{
	int N;
	std::string val;
	std::cin >> N;
	std::cin >> val;
	int pop_count = 0;
	for (auto c : val)
	{
		if (c == '1')
		{
			++pop_count;
		}
	}
	if (pop_count == 0)
	{
		for (auto i : boost::irange(N))
		{
			std::cout << 1 << std::endl;
			return;
		}
	}
	int a = pop_count + 1, b = pop_count - 1;
	int a_dig = 1, b_dig = 1;
	int a_mod = 0, b_mod = 0;
	for (auto i : boost::irange(N) | adaptor::reversed)
	{
		if (val[i] == '1')
		{
			a_mod += a_dig;
			a_mod %= a;
			if (b != 0)
			{
				b_mod += b_dig;
				b_mod %= b;
			}
		}
		a_dig *= 2;
		a_dig %= a;
		if (b != 0)
		{
			b_dig *= 2;
			b_dig %= b;
		}
	}
	a_dig = b_dig = 1;
	std::vector<int> result(N);
	for (auto i : boost::irange(N) | adaptor::reversed)
	{
		if (val[i] == '1')
		{
			if (b == 0)
			{
				result[i] = 0;
			}
			else
			{
				result[i] = count((b_mod + b - b_dig) % b) + 1;
			}
		}
		else
		{
			result[i] = count((a_mod + a_dig) % a) + 1;
		}
		a_dig *= 2;
		a_dig %= a;
		if (b != 0)
		{
			b_dig *= 2;
			b_dig %= b;
		}
	}
	for (auto v : result)
	{
		std::cout << v << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;
int a[1000000 + 5], b[100000 + 5], c[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    int ans = 0;
    rep(i, n) {
        int l = lower_bound(a, a + n, b[i]) - a;
        int r = n - (upper_bound(c, c + n, b[i]) - c);
        ans += l * r;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    for (auto c : s) {
        if (c == '1') {
            cout << '9';
        } else if (c == '9') {
            cout << '1';
        } else {
            cout << c;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  map<int, int> mp;
  REP(_, n) {
    int a; cin >> a;
    ++mp[a];
  }
  int cnt = 0;
  for (auto pr : mp) cnt += pr.second - 1;
  cnt = (cnt + 1) / 2 * 2;
  cout << n - cnt << '\n';
  return 0;
}


Measured memory_bytes: 4992
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    no = 1
    cnt = 0
    for i in range(n):
        if no == a[i]:
            cnt += 1
            no += 1
    print(n - cnt if cnt != 0 else -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 71024
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_TOWN_MAX		100000									// 最大町数

// 内部変数
static int si1Town[D_TOWN_MAX];									// 町
static int siTCnt;												// 町数
static long long slWalk;										// 疲労 - 徒歩
static long long slTpt;											// 疲労 - テレポート

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 町数・疲労取得
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%lld%lld", &siTCnt, &slWalk, &slTpt);

	// 町取得
	for (i = 0; i < siTCnt; i++) {
#ifdef D_TEST
		fscanf(szpFpT, "%d", &si1Town[i]);
#else
		fscanf(stdin, "%d", &si1Town[i]);
#endif
	}
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif

	// 疲労合計
	long long llSum = 0;
	for (i = 1; i < siTCnt; i++) {

		// 徒歩疲労
		long long llWalk = (long long)(si1Town[i] - si1Town[i - 1]) * slWalk;

		// 少ない疲労を加算
		if (llWalk < slTpt) {
			llSum += llWalk;
		}
		else {
			llSum += slTpt;
		}
	}

	// 結果セット
	sprintf(lc1Out, "%lld\n", llSum);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int a, b, c;
  cin >> a >> b >> c;
  cout << max({a * 10 + b + c, a + b * 10 +c, a + b + c * 10}) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
  		int ans=0;
   
		for(int c=1;c<=n;c++){
        	if(String.valueOf(c).length()%2==1){
              ans++;
        }
        }
    	System.out.println(ans);
    }
}

Measured memory_bytes: 28500