akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N,M,X,Y;
    int x[104],y[104];
    int XR=-INF,YL=INF;
    cin >> N >> M >> X >> Y;
    REP(i,N){
        cin >> x[i];
        XR=max(XR,x[i]);
    }
    REP(i,M){
        cin >> y[i];
        YL=min(YL,y[i]);
    }
    for(int Z=X+1;Z<=Y;Z++){
        if(XR<Z && Z<=YL){
            cout << "No ";
            break;
        }
    }
    cout << "War" << endl;
    return 0;
}   


Measured memory_bytes: 256
import decimal
n = int(input())
v = list(map(int, input().split()))
v = sorted(v)

temp = 0
sum_ = 0

for i in range(1,n):
    if i == 1:
        temp += decimal.Decimal((v[0] + v[1])/2)
    else:
        temp = decimal.Decimal((temp + v[i])/2)

print(temp)

Measured memory_bytes: 5076
import math

def tcut(H,W):
    arr1 = [math.floor(2*H/3),math.ceil(2*H/3)]
    arr2 = [math.floor(W/2),math.ceil(W/2)]
    minS = H*W
    for h in arr1:
        for w in arr2:
            smax = max(h*w,(H-h)*W,h*(W-w))
            smin = min(h*w,(H-h)*W,h*(W-w))
            if minS > smax - smin:
                minS = smax - smin
    return minS

H,W = map(int,input().split())

if H%3 == 0 or W%3 == 0:
    print(0)
else:
    Tcut = min(tcut(H,W),tcut(W,H))
    stcut = min(H,W)
    print(min(Tcut,stcut))

Measured memory_bytes: 3188
N = int(input())
d = {}
for i in range(N):
    tmp = input()
    if tmp in d:
        d[tmp] += 1
    else:
        d[tmp] = 1

maxx = 0
for i in d:
    if d[i] > maxx:
        maxx = d[i]
ans = []
for i in d:
    if d[i] == maxx:
        ans.append(i)
for i in sorted(ans):
    print(i)

Measured memory_bytes: 32988
#include<stdio.h>
int main()
{
	int x,N,L1,L2,L3,max,kaitou[1000]={0};
	scanf("%d",&N);
	for(x=0; x<N; x++)
	{
		max=1;
		scanf("%d %d %d",&L1,&L2,&L3);
		if(L1<L2)
		{
			max=2;
			if(L2<L3)
				max=3;
		}
		else if(L1<L3)
			max=3;
		if(max==1)
		{
			if(L1*L1==L2*L2+L3*L3)
				kaitou[x]=1;
			else
				kaitou[x]=2;
		}
		if(max==2)
		{
			if(L2*L2==L1*L1+L3*L3)
				kaitou[x]=1;
			else
				kaitou[x]=2;
		}
		if(max==3)
		{
			if(L3*L3==L2*L2+L1*L1)
				kaitou[x]=1;
			else
				kaitou[x]=2;
		}
	}
	for(x=0; x<1000; x++)
	{
		if(kaitou[x]==0)
			break;
		if(kaitou[x]==1)
			printf("YES\n");
		if(kaitou[x]==2)
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
def count6(n)
  cnt = 0
  loop do
    break if n == 0

    cnt += n % 6
    n /= 6 
  end
  cnt
end

def count9(n)
  cnt = 0
  loop do
    break if n == 0

    cnt += n % 9
    n /= 9
  end
  cnt
end

n = gets.to_i
ans = n
(0..n).each do |i|
  tmp = count6(i) + count9(n - i)
  ans = tmp if ans > tmp
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}



int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll X;
    cin >> X;
    for (ll i = -200; i <= 200; i++) {
        for (ll j = -200; j <= 200; j++) {
            if(i*i*i*i*i - j*j*j*j*j == X) {
                cout << i csp j << endl;
                return 0;
            }
        }
    }
    
    

    
    return 0;
}


Measured memory_bytes: 3648
#Union Find
class union_find:
    #初期化
    #根なら-size,子なら親の頂点
    # par = [-1]*N
    def __init__(self, N):
        self.par = [-1]*N

    #xの根を求める
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    #xとyの属する集合の併合
    def unite(self, x,y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            #sizeの大きいほうがx
            if self.par[x] > self.par[y]:
                x,y = y,x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    #xとyが同じ集合に属するかの判定
    def same(self, x,y):
        return self.find(x) == self.find(y)

    #xが属する集合の個数
    def size(self, x):
        return -self.par[self.find(x)]

N, M = map(int, input().split())
P = list(map(lambda x:int(x)-1, input().split()))
uf = union_find(N)
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    uf.unite(x, y) 

ans = 0
for i in range(N):
    if uf.same(P[i], i):
        ans += 1
print(ans)

Measured memory_bytes: 85356
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int):
    if X >= 30:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61872
function main()
  n,a=(x->parse.(Int128,split(x))).(readlines())
  s=zeros(Int,n[1])
  for i∈1:n[1]; i>1 && (s[i]=s[i-1]+a[i]); end
  println(sum(Int128[(a[i]*(s[end]-s[i]))%(10^9+7) for i∈1:n[1]-1])%(10^9+7))
end
main()

Measured memory_bytes: 257288
import Data.List

main = interact $ unlines . map (show' . misterious_gems) . read' . lines
 where
  read' ("0":_) = [] 
  read' (n:xs) = (read_gems gems, read_orders orders) : read' xs''
   where
    (gems, (m:xs')) = splitAt (read n) xs
    (orders, xs'') = splitAt (read m) xs'
    read_gems = map (map read . words)
    read_orders = concatMap ((\[d,l] -> resolve (d, read l)) . words)
    resolve (d,l) = replicate l (d,1)
  show' p = case p of {True -> "Yes"; False -> "No"}

misterious_gems :: ([[Int]], [(String,Int)]) -> Bool
misterious_gems (gems, orders) = null $ gems \\ (scanl move [10,10] orders)
 where move [x,y] (d,l) = case d of {"N"->[x,y+l]; "E"->[x+l,y]; "S"->[x,y-l]; "W"->[x-l,y]}

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

using namespace std;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a + (b/2) << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  int p = 0, g = 0, ans = 0;
  REP(i, n){
    if(s[i] == 'g'){
      if(p+1 <= g){
        p++;
        ans++;
      }else{
        g++;
      }
    }else{
      if(p+1 <= g){
        p++;
      }else{
        g++;
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    *A,=map(int, input().split())
    s=0
    for i in range(n):
        for j in range(i):
            if s<A[i]+A[j]<=m:
                s = A[i]+A[j]
    print(s or"NONE")

Measured memory_bytes: 7680
n = int(input())
s=[]
isten=0
score=0
for i in range(n):
    si = int(input())
    s.append(si)
    if si%10!=0:
        isten=1

s.sort()
if isten==1:
    score=sum(s)
i=0
while score%10==0 and isten==1:
    s_ = list(s)
    del s_[i]
    i+=1
    score=sum(s_)

print(score)


Measured memory_bytes: 3060
import math
n = int(input())
pri  = [str(n)+":"]

i = 2
while i <= math.sqrt(n):
    while n % i == 0:
        pri.append(str(i))
        n//=i
    i+=1

if n != 1:
    pri.append(str(n))

L=[str(pri) for pri in pri]
L=" ".join(L)
print(L)


Measured memory_bytes: 5672
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void) {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n - 1; ++i) {
		if (x < a[i]) break;
		x -= a[i];
		++ans;
	}
	if (a[n - 1] == x) ++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            string[] strInputArray;
            List<int> inputList = new List<int>();
            string output = "";
            do
            {
                strInputArray = Console.ReadLine().Split(' ');
                if (!strInputArray[0].Equals("0") && !strInputArray[1].Equals("0"))
                {
                    inputList.Add(int.Parse(strInputArray[0]));
                    inputList.Add(int.Parse(strInputArray[1]));
                }
            } while (!strInputArray[0].Equals("0") && !strInputArray[1].Equals("0"));

            for (int i = 1; i <= (inputList.Count / 2); i++)
            {
                for (int h = 1; h <= inputList[(i * 2) - 2]; h++)
                {
                    output = "";

                    if (h % 2 == 1)
                    {
                        for (int w = 1; w <= inputList[(i * 2) - 1]; w++)
                        {
                            if (w % 2 == 1)
                            {
                                output = output + '#';
                            }
                            else
                            {
                                output = output + '.';
                            }
                        }
                    }
                    else
                    {
                        for (int w = 1; w <= inputList[(i * 2) - 1]; w++)
                        {
                            if (w % 2 == 1)
                            {
                                output = output + '.';
                            }
                            else
                            {
                                output = output + '#';
                            }
                        }
                    }
                    Console.WriteLine(output);
                }
                Console.WriteLine();
            }

            Console.ReadLine();
        }
    }


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

#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int,int>
template<typename T, typename U> 
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

int inf = 2e9;
ll INF = 2e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

vi tree[N];
vvi dp(N,vi(2,1));

void dfs(int u,int par){
	for(auto ch : tree[u]){
		if(ch!=par){
			dfs(ch,u);
			dp[u][0] *= ((dp[ch][0]+dp[ch][1])%mod);
			dp[u][0] %= mod;
			dp[u][1] *= dp[ch][0];
			dp[u][1] %= mod;
		}
	}
}

int main(){
	int n;
	cin >> n;
	int x, y;
	rep(i,n-1){
		cin >> x>> y;
		tree[x].push_back(y);
		tree[y].push_back(x);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%mod<<endl;
	return 0;
}

Measured memory_bytes: 18176
#167C bit探索
def main():
    import sys, itertools
    import numpy as np
    N,M,X = map(int, sys.stdin.readline().split())
    L = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
    #print(L)
    ans =-1
    for i in range(2**N):
        result = np.array([0 for _ in range(M+1)])
        for j in range(N): # (i >> j) & 1  2進数のj桁目と1の論理積
            if (i >> j) & 1==1:
                result += np.array(L[j])
        if np.all(result[1:] >=X):
            #print(result)
            if ans ==-1 or result[0] < ans:
                ans = result[0]
    print(ans)
if __name__=='__main__':
    main()

Measured memory_bytes: 27328
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define eb emplace_back

typedef long long ll;
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    REP(i,n)cout << 'x' ;
    cout << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
int n,a,b;
  cin>>n>>a>>b;
  int x=0,y=0;
 x=a*n;
  y=b;
  cout<<min(x,y)<<endl;
}

Measured memory_bytes: 256
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

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

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    vector<int64> v(3);
    cin >> v[0] >> v[1] >> v[2];

    sort(v.begin(), v.end());

    if (!((v[0] * v[1] * v[2]) & 1)) {
        cout << 0 << "\n";
    } else {
        cout << v[0] * v[1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  while(n) {
    if(n%10==7) {
      pr("Yes");
      return;
    }
    n/=10;
  }
  pr("No");
}

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


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;

    vector<pair<int,int>> ab(m);
    for ( int i = 0 ; i < m ; i++ ){
        cin >> ab.at(i).first >> ab.at(i).second;
    }

    vector<int> ans(n+1);
    for ( int i = 0 ; i < m ; i++ ){
        ans.at(ab.at(i).first)++;
        ans.at(ab.at(i).second)++;
    }
 
    for ( int i = 1 ; i < n+1 ; i++ ){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d
a=0
for i in range(1,int(input())+1):
    a+= i%2 and len(divisors(i))==8
print(a)

Measured memory_bytes: 9428
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 1000000007
#define MAXN 5000
#define MAXH 4
#define MAXM 4
#define INF 1LL << 60
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;


bool rcomp(const pair<pii,int> &a, const pair<pii,int> &b){
	if(a.F.F != b.F.F)return a.F.F > b.F.F;
	else return a.F.S > b.F.S;
}

int r,c;

bool edge(pair<pii,int> p){
	return (p.F.F == 0 || p.F.F == c || p.F.S == 0 || p.F.S == r);
}

int main(){
	fast_io();
	int n;
	set<pair<pii,int>> s;
	cin >> c >> r >> n;
	cu(i,0,n){
		int x,y,a,b;
		cin >> x >> y;
		cin >> a >> b;
		pair<pii,int> X = {{x,y},i};
		pair<pii,int> A = {{a,b},i};
		if(edge(X) && edge(A)){
			s.insert(X);
			s.insert(A);
		}
	}
	vector<pair<pii,int>> v;
	int nd = 0;
	for(pair<pii,int> p : s){
		if(p.F.F == 0){
			v.pb(p);	
		}
	}
	cu(i,nd,v.size())s.erase(v[i]);
	sort(all(v));
	nd = v.size();
	for(pair<pii,int> p : s){
		if(p.F.S == r){
			v.pb(p);	
		}
	}
	cu(i,nd,v.size())s.erase(v[i]);
	sort(v.begin() + nd, v.end());
	nd = v.size();
	for(pair<pii,int> p : s){
		if(p.F.F == c){
			v.pb(p);	
		}
	}
	cu(i,nd,v.size())s.erase(v[i]);
	sort(v.begin() + nd, v.end(), rcomp);
	nd = v.size();
	for(pair<pii,int> p : s){
		if(p.F.S == 0){
			v.pb(p);	
		}
	}
	cu(i,nd,v.size())s.erase(v[i]);
	sort(v.begin() + nd, v.end(), rcomp);
	nd = v.size();
	bool vis[n] = {};
	stack<int> st;
	cu(i,0,v.size()){
		if(!vis[v[i].S]){st.push(v[i].S);vis[v[i].S] = 1;}
		else {
			if(st.top() != v[i].S){
				cout << "NO" << '\n';
				return 0;
			}
			else{
				st.pop();
			}
		}
	}
	cout << "YES" << '\n';
}


Measured memory_bytes: 17396
n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a, reverse=True)

ans = a[0]
cnt = 2
i = 1
fl = 0
while cnt < n:
    if fl == 0:
        ans += a[i]
        fl += 1
    else:
        ans += a[i]
        i += 1
        fl = 0
    cnt += 1

print(ans)


Measured memory_bytes: 94088
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	int n,m,tmp,t[200] = {};
	cin >> n;
	int k;
	for(k = 0;k < n;k++){
		cin >> tmp;
		t[k] += tmp * 60;
		cin >> tmp;
		t[k] += tmp;
	}
	cin >> m;
	for(;k < n + m;k++){
		cin >> tmp;
		t[k] += tmp * 60;
		cin >> tmp;
		t[k] += tmp;
	}
	sort(t,t + n + m);
	for(int i = 0;i < n + m - 1;i++){
		if(t[i] == t[i + 1]) t[i] = 1500;
	}
	sort(t,t + n + m);
	printf("%d:%02d",t[0] / 60,t[0] % 60);
	for(int i = 1;t[i] != 1500 && i < n + m;i++){
		printf(" %d:%02d",t[i] / 60,t[i] % 60);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
typedef long long ll;;

#define int long long 
using namespace std;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPR(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define INF 1000000000000 
#define MOD 10000007 
#define MAXR 100000 
#define PI 3.14159265358979323846
using namespace std;

int factorial(int n)
{
    int fact = n;

    if (n <= 0) return 1;

    while (--n)
        fact *= n;

    return fact;
}

signed main(){
    int n,x;
    cin >> n>>x;
    while (x!=0||n!=0)
    {   
        int ans = 0;
        FOR(i,1,n){
            FOR(j,i+1,n){
                FOR(k,j+1,n){
                    if(i+j+k==x){
                        ans++;
                    }
                }
            }
        }
        cout << ans <<endl ;
        cin >> n>>x;

    }
    
    

    return 0 ;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int T;
char s[20001];
int b[26];
int a[26]={};
int main(){
    cin>>T;
    memset(b,0x3f,sizeof(b));
    while(T--){
    	scanf("%s",s);
    	memset(a,0,sizeof(a));
    	int l=strlen(s);
    	for(int i=0;i<l;++i)
    		a[s[i]-'a']++;
    	for(int i=0;i<26;++i)
    		b[i]=min(b[i],a[i]);
    }
    for(int i=0;i<26;++i)
    	for(int j=1;j<=b[i];++j)
    		printf("%c",(char)'a'+i);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int t,n,k,x[100000],d[99999];

int main(){
	cin>>t;
	while(cin>>n>>k){
		for(int i=0;i<n;i++)cin>>x[i];
		sort(x,x+n);
		for(int i=0;i<n-1;i++)d[i]=x[i+1]-x[i];
		sort(d,d+n-1);
		int ans=x[n-1]-x[0];
		for(int i=0;i<k-1;i++){
			if(n-2-i<0)break;
			ans-=d[n-2-i];
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1644
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<bitset>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,x,y,dy,dx;
int op;
string st;
vector<int> tdx,tdy;
bitset<32005> dp[2],dp2[2];
int main()
{
	cin>>st>>x>>y;
	st+="T";
	for (i=0;i<st.length();i++)
	{
		if (st[i]=='F')
		{
			if (op==0) x--;
			if (op==1) dx++;
			if (op==2) dy++;
		}
		else
		{
			if (op==0) op=2;
			else if (op==1)
			{
				tdx.push_back(dx);
				dx=0;
				op=2;
			}
			else
			{
				tdy.push_back(dy);
				dy=0;
				op=1;
			}
		}
	}
	dp[1][16000]=1;
	x+=16000;
	for (i=0;i<tdx.size();i++)
	{
		dp[i&1]=dp[(i-1)&1]<<tdx[i];
		dp[i&1]|=dp[(i-1)&1]>>tdx[i];
	}
	dp2[1][16000]=1;
	y+=16000;
	for (i=0;i<tdy.size();i++)
	{
		dp2[i&1]=dp2[(i-1)&1]<<tdy[i];
		dp2[i&1]|=dp2[(i-1)&1]>>tdy[i];
	}
	if (dp[(tdx.size()-1)&1][x]&&dp2[(tdy.size()-1)&1][y]) cout<<"Yes";else cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    long double n;
    int k;
    double ans;
    long long int j = 1;

    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        double res = 1/n;
        if (i < k) {
            while (i * pow(2,j) < k) j++;
            res *= 1/(double)pow(2,j);
        }
        ans += res;
        j = 1;
    }

    printf("%.12lf\n", ans);
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    lint n;
    cin>>n;
    vec x(n),y(n);
    vector<pair<lint,lint>>v(n);
    rep(i,n)cin>>x[i]>>y[i];
    rep(i,n)v[i]=make_pair(x[i],y[i]);
    sort(all(v),[](auto s,auto t){return atan2(s.second,s.first)<atan2(t.second,t.first);});
    lint ans=0;
    rep(i,n)repi(j,1,n+1){
        lint sx=0,sy=0;
        rep(k,j){
            sx+=v[(i+k)%n].first;
            sy+=v[(i+k)%n].second;
        }
        chmax(ans,(sx*sx+sy*sy));
    }
    cout<<sqrtl(ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int ppow(int a,int b,int MOD){
	a %= MOD;
	ll res = 1;
	while(b){
		if(b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

int main(void){
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(p == 2 || p == 5){
        ll ans = 0;
        rep(i,n){
            if((s[i]-'0')%p == 0){
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> cum(n+1,0);
    map<int,int> dict;
    dict[0]++;
    for(int i=n-1; i>=0; i--){
        cum[i] = (cum[i+1] + (s[i]-'0') * ppow(10,n-1-i, p)) % p;
        dict[cum[i]]++;
    }
    ll ans = 0;
    for(auto ob: dict){
        int sec = ob.sc;
        ans += (ll)sec * (sec-1) /2;
    }
    cout << ans << endl;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll x, a, b;

int main(void) {
  // Here your code !
  scanf("%lld %lld %lld", &x, &a, &b);

  if (a >= b) {
    printf("delicious\n");
  } else {
    if ((b - a) <= x) {
      printf("safe\n");
    } else {
      printf("dangerous\n");
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
//#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define double long double
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int power(int a, int b,int mod)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}


int getMod(string str, int n, int k)  
{  
  
    // pwrTwo[i] will store ((2^i) % k)  
    int pwrTwo[n];  
    pwrTwo[0] = 1 % k;  
    for (int i = 1; i < n; i++)  
    {  
        pwrTwo[i] = pwrTwo[i - 1] * (2 % k);  
        pwrTwo[i] %= k;  
    }  
  
    // To store the result  
    int res = 0;  
    int i = 0, j = n - 1;  
    while (i < n)  
    {  
  
        // If current bit is 1  
        if (str[j] == '1')  
        {  
  
            // Add the current power of 2  
            res += (pwrTwo[i]);  
            res %= k;  
        }  
        i++;  
        j--;  
    }  
    return res;  
}  
  
signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{//cout<<"Case #"<<T1<<": ";
  int n;
  cin>>n;
  VI dp(n+1);int ans=0;
  string x;
  cin>>x;
  for(int i=0;i<n;i++)if(x[i]=='1')ans++;
  int a=getMod(x,n,ans+1);
  int b=0;
  if(ans!=1)
  b=getMod(x,n,ans-1);
  for(int i=0;i<n;i++)
  {
      if(i==0)dp[i]=0;
      else
      {  int ss=0;
          for(int j=0;j<32;j++)if((i>>j)&1)ss++;
          dp[i]=1+dp[i%ss];
      }
  }
  for(int i=0;i<n;i++)
  {
      if(x[i]=='0')
      {   int mod=ans+1;
          int ab=power(2,n-i-1,ans+1);
          ab=a+ab;
          ab%=mod;
          ab+=mod;
          ab%=mod;
          cout<<dp[ab]+1<<endl;
      }
      else
      {   int mod=ans-1;
      if(ans==1){cout<<0<<endl;continue;}
          int ab=power(2,n-i-1,ans-1);
          ab=b-ab;
          ab%=mod;
          ab+=mod;
          ab%=mod;
          cout<<dp[ab]+1<<endl;
      }
  }
  
}


return 0;
}





Measured memory_bytes: 6808
# -*- coding:utf-8 -*-
h,w = map(int,input().split())

if h == 1 or w == 1:
    print(1)
elif w %2 == 0:
    print(h * w //2)
elif h % 2 == 0:
    print(h * w //2)
else:
    print(h*w//2+1)

Measured memory_bytes: 9096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		for (int i = 1; i <= 100; i++)
			assert null != System.out.format("%d %d\n", i, solve(i));

		int n = cin.nextInt();

		long millis = System.currentTimeMillis();

		int ans = solve(n);

		cout.println(ans);
		assert null != cout.format("%d elapsed", System.currentTimeMillis() - millis);
	}

	private static int solve(int n) {
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i < 30; i++)
			if (n >> i != 0)
				ans = Math.min(ans, (n >> i) << i);
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

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

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

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a >> s;
    if(3200<= a) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<int>;
using m = map<int,int>;
int main(){
	string s;
    cin >>s;
    bool f=true;
    for(int i=0;i<s.size();i++){
        if(i%2==1){
            if(s[i] != 'L' && s[i] != 'U'&&s[i] !='D'){
                f=false;
                break;
            }
        }else{
            if(s[i] != 'R' && s[i] != 'U'&&s[i] !='D'){
                f=false;
                break;
            }
        }
    }
    
    cout << (f?"Yes":"No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
const int mod = 1e9+7;
struct Combination {
    static const int buf = 100010;
    long long fac[buf] = {1, 1}, facInv[buf] = {1, 1}, inv[buf] = {0, 1};
    Combination() {
        for (int i = 2; i < buf; ++i) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            facInv[i] = facInv[i - 1] * inv[i] % mod;
        }
    }
    long long calc(int n, int k) {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * facInv[k] % mod * facInv[n - k] % mod;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto & a : A) cin >> a;
    sort(A.begin(), A.end());
    auto ncr = Combination();
    long long tmp;
    for (int i = K-1; i < N; ++i) {
        tmp = 0;
        if ((tmp += A[i]) < 0) tmp += mod;
        if ((tmp -= A[N-i-1]) < 0) tmp += mod;
        tmp %= mod;
        if ((ans += ncr.calc(i, K-1) * tmp % mod) >= mod) ans -= mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2944
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    long MOD = (long)Math.pow(10, 9) + 7;
    long[] dp = new long[2001];
    dp[0] = 1;
    for(int i = 3; i < 2001; i++) {
      dp[i] = (dp[i - 3] + dp[i - 1]) % MOD;
    }
    System.out.println(dp[s]);
  }
}

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

using namespace std;

int max3(int x, int y, int z);

int main() {
  int n, i;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (i = 0; i<n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  if (n == 1) {
    cout << max3(a[0],b[0],c[0]) << endl;
    return 0;
  }
  vector<int> dHap(3), tHap(3);
  dHap[0] = a[0];
  dHap[1] = b[0];
  dHap[2] = c[0];
  for (i = 1; i<n; i++) {
    tHap[0] = a[i]+max(dHap[1],dHap[2]);
    tHap[1] = b[i]+max(dHap[0],dHap[2]);
    tHap[2] = c[i]+max(dHap[0],dHap[1]);
    dHap[0] = tHap[0];
    dHap[1] = tHap[1];
    dHap[2] = tHap[2];
  }
  cout << max3(dHap[0],dHap[1],dHap[2]) << endl;
  return 0;
}

int max3(int x, int y, int z) {
  return max(max(x,y),z);
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


vector<pii> a;
int ans[100010];
bool ed[100010];

signed main()
{
	QUICK_CIN;
	//debug_input;

	int n;

	cin >> n;
	REP(i, n) {
		int k;
		cin >> k;
		a.push_back(pii(i, k));
	}

	sort(ALL(a), [](pii r, pii l) 
	{return r.second == l.second ? r.first > l.first : r.second < l.second; });
	int sum = 0;
	int it = 0;

	REP(i,n) {
		while (ed[it])it++;

		if (a[i].first != it) {
			ans[it] += a[i].second - sum;
		}
		else {
			ans[it] += (a[i].second-sum) * (n  - i);
			sum += (a[i].second-sum);
		}
		ed[a[i].first] = true;
	}
	REP(i, n) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

int main()
{
  char* s;
  int n;
  cin>>n;
  s=new char[n];
  cin>>s;
  if(n%2) cout<<"No";
  else
  {
    int m=n/2;
    for(int i=0;i<m;i++)
    {
      if(s[i]!=s[m+i]){cout<<"No";return 0;}
    }cout<<"Yes";
  }
  return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;




int main() {

    int h,w;
    cin>>h>>w;
    bool ch=1;
    vs v(h);
    rep(i,h)cin>>v[i];
    rep(i,h)rep(j,w){
        int t=0;
        if(v[i][j]=='.')continue;
        rep(k,4){
            int nx=j+dx[k];
            int ny=i+dy[k];
            if(nx<0||ny<0||nx>=w||ny>=h)continue;
            if(v[ny][nx]=='#')t++;
        }
        if(t==0)ch=0;
    }
    Yn(ch);
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int a;
    cin >> a;

    cout << a+a*a+a*a*a << endl;

    return 0;
}


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

#define N 100010

using namespace std;

const int inf = 0x3f3f3f3f;
map<int,int>Map;
int a[N],k;
char s[N];
int main()
{
    int n,x = 0;
    for( k = 1; x <= 1000000000; k++)
    {
        x += k;
        Map[x] = k;
        a[k] = x;
    }
    scanf("%d",&n);
    if(Map.find(n) != Map.end())
    {
        for(int i = 1; i <= Map[n]; i++)
            printf(")");
        for(int i = 1; i <= Map[n]; i++)
            printf("(");
        printf("\n");
    }
    else
    {
        int x = n;
        while(Map.find(x) == Map.end())x++;
        int l = x;
        x = Map[x];
        n = l - n;
        for(int i = 1; i <= 2*x; i++)
            if(i <= x)s[i] = ')';
            else s[i] = '(';
        s[x*2+1] = '\0';
        while(n --)
        {
            swap(s[x],s[x+1]);
            x--;
        }
        puts(s+1);
    }
    return 0;
}

Measured memory_bytes: 5508
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i,n)for(int i=0;i<(n);i++)
typedef pair<int,int> pii;
const int N = 1<<18;
pii seg1[2*N];
pii seg2[2*N];
void set(pii seg[2*N],int x,pii val){
    x += N-1;
    seg[x] = val;
    while(x>0){
        x=(x-1)/2;
        seg[x]=min(seg[2*x+1],seg[2*x+2]);
    }
}
pii rmq(pii seg[2*N],int l,int r,int a,int b,int k){
    if(r<=a || b<=l)return pii(830252521,830252521);
    if(l<=a && b<=r)return seg[k];
    int m=(a+b)/2;
    return min(rmq(seg,l,r,a,m,2*k+1),rmq(seg,l,r,m,b,2*k+2));
}
pii rmq(pii seg[2*N],int l,int r){
    return rmq(seg,l,r,0,N,0);
}
int n;
int p[252521];
int calc(pii range){
    return -rmq(range.first%2==0?seg1:seg2,range.first,range.second).first;
}
int main(void){
    // Here your code !
    scanf("%d",&n);
    REP(i,n)scanf("%d",p+i);
    REP(i,2*N)seg1[i]=seg2[i]=pii(830252521,830252521);
    REP(i,n)if(i%2==0)set(seg1,i,pii(p[i],i));
    REP(i,n)if(i%2==1)set(seg2,i,pii(p[i],i));
    priority_queue<pair<int,pii>> Q;
    pii init = pii(0,n);
    Q.push(make_pair(calc(init),init));
    vector<int> ans;
    while(Q.size()){
        auto PP = Q.top(); Q.pop();
        pii range = PP.second;
        int l = range.first;
        int r = range.second;
        pii a = rmq(l%2==0?seg1:seg2,l,r);
        pii b = rmq(l%2==1?seg1:seg2,a.second+1,r);
        ans.push_back(a.first);
        ans.push_back(b.first);
        pii x = pii(l,a.second);
        pii y = pii(a.second+1,b.second);
        pii z = pii(b.second+1,r);
        if(x.first<x.second)Q.push(make_pair(calc(x),x));
        if(y.first<y.second)Q.push(make_pair(calc(y),y));
        if(z.first<z.second)Q.push(make_pair(calc(z),z));
    }
    REP(i,n)printf("%d%c",ans[i],i==n-1?'\n':' ');
}


Measured memory_bytes: 11916
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll nCm(ll n, ll m){
    if (m == 0 || m == n)
        return (1);
    else if (m == 1)
        return (n);
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int n, m;
    cin >> n >> m;

    cout << (1900 * m + 100 * (n - m)) * pow(2, m) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] xy = br.readLine().split(" ");
        int x = Integer.parseInt(xy[0]);
        int y = Integer.parseInt(xy[1]);
        System.out.println(problem113a(x, y));
    }

    private static int problem113a(int x, int y) {
        return x + y / 2;
    }
}

Measured memory_bytes: 22996