akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    ll i, o, t, j, l, s, z; cin>>i>>o>>t>>j>>l>>s>>z;

    ll ans1 = o * 2;
    ll ans0 = o * 2;

    ll IJL = min({i, j, l});
    if(0 < IJL){
        ans1 += 6;
        ans1 += ((i - 1) / 2) * 4;
        ans1 += ((j - 1) / 2) * 4;
        ans1 += ((l - 1) / 2) * 4;
    }

    ans0 += (i / 2) * 4;
    ans0 += (j / 2) * 4;
    ans0 += (l / 2) * 4;

    cout << max(ans1 / 2, ans0 / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  ll X;
  cin >> X;
  ll ma = 1;
  for (ll i = 1; i <= X/2; i++) {
    for (ll j = 2; j <= X; j++) {
      ll c = pow(i,j);
      if (c > X) break;
      if (c <= X) {
        ma = max(ma, c);
      }
    }
  }
  cout << ma << endl;
}


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

int main(void){

    int n;

    scanf("%d", &n);

    char S[n][51];

    for(int i = 0; i < n; i++){
        scanf("%s", S[i]);
    }

    int c['z'-'a'+1];

    for(int i = 0; i <= 'z'-'a'; i++){
        c[i] = 100;
    }

    for(int i = 0; i < n; i++){
        int d['z'-'a'+1];
        for(int j = 0; j <= 'z'-'a'; j++){
            d[j] = 0;
        }
        for(int j = 0; j < strlen(S[i]); j++){
            d[S[i][j] - 'a']++;
        }
        for(int j = 0; j <= 'z'-'a'; j++){
            if(d[j] < c[j]){
                c[j] = d[j];
            }
        }
    }

    for(int i = 0; i <= 'z'-'a'; i++){
        for(int j = 0; j < c[i]; j++){
            printf("%c", 'a' + i);
        }
    }
    printf("\n");

    return 0;
}

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

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

  int n;
  cin >> n;

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

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;

      ans += d[i] * d[j];
    }
  }

  cout << ans / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 1e9
#define MOD 1000000007;//1e9+7

long long ans(long long H) {
    if (H == 1)return 1;
    if (H > 1) return 2 * ans(H / 2) + 1;
}

int main() {
    long long H;
    cin >> H;
    cout << ans(H);

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Control.Applicative
import Text.Printf


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

main = f =<< replicateM 3 readInt

f [m,f,r]
  | m == -1 && f == -1 && r == -1 = return ()
  | m == -1 || f == -1 = p "F"
  | s >= 80 = p "A"
  | s >= 65 = p "B"
  | s >= 50 || r >= 50 = p "C"
  | s >= 30 = p "D"
  | otherwise = p "F"
  where
    s = m + f
    p t = putStrLn t >> main


Measured memory_bytes: 4020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, x, t;
   cin >> n >> x >> t;
   if (n%x==0) {
       cout << n/x*t << endl;
   } else {
          cout << (n/x+1)*t << endl;
   }
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void) {
  int i, j, k, n, t, l, r, ans = 0, now = 0;
  scanf("%d%d", &n, &t);
  int num[t + 1];
  for(i = 0; i <= t; ++i) num[i] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%d%d", &l, &r);
    num[l]++, num[r]--;
  }
  for(i = 0; i <= t; ++i) {
    now += num[i];
    if(ans < now) ans = now;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3128
import sys
S = str(input())
K = int(input())

arr = [ord(S[i]) for i in range(len(S))]
count = K
for i in range(len(S)):
    if i == len(S) - 1:
        count %= 26
        if ord('z') - arr[i] + 1 <= count:
            arr[i] = ord('a')
            count -= ord('z') - ord(S[i]) + 1
        arr[i] += count
        break

    if ord('z') - arr[i] + 1 <= count and arr[i] != ord('a'):
        arr[i] = ord('a')
        count -= ord('z') - ord(S[i]) + 1

    if count == 0:
        break

for c in arr:
    sys.stdout.write(chr(c))

print('')

Measured memory_bytes: 4980
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
int H[500005],h;
void heapify(int i){
	int l=2*i,r=2*i+1,large;
	if (l<=h&&H[l]>H[i]) large=l;
	else large=i;
	if (r<=h&&H[r]>H[large]) large=r;
	if (large!=i){
		swap(H[i],H[large]);
		heapify(large);
	}
}
int main(){
	scanf("%d",&h);
	for (int i=1;i<=h;i++) scanf("%d",&H[i]);
	for (int i=h/2;i>=1;i--) heapify(i);
	for (int i=1;i<=h;i++) printf(" %d",H[i]);
	printf("\n");
}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ok = 1e9;
	int ng = 0;
	while (abs(ok - ng) > 1)
	{
		int mid = (ok + ng) / 2;
		int tmp_cnt = 0;
		for (int i = 0; i < n; i++) tmp_cnt += (a[i] - 1) / mid;
		if (tmp_cnt <= k) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return (0);
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::greater<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  map<pair<int, int>, int> mp;
  for (int i = 1; i <= n; ++i) {
    auto s = to_string(i);
    int f = s.front() - '0', l = s.back() - '0';
    ++mp[make_pair(f, l)];
  }
  int64 ans = 0;
  for (const auto& pr : mp) {
    ans += pr.second * 1ll * mp[make_pair(pr.first.second, pr.first.first)];
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <algorithm>
#include <iomanip>

const int DEPTH_LIMIT = 45;

using namespace std;

void PrintBoard( const vector<int>& b ) {
    for ( int row=0; row<4; ++row ) {
	for ( int col=0; col<4; ++col ) cout << setw(2) << " " << b[row*4+col];
	cout << endl;
    }
}

bool IsCompleted( const vector<int>& b ) {
    for ( int i=0; i<15; ++i ) {
	if ( b[i] != i+1 ) return false;
    }
    return b[15] == 0;
}

int H1( const vector<int>& b ) {
    int dist = 0;
    for ( int i=0; i<15; ++i ) dist += b[i] == (i+1) ? 1 : 0;
    return dist;
}

int H2( const vector<int>& b ) {
    static int tab[16][2] = {
	{ 3, 3 },//0
	{ 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 },
	{ 0, 1 }, { 1, 1 }, { 2, 1 }, { 3, 1 },
	{ 0, 2 }, { 1, 2 }, { 2, 2 }, { 3, 2 },
	{ 0, 3 }, { 1, 3 }, { 2, 3 } };
	
    int dist = 0;
    for ( int i=0; i<16; ++i ) {
	if ( b[i] == 0 ) continue;//ignore pos of 0
	int x = i%4;
	int y = i/4;
	dist += abs( tab[b[i]][0] - x ) + abs( tab[b[i]][1] - y );
    }
    return dist;
}

const int dx[4] = { -1, 0, 1,  0 };
const int dy[4] = {  0, 1, 0, -1 };
vector<int> board, board_org( 16 );
    
bool Solve( int x, int y, int curr, int lim, int prev ) {

    if ( IsCompleted( board ) ) return true;

    //    cout << "--- " << x << " " << y << " " << curr << " " << lim << endl;
    //    PrintBoard( board );
    
    if ( curr == lim ) return false;
    
    for ( int i=0; i<4; ++i ) {

	if ( (i+2)%4 == prev ) continue;
	
	int nx = x + dx[i];
	int ny = y + dy[i];

	if ( nx < 0 || nx > 3 || ny < 0 || ny > 3 ) continue;

	swap( board[4*y+x], board[4*ny+nx] );
	
	//	cout << "i = " << i << " " << curr + H2( board ) << endl;
	//	PrintBoard( board );
	
	if ( curr + H2( board ) > lim ) {
	    swap( board[4*y+x], board[4*ny+nx] );
	    continue;
	}

	if ( Solve( nx, ny, curr+1, lim, i ) ) return true;

	swap( board[4*y+x], board[4*ny+nx] );	
    }

    return false;
}

int main() {

    int x, y;
    
    for ( int i=0; i<4; ++i ) {
	for ( int j=0; j<4; ++j ) {
	    cin >> board_org[i*4+j];
	    if ( board_org[i*4+j] == 0 ) {
		x = j;
		y = i;
	    }
	}
    }

    for ( int d=0; d<DEPTH_LIMIT; ++d ) {
	board = board_org;
	if ( Solve( x, y, 0, d, 5 ) ) {
	    cout << d << endl;
	    return 0;
	}
	//	cout << endl;
    }

    cout << DEPTH_LIMIT << endl;
    
    return 0;
}



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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	string s; cin >> s;
	int n = s.size();
	
	cout << ((s[0] == s[n-1] ^ n%2) ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
    string s;
    cin >> s;
    if (s.back() != 's') {
        cout << s << "s" << endl;
    } else {
        cout << s << "es" << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int n;
	while (cin >> n&&n != 0) {
		int a[100], k = 0, s = 0, e = n - 1, sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		cin >> k;
		while (s - e!=1) {
			int b = floor((s + e) / 2);
			if (a[b] < k) {
				s = b+1;
				sum++;
			}
			else if (a[b] > k) {
				e = b-1;
				sum++;
			}
			else {
				sum++;
				break;
			}
		}
		cout << sum << endl;
	}
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i=0; i<N; i++) cin >> A[i]; 
    bool flag = true;
    int cnt =0;
    while(flag){
        for(int i=0; i<N; i++){
            if(A[i]%2!=0){
                flag = false;
            }else{
                A[i] /= 2;
            }
        }
        if(flag) cnt++;
    }
    cout << cnt << endl;
}

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

int main()
{
    string s, t;

    cin >> s;
    cin >> t;

    bool b = false;
    int y = -1;
    for (int i = 0; i < s.size(); i++)
    {
        int x = 0;
        for (int j = 0; j < t.size(); j++)
        {
            if (s[i + j] == t[j] || s[i + j] == '?')
            {
                x++;
            }
            else
            {
                break;
            }

            if (x == t.size())
            {
                b = true;
                break;
            }
        }

        if (b == true)
        {
            y = i;
            b = false;
        }
    }

    if (y >= 0)
    {
        for (int i = 0; i < t.size(); i++)
        {
            s[i + y] = t[i];
        }
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] == '?')
            {
                s[i] = 'a';
            }
        }
    }
    else
    {
        s = "UNRESTORABLE";
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int a[4][3][10]={0};
    int n, b, f, r, v;
    int i, j, k;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        a[b-1][f-1][r-1]+=v;
    }
    for(i=0; i<4; i++) {
        for(j=0; j<3; j++) {
            for(k=0; k<10; k++) {
                printf("%2d", a[i][j][k]);
            }
            putchar('\n');
            if(i<3 && j==2) printf("####################\n");
        }
    }
     return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;

  ll ans = divisor(N - 1).size() - 1;

  vll d2 = divisor(N);
  rep(i, d2.size()) {
    if (d2[i] == 1) continue;
    ll t = N;
    while (t % d2[i] == 0) t /= d2[i];
    if (t % d2[i] == 1) ans++;
  }

  COUT(ans);

  return 0;
}

Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))

# m = bin(10**9)[2:]
# print(int('11010', 2))
# print(17^19^2)
# print(26^19^2)
# print(26^17^2)
# print(26^17^19)

first = 0
tmp = 0

for (i, a) in enumerate(A):
    if i == 0:
        first = a
        continue
    else:
        xor = first^a
        tmp = tmp^xor

f = tmp^first
print(f)
for (i, a) in enumerate(A):
    if i == 0:
        continue
    else:
        print(first^f^a)


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

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

    vector<ll> l(n);
    rep(i,n-1){
        l[i+1] = l[i];
        if(s[i] == 'W') l[i+1]++;
    }

    vector<ll> r(n);
    for(int i = n-1; i >0; i--){
        r[i-1] = r[i];
        if(s[i] == 'E') r[i-1]++;
    }

    ll ans = 1002003004;
    rep(i,n) ans = min(ans,l[i]+r[i]);

    cout << ans << endl;

    //rep(i,n) cout << l[i] << " " << r[i] << endl;
}

Measured memory_bytes: 5380
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int MOD=1e9+7;
ll N,K;
ll x[100];
int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a,b=8;
		cin >> a;
		if (a < 400)b = 0;
		else if (a < 800)b = 1;
		else if (a < 1200)b = 2;
		else if (a < 1600)b = 3;
		else if (a < 2000)b = 4;
		else if (a < 2400)b = 5;
		else if (a < 2800)b = 6;
		else if (a < 3200)b = 7;
		if (b != 8)x[b] = 1;
		else x[b]++;
	}
	int c = count(&x[0],&x[8], 1);
	int ma = c, mi = c;
	while (x[8] > 0) {
		x[8]--;
		ma++;
		if (c > 8)ma--;
	}
	if (mi == 0)mi=1;
	else if(x[8]>0)mi = (c < 8) ? mi = c : mi = 8;
	cout << mi << " " << ma;
	return 0;
}



Measured memory_bytes: 256
def findProductSum(A, n):
    tmp = (10**9)+7

    array_sum = 0
    for i in range(0, n, 1):
        array_sum = array_sum + A[i]

    array_sum_square = array_sum * array_sum

    individual_square_sum = 0
    for i in range(0, n, 1):
        individual_square_sum += A[i] * A[i]
        individual_square_sum = individual_square_sum

    return ((array_sum_square - individual_square_sum) // 2) % tmp

n = int(input())
a = list(map(int,input().split()))

print(findProductSum(a,n))


Measured memory_bytes: 31548
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int d = sc.nextInt();
      	if(d == 25) System.out.println("Christmas");
      	else if(d == 24)  System.out.println("Christmas Eve");
     	else if(d == 23)  System.out.println("Christmas Eve Eve");
      	else if(d == 22)  System.out.println("Christmas Eve Eve Eve");
    }
}

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

#define cMaxLimit 260

typedef struct {
    int key;
    int parent;
    int leftChild;
    int rightChild;
}Node;

void print(Node node[], int maxNum) {
    for (int i = 1; i <= maxNum; i++) {
        cout << "node " << i << ": ";
        cout << "key = " << node[i].key << ", ";
        if (node[i].parent != -1) {
            cout << "parent key = " << node[i].parent << ", ";
        }
        if (node[i].leftChild != -1) {
            cout << "left key = " << node[i].leftChild << ", ";
        }
        if (node[i].rightChild != -1) {
            cout << "right key = " << node[i].rightChild << ", ";
        }
        cout << endl;
    }
}

int main() {
    int nodeMaxNum;
    Node node[cMaxLimit+1];//????????????????????????1-???????????????????????????
    cin >> nodeMaxNum;

    for (int i = 1; i <= nodeMaxNum; i++) {
        int key; cin >> key;
        node[i].key = key;
        node[i].leftChild = -1;
        node[i].rightChild = -1;
        node[i].parent = -1;
    }
    for (int i = 1; i <= nodeMaxNum; i++) {
       cout << "node " << i << ": ";
       cout << "key = " << node[i].key << ", ";
       if (i/2 >= 1) {
           cout << "parent key = " << node[i/2].key << ", ";
       }
       if (i*2 <= nodeMaxNum) {
           cout << "left key = " << node[i * 2].key << ", ";
       }
       if (i*2+1 <= nodeMaxNum) {
           cout << "right key = " << node[i * 2 + 1].key << ", ";
       }
       cout << endl;
    }
    for (int i = 1; i <= nodeMaxNum; i++) {
        if (i / 2 >= 1) {
            node[i].parent = node[i / 2].key;
        }
        if (i * 2 <= nodeMaxNum) {
            node[i].leftChild = node[i * 2].key;
        }
        if (i * 2 + 1 <= nodeMaxNum) {
            node[i].rightChild = node[i * 2 + 1].key;
        }
    }

    //print(node, nodeMaxNum);

    return 0;
}

Measured memory_bytes: 3096
import sys
input = sys.stdin.readline

a, b = map(int, input().split())


#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

print(lcm(a, b))

Measured memory_bytes: 3060
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

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

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

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

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };


int main () {
	vector<int> a (3);
	rep (i, 3) {
		cin >> a[i];
	}

	sort (all (a));
	cout << ( a[0] * a[1] ) / 2 << endl;
	

	
}

  

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

int main(){
   int n,i,j;
   cin >> n;
   int seq[n];

   for(i=0;i<n;i++){
	cin >> seq[i];
   }

   for(j=n-1;j>0;j--){
	cout << seq[j] << " ";
   }
   cout << seq[0] << endl;

   // cout << endl;

   return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vll d(n);
  for (ll i = 0; i < n; i++) cin >> d[i];
  sort(all(d));
  cout << d[n / 2] - d[n / 2 - 1] << endl;
}

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

char txt[10000];

int main(){
    while( cin >> txt ){
        int joi = 0, ioi = 0;
        for(int i = 2; txt[i]; i++){
            if( txt[i] != 'I' ) continue;
            if( txt[i-1] != 'O' ) continue;
            if( txt[i-2] == 'I' ) ioi++;
            if( txt[i-2] == 'J' ) joi++;
        }
        cout << joi << '\n' << ioi << endl;
    }
    return 0;
}

Measured memory_bytes: 1148
N = int(input())
cnt = 0
flg = False
for _ in range(N):
    S1, S2 = input().split()
    if S1 == S2:
        cnt += 1
        if cnt >= 3:
            flg = True
    else:
        cnt = 0
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62184
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abc= {sc.nextInt(),sc.nextInt(),sc.nextInt()};
		int k=sc.nextInt();
		Arrays.sort(abc);
		for(int i=0; i<k;i++) abc[2] *= 2;
		System.out.println(abc[0]+abc[1]+abc[2]);
	}
}


Measured memory_bytes: 23892
#include<cstdio>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&a!=c)	printf("Yes\n");
	else if(a==c&&a!=b) printf("Yes\n");
	else if(b==c&&a!=b) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

long long gcm(long long a, long long b){
    long long g = 0;
    while(a%b != 0){
        g = a%b;
        a = b;
        b = g;
    }
    return b;
}

long long lcm(long long a, long long b){
    if(a < b) return lcm(b,a); 
    if(a%b == 0) return a;
    auto g = gcm(a, b);
    return a/g*b;
}


int main()
{
    int n;
    cin >> n;
    long long a[n] = {};
    for(int i=0; i<n; i++) cin >> a[i];
    
    long long ans = a[0];
    for(int i=0; i<n; i++){
        ans = lcm(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, D; cin >> N >> D;
    ll res = 0;
    rep(i,N) {
        ll x,y; cin >> x >> y;
        if (sqrt(x * x + y * y) <= D) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int N, L;
    cin >> N >> L;
    string a[N];
    for (int i=0; i<N; i++) {
        cin >> a[i];
    }
    sort(a,a+N);
    for (int i=0; i<N; i++) {
        cout << a[i];
    }
}

Measured memory_bytes: 256
N = int(input())
A = [ int(v) for v in input().split() ]

if N < 2 and 1e5 < N: raise()
for v in A:
    if v < -1e9 and v < 1e9: raise()

abs_list = [abs(v) for v in A]

total = sum( abs_list )
num_of_minus = sum([ True for v in A if v < 0 ])

if num_of_minus % 2 == 1:
    print(total - min( abs_list ) * 2)
else:
    print(total)

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

using namespace std;

#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

typedef pair<int, int> P;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;
  int c[1010][505];
  rep(i, K) rep(j, N/2) cin >> c[i][j];
  srand((unsigned)time(NULL));
  while(1) {
    string bin = "";
    rep(i, N) bin += '0' + rand()%2;
    bool flag = true;
    rep(i, K) {
      int sum = 0;
      rep(j, N/2) sum += bin[c[i][j]-1] - '0';
      if(sum < N/8 || 3*N/8 < sum) flag = false;
      if(!flag) break;
    }
    if(flag) {
      cout << bin << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 5132
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			int result = n - IntStream.range(0, m).map(i -> scanner.nextInt()).sum();
			System.out.println((result >= 0) ? result : -1);
		}
	}
}


Measured memory_bytes: 46740
#include <stdio.h>

int main()
{
	int d, t, s;
	scanf("%d %d %d", &d, &t, &s);
	if (d <= t * s)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 long long N,M,f,g;
  cin>>N;
  string S;
  cin>>S;
 vector<int> W(N+2),E(N+2);
  
  for(int i=0;i<N;i++){
    W[i+1]=W[i];
    E[i+1]=E[i];
    if(S[i]=='W'){
      W[i+1]++;
    }
    else{
      E[i+1]++;
    }
  }
  g=1000000;
 
    for(int i=0;i<N;i++){
   f=W[i]+E[N]-E[i+1];
      g=min(f,g);
   }
 cout<<g<<endl;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>

int main() {
	char a[200], b[100], r[200];

	scanf("%s", a);
	scanf("%s", b);
	strcpy(r,a);
	strcat(r,a);

	if (strstr(r,b)) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 540
<?php
// B
fscanf(STDIN, '%d %d', $n, $k);
$cnt = 0;
for ($i  = 0; $i < $k; $i++) {
    fscanf(STDIN, '%d', $d[]);
    $a = array_map('intval', explode(' ', trim(fgets(STDIN))));
    foreach ($a as $aa) {
        if (!isset($have[$aa])) {
            $cnt++;
            $have[$aa] = true;
        }
    }
}
$ans = $n - $cnt;
echo $ans;

Measured memory_bytes: 16144
#include<iostream>
#include<math.h>
#include<cstdio>
#include<cstring>
#include<string>
#include<string.h>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
	int a=0;
	string s;
	cin>>s;
	vector<int>v;
	for(int i=0;i<s.size();i++)
	if(s[i]=='1')
	a++;
	cout<<a;
    return 0;
}

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

using namespace std;

int main() {
  int n;
  int count = 0;
  string s;
  cin >> n;
  cin >> s;
  
  for(int i = 0; i < s.length() - 2; i++) {
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      count++;
      i = i + 2;
    }
   }
  
  cout << count;
  
  return 0;
  
}

Measured memory_bytes: 256
N = int(input())
l = [int(input()) for i in range(N)]

minv = l[0]
maxv = l[1] - l[0]
for i in range(1, len(l)):
  maxv = max(maxv, l[i] - minv)
  minv = min(minv, l[i])
print(maxv)


Measured memory_bytes: 13596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int n,k,a[maxn],ans=0;
const int K=400;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	a[1]=1;
	rep2(i,2,k+1){
		a[i]=Pow(i,n);
		rep2(j,2,i+1){
			if(i/j<=K) break;
			a[i]=sub(a[i],a[i/j]);
		}
		rep2(j,1,K+1){
			if(j==i) break;
			a[i]=sub(a[i],(i/j-i/(j+1))*a[j]%MOD);
		}
	}
	rep2(i,1,k+1) ans=add(ans,i*a[k/i]%MOD);
	print1(ans);
	return 0;
}

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

int main() {
    ll n;
    cin >>n;
    stack<char> S;
    while(n>=0){
        char s='a';
        int r = n%26;
        if(r>0){
            r--;
            S.push(s+r);
            n=n/26;
        }else{
            S.push('z');
            n=(n-1)/26;
        }
        if(n==0)break;
    }
    while(!S.empty()){
        char i = S.top();
        S.pop();
        printf("%c",i);
    }
    printf("\n");
}


Measured memory_bytes: 3632
// verified at https://judge.yosupo.jp/submission/3400
#ifndef Union_find_hpp
#define Union_find_hpp

#include <cassert>
#include <cstddef>
#include <vector>

class union_find
{
    std::vector<int> link;

public:
    explicit union_find(const size_t n) : link(n, -1) {}

    size_t find(size_t x)
    {
        assert(x < size());
        return link[x] < 0 ? x : (link[x] = find(link[x]));
    }

    size_t size() const { return link.size(); }

    size_t size(const size_t x)
    {
        assert(x < size());
        return -link[find(x)];
    }

    bool same(const size_t x, const size_t y)
    {
        assert(x < size() && y < size());
        return find(x) == find(y);
    }

    size_t unite(size_t x, size_t y)
    {
        assert(x < size() && y < size());
        if((x = find(x)) != (y = find(y)))
        {
            if(link[x] > link[y]) std::swap(x, y);
            link[x] += link[y];
            link[y] = x;
        }
        return x;
    }
}; // class union_find

#endif // Union_find_hpp

#include <algorithm>
#include <iostream>
#include <tuple>

using namespace std;

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

    int n,h,w; cin>>n>>h>>w;
    vector<tuple<int,int,int>> cards(n);
    for(auto &e : cards)
    {
        int r,c,a; cin>>r>>c>>a;
        --r,--c; c+=h;
        e=tie(a,r,c);
    }
    sort(cards.rbegin(),cards.rend());
    union_find uf(h+w);
    long long ans{};
    bool ext[2<<17]={};
    for(auto &e : cards)
    {
        int a,r,c; tie(a,r,c)=e;
        r=uf.find(r),c=uf.find(c);
        if(r!=c)
        {
            if(ext[r] and ext[c]) continue;
            ext[uf.unite(r,c)]=ext[r]||ext[c];
            ans+=a;
        }
        else if(!ext[r])
        {
            ext[r]=true;
            ans+=a;
        }
    }
    cout << ans << "\n";
}


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

int main() {
  int n;cin>>n;
  int s=0;
  int l,r;
  rep(i,n) {
    cin>>l>>r;
    s+= r-l+1;
  }
  cout <<s;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int n,b = 0;
	cin >> n;
	int a[n];
	for (int i = 0 ; i < n ; i++) cin >> a[i], b += a[i];
	sort(a, a + n);
	if (b % 10 != 0) {
		cout << b;
		return 0;
	}
	else {
		for (int j = 0 ; j < n ; j++) {
			for (int i = j ; i < n ; i++) {
				if ((b - a[i]) % 10 != 0) {
					cout << b - a[i];
					return 0;
				}
			}
			b -= a[j];
		}	
	} 
	cout << 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int n;
	cin >> n;

	cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n;
	char s[10000];

	scanf("%d", &n);
	scanf("%s", s);
	int i = 0, count = 0;
	while (s[i] != 0) {
		i++;
		count++;
	}
	for (i = 0; i < count; i++) {
		if (s[i] + n > 90)
			printf("%c", s[i] + n - 26);
		else
			printf("%c", s[i] + n);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
q = int(input())
sums = sum(a)
d = {}

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
    b,c = map(int, input().split())
    if b in d:
        sums += d[b]*(c-b)
        if c in d:
          d[c] += d[b]
        else:
          d[c] = d[b]
        d[b] = 0
    print(sums)

Measured memory_bytes: 20620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}

template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl a(n);
	cin>>a;
	ll x=0;
	rep(i,62){
		ll m=1ll<<(61-i);
		ll cnt=0;
		rep(j,n){
			if(a[j]&m)cnt++;
		}
		if(cnt*2<n and (x|m)<=k){
			x|=m;
		}
	}
	ll ans=0;
	rep(i,n)ans+=x^a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
//dp[i]=i個のどんぐりを使って取引所A→Bを使ったあとのどんぐりの個数の最大値
long long dp[5001];
//dp2[i]=i個のどんぐりを使って取引所B→Aを使ったあとのどんぐりの個数の最大値
long long dp2[5000*5000+1];
int main(){
    long long n,a[3],b[3];
    scanf("%lld",&n);
    for(int i=0;i<3;i++)scanf("%lld",&a[i]);
    for(int i=0;i<3;i++)scanf("%lld",&b[i]);
    dp[0]=0;
    for(int i=1;i<=5000;i++){
        dp[i]=dp[i-1]+1;
        for(int j=0;j<3;j++){
            if(a[j]<=i)dp[i]=std::max(dp[i],dp[i-a[j]]+b[j]);
        }
    }
    dp2[0]=0;
    for(int i=1;i<=5000*5000;i++){
        dp2[i]=dp2[i-1]+1;
        for(int j=0;j<3;j++){
            if(b[j]<=i)dp2[i]=std::max(dp2[i],dp2[i-b[j]]+a[j]);
        }
    }
    printf("%lld\n",dp2[dp[n]]);
    return 0;
}

Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
int a[1005];
int c[1005];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n;i++){
        cin >> c[i];
    }
    int q;
    cin >> q;
    while(q--){
        int t,x,d;
        cin >> t >> x >> d;
        if(t == 1){
            a[x] += d;
            if(a[x] > c[x]){
                 cout << x << endl;
                 return 0;
            }
        }else{
            a[x] -= d;
            if(a[x] < 0){
                cout << x << endl;
                return 0;
            }
        }
    }
    cout << 0 <<endl;

    return 0;
}



Measured memory_bytes: 3128
N,M = map(int,input().split())
adict = {}
for i in range(M):
    p,y = map(int,input().split())
    if not p in adict.keys():adict[p] = [[i,y]]
    else:adict[p].append([i,y])

ln = [''] * M
for k in adict.keys():
    for j,d in enumerate(sorted(adict[k],key=lambda x: x[1])):
        num = d[0]
        ln[num] = str(k).zfill(6) + str(j+1).zfill(6)

for z in ln:print(z)

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

int main() {
    int a, b;
    cin >> a >> b;
    const double tax8 = 0.08;
    const double tax10 = 0.1;
    for (int i = 1; i < 1010; i++) {
        if ((int)(i * tax8) == a && (int)(i * tax10) == b) {
            cout << i << endl;
            return 0;
        }
    }

    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;
 
#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   N     =  5e5+5;
const ll   mod   =  1e9;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, a, b;

ll calc(ll n){
	ll res = 0;
	if(n%4 == 1 or n%4 == 2) res = 1;
	if(n%2 == 0) res ^= n;
	return res; 
}

void solve(){
	cin >> a >> b; a = max(a-1,0ll);
	deb1((calc(a)^calc(b)))
}

int main(){
	GODSPEED;
	//cin>>test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main ()
{
  int N; cin >> N;
  vector < int > A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector < pair < int,int > > ord;
  for (int i = 0; i < N; i++) {
    ord.push_back(make_pair(A[i], i + 1));
  }
  sort(ord.begin(), ord.end());
  for (int i = 0; i < ord.size(); i++) {
    cout << ord[i].second << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2164
S = input()

A, B = int(S[:2]), int(S[2:])

is_MM_A = 1 <= A <= 12
is_MM_B = 1 <= B <= 12

if is_MM_A and is_MM_B :
	print('AMBIGUOUS')
elif is_MM_A :
	print('MMYY')
elif is_MM_B :
	print('YYMM')
else :
	print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){
  string s;
  cin  >> s;
  int n,i,ans,a=0,b=0;
  n = s.length();

  for(i=0 ; i<n ; i++){
    if(s[i] == '0'){
      a++;
    }else{
      b++;
    }
  }

  ans = min(a,b)*2;

  cout << ans << endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll N;
ll nega=0;
ll ans=0;
ll minimum=1'000'000'000;

int main(){
    cin>>N;
    rep(i,N){
        ll a;
        cin>>a;
        ans+=abs(a);
        nega+=a<0;
        minimum=min(minimum,abs(a));
    }

    if(nega%2==1) ans-=minimum*2;

    cout<<ans<<endl;
}

Measured memory_bytes: 384
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	ll r, D, x2;
	cin >> r >> D >> x2;
	rep(i, 10) {
		x2 = r * x2 - D;
		cout << x2 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 struct UnionFind {
   // コンストラクタ
     vector<int> par;

     UnionFind(int n) : par(n, -1) { } //初期化

     // メンバ関数
     void init(int n) { par.assign(n, -1); } //途中で初期化したいときに使う。

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

     bool issame(int x, int y) {
         return root(x) == root(y);
     }

     void merge(int x, int y) {
         x = root(x); y = root(y);
         if (x == y) return; //root同じ場合
         if (par[x] > par[y]) swap(x, y); // merge technique
         par[x] += par[y];
         par[y] = x;
         return;
     }

     int size(int x) {
         return -par[root(x)];
     }
 };

 int main() {
   int N, M; cin >> N >> M;
   vector<int> p(N);
   rep(i, 0, N) cin >> p.at(i);

   UnionFind uf(N);

   rep(i, 0, M) {
     int x, y; cin >> x >> y;
     uf.merge(x - 1, y - 1);
   }

   int ans = 0;
   rep(i, 0, N) if (uf.issame(p.at(i) - 1, i)) ans++;

   cout << ans << endl;
 }


Measured memory_bytes: 1024