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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    string s,t;
    cin>>s>>t;
    int l1,l2;
    l1=s.size();
    l2=t.size();
    string dp[2][l2+1];
    rep(i,l1+1){
        dp[i%2][0]="";
    }
    rep(i,l2+1){
        dp[0][i]="";
    }
    int m;
    string w1,w2,w3;
    for (int i=1;i<l1+1;i++){
        for (int j=1;j<l2+1;j++){
            w1=dp[1-i%2][j];
            w2=dp[i%2][j-1];
            w3=dp[1-i%2][j-1];
            m=max(w1.size(),max(w2.size(),1+w3.size()));
            if (s.at(i-1)==t.at(j-1)){
                if (w1.size()==m){
                    dp[i%2][j]=dp[1-i%2][j];
                }
                else if(w2.size()==m){
                    dp[i%2][j]=dp[i%2][j-1];
                }
                else{
                    dp[i%2][j]=dp[1-i%2][j-1]+s.at(i-1);
                }
                
            }
            else{
                if (w1.size()>w2.size()){
                    dp[i%2][j]=dp[1-i%2][j];
                }
                else{
                    dp[i%2][j]=dp[i%2][j-1];
                }
            }
        }
    }
    cout<<dp[l1%2][l2]<<endl;
    

    return 0;
}

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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1,2,4,3);}
  void roll_y(){ roll(0,2,5,3);}
  void roll_x(){ roll(0,1,5,4);}
  void roll(int i,int j,int k,int l){
    int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
  }
};

bool eq( Cube c1,Cube c2 ){
  for(int i=0;i<6;i++)
    if(c1.f[i] != c2.f[i] )return false;
    return true;
}

bool equal( Cube c1, Cube c2 ){
  for(int i=0;i<6;i++){
    for(int j=0;j<4;j++){
      if( eq(c1,c2) )return true;
      c1.roll_z();
    }
    if(i%2 == 0)c1.roll_y();
    else c1.roll_x();
  }
  return false;
}

int main(){
  Cube c1,c2;
  for(int i=0;i<6;i++)cin>>c1.f[i];
  for(int i=0;i<6;i++)cin>>c2.f[i];
  if( equal(c1,c2) )cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}




Measured memory_bytes: 3104
import collections

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

bc = []

for i in range(q):
    bci = list(map(int, input().split()))
    bc.append(bci)

d = collections.Counter(a)
ans = sum(a)

for i in range(q):
    b, c = bc[i]
    num = (c-b)*d[b]
    ans += num
    print(ans)
    d[c] += d[b]
    d[b] = 0

Measured memory_bytes: 40324
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B, C, K = map(int, input().split())

    if A > K:
        print(K)
    elif A + B > K:
        print(A)
    else:
        print(A-(K-(A+B)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 61784
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n,k; cin >> n >> k;
    vector<int>v(n);
    vector<int>sum(n);
    vector<int>res(n);
    int ans = -INF;
    rep(i,n) cin  >> v[i];
    rep(i,n){
        if(i)sum[i] = sum[i-1]+v[i];
        else sum[i] = v[i];
    }
    rep(i,n){
        if(i)res[i] = res[i-1]+max(0LL,v[i]);
        else res[i] = max(0LL,v[i]);
    }
    int allsum  = res[n-1];
    for(int i = 0; i +k -1 <n; i++){
        if(i == 0){
            cmax(ans,max(0LL,sum[i+k-1])+allsum-res[i+k-1]);
        } else cmax(ans,max(0LL,sum[i+k-1]-sum[i-1]) + allsum - res[i+k-1] + res[i-1]);
    }
    cout << ans << endl;
}






Measured memory_bytes: 2688
/**
 *    author:  FromDihPout
 *    created: 2020-08-25
**/

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

const int INF = 1e9;
vector<pair<int,int>> ADJ = {{1,0}, {-1,0}, {0,1}, {0,-1}};
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w, sh, sw, eh, ew;
    cin >> h >> w >> sh >> sw >> eh >> ew;
    sh--; sw--; eh--; ew--;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }
    
    deque<pair<int,int>> q;
    vector<vector<int>> dist(h, vector<int> (w, INF));
    q.emplace_front(sh, sw);
    dist[sh][sw] = 0;
    while (!q.empty()) {
        auto pos = q.front();
        q.pop_front();
        int r = pos.first, c = pos.second;
        if (r == eh && c == ew) break;
        
        for (auto nxt : ADJ) {
            int nr = r + nxt.first, nc = c + nxt.second;
            if (nr < 0 || nr >= h || nc < 0 || nc >= w) continue;
            if (a[nr][nc] == '#') continue;
            if (dist[r][c] < dist[nr][nc]) {
                dist[nr][nc] = dist[r][c];
                q.emplace_front(nr, nc);
            }
        }
        
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nr = r + i, nc = c + j;
                if (nr < 0 || nr >= h || nc < 0 || nc >= w) continue;
                if (a[nr][nc] == '#') continue;
                if (dist[r][c] + 1 < dist[nr][nc]) {
                    dist[nr][nc] = dist[r][c] + 1;
                    q.emplace_back(nr, nc);
                }
            }
        }
    }
    
    if (dist[eh][ew] < INF) {
        cout << dist[eh][ew] << '\n';
    }
    else {
        cout << -1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 8680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)

int main()
{
    fast;
    int n;
    cin>>n;
    //bool flag=false;
    for(int i=1;i<=9;i++)
    {
        int temp;
        if(n%i==0)
        {
            temp=n/i;
       // cout<<i<<" "<<temp<<endl;
        if(temp<=9&&temp>=1)
        {
            cout<<"Yes"<<endl;
            return 0;
        }

        }
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 3664
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int ans;
    if(n<10){
        ans=n;
    }else if(n<100){
        ans=9;
    }else if(n<1000){
        ans=9+(n-99);
    }else if(n<10000){
        ans=9+900;
    }else if(n<100000){
        ans=9+900+(n-9999);
    }else{
        ans=9+900+90000;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int i,t,re,d;
  char a[4],o[3];
  
  for (i=0;i<4;i++) cin >> a[i];
  
  for (t=0;t<8;t++){
    re=a[0]-'0';
    d=t;
    for (i=0;i<3;i++){
      if (d%2==0){
        re+=a[i+1]-'0';
        o[i]='+';
      }else{
        re-=a[i+1]-'0';
        o[i]='-';
      }
      d/=2;
    }
    if (re==7){
      for (i=0;i<3;i++) cout << a[i] << o[i];
      cout << a[3] << "=7" << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    ll N,K; cin>>N>>K;
    vector<pair<ll,ll>> S(N);
    for(ll i=0;i<N;i++){
        ll a,b; cin>>a>>b;
        S[i].first=a;
        S[i].second=b;
    }
    sort(S.begin(),S.end());
    ll i=0;
    while(K>=0){
        if(K>S[i].second){
            K-=S[i].second;
        }
        else{
            cout<<S[i].first;
            return 0;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}

signed main()
{
    io;
    int n,m;cin>>n>>m;
    if(n==m)puts("Yes");
    else puts("No");
    getchar(); //
    getchar();
}


Measured memory_bytes: 256
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(M)]
for i in range(10**N):
    ans=str(i)
    if len(ans)==N and all(ans[s-1]==str(c) for s,c in sc):
        print(ans)
        quit()
print(-1)

Measured memory_bytes: 3060
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>

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

using namespace std;

int main(){

	int n;


	cin >> n;

	double x1,y1,x2,y2,x3,y3;
	rep(i,n){

	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

	double a=x2*x2-x1*x1+y2*y2-y1*y1;
	double b=x3*x3-x1*x1+y3*y3-y1*y1;
	double c=4*(x2-x1)*(y3-y1)-4*(x3-x1)*(y2-y1);

	double xp=(2*(y3-y1)*a-2*(y2-y1)*b)/c;
	double yp=(-2*(x3-x1)*a+2*(x2-x1)*b)/c;
	double r=sqrt((xp-x1)*(xp-x1)+(yp-y1)*(yp-y1));

    printf("%.3lf %.3lf %.3lf\n",xp,yp,r);

	}


	return 0;
}

Measured memory_bytes: 1244
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
int v[30];
int main(){
  v[0]=1;
  for(int i=1;i<10;i++){
    v[i]=v[i-1]*2;
  }
  int s;
  while(cin>>s){
    vector<int> b;

    for(int i=9;i!=-1;i--){
      if(s==0)break;
      if(s>=v[i]){
        b.push_back(v[i]);
        s-=v[i];

      }
    }
    sort(b.begin(),b.end());
    for(int i=0;i<b.size()-1;i++){
      if(b[i])cout<<b[i]<<" ";
    }
    cout<<b[b.size()-1]<<endl;
    
  }

  return 0;
}



Measured memory_bytes: 3028
def f(x):
    return (x + 1) / 2


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[:k])
a = ans
for i in range(k, n):
    a = a + p[i] - p[i - k]
    ans = max(ans, a)
print(ans)


Measured memory_bytes: 23524
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int rsl = 0;
    for(int r = 0; r <= N; r += R) {
        for(int g = 0; g <= N; g += G) {
            int b = N - r - g;
            if(b % B == 0) {
                if(0 <= b and b <= N) rsl++;
            }
        }
    }

    cout << rsl << endl;


}


Measured memory_bytes: 256
//func i()->Int{return Int(readLine()!)!};let N=i(),K=i();print(min(N,K)*i()+max(N-K,0)*i())
func i()->Int{return Int(readLine()!)!};let N=i(),K=i(),X=i();print(N>K ?K*X+(N-K)*i():N*X)

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define count2way(v, x) high2way(v, x) - low2way(v, x)
#define lower(v, x) low2way(v, x) - v.begin()       //1番左が0、もし見つから無いならｎを出力
#define higher(v, x) high2way(v, x) - v.begin() - 1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout << a << endl
#define putout2(a, b) \
    putout(a);        \
    putout(b)
#define putout3(a, b, c) \
    putout(a);           \
    putout(b);           \
    putout(c)
#define putout4(a, b, c, d) \
    putout(a);              \
    putout(b);              \
    putout(c);              \
    putout(d)
#define putout5(a, b, c, d, e) \
    putout(a);                 \
    putout(b);                 \
    putout(c);                 \
    putout(d);                 \
    putout(e)
#define Gput(a, b) G[a].push_back(b)
#define cin1(a) cin >> a
#define cin2(a, b) cin >> a >> b
#define cin3(a, b, c) cin >> a >> b >> c
#define cin4(a, b, c, d) cin >> a >> b >> c >> d
#define cin5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
T modinv(T a, T m)
{
    T b = m, u = 1, v = 0;
    while (b)
    {
        T t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//多次元配列の宣言法
//vector<vector<ll>> field(h, vector<ll>(w));
template <class T>
inline void chmax(T &a, T b)
{
    if (a < b)
        a = b;
}
template <class T>
inline void chmin(T &a, T b)
{
    if (a > b)
        a = b;
}
/*
ライブラリをここに置いてコメントを削除
*/

int main()
{
    cout << fixed << setprecision(30);
    ll n,k;
    cin>>n>>k;
    ll count=n/k;
    n-=count*k;
    putout(min(n,abs(n-k)));
    return 0;
}


Measured memory_bytes: 256
from itertools import product

N, W = map(int,input().split())
L = [[] for _ in range(4)]
w, v = map(int,input().split())
L[0].append(v)
for _ in range(N-1):
    tmp_w, tmp_v = map(int,input().split())
    L[tmp_w - w].append(tmp_v)

for i in range(4):
    L[i].sort(reverse = True)

for i in range(4):
    for j in range(len(L[i]) - 1):
        L[i][j+1] += L[i][j]
    L[i] = [0] + L[i]

ans = 0

for i, j, k, l in product(range(len(L[0])), range(len(L[1])), range(len(L[2])), range(len(L[3]))):
   if w * (i + j + k + l) + j + 2 * k + 3 * l <= W:
        ans = max(ans, L[0][i] + L[1][j] + L[2][k] + L[3][l])

print(ans)

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

int main()
{
    ll N;
    cin >> N;
    char S[N+3];
    cin >> S;
    ll left = 0, right = 0;
    for(ll i = 1; i < N; ++i) if(S[i] == 'E') ++right;
    ll ans = right;
    for(ll i = 1; i < N; ++i) {
        if(S[i-1] == 'W') ++left;
        if(S[i] == 'E') --right;
        ans = min(ans, right + left);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.20 03:08:54
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    ll n,x,m;cin >> n >> x >> m;
    vector<vector<int>> to(35,vector<int>(m));
    vector<vector<ll>> doubling(35,vector<ll>(m));
    for (ll i = 0; i < m; i++) {
        to[0][i] = i*i%m;
        doubling[0][i] = i*i%m;
    }
    for (int i = 0; i < 33; i++) {
        for (int j = 0; j < m; j++) {
            to[i+1][j] = to[i][to[i][j]];
            doubling[i+1][j] = doubling[i][j] + doubling[i][to[i][j]];
        }
    }
    ll ans = 0;
    int now = x;
    n--;
    for (int i = 0; i < 35; i++) {
        if ((1LL<<i) & n) {
            
            ans += doubling[i][now];
            now = to[i][now];
        }
    }
    cout << ans + x << endl;
    return 0;
}

Measured memory_bytes: 45020
N = int(input())
n_AC = 0
n_WA = 0
n_TLE = 0
n_RE = 0
for i in range(N):
    x = input()
    if x == 'AC':
        n_AC += 1
    elif x == 'WA':
        n_WA += 1
    elif x == 'TLE':
        n_TLE += 1
    elif x == 'RE':
        n_RE += 1

print(f'AC x {n_AC}')
print(f'WA x {n_WA}')
print(f'TLE x {n_TLE}')
print(f'RE x {n_RE}')


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

ll N, M;
vector<ll> E[200000], R[200000];
ll parent[200000];
bool path[200000];

void dfs(ll v, ll p) {
  bool ok = true;
  for (ll u : R[v]) if (!path[u]) ok = false;
  if (!ok) return;

  parent[v] = p;
  path[v] = true;

  for (ll u : E[v]) dfs(u, v);

  path[v] = false;
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, N + M - 1) {
    ll A, B;
    cin >> A >> B, A--, B--;
    E[A].push_back(B);
    R[B].push_back(A);
  }

  ll root;
  REP(i, 0, N) if (R[i].size() == 0) root = i;

  dfs(root, -1);

  REP(i, 0, N) cout << parent[i] + 1 << endl;
}

Measured memory_bytes: 22400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main() {
	const string vowel = "aiueo";
	char character;
	cin >> character;

	if ( vowel.find(character) != string::npos){
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
// シェルソート 自分じゃ分からん　p.77

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// 間隔gを指定した挿入ソート
void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}


// 数列G = {1, 4, 13, 40, 121, 364, ... }を生成
void shellSort(int A[], int n) {
    for (int h = 1; ; ) {
        if (h > n)
            break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    // より速い入力scanf関数を使用
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i)
            printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++)
        printf("%d\n", A[i]);
    return 0;
}


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

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 == 0 or A[i] % 5 == 0:
      pass
    else:
      print('DENIED')
      break
else:
  print('APPROVED')


Measured memory_bytes: 3060
//
// B - Checkpoints
//

#include <iostream>
#include <vector>

using namespace std;

struct checkpoint {
    int id, x, y;

    bool operator<(const checkpoint &right) const {
        return x == right.x ? id < right.id : x < right.x;
    }

    int distance(const pair<int, int> &s) {
        return abs(x - s.first) + abs(y - s.second);
    }
};

int main() {

    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> S;
    vector<checkpoint> C;

    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        S.emplace_back(make_pair(a, b));
    }

    for (int i = 0; i < M; i++) {
        int c, d;
        cin >> c >> d;
        C.push_back((checkpoint) {i + 1, c, d});
    }

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

    for (auto s: S) {
        int id, min_ = INT32_MAX;
        for (auto c: C) {
            if (abs(c.x - s.first) > min_) {
                break;
            }
            if (min_ > c.distance(s)) {
                id = c.id;
                min_ = c.distance(s);
            }
        }
        cout << id << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        boolean b = true;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a % 2 == 0) {
                if (!(a % 3 == 0 || a % 5 == 0)) {
                    b = false;
                    break;
                }
            }
        }

        if (b) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }
        sc.close();
    }
}

Measured memory_bytes: 22868
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    A = list(map(int, input().split()))

    A.sort()
    print(A[-1] - A[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 62928
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char a[105];
char b[105];

int main() {
  scanf("%s%s", a, b);
  for(int i = 0; i < strlen(a); i++) {
    printf("%c", a[i]);
    if(i < strlen(b)) {
      printf("%c", b[i]);
    }
  }
  printf("\n");
}


Measured memory_bytes: 256
N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]

P.sort(key=lambda x: x[2])
array = []
p = P.pop()

for x in range(0, 101):
    for y in range(0, 101):
        H = p[2]+abs(p[0]-x)+abs(p[1]-y)
        if H > 0:
            array.append((x, y, H))

for x, y, h in P:
    ary = []
    for cx, cy, H in array:
        if h == 0:
            if h >= (H-abs(x-cx)-abs(y-cy)):
                ary.append((cx, cy, H))
        else:
            if h == (H-abs(x-cx)-abs(y-cy)):
                ary.append((cx, cy, H))
    array = ary

print(*array[0])


Measured memory_bytes: 45808
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;

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

int main(){
	int a, b;
	while(cin>>a>>b){
		cout<<gcd(a,b)<<" "<<(a/gcd(a,b)*b)<<endl;
		
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int getSum(int n)
{ 
   int sum = 0;
   while (n != 0)
   {
       sum = sum + n % 10;
       n = n/10;
   }
   return sum;
}
int main() {
int n;
cin>>n;
int p=103888;
int a=0,b=0;
for(int i=1;i<n;i++)
{
    int y=i;int t=n-i;
    int g=getSum(y)+getSum(t);
    p=min(p,g);
    
}
cout<<p<<"\n";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())
#define mp make_pair
#define pb push_back
#define forn(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

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




void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int fl = 1;
    while (true) {
        if (c <= 0) {
            cout << "Yes\n";
            return;
        }
        if (a <= 0) {
            cout << "No\n";
            return;
        }
        if (fl) {
            c -= b;
        }
        else {
            a -= d;
        }
        fl ^= 1;
    }
}



int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    while (cin.peek() != EOF) {
        solve();
        cout << endl << endl;
        string s;
        do getline(cin, s);
        while (!cin.eof() && !s.empty());
        while (isspace(cin.peek())) cin.get();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


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

	vector<vector<string> > vec(6);
	rep(i, n){
		string s;
		cin >> s;
		if (s[0]=='M') vec.at(0).push_back(s);
		else if (s[0]=='A') vec.at(1).push_back(s);
		else if (s[0]=='R') vec.at(2).push_back(s);
		else if (s[0]=='C') vec.at(3).push_back(s);
		else if (s[0]=='H') vec.at(4).push_back(s);
		else vec.at(5).push_back(s);
	}

	ll res = 0;
	for (int bit=1; bit<(1<<5); bit++) {
		vector<int> s;
		rep(i, 5) {
			if (bit & (1<<i)) s.push_back(i);
		}
		if (s.size()==3) {
			ll num = 1;
			for (int i=0; i<(int)s.size(); i++) {
				num *= vec.at(s.at(i)).size();
			}
			res += num;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 7336
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    cout<<(a+b+c+max({a,b,c})*((1<<k)-1));
}


Measured memory_bytes: 380
#include <stdio.h>
int main(void){
    int h,w,H,W;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)break;
        for(h=0; h<H; h++){
            for(w=0; w<W; w++){
                printf("#");
                
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a, b;
  cin >> a >> b;
  double c, d;
  c = ( a + b ) /2;
  d = ( a + b + 1) /2;
  
  if((a + b ) % 2 == 0){
    cout << c << endl;
  }
  else{
    cout << d << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	int k=in(),t=in(),a[100],i;
	rep(i,t)a[i]=in();
	sort(a,t);
	if(a[t-1]<=(k+1)/2)print(0);
	else if(t==1)print(k-1);
	else print(k-2*(k-a[t-1])-1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    vector<int> vec;
    ll num;
    cin >> num;
    while(num > 100){
        vec.push_back(num % 1000);
        num /= 10;
    }
    int ans = 1000;
    for(auto e : vec) {
        ans = min(ans,abs(753-e));
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
const int max_n = 2e5 + 100;
ll a[max_n];int n;

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	sort(a, a + n, greater<ll>());
	ll ans = a[0];int k = n - 2;
	for (int i = 1;i < n;i++) {
		if (k <= 0)break;
		k--;ans += a[i];
		if (k <= 0)break;
		k--;ans += a[i];
	}cout << ans << endl;
}

Measured memory_bytes: 4752
package main

import (
	"fmt"
)

func main() {

	var N,Y int

	fmt.Scan(&N,&Y)

	for x:=0;x<=N;x++{

		for y:=0;y<=N-x;y++{

			z := N-x-y

			if x*10000+y*5000+z*1000 == Y{

				fmt.Println(x,y,z)

				return
			}

		}


	}


	fmt.Println("-1 -1 -1")

}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    
	long long n;
	cin >> n;
	
    char c;
    vector<char> v;
    int len = 0;
    
    while (n > 0) {
        c = (n-1) % 26 + 'a';
        v.push_back(c);
        len ++;
        if (n % 26 == 0)
            n = n / 26 - 1;
        else
            n = n / 26;
    }
    
    for (int i = 0; i < len; i++)
        cout << v[len - i -1]; 
    cout << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int ans,count=0;
  for(int i=min(a,b);i>=0;i--){
    if(a%i==0&&b%i==0){
      count++;
    }
    if(count==k){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}

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

int main(){
    int n,k,c=0,i;
    cin>>n>>k;
    int suu[n];
    for(i=0;i<n;i++){
      cin>>suu[i];
    }
    n--;
    k--;
    int ans=(n+k-1)/k;
    cout<<ans<<endl;
}

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

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=200005;
bool vis[N];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll a[n];
  map<ll,ll> ma;
  map<ll,vi> ind;   
  forn(i,n) cin>>a[i],ma[a[i]]++;
  sort(a,a+n);
  forn(i,n) ind[a[i]].pb(i);
  ll ans=0;
  for(ll i=n-1;i>=0;i--)
  {
    if(vis[i]) continue;
    ll x=a[i];
    ma[x]--;
    for(ll j=1;j<=31;j++)
    {
      ll z=(1LL<<j);
      if(z>x)
      {
        ll diff=z-x;
        if(ma[diff]>0)
        {
          ma[diff]--;
          ans++;
          //cout<<x<<" "<<diff<<" ";
          ll pos=ind[diff].back();
          ind[diff].pop_back();
         // cout<<pos<<"\n";
          vis[pos]=true;
          break;
        }
      }
    }
  }
  cout<<ans;
} 
//nothing is impossible

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

A_sum=sum(A)
A[0]=min(X,A[0])

for i in range(N-1):
    if A[i]+A[i+1]>X:
        A[i+1]=X-A[i]
print(A_sum-sum(A))

Measured memory_bytes: 85640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
  int a[3] ={0};
  rep(i,0,3)
  a[i]=rr;
  sort(a,a+3);
  printf("%d",a[0]+a[1]);
}




Measured memory_bytes: 256
using System;

namespace abc148A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            if (A == 1 && B == 2)
                Console.WriteLine(3);
            else if (A == 1 && B == 3)
                Console.WriteLine(2);
            else if (A == 2 && B == 1)
                Console.WriteLine(3);
            else if (A == 2 && B == 3)
                Console.WriteLine(1);
            else if (A == 3 && B == 1)
                Console.WriteLine(2);
            else
                Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    for (auto& in : a)
        cin >> in;
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        if (a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
        if (a[i - 1] > x) {
            ans += a[i - 1] - x;
            a[i - 1] = x;
        }
        ll tmp = a[i] + a[i - 1];
        if (tmp > x) {
            ans += tmp - x;
            a[i] -= min(tmp - x, a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    ll a;
    REP(i, n) {
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {

    let s = read_line();
    let mut bytes = vec![];
    for (ln, c) in s.into_bytes().iter().enumerate() {
        if ln % 2 == 0 {
            bytes.push(*c);
        }
    }


    let res = String::from_utf8(bytes).unwrap();
    println!("{}", res);
    

}


Measured memory_bytes: 4352
import bisect
n=int(input())
L=list(map(int,input().split()))

L.sort()
ans=0
for i in range(n):
  for j in range(i+1,n):
    index=bisect.bisect_left(L,L[i]+L[j])
    ans+=index-(j+1)
    
print(ans)

Measured memory_bytes: 3188
# coding:utf-8

INF = float('inf')


N = int(input())
S = input()

ans = 0
for i in range(1, N - 1):
    str_list = []
    score = 0

    for x in S[:i]:
        if x not in str_list: str_list.append(x)

    for xi in str_list:
        if xi in S[i:]: score += 1

    ans = max(ans, score)

print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ull N,sum=1,a[100050],b=0;	cin>>N;
	FOR(i,0,N){
      cin>>a[i];
      if(a[i]==0){
      	cout<<"0"<<endl;
        return 0;
      }
    }
  	FOR(i,0,N){
      	if(sum>1000000000000000000/a[i]){
        	cout<<"-1"<<endl;
          	return 0;
        }
    	sum*=a[i];
        if(sum>1000000000000000000){
        	cout<<"-1"<<endl;
          	return 0;
        }
    }
  	cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 4400
n, m = map(int, input().split())

brides = []
for _ in range(m):
    a, b = map(int, input().split())
    brides.append((a, b))


class Union:
    def __init__(self, val):
        self.val = val
        self.parent = self
        self.rank = 0

    def get_root(self):
        n = self
        while n.parent != n:
            n = n.parent
        return n

    def find_set(self):
        return self.get_root().val

ans = 0
for i in range(m):
    unions = []
    for val in range(n):
        unions.append(Union(val))
    for index, (a, b) in enumerate(brides):
        if i == index:
            continue
        x, y = unions[a - 1], unions[b - 1]
        x_root = x.get_root()
        y_root = y.get_root()
        if x_root.rank == y_root.rank:
            x_root.rank += 1
            y_root.parent = x_root
        elif x_root.rank > y_root.rank:
            y_root.parent = x_root
        else:
            x_root.parent = y_root

    groups = [None] * n
    for j, u in enumerate(unions):
        root = u.find_set()
        groups[j] = root
    for g in range(1, n):
        if groups[g - 1] != groups[g]:
            ans += 1
            break
print(ans)

Measured memory_bytes: 43484
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;
    ll ans = ao;
    if(ai == 0 || aj == 0 || al == 0){
        ans += ai/2*2;
        ans += aj/2*2;
        ans += al/2*2;
    }
    else{
        ll m = ai%2 + aj%2 + al%2;
        if(m == 0 || m == 1){
            ans += ai/2*2;
            ans += aj/2*2;
            ans += al/2*2;
        }
        else{
            ans += 3;
            ans += (ai-1)/2*2;
            ans += (aj-1)/2*2;
            ans += (al-1)/2*2;
        }
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a;
int DP[100002];
int main() {
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        DP[a]++;
        DP[a+1]++;
        DP[a+2]++;
    }
    int ans=0;
    for(int i=0;i<100002;i++)ans=max(ans,DP[i]);
    cout<<ans;
};


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


bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> work(n);
    vector<int> A(n),B(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
        work[i].first = i;
        work[i].second = b;
    }
    sort(work.begin(),work.end(),compare_by_b);
    int time = 0;
    for(auto p : work){
        
        int idx = p.first;
        if(time+A[idx] > B[idx]){
            cout<<"No"<<endl;
            return 0;
        }
        time += A[idx];
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long x;
	cin >> x;

	long long ans = x / 11;
	ans *= 2;

	long long v = x % 11;

	if (v == 0) {
	}
	else if (v <= 6) {
		ans += 1;
	}
	else {
		ans += 2;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3576
import collections

k = int(input())

li = [str(i) for i in range(1,10)]
q = collections.deque(li)
count = 0
n = 10 ** 6

for i in range(1, n):
    a = q.popleft()
    count += 1
    if count == k:
        print(a)
        exit(0)
    num = int(a[-1])
    if num != 0:
        aa = a + str(num-1)
        q.append(aa)
    aa = a + str(num)
    q.append(aa)
    if num != 9:
        aa = a + str(num+1)
        q.append(aa)

Measured memory_bytes: 17012