akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
#include<algorithm>

using namespace std;

int n,m;
long long s[16], d[101], sigma[1<<15], dp[101][1<<15];

int main(){
    while(cin >> n >> m && n){
        for(int i=0;i<n;i++) cin >> s[i];
        d[0] = 0LL;
        for(int i=1;i<=m;i++) cin >> d[i];
        sort(d, d+m+1);

        sigma[0] = 0LL;
        for(int j=0;j<(1<<n);j++){
            for(int k=0;k<n;k++){
                if(j & (1 << k)) continue;
                sigma[j|(1<<k)] = sigma[j] + s[k];
            }
        }
        
        fill(dp[0], dp[m+1], LLONG_MAX);
        for(int j=0;j<(1<<n);j++) dp[0][j] = 0LL;
        for(int i=1;i<=m;i++) dp[i][0] = dp[i-1][0] + d[i];
        for(int i=1;i<=m;i++){
            for(int j=0;j<(1<<n);j++){
                for(int k=0;k<n;k++){
                    if(j & (1 << k)) continue;
                    dp[i][j|(1<<k)] = min({dp[i][j|(1<<k)], dp[i][j], dp[i-1][j] + abs(sigma[j] - d[i]), dp[i-1][j|(1<<k)] + abs(sigma[j|(1<<k)] - d[i])});
                }
            }
        }

        cout << dp[m][(1<<n)-1] << endl;
    }
}


Measured memory_bytes: 29244
from collections import defaultdict
dic = defaultdict(int)
n = int(input())

for i in range(n):
    tmp = input()
    dic[tmp] += 1

m = int(input())
ans = 0
for i in range(m):
    tmp = input()
    dic[tmp] -= 1
print(max(max(dic.values()),0))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,x,a;cin>>n>>m>>x;
  lvector A(n+1,0);rep(i,m) {cin>>a;A[a]=1;}
  ll ans1=accumulate(A.begin(),A.begin()+x,0);
  ll ans2=accumulate(A.begin()+x,A.end(),0);
  print(min(ans1,ans2));
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int N, K;
int bb[4010][4010];
int ww[4010][4010];

int bacc[4010][4010];
int wacc[4010][4010];

int bsum(int x1, int y1, int x2, int y2) {
	return bacc[y2][x2] - bacc[y2][x1] - bacc[y1][x2] + bacc[y1][x1];
}
int wsum(int x1, int y1, int x2, int y2) {
	return wacc[y2][x2] - wacc[y2][x1] - wacc[y1][x2] + wacc[y1][x1];
}

int main() {
	cin >> N >> K;
	int K2 = K * 2;
	rep(i, N) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		x %= K2;
		y %= K2;
		if (c == 'B') {
			bb[y][x]++;
			bb[y + K2][x]++;
			bb[y][x + K2]++;
			bb[y + K2][x + K2]++;
		}
		else {
			ww[y][x]++;
			ww[y + K2][x]++;
			ww[y][x + K2]++;
			ww[y + K2][x + K2]++;
		}
	}

	rep(y, K2 * 2) rep(x, K2 * 2) {
		bacc[y + 1][x + 1] += bb[y][x] + bacc[y + 1][x] + bacc[y][x + 1] - bacc[y][x];
		wacc[y + 1][x + 1] += ww[y][x] + wacc[y + 1][x] + wacc[y][x + 1] - wacc[y][x];
	}

	int ans = 0;
	rep(y1, K2) rep(x1, K2) {
		int x2 = x1 + K, y2 = y1 + K;
		int sum = bsum(x1, y1, x2, y2) + bsum(x2, y2, x2 + K, y2 + K);
		sum += wsum(x2, y1, x2 + K, y2) + wsum(x1, y2, x2, y2 + K);

		ans = max(ans, sum);
	}

	cout << ans << endl;
}

Measured memory_bytes: 251264
#include <stdio.h>
int main(int argc, char *argv[])
{
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  if(A*B*C == 5 * 5 * 7) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 128
/**
 * @Author: Mingyu Li
 * @Date:   2019-02-24T19:53:08+08:00
 * @Email:  class11limingyu@126.com
 * @Filename: task.cpp
 * @Last modified by:   Mingyu Li
 * @Last modified time: 2019-02-24T20:53:42+08:00
 */

#include <bits/stdc++.h>
#define tpname typename
#define int long long
#define go(i , x , y) for(__typeof(x) i = x; i <= y; i++)
#define god(i , y , x) for(__typeof(y) i = y; i >= x; i--)
typedef long long LL;
typedef long double ld;
typedef unsigned long long ULL;
template < tpname T > void scan(T& t) {
  char c = getchar(); T x = 1; t = 0; while(!isdigit(c)) {if(c == '-') x = -1; c = getchar();}
  while(isdigit(c)) t = t * 10 + c - '0' , c = getchar();t *= x;
}
template < tpname T , tpname... Args > void scan(T& t , Args&... args) {scan(t); scan(args...);}
template < tpname T > T mul(T x , T y , T _) {
  x %= _,y %= _;
  return ((x * y - (T)(((ld)x * y + 0.5) / _) * _) % _ + _) % _;
}
using namespace std;

const int N = 20;
int a[N] , n , l[N];
int ans , A , B , C;
int Abs(int x) {
  return x > 0 ? x : -x;
}
void check() {
  int cntA= 0, cntB = 0 , cntC = 0;
  int sumA = 0 , sumB = 0 , sumC = 0;
  for(int i = 1; i <= n; i++) {
    if(a[i] == 1) cntA++ , sumA += l[i];
    else if(a[i] == 2) cntB++ , sumB += l[i];
    else if(a[i] == 3) cntC++ , sumC += l[i];
  }
  if(!cntA || !cntB || !cntC) return ;
  int cost = (cntA - 1) * 10 + Abs(sumA - A) + (cntB - 1) * 10 + Abs(sumB - B) + (cntC - 1) * 10 + Abs(sumC - C);
  if(ans > cost) ans = cost;
}
void dfs(int cur) {
  if(cur == n + 1) {
    check();
    return ;
  }
  a[cur] = 0;
  dfs(cur + 1);
  a[cur] = 1;
  dfs(cur + 1);
  a[cur] = 2;
  dfs(cur + 1);
  a[cur] = 3;
  dfs(cur + 1);
}
signed main() {
  ans = (1e18);
  cin >> n >> A >> B >> C;
  for(int i = 1; i <= n; i++) cin >> l[i];

  dfs(1);

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


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

long long a[200005];

int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    long long ans=a[0];
    for(int i=1;i<n;i++)
        ans=ans^a[i];
    for(int i=0;i<n;i++){
        printf("%lld ",ans^a[i]);
    }
}


Measured memory_bytes: 5276
from itertools import product

n, m, x = map(int, input().split())

states = []

for i in range(n):
    tmp = list(map(int, input().split()))
    state = {
        'cost': tmp[0],
        'value': tmp[1:]
    }
    states.append(state)


def check(use_list : list):
    gain = [0 for _ in range(m)]
    cost = 0
    for i, is_use in enumerate(use_list):
        if is_use:
            for j in range(m):
                gain[j] += states[i]['value'][j]
            cost += states[i]['cost']

    for j in range(m):
        if gain[j] < x:
            return 1000000000
    return cost

ans = 1000000000

for use_list in product(range(2), repeat=n):
    ans = min(ans, check(use_list))
if ans == 1000000000:
    ans = -1
print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n;
	cin>> n;

	if(n%2==0) n/=2;

	cout<< 2*n << endl;
 
	return 0;
}

Measured memory_bytes: 3592
/*input
20
*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 1e5+100;
typedef long long int lld;
typedef long long ll;


ll A[lim];

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,val,countA,indicator=0,pos,h,minA,maxA,type;
    ans=0;
    cin>>n;
    for(int i=1;i<=100;i++) {
        for(int j=1;j<=100;j++) {
            for(int k=1;k<=100;k++) {
                if(i*i+ j*j + k*k + i*j + i*k + j*k <= n)
                A[i*i+ j*j + k*k + i*j + i*k + j*k]++;
            }
        }
    }

    for(int i=1;i<=n;i++) cout<<A[i]<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;



int main() {
   ll N;
   cin>>N;
   vector<ll> ans;
   for(ll i=1;i*i<=N;i++){
       if(N%i==0){
           if((N-i)/i>i){
           ans.push_back(N/i-1);
           }
           
       }
   }
ll sum=0;
rep(i,ans.size()){
    sum+=ans[i];
}
cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 2010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    char s;
    cin >> s;

    if (s == 'a' || s== 'e' || s == 'i' || s == 'o' || s == 'u'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math, std.typecons;


void main() {
    int n; scan(n);
    writeln(euler_phi(n));
}


int euler_phi(int n) {
    int ans = n;

    for (int p = 2; p*p <= n; p++) {
        if (n % p == 0) {
            ans = ans / p * (p - 1);
            while (n % p == 0) n /= p;
        }
    }

    if (n > 1) ans = ans / n * (n - 1);

    return ans;
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



Measured memory_bytes: 2484
# abc170_d.py
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = [0]*(10**6+1)
for i in A:
    if cnt[i]<1:
        multiple = 2
        while i*multiple <= 10**6:
            cnt[multiple*i]+=1
            multiple+=1
    cnt[i]+=1
ans = 0
for i in A:
    if cnt[i]==1:
        ans+=1
print(ans)


Measured memory_bytes: 32148
n = int(input())

a = [[] for _ in range(n)]
for i in range(n):
    temp = int(input())
    for _ in range(temp):
        x, y = map(int, input().split())
        a[i].append([x-1, y])

#print(a)

q = 2 ** n
ans = 0
for i in range(q):
    d = list(map(int, list(str(bin(q + i))[2:])))
    check = 0
    for j, x in enumerate(d[1:]):
        if x == 1:
            for c, b in a[j]:
                if d[c+1] != b:
                    check = 1
                    break
    if check == 1:
        continue
    else:
        ans = max(ans, d.count(1) - 1)

print(ans)




Measured memory_bytes: 45020
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
int n, a[maxn], t[maxn], c;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    f1(i,n) cin>>a[i];
    fr(i,n,1)
    {
        int s = 0;
        for(int j=i+i;j<=n;j+=i) s+=t[j];
        if(s%2!=a[i]) t[i] = 1, c++;
    }
    
    f1(i,n)
    {
        int s = 0;
        for(int j=i;j<=n;j+=i) s+=t[j];
        if(s%2!=a[i]){
            cout << "-1\n";
            return 0;
        }
    }
    cout << c << "\n";
    int b = 1;
    f1(i,n) {
        if(t[i]==1){
            if(!b) cout << " ";
            cout << i;
            b = 0;
        }
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
#define STEP 2
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> a(N + 1, 0);
    vector<int> flg(N + 1, 1);
    REP(i, M)
    {
        int p;
        cin >> p;
        flg[p] = 0;
    }
    a[0] = 1;
    REPS(i, N)
    {
        if (flg[i] == 1)
        {
            REPS(j, STEP)
            {
                a[i] += a[i - j];
                a[i] %= MOD;
            }
        }
    }
    cout << a[N] << "\n";
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

int main()
{
ll n , m ;
cin >> n >> m ;
pair<ll,vector<ll>> p[m];
rep(i,m){
  ll a , b ;
  cin >> a >> b ;
  p[i].first=a;
  rep(j,b){
    ll c ;
    cin >> c ;
    p[i].second.push_back(c);
  }
}
vector<vector<ll>> dp(m+1, vector<ll>(1LL<<n,INF) );
dp[0][0]=0;

rep(i,m){
  ll key=0;
  for(auto aa:p[i].second)key+=(1LL<<(aa-1));
  rep(j,1LL<<n){
    dp[i+1][j]=min(dp[i][j],dp[i+1][j]);//使わない
    dp[i+1][j|key]=min(dp[i][j]+p[i].first,dp[i+1][j|key]);//使う
  }
}
if(dp[m][(1LL<<n)-1]<(1LL << 59))cout << dp[m][(1LL<<n)-1] << endl;
else cout << -1 << endl;
return 0;
}

Measured memory_bytes: 32512
#include <iostream>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{

    
    int a, b, c, d;
    
    cin >> a >> b >> c >> d;
    
    while(1)
    {
        c -= b;
        if(c <= 0)
        {
            cout << "Yes";
            break;
        }
        a -= d;
        if(a <= 0)
        {
            cout << "No";
            break;
        }
    }
    
}

Measured memory_bytes: 3596
N = int(input())
dl = list(map(int, input().split()))

dl.sort()
ans = 0

if len(dl) % 2 == 1:
    print(0)
else:
    i_mid = len(dl) // 2
    abc_max = dl[i_mid-1]
    arc_min = dl[i_mid]
    print(arc_min - abc_max)

Measured memory_bytes: 14008
N, Q = map(int, input().split())
S = input()

# 累積和 s を計算
c = [0 for _ in range(N + 1)]
for i in range(1, N):
    a = 0
    if S[i-1:i+1] == 'AC':
        a = 1
    c[i + 1] = c[i] + a

# 各クエリに答える
for _ in range(Q):
    l, r = map(int, input().split())
    l -= 1
    result = c[r] - c[l]
    if l > 0 and S[l-1:l+1] == 'AC':
        result -= 1
    print(result)
    


Measured memory_bytes: 13028
import math

# 1年での試行回数
Y = 365*10

# dpテーブル初期化
dp = [0]*(30+1)
dp[0] = 1
dp[1] = 1
dp[2] = 2

# dpテーブル作成
for i in range(3, 31):
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

# 終了フラグ
flag = 0

# dpテーブル更新のindexの最大値を記録
i_max = 2

while flag == 0:
    floor = int(input())
    if floor == 0 :
        # 終了する
        flag = 1
    else:
        print(math.ceil(dp[floor]/Y))


Measured memory_bytes: 5664
#include<bits/stdc++.h>
using namespace std;
const int INF = (1<<30);

int main() {
  
  int min_p = INF, min_j = INF;

  for(int i=0; i<3; i++) {
    int a; cin >> a;
    if( min_p > a ) min_p = a;
  }

  for(int i=0; i<2; i++) {
    int a; cin >> a;
    if( min_j > a ) min_j = a;
  }

  cout << min_p + min_j - 50 << endl;
}

Measured memory_bytes: 1160
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
    
// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
    
fn main() {
    let r: i32 = read();
    
    println!("{}", r * r);
}

Measured memory_bytes: 4352
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int i,n,k;cin>>n>>k;
vector<double> a(n);
for(i=0;i<n;i++) cin>>a[i];
for(i=0;i<n;i++) a[i]=(a[i]+1)/2;
double s=0,m;
for(i=0;i<k;i++) s+=a[i];
m=s;
for(i=k;i<n;i++)
{
	s+=a[i]-a[i-k];
	m=max(s,m);
}
cout<<fixed<<setprecision(7)<<m;


return 0;
}

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

int main() {
    string str;
    int cnt = 0;

    // 変数aで入力を受け取る
    cin >> str;

    for(int i=0; i < str.size(); i++){
        if(str.at(i) == '1'){
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int T =sc.nextInt();
      HashMap<String, Integer> map = new HashMap<>();
      for(int i =0; i<T;i++){
      	String a =sc.next();
        if( map.containsKey(a))
          	continue;
        else
          map.put(a,0);
      }
      System.out.println(map.size());
    }
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

int main(){
    fcin;
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        if(x >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N + 1);
    for(int i = 0; i < N; ++i) {
        cin >> a[i + 1];
    }

    vector<vector<int>> dp(N + 1, vector<int>(2, -1));//dp[i][j]:=topがai
    // 直前の相手の手: top, turn: 今の手番
    function<int(int, int)> rec = [&] (int top, int turn) {
        int& res = dp[top][turn];
        if(dp[top][turn] != -1) {
            return dp[top][turn];
        }
        
        if(top == 0) {
            res = abs(W - a.back()); // 最後まで引く
        } else {
            res = abs(a[top] - a.back()); // 最後まで引く
        }
        //topはどこまでひかれたか
        if(turn == 0) { // 先手途中まで引く
            for(int nex = top + 1; nex < N; ++nex) {
                res = max(res, rec(nex, turn^1));
            }
        } else {
            for(int nex = top + 1; nex < N; ++nex) {
                res = min(res, rec(nex, turn^1));
            }
        }
        return res;
    };

    cout << rec(0, 0) << endl;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  
  vector<long long> dp(n+100);
  vector<bool> dd(n+100,true);
  for(int i=0;i<m;i++){
    cin>>a[i];
    dd[a[i]]=false;
  }
  dp[0]=1;
  if(dd[1]) dp[1]=1;
  else dp[1]=0;
  for(int i=1;i<n+3;i++){
    if(dd[i+1]) dp[i+1]=dp[i]+dp[i-1];
    dp[i+1]%=(1000000000+7);
  }
  cout<<dp[n]<<endl;
}
  


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
	int n;
	long long int sum = 0;
	cin >> n;
	vector<int> a(n, 0), b(n, 0), c(n, 0);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++) cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	for (int i = 0; i < n; i++) {
		sum += (long long)(lower_bound(a.begin(), a.end(), b[i]) - a.begin()) * (long long)(c.end() - upper_bound(c.begin(), c.end(), b[i]));
	}
	cout << sum << endl;
}


	



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
// const int N = 1e5 + 5; 
// int n;
// int a[N];



int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){

int n;cin >>n;

if(n<= 1000) {cout << 1000 - n <<endl;}
else if(n<= 2000) {cout << 2000 - n <<endl;}
else if(n<= 3000) {cout << 3000 - n <<endl;}
else if(n<= 4000) {cout << 4000 - n <<endl;}
else if(n<= 5000) {cout << 5000 - n <<endl;}
else if(n<= 6000) {cout << 6000 - n <<endl;}
else if(n<= 7000) {cout << 7000 - n <<endl;}
else if(n<= 8000) {cout << 8000 - n <<endl;}
else if(n<= 9000) {cout << 9000 - n <<endl;}
else if(n<= 10000) {cout << 10000 - n <<endl;}







}
return 0;
}

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

int main(){
    char a, b;
    cin >> a >> b;
    cout << (a==b ? 'H' : 'D') << endl;
    /*
    if(a == 'H' && b == 'D')    cout << "D" << endl;
    if(a == 'H' && b == 'H')    cout << "H" << endl;
    if(a == 'D' && b == 'D')    cout << "H" << endl;
    if(a == 'D' && b == 'H')    cout << "D" << endl;
    */
    return 0;
}

Measured memory_bytes: 256
def main():
    A, B = map(int, input().split())
    S = input()
    digit = [str(a) for a in range(10)]
    collect = True
    for i in range(len(S)):
        if i == A:
            if S[i] != "-":
                collect = False
                break
        else:
            if S[i] not in digit:
                collect = False
                break
    if collect == True:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
branch = sum(a) - 1
now = 1
ans = 0
for i, num in enumerate(a):
    ans += now
    now -= num
    if branch >= now:
        branch -= now
        now *= 2
    elif branch > 0:
        now += branch
        branch = 0
    if now < 0:
        print(-1)
        exit()
print(ans)
    

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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

LL a, b, c, d;

LL gcd(LL a, LL b){
    if(a < b)   swap(a, b);
    LL c = a % b;
    while(c){
        a = b; b = c; c = a % b;
    }
    return b;
}

LL cal(LL n){
    LL ret = n / c + n / d;
    LL g = gcd(c, d);
    g = c / g * d;
    ret = ret - n / g;
    return n - ret;
}

int main(){
    while(~scanf("%lld %lld %lld %lld", &a, &b, &c, &d)){
        printf("%lld\n", cal(b) - cal(a-1));
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

int a[100005];

bool f(int x,int y){
	if (y>=a[x]) return 1;
	return !f(x-1,y) || !f(x,y+1);
}

int main(){
	int n;
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	std::sort(a+1,a+n+1);
	int p=0;
	for (int i=1;i<=n;i++)
	if (i>=a[n-i]){
		p=n-i+1;break;
	}
	if (!((a[p]-n+p)&1) || !f(p-1,n-p)) printf("First\n");
		else printf("Second\n");
}

Measured memory_bytes: 3712
num = raw_input()
numarray = list(num)
A = int(numarray[0])
B = int(numarray[1])
C = int(numarray[2])
D = int(numarray[3])
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = 0
            if i == 0:
                ans += A - B
                if j == 0:
                    ans -= C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
                else:
                    ans += C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
            else:
                ans += A + B
                if j == 0:
                    ans -= C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
                else:
                    ans += C
                    if k == 0:
                        ans -= D
                    else:
                        ans += D
            if ans == 7:
                if i == 0:
                    Si = "-"
                else:
                    Si = "+"
                if j == 0:
                    Sj = "-"
                else:
                    Sj = "+"
                if k == 0:
                    Sk = "-"
                else:
                    Sk = "+"
                print str(A) + Si +str(B) + Sj + str(C) + Sk + str(D) + "=7"
                break
        if ans == 7:
            break
    if ans == 7:
            break

Measured memory_bytes: 2696
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll long long
#define vi vector <int >
#define vii vectir < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second

ll arr[100010];

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	int t;
	cin >> t;
	ll resp = 0;
	forn(i, t){
		cin >> arr[i];
		resp += arr[i];
	}
	ll ans = INT_MAX, aux = 0;
	forn(i, t - 1){
		aux += arr[i];
		ans = min(ans, abs((resp - aux) - aux));
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if(a+b==15)
	{
		cout<<"+"<<endl;
		return 0;
	}
	if(a*b==15)
	{
		cout<<"*"<<endl;
		return 0;
	}
	cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 256
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int a[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  int ma = -INF, mi = INF;
  REP(i, n) {
    ma = max(ma, a[i]);
    mi = min(mi, a[i]);
  }

  if(ma - mi >= 2) {
    cout << "No" << endl;
  } else if(ma == mi) {
    bool f = true, g = true;
    REP(i, n) {
      if(a[i] != n-1) f = false;
      if(a[i]*2 > n) g = false;
    }
    if(f || g) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    int x = 0, y = 0;
    REP(i, n) {
      if(a[i] == ma) y++;
      else x++;
    }
    if(x < ma && 2*(ma-x) <= y) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    clock_t start = clock();
    auto now = [&] () {
        return (double)(clock() - start) / CLOCKS_PER_SEC;
    };
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll d; cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) cin >> s[i][j];
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) w.push_back(i);
    }
    ll m = w.size();
    
    vector<ll> t(d);
    random_device rand;
    for (ll i = 0; i < d; i++) t[i] = w[rand() % m];
    
    ll score = 0;
    {
        vector<ll> v(26, -1);
        for (ll i = 0; i < d; i++) {
            v[t[i]] = i;
            score += s[i][t[i]];
            for (ll j = 0; j < 26; j++) score -= c[j] * (i - v[j]);
        }
    }
    
    vector<set<ll>> v(26);
    for (ll i = 0; i < 26; i++) v[i].insert(-1);
    for (ll i = 0; i < d; i++) v[t[i]].insert(i);
    for (ll i = 0; i < 26; i++) v[i].insert(d);
    
    auto modified_score = [&] (ll day, ll into) {
        ll ret = score;
        ret += s[day][into] - s[day][t[day]];
        auto itr1 = v[t[day]].find(day);
        ll p = *(--itr1), q = *(++itr1), r = *(++itr1);
        ret += ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[t[day]] / 2;
        ret -= (r - p) * (r - p - 1) * c[t[day]] / 2;
        auto itr2 = v[into].upper_bound(day);
        p = *(--itr2); q = day; r = *(++itr2);
        ret -= ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[into] / 2;
        ret += (r - p) * (r - p - 1) * c[into] / 2;
        return ret;
    };
    auto prob = [&] (ll e1, ll e2) {
        double x = exp((e2 - e1) / (1.95 + now()));
        return (rand() <= RAND_MAX * x);
    };
    
    while (now() <= 1.95) {
        ll day = rand() % d, into = w[rand() % m];
        ll x = modified_score(day, into);
        if (x >= score) {
            score = x;
            v[t[day]].erase(day);
            v[into].insert(day);
            t[day] = into;
        }
        else if (prob(score, x)) {
            score = x;
            v[t[day]].erase(day);
            v[into].insert(day);
            t[day] = into;
        }
    }
    
    /*while (now() <= 1.95) {
        ll day = rand() % d, into = w[rand() % m];
        ll x = modified_score(day, into);
        if (x >= score) {
            score = x;
            v[t[day]].erase(day);
            v[into].insert(day);
            t[day] = into;
        }
    }*/
    
    for (ll i = 0; i < d; i++) cout << t[i] + 1 << endl;
    xout << score << endl;
}


Measured memory_bytes: 4356
N, Y = gets.strip.split.map(&:to_i)

def fin(i, j, k)
  puts "#{i} #{j} #{k}"
  exit
end

(0..N).each do |i|
  (0..(N - i)).each do |j|
    k = N - i - j
    fin(i, j, k) if Y.eql?(i * 10000 + j * 5000 + k * 1000)
  end
end

fin(-1, -1, -1)


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

using namespace std;

int main () {
  int ans = 1e8;
  string s; cin >> s;

  for (int i = 0; i < s.length(); i++) {
    char cur = s[i];
    int t = 0;
    int d = 0;

    for (int j = i+1; j < s.length(); j++) {
      t++;
      if (s[j] == cur) {
        t = 0;
      }
      d = max(d, t);
    }
    ans = min( ans, max(i, d) );
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(long *a, long *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(long a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];

    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}
   
int main(){
    int N;
    cin>>N;
    long A[N];

    rep(i,N) cin>>A[i];

    q_sort(A,0,N-1);
    rep(i,N){
        if(A[i]==A[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

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

	long long ans = 0;
	int cur = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= cur + 1) {
			cur = max(cur, a[i]);
		} else {
			ans += (a[i] - 1) / (cur + 1);
			cur = max(cur, 1);
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=-max(a,c)+min(b,d);
	if (x>=0)
	cout<<x;
	else
	cout<<0;
	return 0;
}

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

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n;
  cin >> n;
  ll ans = 0;
  while(n--) {
  	int x;
  	cin >> x;
  	ans += x-1;
  }
  cout << ans<< flush;
}

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

const int N = 410, M = 100010;
typedef std::bitset <N> bit;

int V, E;
int u[M], v[M];
bit G[N];

int main() {
	int i, j, ans = 0;
	scanf("%d%d", &V, &E);
	for (i = 1; i <= E; ++i) scanf("%d%d", u + i, v + i);
	for (i = 1; i <= V; ++i)
		for (G[i].set(i), j = E; j; --j) {
			if (G[i].test(u[j]) && G[i].test(v[j])) {G[i].set(0); break;}
			if (G[i].test(u[j]) || G[i].test(v[j])) G[i].set(u[j]).set(v[j]);
		}
	for (i = 1; i < V; ++i)
		if (!G[i].test(0))
			for (j = i + 1; j <= V; ++j)
				ans += !G[j].test(0) && (G[i] & G[j]).none();
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=20010;
int n,p[N],a[N],b[N];
int main() {
    R(n);
    REP1(i,1,n) R(p[i]);
    REP1(i,1,n) a[i]=i*N;
    REP1(i,1,n) b[i]=(n-i+1)*N;
    REP1(i,1,n) a[p[i]]+=i;
    W(VI(a+1,a+n+1));
    W(VI(b+1,b+n+1));
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	ll n,k;
	cin>>n>>k;
	vector<int> a(n);
	rep(i,n)cin>>a[i];

	vector<int> b = a;
	sort(all(b));

	ll ans = 0;

	ll xl = (k-1)*k/2;
	xl %= mod;
	ll xr = k*(k+1)/2;
	xr%=mod;
	rep(i,n){
		ll left = 0;
		ll right = 0;
		for (int j = 0; j < i; j++){
			if(a[i]>a[j]) left++;
		}
		for (int j = i+1; j < n; j++){
			if(a[i]>a[j]) right++;
		}
		// cout<<left<<" "<<right<<endl;
		ans+=left*xl;
		ans%=mod;
		ans+=right*xr;
		ans%=mod;
		// ans -= left;
		// ans+=mod;
		// ans%=mod;
	}

	
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#define lp(i, l, r) for (int i = l; i <= r; ++i)
#define rp(i, r, l) for (int i = r; i >= l; --i)
#define ls(i, s) for (int i = 0; s[i]; ++i)
#define rs(i, s) for (int i = strlen(s) - 1; i >= 0; --i)
#define lv(i, a) for (int i = 0; i < a.size(); ++i)
#define rv(i, a) for (int i = (int)a.size() - 1; i >= 0; --i)
#define in(a) int a = (cin >> a, a)
#define ou(a) cout << a << endl
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define prec(a) cout << setprecision(a) << fixed
#define appl(f, a) for (auto i = begin(a); i != end(a); f, ++i)
#define many for (int T = -1; T < 0 && cin >> T, T--;)
#define rang(a) begin(a), end(a)
#define gene template <class T>
#define endl '\n'
#define asse assert
using namespace std;
using namespace __gnu_pbds;
gene void sort(T &a) { sort(rang(a)); }
gene void reve(T &a) { reverse(rang(a)); }
gene void uniq(T &a) { sort(a), a.erase(unique(rang(a)), end(a)); }
gene void shuf(T &a) { random_shuffle(rang(a)); }
gene void merg(T l, T m, T r) { inplace_merge(l, m, r); }
gene auto gath(const T &a, const vector<int> &b) {
    vector<typename T::value_type> r;
    for (auto i : b)
        r.push_back(a[i]);
    return r;
}
gene auto min(const T &a) { return *min_element(rang(a)); }
gene auto max(const T &a) { return *max_element(rang(a)); }
gene auto sum(const T &a) { return accumulate(rang(a), 0); }
gene T inf() { return numeric_limits<T>::max(); }
gene int tmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
gene int tmax(T &a, T b) { return b > a ? a = b, 1 : 0; }
gene using bbst =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
gene using heap = __gnu_pbds::priority_queue<T, greater<T>, pairing_heap_tag>;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
template <class F, class S> auto &operator>>(istream &s, pair<F, S> &a) {
    return s >> a.first >> a.second;
}
gene auto &operator>>(istream &s, vector<T> &a) {
    for (int i = -1; i < 0 && (!a.size() && (cin >> i, a.resize(i), 0), i = 0),
             i < a.size();)
        s >> a[i++];
    return s;
}
template <class F, class S> auto &operator<<(ostream &s, const pair<F, S> &a) {
    return s << '(' << a.first << ", " << a.second << ')';
}
gene auto &operator<<(ostream &s, const vector<T> &a) {
    lv(i, a) cout << a[i] << (i + 1 == a.size() ? "" : " ");
    return s;
}
int main() {
    fast, prec(12);
    int h, w, n;
    cin >> h >> w >> n;
    // k*max(h,w)>=n
    int ans;
    if (n % max(h, w) == 0)
        ans = n / max(h, w);
    else
        ans = n / max(h, w) + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
a = (len(s)-1)//2
b = (len(s)+3) // 2
if s == s[::-1] and s[:a] == s[:a][::-1] and s[b-1:len(s)] == s[b-1:len(s)][::-1]:
    print("Yes")
else:
    print("No")


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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

int main() {
    int n = read(), k = read();
    if (k == 0) {
        for (int i = 0; i < (1 << n); i++) {
            if (i) putchar(' ');
            printf("%d %d", i, i);
        }
        puts("");
        return 0;
    }
    if (k >= (1 << n)) {
        puts("-1");
        return 0;
    }
    int res = 0;
    for (int i = 0; i < (1 << n); i++) res ^= i;
    if (res != 0) {
        puts("-1");
        return 0;
    }
    for (int i = 0; i < (1 << n); i++) if (i != k) printf("%d ", i);
    printf("%d ", k);
    for (int i = (1 << n) - 1; i >= 0; i--) if (i != k) printf("%d ", i);
    printf("%d", k);
    puts("");
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int maxn=200010;
int a[maxn];
ll sum[maxn];
pll val[maxn],val2[maxn];
inline ll get_sum(int l,int r){
	return sum[r]-sum[l-1];
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		sum[i]=sum[i-1]+a[i];
	}
	int cur=1;
	for(int i=2;i<=n;i++){
		while(cur+1<i && abs(get_sum(1,cur)-get_sum(cur+1,i))>=abs(get_sum(1,cur+1)-get_sum(cur+2,i)))
			cur++;
		val[i]=pll(get_sum(1,cur),get_sum(cur+1,i));
	}
	cur=n;
	for(int i=n-1;i>=1;i--){
		while(cur-1>i && abs(get_sum(cur,n)-get_sum(i,cur-1))>=abs(get_sum(cur-1,n)-get_sum(i,cur-2)))
			cur--;
		val2[i]=pll(get_sum(cur,n),get_sum(i,cur-1));
	}
	ll ans=1ll<<62;
	for(int i=2;i<=n-2;i++){
		ll maxv=max(max(val[i].first,val[i].second),max(val2[i+1].first,val2[i+1].second));
		ll minv=min(min(val[i].first,val[i].second),min(val2[i+1].first,val2[i+1].second));
		ans=min(ans,maxv-minv);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8832