akhauriyash/Code-Regression huggingface dataset:
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
 
using namespace std;
 
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
 
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;
 
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end(), greater<int>());
  int m = n - 2;
  int64 ret = a[0];
  for (int i = 0; i < m; ++i) {
    ret += a[i / 2 + 1];
  }
  printf("%lld\n", ret);
  return 0;
}

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

using namespace std;

int main() {
  const vector<string> S = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  string s;
  cin >> s;

  int idx = 0;
  for (auto i = 0; i < S.size(); ++i) {
    if (s == S[i]) {
      idx = i;
    }
  }

  cout << 7 - idx << endl;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

for i in range(1,4):
    ans = 0
    for j in range(n):
        ans += abs(x[j] - y[j]) ** i
    else:
        ans **= 1/i
        print(ans)
        
max_d = 0
for i in range(n):
    max_d = max(max_d, abs(x[i]-y[i]))
ans = max_d

print(ans)



Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll n,m;

//UnionFind
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int n) : par(n, -1) { }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool merge(int x, int y) {//xの木とyの木を結合する
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {//sizeの取得
        return -par[root(x)];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    cin >> n >> m;
    UnionFind u(n+m);
    rep(i,n){
        ll k;
        cin >> k;
        rep(j,k){
            ll l;
            cin >> l;
            u.merge(i,l+n-1);
        }
    }
    ll cnt = 0;
    for(int i=n;i<n+m;i++){
        if(u.size(i)==1)cnt++;
    }
    if(u.size(0)<n+m-cnt){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
    return 0;
}



Measured memory_bytes: 3920
#include<cstdio>
#include<algorithm>
const int N=2003,INF=1e9+6;
struct edge{int v,nxt;}g[N+N];
int n,head[N],k,f[N],siz[N],ans;char a[N];
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs0(int u,int fa){
	int v;
	siz[u]=a[u]=='1',f[u]=0;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa)
	  Dfs0(v,u),f[u]+=siz[v]+f[v],siz[u]+=siz[v];
}
bool Check(int u,int fa,int r,int m){
	int v,p=0,deg=0;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa){
	  ++deg;
	  p=siz[v]+f[v]>=siz[p]+f[p]?v:p;
	}
	if((f[u]&1)&&r||!deg||deg==1&&r||f[u]<m*2)return 0;
	if((siz[p]+f[p])*2<=f[u]||f[u]-siz[p]-f[p]>=m)return 1;
	return Check(p,u,0,m-(f[u]-siz[p]-f[p]));
}
int main(){
	int u,v;
	scanf("%d%s",&n,a+1);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	ans=INF;
	for(u=1;u<=n;u++){
	  Dfs0(u,0);
	  if(!f[u])return 0*puts("0");
	  if(Check(u,0,1,f[u]/2))ans=std::min(ans,f[u]);
	}
	printf("%d\n",ans==INF?-1:ans/2);
	return 0;
}

Measured memory_bytes: 1880
import sys
readline = sys.stdin.readline

N = int(readline())
X = readline().rstrip()

X0 = int(X, 2)
count1 = X.count("1")

X0mod0to1 = X0 % (count1 + 1) # 0->1に変化した際の、X0を割った余り
if count1 > 1:
  X0mod1to0 = X0 % (count1 - 1) # 1->0に変化した際の、X0を割った余り
else:
  X0mod1to0 = 0

from collections import defaultdict
dp = defaultdict(int)
dp[0] = 0
def f(x): # 愚直にf(x)を求める式
  if x in dp:
    return dp[x]
  pc = bin(x).count("1")
  val = f(x % pc) + 1
  dp[x] = val
  return val
  
val0to1 = 1
val1to0 = 1
ans = [-1] * N

for i in range(N - 1, -1, -1): # 下の桁から順に、f(Xi)の値を求める
  if X[i] == "0": # 0を1に変える場合
    pat = (X0mod0to1 + val0to1 % (count1 + 1)) % (count1 + 1)
    ans[i] = f(pat) + 1
  elif X[i] == "1": # 1を0に変える場合
    if count1 > 1:
      pat = (X0mod1to0 - val1to0 % (count1 - 1)) % (count1 - 1)
      ans[i] = f(pat) + 1
    else:
      ans[i] = 0
  val0to1 = val0to1 * 2 % (count1 + 1)
  if count1 != 1:
    val1to0 = val1to0 * 2 % (count1 - 1)

print(*ans, sep = "\n")

Measured memory_bytes: 16116
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	k := sc.ReadInt()

	total := int64(0)
	for i := k; i <= n+1; i++ {
		total += combi(n, i)
		total = total % (Pow64(10, 9) + 7)
	}
	fmt.Println(total)
}

func combi(n int, k int) int64 {
	min := int64(k-1) * int64(k) / 2
	max := int64(2*n-k+1) * int64(k) / 2
	return max - min + 1
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1760
list0=list(map(int,input().rstrip().split(" ")))

N=list0[0]
D=list0[1]
sum=0
for i in range(N):
    list1=list(map(int,input().rstrip().split(" ")))
    D1=list1[0]**2+list1[1]**2
    if D1<=D**2:
        sum += 1
print(sum)

Measured memory_bytes: 9200
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int INF = 1000000;
const int x[4] = {1, 0, -1, 0};
const int y[4] = {0, 1, 0, -1};

int main()
{
    int h, w;
    cin >> h >> w;
    char a[1002][1002];
    int c[1002][1002];
    queue<P> q;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            c[i][j] = INF;
            cin >> a[i][j];
            if(a[i][j] == '#'){
                c[i][j] = 0;
                q.push(P(i, j));
            }
        }
    }
    int l = 0;
    while(q.size() > 0){
        P now = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            P next = P(now.first + x[i], now.second + y[i]);
            if(0 <= next.first && next.first < h && 0 <= next.second && next.second < w &&
               c[next.first][next.second] == INF){
                q.push(next);
                c[next.first][next.second] = c[now.first][now.second] + 1;
                l = c[next.first][next.second];
            }
        }
    }
    cout << l << endl;
}

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

int main(){
    int n,l;
    cin >> n >> l;
    string s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

map<int, int>mp;
const int MAX_INT = 1000000;
int is_prime[MAX_INT + 1];
vector<int>P;
void calc(int N) {
	while (-1 != is_prime[N]) {
		int p = is_prime[N];
		while (0 == N % p) {
			N /= p;
		}
		mp[p]++;
	}
	if (1 != N) {
		mp[N]++;

	}
	return;
}
//エラトステネスの篩(素数の数を返している)
void sieve(int  n) {
	is_prime[0] = -1;
	is_prime[1] = -1;
	for (int m = 2; m <= n; ++m) {//初期化
		is_prime[m] = -1;
	}
	for (int m = 2; m <= n; ++m) {
		if (-1 == is_prime[m]) {
			P.push_back(m);
			for (int l = 2 * m; l <= n; l += m) {
				is_prime[l] = m;
			}
		}
	}
	return;
}

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	int maxA = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		maxA = max(maxA, A[i]);
	}
	sieve(maxA);
	for (int i = 0; i < N; ++i) {
		calc(A[i]);
	}

	bool b1 = true;
	bool b2 = false;
	for (auto p : mp) {
		if (1 != p.second) {
			b1 = false;
		}
		if (N == p.second) {
			b2 = true;
		}
	}
	if (b1) {
		cout << "pairwise coprime" << endl;
	}
	else if (!b2) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
	return 0;
}

Measured memory_bytes: 14860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n);
	set<int> st;
	int cnt=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]>=3200){
			cnt++;
		}else{
			st.insert(a[i]/400);
		}
	}
	if(st.size()){
		cout<<st.size()<<' '<<st.size()+cnt<<endl;
	}else{
		cout<<1<<' '<<cnt<<endl;
	}
}

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

template<typename T, char start='a', int C=26>
struct Trie{
    struct Node{
        vector<int> ch;
        T val;
        Node(){
            val = 0;
            ch.resize(C, -1);
        }
    };

    vector<Node> nodes;

    Trie(){ nodes.push_back(Node()); }

    void update(int nd, T v){
        nodes[nd].val += v;
    }
    
    int add(int nd, int d, const string& S, T v){
        if(int(S.size()) == d){
            update(nd, v);
            return nd;
        }else{
            int c = S[d] - start;
            if(nodes[nd].ch[c] == -1){
                nodes[nd].ch[c] = nodes.size();
                nodes.push_back(Node());
            }
            return add(nodes[nd].ch[c], d+1, S, v);
        }
    }
    int add(const string& S, T v){ return add(0, 0, S, v); }

    int64_t calc(int nd, int64_t d){
        int c0 = nodes[nd].ch[0], c1 = nodes[nd].ch[1];
        int64_t ans = 0;
        if((c0 >= 0) != (c1 >= 0)) ans ^= (d&(-d));
        if(c0 >= 0) ans ^= calc(c0, d-1);
        if(c1 >= 0) ans ^= calc(c1, d-1);
        return ans;
    }
    int64_t calc(int64_t L){ return calc(0, L); }
};

int main(){
    int N;
    int64_t L;
    cin >> N >> L;
    Trie<int, '0', 2> trie;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        trie.add(s, 1);
    }
    int64_t G = trie.calc(L);
    cout << (G ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 9200
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, m;
    cin >> n >> m;
    
    vector<string> map1(n), map2(m);
    for (auto &str : map1) cin >> str;
    for (auto &str : map2) cin >> str;
    
    for (int i = 0; i+m <= n; ++i) {
        for (int j = 0; j+m <= n; ++j) {
            int fl = 1;
            for (int di = 0; di < m and fl; ++di) {
                for (int dj = 0; dj < m and fl; ++dj) {
                    if (map1[i+di][j+dj] != map2[di][dj]) fl = 0;
                }
            }
            if (fl) return cout << "Yes\n", 0;
        }
    }
    
    cout << "No\n";
    
    return 0;
}

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

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> t(N);
  for (int i = 0; i < N; ++i)
    cin >> t[i];
  int X = 0;
  for (int i = 0; i < N; ++i)
    if (i == N - 1)
      X += T;
    else
      X += min(t[i + 1] - t[i], T);
  cout << X << endl;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

	int N;
    cin >> N;
    vector<int> A(1 << N);
    FOR(i, 0, 1 << N) {
        cin >> A[i];
    }

    vector<vector<priority_queue<int, vector<int>, greater<int>>>> K(N + 1, vector<priority_queue<int, vector<int>, greater<int>>>(A.size()));

    FOR(i, 0, A.size()) {
        K[0][i].push(A[i]);
        K[0][i].push(0);
    }
    FOR(i, 0, K.size() - 1) {
        FOR(j, 0, K[0].size()) {
            int a = K[i][j].top(); K[i][j].pop();
            int b = K[i][j].top(); K[i][j].pop();

            K[i + 1][j].push(a);
            K[i + 1][j].push(b);
            while (K[i + 1][j].size() > 2) {
                K[i + 1][j].pop();
            }

            int r = 1 << i;
            if (!(j & r)) {
                if (j + r < K[0].size()) {
                    K[i + 1][j + r].push(a);
                    K[i + 1][j + r].push(b);
                    while (K[i + 1][j + r].size() > 2) {
                        K[i + 1][j + r].pop();
                    }
                }
            }
        }
    }

    LL maxi = 0;
    FOR(j, 1, K[0].size()) {
        LL a = K[K.size() - 1][j].top(); K[K.size() - 1][j].pop();
        LL b = K[K.size() - 1][j].top(); K[K.size() - 1][j].pop();
        maxi = max(maxi, a + b);
        print(maxi);
    }

	return 0;
}

Measured memory_bytes: 315516
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    X, Y, A, B, C = lr()
    p = sorted(lr())[-X:][::-1]
    q = sorted(lr())[-Y:][::-1]
    r = sorted(lr())
    tmp = r.pop()
    pt = p[-1]
    qt = q[-1]
    ext = [0]
    while (tmp > pt or tmp > qt) and len(r) >= 0:
        if pt > qt:
            g = q.pop()
            ext.append(tmp)
            if len(q) == 0:
                qt = pow(10, 9)+1
            else:
                qt = q[-1]
        else:
            g = p.pop()
            ext.append(tmp)
            if len(p) == 0:
                pt = pow(10, 9)+1
            else:
                pt = p[-1]
        if len(r) > 0:
            tmp = r.pop()
        else:
            break
    print(sum(p)+sum(q)+sum(ext))
resolve()

Measured memory_bytes: 96044
H, W = map(int, input().split())
a = []
for h in range(H):
    a.append([int(i) for i in input().split()])
def func(H, W, i):
    h_tmp = i // W
    w_tmp = i % W
    if h_tmp % 2 == 1:
        w_tmp = W - w_tmp - 1
    return  h_tmp, w_tmp
res = []
for i in range(0, H*W-1):
    h, w = func(H, W, i)
    if a[h][w] % 2 == 1:
        h1, w1 = func(H, W, i+1)
        a[h1][w1] += 1
        res.append(['{} {} {} {}'.format(h+1, w+1, h1+1, w1+1)])
print(len(res))
for i in range(len(res)):
    print(res[i][0])

Measured memory_bytes: 27884
def paoers_please():
    N=input()
    A=list(map(int,input().split()))
    E=[]
    for i in A:
        if i%2==0:
            E.append(i)
    for i in E:
        if i%3!=0 and i %5!=0:
            print('DENIED') 
            exit()
    print('APPROVED')
paoers_please()

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

int main() {
    int N;
    cin >> N;
    vec<int> X(N);
    rep(i,N) cin >> X[i];
    vec<int> sX(N);
    sX = X;
    sort(all(sX));
    int b1 = sX[N/2 - 1];
    int b2 = sX[N/2];
    
    rep(i,N){
        if(X[i]<=b1) cout << b2 << endl;
        else cout << b1 << endl;
    }
}


Measured memory_bytes: 3712
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$n = $sc->nextInt();
$a = [];

for ($i = 0; $i < $n; $i++) {
    $a[] = $sc->nextInt();
}
$c = 0;
// 偶数判定
while(true){
    for ($i = 0; $i < $n; $i++) {
        if($a[$i] % 2 !== 0){
            break 2;
        }
        $a[$i] /= 2;
    }
    $c ++;
}

echo $c;

Measured memory_bytes: 4604
# your code goes here
def nextPowerOf2(n): 
	count = 0; 

	# First n in the below 
	# condition is for the 
	# case where n is 0 
	if (n and not(n & (n - 1))): 
		return n 
	
	while( n != 0): 
		n >>= 1
		count += 1
	
	return 1 << count; 
# Python3 program to find whether a number 
# is power of 2 or not 

# Function to check whether a 
# number is power of 2 or not 
def ispowerof2(num): 

	if((num & (num - 1)) == 0): 
		return 1
	return 0

# This code is contributed by 
# Sanjit_Prasad 

n=int(input())
if(n==1):
	print(1)
else:
	if(ispowerof2(n)):
		print(2*n-1)
	else:
		k=nextPowerOf2(n)
		k=k//2
		print(2*k-1)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> tmp;
  map<ll, ll> mp;
  ll a;
  rep(i, 0, N) {
    cin >> a;
    A[i] = a;
    if (Find(mp, a)) {
      mp[a]++;
    } else {
      mp[a] = 1ll;
      tmp.pb(a);
    }
  }

  map<ll, ll> ans;
  ll total = 0ll;

  for (ll t: tmp) {
    ll n = mp[t];
    total += n *(n-1ll) / 2ll;
  }

  rep(i, 0, N) {
    ll ai = A[i];
    ll n = mp[ai];
    cout << total - (n-1) << endl;
  }

  return 0;
};


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	string s, t;
	cin >> s >> t;

	int n = s.size();

	int a[26] = {};
	rep(i, n) a[s[i] - 'a']++;
	/*
	rep(i, 26) cout << a[i];
	cout << endl;
	*/
	sort(a, a+26);

	int b[26] = {};
	rep(i, n) b[t[i] - 'a']++;
	/*
	rep(i, 26) cout << b[i];
	cout << endl;
	*/
	sort(b, b+26);

	bool ok = true;
	rep(i, 26){
		if(a[i] != b[i]) {
			ok = false;
			break;
		}
	}

	cout << (ok ? "Yes" : "No") << endl;
}


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

int main(){
    int a, b; cin >> a >> b;
    
    if( a%3==0 || b%3==0 || (a+b)%3==0 ){
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()


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

  int A1,A2,A3;
  cin>>A1>>A2>>A3;
  int A12=abs(A1-A2);
  int A23=abs(A2-A3);
  int A31=abs(A3-A1);
  cout<<A12+A23+A31-max({A12,A23,A31})<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> A(3 * N);
    rep(i, 0, 3 * N) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0;
    int num = 0;
    for (int i = 3 * N - 2; ; i -= 2)
    {
        ans += A[i];
        ++num;
        if (num == N) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1 ;
const ll N = 1e3 + 55 ;
vector<ll> adj[N] ;
vector<ll> bfs(ll node){
    vector<ll> vis(N,0) , par(N,-1) ;
    queue<ll> q ;
    q.push(node);
    vis[node]=1;
    while(!q.empty()){
        ll x = q.front();
        q.pop();
        for(auto i : adj[x]){
            if( vis[i] == 0 ){
                q.push(i);
                vis[i]=1;
                par[i]=x;
            }
            else{
                if(i==node){
                    vector<ll> tmp ;
                    while(x!=-1){
                        tmp.pb(x);
                        x=par[x];
                    }
                    return tmp;
                }
            }
        }
    }
    return {} ;
}
void solve() 
{
    ll n , x , y , m, mx = hell ;
    cin >> n >> m ;
    rep( i , 0 , m ){
        cin >> x >> y ;
        adj[x].pb(y);
        //adj[y].pb(x);
    }
    map<ll, vector<ll> > ans ;
    rep( i , 1 , n + 1 ){
        ans[i] = bfs(i);
        if(sz(ans[i])>0){
            mx = min(mx,sz(ans[i]));
        }
    }
    if(mx==hell){
        cout<<"-1";return;
    }
    cout << mx << "\n" ;
    rep( i , 1 , n + 1 ){
        if(sz(ans[i])==mx){
            for(auto j : ans[i])
                cout << j << "\n" ;
            return;
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 8448
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll a[n];
	for(ll i=0; i<n; i++)
		cin >> a[i];
	ll ans = 0;
	for(ll i=0; i<n; i++){
		for(ll j=i+1; j<n; j++){
			ans += a[i]*a[j];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

int main() {
  int N, R, ans;
  scanf("%d %d", &N, &R);
  if(N <= 9){
    ans = R + 100 * (10 - N);
  } else {
   	ans = R;
  }
  
  printf("%d", ans);
 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#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;

string S;

int main(){
    cin>>S;

    if(S[5]=='0' && 
      (S[6]=='1' || S[6]=='2' || S[6]=='3' || S[6]=='4')){
          cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
}

Measured memory_bytes: 256
n = input()
a = map(int, raw_input().split())
ans = 0
donotbreak = True
for i in range(n):
	if a[i] % 2 == 0:
		donotbreak = False
		break
if donotbreak:
	print ans
	exit()
for i in range(n):
	while a[i] %2 == 0:
		ans += 1
		a[i] /= 2
print ans

Measured memory_bytes: 3460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    vector<ll> a(n);

    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(all(a));
    reverse(all(a));
    ll cnt = 1;
    ans += a[0];
    int point = 1;
    for (int i = 2; i < n ; i++)
    {
        ans += a[point];
        i++;
        if (i < n)
        {
            ans += a[point];
        }
        point++;
    }
    cout << ans << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
//   cin >> t;
    while (t--)
        solve();
    return 0;
}





Measured memory_bytes: 4684
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <climits>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;

#define mkp make_pair
#define eb emplace_back
#define sz(s) (ll)(s.size())
const int N = 3e6 + 123;
const int mod = 1e9 + 7;
const int INF = INT_MAX;

#define all(s) s.begin(), s.end()

main (){
	clog << "Ready\n";
	
	string s;
	cin >> s;
	
	if (s == "SUN")
		cout << 7;
	if (s == "SAT")
		cout << 1;
	if (s == "FRI")
		cout << 2;
	if (s == "THU")
		cout << 3;
	if (s == "WED")
		cout << 4;
	if (s == "TUE")
		cout << 5;
	if (s == "MON")
		cout << 6;
	
    cout << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[] a = new int[h];
        int[] b = new int[h];

        for(int i=0; i<h; i++) {
            a[i] = Integer.parseInt(sc.next())-1;
            b[i] = Integer.parseInt(sc.next())-1;
        }

        TreeMap<Integer, Integer> map = new TreeMap<>();
        Counter counter = new Counter();

        for(int i=0; i<w; i++) {
            map.put(i, 0);
        }
        counter.map.put(0, w);
        counter.map.put(w, 1);
        for(int i=0; i<h; i++) {
            Integer key;
            int rmin = w;
            while((key = map.ceilingKey(a[i])) != null && key <= b[i]) {
                rmin = Math.min(rmin, map.get(key) + b[i]+1-key);
                counter.remove(map.get(key));
                map.remove(key);
            }
            if(b[i]+1<w) {
                if (map.containsKey(b[i] + 1)) {
                    counter.remove(map.get(b[i] + 1));
                    int num = Math.min(rmin, map.getOrDefault(b[i] + 1, w));
                    map.put(b[i] + 1, num);
                    counter.add(num);
                } else {
                    map.put(b[i] + 1, rmin);
                    counter.add(rmin);
                }
            }
            int min = counter.head();
            if(min == w) {
                System.out.println(-1);
            } else {
                System.out.println(min + i + 1);
            }
        }

    }

    static class Counter {
        TreeMap<Integer, Integer> map = new TreeMap<>();

        void add(Integer key) {
            map.put(key, map.getOrDefault(key, 0)+1);
        }
        void remove(Integer key) {
            int num = map.get(key);
            if(num == 1) {
                map.remove(key);
            } else {
                map.put(key, num-1);
            }
        }

        Integer head() {
            return map.firstKey();
        }
    }



}


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

using namespace std;
using ll = long long;

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

int main() {
  int n = 5;
  int a[n];
  rep(i, n) cin >> a[i];

  int ans = 0;
  int mx = 0;
  rep(i, n) {
    ans += (a[i] + 9) / 10 * 10;
    if (a[i] % 10 == 0) continue;
    mx = max(mx, 10 - (a[i] % 10));
  }
  ans -= mx;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main()
{
    int N, M;
    cin >> N >> M;

    ll s = 0;
    rep(i, M)
    {
        ll a = 0;
        cin >> a;
        s += a;
    }

    if (N >= s)
    {
        cout << N - s << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}

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

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,b,i,j;
    vector<string> ss{"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
    string s;
    cin>>s;
    n=find(ss.begin(),ss.end(),s)-ss.begin();
    cout<<7-n%7<<endl;

    return 0;
}


Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc122/tasks/abc122_b
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int ans = 0;
  REP(i, s.size()) {
    int t=0;
    RREP(j,i,s.size()) {
      if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
        t++;
      } else {
        break;
      }
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
num = int(input())

array = []
for i in range(num):
    array.append(int(input()))

point_max = sum(array)
tmp_max = point_max

array_sort = sorted(array)

if point_max % 10 != 0:
    print(point_max)
else:
    for i in array_sort:
        point_max -= i
        if point_max % 10 != 0:
            res = point_max
            break
        else:
            point_max += i
    print(0 if point_max == tmp_max else point_max)



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	int a, b;
	cin >> a >> b;
	a += b;
	while(a > 23) a -= 24;
	cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int dp[100001];
int n;
int a[100001];
int solve(int in){
    
    if(in>=n){
        return 0;
    }
    if(dp[in]!=-1){
        return dp[in];
    }
    int ans = 1e18;
    
    ans = min(ans, abs(a[in]-a[in+1])+solve(in + 1));
    if(in+2<n)
    ans = min(ans, abs(a[in]-a[in+2])+ solve(in + 2));
    return dp[in]=ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    memset(dp, -1, sizeof(dp));
    //cin >> tc;
    while (tc--)
    {

        cin >> n;
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        a[n] = a[n - 1];
        int f = solve(0);
        cout << f << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
<?php
#C - Dice and Coin

fscanf(STDIN, "%d %d", $N, $K);

$P = [];

#サイコロの目が$iの時、得点が$K以上になるためには、$coin_count連続で表が出る必要がある。
for ( $i = 1; $i <= $N; $i++ ) {

    #scoreが$K以上になるためのコイントス回数
    $score = $i;
    $coin_count = 0;
    while ( $K > $score) {
        $score *= 2;
        $coin_count++;
    }

    #コイントス回数からサイコロが$iの時の分母を計算
    $denominator = 1;
    for ( $j = 1; $j <= $coin_count; $j++ ) {
        $denominator *= 2;
    }

    $score = $i;
    $coin_count = 0;
    
    $P[] = $N * $denominator;
}

$numerator = 0;
foreach ($P as $el) {
    $numerator += ($P[0] / $el);
}

$probability = ($numerator / $P[0]);

echo $probability;

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    string A, B;
    std::cin >> A >> B;

    ll x = stoll(A + B);
    for(ll i=1;i*i<=x;++i){
        if(i * i == x){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],num,b[100005];
int main(){    
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],num+=a[i]/2,b[i]=a[i]%2;
    for(int i=1;i<n;i++)
    {
    	if(b[i]==1) 
		{
			if(b[i+1]==1) num++,b[i+1]=0;
			else if(a[i+1]>0) b[i+1]=1;
		}
	}
	cout<<num;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<Pll> x(n);
    for(int i=0;i<n;++i) {
        cin >> x[i].first >> x[i].second;
        x[i].first -= x[i].second;
        x[i].second = x[i].first + x[i].second * 2;
    }
    sort(x.begin(), x.end());

    vector<int> dp(n, 0);
    dp[0] = 1;
    for(int i=0;i<n;++i) {
        if(i < n-1) dp[i+1] = max(dp[i+1], dp[i]);
        int j = distance(x.begin(), lower_bound(x.begin()+(i+1), x.end(), Pll(x[i].second, -LINF)));
        // cerr << i << ": " << j << endl;
        if(j < n) dp[j] = max(dp[j], dp[i] + 1);
    }

    cout << dp[n-1] << endl;
}


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

int main(void){
    string s;
    cin >> s;
    long long k;
    cin >> k;

    int n = s.length();
    rep(i, n){
        if(s.at(i) == '1'){
            if(k == i+1){
                cout << 1 << endl;
                return 0;
            }
        }
        else{
            cout << s.at(i)-'0' << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int A[4];
void Calc(){
	for(int i=0;i<4;i++){
		A[i] = rei();
	}
	sort(A,A+4);
	if(A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256