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

using namespace std;

typedef long long ll;

int main() {
    ll N, A[51];

    cin >> N;
    ll mmax = -1000001, mmin = 1000001, maxAbs = 0;
    int maxAbsIdx = 0;

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        mmax = max(mmax, A[i]);
        mmin = min(mmin, A[i]);
        if (abs(A[i]) > maxAbs) {
            maxAbs = abs(A[i]);
            maxAbsIdx = i;
        }
    }

    if (maxAbs == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<string> ans;
    
    if (mmax > 0 && mmin < 0) {
        if (A[maxAbsIdx] > 0) {
            // make everything positive
            for (int i = 1; i <= N; i++) {
                if (A[i] < 0) {
                    A[i] += maxAbs;
                    char s[100];
                    sprintf(s, "%d %d\n", maxAbsIdx, i);
                    ans.push_back(s);
                }
            }
        } else {
            // make everything negative
            for (int i = 1; i <= N; i++) {
                if (A[i] > 0) {
                    A[i] -= maxAbs;
                    char s[100];
                    sprintf(s, "%d %d\n", maxAbsIdx, i);
                    ans.push_back(s);
                }
            }
        }
    }

    if (A[maxAbsIdx] > 0) {
        for (int i = 2; i <= N; i++) {
            if (A[i-1] > A[i]) {
                A[i] += A[i-1];
                char s[100];
                sprintf(s, "%d %d\n", i-1, i);
                ans.push_back(s);
            }
        }
    } else {
        for (int i = N - 1; i >= 1; i--) {
            if (A[i] > A[i+1]) {
                A[i] += A[i+1];
                char s[100];
                sprintf(s, "%d %d\n", i+1, i);
                ans.push_back(s);
            }
        }
    }
    /*
    for (int i = 1; i <= N; i++) {
        cout << A[i] << " ";
    }
    cout << endl;
    */
    cout << ans.size() << endl;
    for (const auto& e : ans) {
        std::cout << e;
    }
}


Measured memory_bytes: 3728
///    Md.ASADUZZAMAN
///    Dept of ICT
///    MBSTU
#include<bits/stdc++.h>
using namespace std;

#define fr(i,a,b) for(int i=(a);i<(b);i++)

#define rfr(i,a,b) for(int i=(b-1);i>=(a);i--)
#define freach(i, c) for( __typeof( (c).begin() ) i = (c).begin(); i != (c).end(); ++i )
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

#define PINF INT_MAX
#define MINF INT_MIN
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mset(a,c) memset(a,c,sizeof a)
#define clr(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define psi pair<sting,int>
#define pis pair<int,string>
#define ff first
#define ss second
#define vs vector<string>
#define vi vector<int>
#define vll vector<long long>
#define vpi vector<pair<int,int> >
#define vpl vector<pair<long long,long long> >

#define qi  queue<int>
#define ql  queue<long>
#define qll queue<long long>
#define PQ priority_queue

#define mpii map<int,int>
#define mpsi map<string,int>
#define mpci map<char,int>

#define bug(x) cout<<#x<<": "<<x<<endl
#define bug1(x,y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<endl
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define pi acos(-1.0)
#define rad(x) (((1.0 * x * pi) / 180.0))
#define deg(x) (((x * 180.0) / (1.0 * pi)))
#define sinr(x) (sin(rad(x)))
#define cosr(x) (cos(rad(x)))
#define tanr(x) (tan(rad(x)))
#define asind(x) (deg((asin(x))))
#define acosd(x) (deg((acos(x))))
#define atand(x) (deg((atan(x))))

#define setbiton(x, i) (x |= (1 << i))
#define setbitoff(x, i) (x ^= (1 << i))
#define countbit(x) __builtin_popcountll((ll)x)
#define resetbit(x, i) (x &= (~(1 << i)))

#define LB(a,x) (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.

#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())


#define input() freopen("in0.txt","r",stdin)
#define output()freopen("out0.txt","w",stdout)
#define fast() ios_base::sync_with_stdio(0);cin.tie();


#define IN scanf
#define OUT printf
//    #define SI(a) scanf("%d",&a)
//    #define SL(a) scanf("%lld",&a)
//    #define SD(a) scanf("%lf",&a)
//   #define OI(a) printf("%d",a)
//    #define OL(a) printf("%lld",a)
//    #define OD(a) printf("%lf",a)
//     #define ON() printf("\n")
#define ll long long
#define ull unsigned long long
#define EPS 1e-9
#define MOD 1000000007
int main()
{
    #ifndef ONLINE_JUDGE
    //input();
    //output();
    #endif
    fast();
    ll n,t,a,b,x,y,z,w;
    while(cin>>w>>a>>b)
    {
       if(a>b)
        swap(a,b);
       if(b-(a+w)<0)
        cout<<0<<endl;
       else cout<<b-(a+w)<<endl;

    }


return 0;
}








Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include <string>
using namespace std;
int main()
{
    int N,M;
    string a,b;
    string c;
    cin>>a>>b;

    cin>>N>>M;
   cin>>c;
   if(c==a)
    cout<<N-1<<' '<<M;
   else
    cout<<N<<' '<<M-1;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

struct UnionFind {
	vector<int> data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}

	int find(int k) {
		if(data[k] < 0) return(k);
		return data[k] = find(data[k]);
	}

	bool same(int x, int y)	{
		return find(x) == find(y);
	}

	int size(int k)	{
		return -data[find(k)];
	}
};

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

    UnionFind uf(n);
    rep(i, m) {
        int x, y; cin >> x >> y;
        x--; y--;
        uf.unite(x, y);
    }

    int ans = 0;
    rep(i, n) {
        if (uf.same(a[i], i)) ans++;
    }

    debug(uf.data);

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int i, j, N, *A, flag, temp, count=0;

  scanf("%d", &N);

  A = malloc( N * sizeof(int));

  flag = 1;

  for( i=0; i<N; i++ ) scanf("%d", &A[i]);

  while(flag==1)
    {
      flag = 0;

      for( j=N-1; j>0; j-- )
	{
	  if( A[j] < A[j-1] )
	    {
	      temp = A[j];
	      A[j] = A[j-1];
	      A[j-1] = temp;
	      flag = 1;
	      count++;
	    }
	}
    }

  for( i=0; i<N; i++ )
    {
      printf("%d", A[i]);
      if( i == N-1 )
	{
	  printf("\n");
	  break;
	}
      printf(" ");
    }

  printf("%d\n", count);

  return 0;
}
  



Measured memory_bytes: 2104
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	vector<lint> alp(26);
	for (const auto &c : s) alp[c - 'a']++;

	lint ans = s.size() * (s.size() - 1) / 2;
	for (const auto &e : alp) ans -= e * (e - 1) / 2;
	
	cout << ans + 1 << "\n";

	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  string s;
  cin>>N>>s;
  vector<string> s1={"SS","WW","SW","WS"};

  rep(x,4){
    reps(i,1,N-1){
      s1[x]+=( !(s1[x][i]==s1[x][i-1]) xor (s[i]=='o') ? 'S' : 'W' );
    }

    if( ( (s1[x][0]==s1[x][N-2]) xor (s[N-1]=='o') xor s1[x][N-1]=='S') and ( (s1[x][N-1]==s1[x][1]) xor (s[0]=='o') xor s1[x][0]=='S' ) ){
      cout << s1[x] <<"\n";
      return;
    }

  }

  cout << -1 <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main(){
    int f = 0, cf = 0;
    string s; cin >> s;

    rep(i,s.size()){
        if(i == 0 && s[0] == 'A'){
            f = true;
        }else if(i >= 2 && i <= s.size()-2 && s[i] == 'C'){
            cf++;
            if(cf > 1){
                cf = 0;
                break;
            }
        }else if(s[i] < 'a' || s[i] > 'z'){
            f = false;
            break;
        }
    }

    cout << (f && cf ? "AC" : "WA") << endl;  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int64_t x;
    cin>>x;
    int64_t a=100;
    for(int i=1;;i++){
        a+=a*0.01;
    if(a>=x){
        cout<<i<<endl;
        break;
    }
    }
}


Measured memory_bytes: 3636
N=int(input())

if N==1:
  print('0')
  exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
def divcount(n):
  cnt=0
  while n>=0:
    n-=cnt+1
    cnt+=1
  return cnt-1

s=factorization(N)
t=[i[1] for i in s]
ans=0
for i in t:
  ans+=divcount(i)
print(ans)

Measured memory_bytes: 9444
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N, K = list(map(int, input().split()))

    if K == 1:
        print("0")
    else:
        print(N - K)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
    long h,w;
    cin >> h >> w;
    if(w==1 || h==1){
        cout <<1;
    }else if(w%2&&h%2){
        cout << h/2 * w + w/2 + 1;
    }else if(w%2){
        cout << w * (h / 2);
    }else
        cout << h * (w / 2);
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
v_arr = gets.chomp.split.map(&:to_i)
c_arr = gets.chomp.split.map(&:to_i)

ans = 0

n.times do |i|
	if v_arr[i] - c_arr[i] > 0
		ans += v_arr[i] - c_arr[i]
	end
end

puts ans


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

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  double ans = 0.0000000000;
  for(int i = 0; i < n; i++){
  	cin >> a.at(i);
    a.at(i) = 1.0000000000/a.at(i);
    ans += a.at(i);
  }
  ans = 1.0000000000/ans;
  cout << fixed << setprecision(7);
  cout << ans << endl;
}

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

int main() {
    ll a,b,k;cin>>a>>b>>k;
    if(a<=k){
        k-=a;
        a=0;
        if(b<=k){
            b=0;
        }else{
            b-=k;
        }
    }else{
        a-=k;
    }
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> a(n);
  long long sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  long long x = a[0], y = sum - a[0];
  long long ans = abs(x - y);
  for(int i = 1; i < n - 1; i++){
    x += a[i];
    y -= a[i];
    ans = min(abs(x - y), ans);
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    int n;
    string s,l,r;
    cin >> n >> s;
    l = s.substr(0,n/2);
    r = s.substr(n/2);
    if (l == r){
        Yes;
    }else{
        No;
    }
    return 0;
}


Measured memory_bytes: 256
#include <string.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <fstream>
#include <iostream>
#define mod 1000000007
using namespace std;
ifstream f("date.in");
ofstream g("date.out");
int n,m,sum;
int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
    int x;
    cin>>x;
    sum+=x;


}
if(sum>n) cout<<-1;
else cout<<n-sum;


}


Measured memory_bytes: 3644
from sys import stdin
input = stdin.readline

INFTY = 2**21
WHITE = 0
GRAY = 1
BLACK = 2

n = int(input())

M = [[0]*n for _ in range(n)]

for i in range(n):
    ee = map(int, input().split())
    for j, e in enumerate(ee): # 先に1行分読み込んでから、eにわける
        if e == -1:
            M[i][j] = INFTY
        else:
            M[i][j] = e


def prim():
    d = [INFTY]*n
    p = [-1]*n
    color = [WHITE]*n

    d[0] = 0

    while True:
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i]) and (color[i] != BLACK):
                u = i
                minv = d[i]

        if u == -1:
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK) and (M[u][v] != INFTY):
                if d[v] > M[u][v]:
                    d[v] = M[u][v]
                    p[v] = u
                    color[v] = GRAY

    _sum = 0 # pythonは標準でsum関数があるので一応sumは使わないでおく
    for i in range(n):
        if p[i] != -1:
            _sum += M[i][p[i]]

    return _sum

print(prim())


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int x;
	cin >>x;
	x^=1;
	cout <<x;
	return 0; 
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3628
using System;

class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var b = int.Parse(Console.ReadLine());
        var c = int.Parse(Console.ReadLine());
        var d = int.Parse(Console.ReadLine());
        var e = int.Parse(Console.ReadLine());
        var k = int.Parse(Console.ReadLine());

        var all = true;
        all &= b - a <= k;
        all &= c - a <= k;
        all &= d - a <= k;
        all &= e - a <= k;
        all &= c - b <= k;
        all &= d - b <= k;
        all &= e - b <= k;
        all &= d - c <= k;
        all &= e - c <= k;
        all &= e - d <= k;

        Console.WriteLine(all ? "Yay!" : ":(");
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

    priority_queue<ll, vector<ll>, greater<ll>> que;
    rept(i, 1, 10)que.push(i); 
    int cnt = 0; ll num;
    while(cnt < k){
        num = que.top(); que.pop();
        cnt++;
        if(num%10>0)que.push(num*10 + num%10-1);
        que.push(num*10 + num%10);
        if(num%10<9)que.push(num*10 + num%10+1);
    }
    cout << num << ln;
}


Measured memory_bytes: 5368
#include <iostream>
#include <iomanip>
using namespace std;
int main() {

	double ans = 0;

	int n; cin >> n;
	for(int i = 0; i < n; i++){
		double a; cin >>a;
		string s; cin >> s;

		if(s == "JPY")
			ans += a;
		else
			ans += a * 380000.0;
	}

	cout <<ans;

    return 0;
}


Measured memory_bytes: 256
def main():
  A,B,C,K = map(int, input().split())
  
  sum = 0
  
  if K > A:
    sum += 1 * A
  elif K <= A:
    sum += 1 * K
  
  if K > A + B:
    sum += -1 * (K - (A + B))
  
  print(sum)
  
main()

Measured memory_bytes: 9048
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

struct vertex {
    double x, y;
};
 
double determinant( vertex a, vertex b ) {
    return ( (a.x * b.y) - (a.y * b.x) );
}

int main () {
   vertex *coordinate;
   double area;
   int i, n, order = 0;
   while( cin >> n ){
      if( n == 0 )
         break;
      coordinate = new vertex[n+1];
      for( i = 0; i < n; i++ )
         cin >> coordinate[i].x >> coordinate[i].y;
      coordinate[n] = coordinate[0];
      area = 0;
      for( i = 0; i < n; i++)
         area += determinant( coordinate[i], coordinate[i+1] );
      cout << ++order << " " << fixed << setprecision(1) << fabs( area/2 ) << endl;
   }
 
   return 0;
}

Measured memory_bytes: 3264
def resolve():
    s = input()
    k = int(input())
    l = len(s)
    subs = []
    for i in range(l):
        for j in range(i + 1, i + k + 1):
            sub = s[i:j]
            if sub not in subs:
                subs.append(sub)
    print(sorted(set(subs))[k - 1])


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 40432
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
int l[1005],r[1005];
int p1,p2,now;
void solve(ll x)
{
    //cout<<x<<endl;
    if(x==1)return ;
    if(x%2==1)l[++p1]=++now,x--;
    r[++p2]=++now;
    solve(x/2);
}
int main()
{
    cin>>n;
    solve(n+1);
    printf("%d\n",now*2);
    for(int i=1;i<=p1;i++)cout<<now-l[i]+1<<' ';
    for(int i=p2;i>=1;i--)cout<<now-r[i]+1<<' ';
    for(int i=1;i<=now;i++)cout<<i<<' ';
    return 0;
}


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

using namespace std;

int main(){
	string a , b;
	cin>>a>>b;
	if(b.size() != a.size() + 1) cout<<"No"<<endl;
	else{
		bool s = 1;
		for(int i = 0 ; i < a.size() ; i++) if(a[i] != b[i]) s = 0;
		cout<<(s ? "Yes" : "No")<<endl;
	}
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <sysexits.h>
int main(void){
  int x;
  if(scanf("%d",&x)!=1){
exit(1);
}
  if(x==3 || x==5 ||x ==7){
  printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}







Measured memory_bytes: 128
n = int(input())
ans = 0

li = [[0]*10 for _ in range(10)]

for i in range(1,n+1):
    j = str(i)
    li[int(j[0])][int(j[-1])] += 1

for i in range(1,10):
    for j in range(1,10):
        ans += li[i][j] * li[j][i]

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }

  return x;
}

Node treeMaximum(Node x){

  while(x->right!=NIL){
    x=x->right;
  }

  return x;
  
}

Node treeSearch(Node u, int k){
  u=root;

  while(u!=NIL && u->key!=k){
    if(k < u->key) u=u->left;
    else u=u->right;
  }

  return u;
  
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right!=NIL) return treeMinimum(x->right);

  y=x->parent;

  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }

  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;

  if(z->left==NIL || z->right==NIL) y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;

  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;
  
}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }

  z->parent=y;

  if(y==NIL) root=z;
  else if (z->key < y->key) y->left=z;
  else y->right=z;

}

void inorder(Node u){
  
  if(u==NIL) return;

  if(u->left!=NIL) inorder(u->left);
  
  printf(" %d",u->key);
  
  if(u->right!=NIL) inorder(u->right);
  
}

void preorder(Node u){

  if(u==NIL) return;
  
  printf(" %d",u->key);
  
  if(u->left!=NIL) preorder(u->left);
  

  if(u->right!=NIL) preorder(u->right);
  
  
}

int main(){
  int n, i, x;
  char com[20];
  
  scanf("%d", &n);

  for(i = 0; i < n; i++ ){
    scanf("%s", com);
    if( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20556
#define MOD 1000000007
#define  endll   "\n"
#define  ll long long
#define vi vector<int>
#define vll vector<ll>

#include <bits/stdc++.h>

using namespace std;
int const N = 2e5 + 5;
ll arr[N];
set<pair<int, int>> st;
int flag[N];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input", "rt", stdin);
    //freopen("output", "wt", stdout);
#endif
    int n;
    cin>>n;
    map<ll, ll> mp;
    for (ll i = 1; i <= 100; i++) {
        for (ll j = 1; j <= 100; j++)
            for (ll k = 1; k <= 100; k++) mp[i * i + j * j + k * k + i * k + k * j + j * i]++;
    }
    for (int i = 1; i <= n; i++)
        cout << mp[i] << endll;
}

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

using namespace std;

typedef long long ll;

int main(){
 string s; cin >> s;
  for(int i = 0; i < 3; i++){
    if( s[i] == s[i+1]){ cout << "Bad" << endl; return 0;}
    
  }

  cout <<"Good" << endl;
  
  return 0;
}

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

int a, b, c, d, e, f;

int main() {
  scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
  int min1 = 1000, min2 = 1000;
  min1 = min(min(a, b), min(c, d));
  min2 = min(e, f);
  printf("%d\n", a + b + c + d + e + f - min1 - min2);
}



Measured memory_bytes: 2732
n=int(input())
s=list(input())
e_count=s.count("E")
w_count=n-e_count
w_left=0
e_right=e_count
c=[]
for i in range(n):
    if s[i]=='W':
        c+=[w_left+e_right]
        w_left+=1
    else:
        e_right-=1
        c+=[w_left+e_right]
print(min(c))

Measured memory_bytes: 17780
t,a,k = map(int, input().split())
x = 0

for i in range(k):
        if x == 0:
                t = int(t/2)
                a += t
                x = 1
        elif x == 1:
                a = int(a/2)
                t += a
                x = 0

print(t)
print(a)

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

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	map <string, int> m; string s;
	cin >> t;
	while(t--) {
		cin >> s;
		m[s];
	}

	cout << m.size() << "\n";
}

Measured memory_bytes: 19288
from itertools import product
n_str = input()
n = int(n_str)
ans = 0
for i in range(3, len(n_str) + 1):
    for temp in list(product(["3", "5", "7"], repeat=i)):
        if "3" in temp and "5" in temp and "7" in temp and int("".join(temp)) <= n:
            ans += 1
print(ans)

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

int main()
{   
    string s;
    cin>>s;
    rep(i,s.length()) cout<<"x";
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
 

int main(){
    LL n,k;cin >> n >> k;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<LL> c(n+1,0);
    for (int i = 0; i < n; i++) {
        c[i+1] = (c[i] + a[i])%k;
    }
    map<LL,LL> ma;
    ma[0]++;
    LL ans = 0;
    for (int i = 1; i <= n; i++) {
        if(i - k >= 0) ma[(c[i - k] - ((i - k)%k) + k)%k]--;
        ans += ma[(c[i] - (i%k) + k)%k];
        ma[(c[i] - (i%k) + k)%k]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
RRLRL
---+/
/+---test
RRLLLLRLRRLL
---+/
/+---test
RRRLLRLLRRRLLLLL
---+/

void main(string[] args) {
  const S = readln.chomp;

  auto ans = new size_t[S.length];

  char prev = 'R';
  size_t st, md;
  foreach (i, c; S~'R') {
    if (prev != c) {
      if (c == 'L') {
        md = i;
      }
      if (c == 'R') {
        const len = i - st;
        ans[md-1] = ans[md] = len/2;

        if (ans[md]*2 != len) {
          if ((md-st)%2 == 0) {
            ++ans[md];
          } else {
            ++ans[md-1];
          }
        }

        st = i;
      }
    }
    prev = c;
  }
  foreach (i, v; ans) {
    if (i != 0) " ".write;
    v.write;
  }
  writeln;
}


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

using namespace std;

int N, M, G[100][100];

int dfs(int idx, vector< int > used)
{
  if(idx == N) {
    if(used.size() <= 1) return (0);
    int res = 0;
    for(int i : used) {
      int ret = 11451419;
      for(int j : used) if(i != j) ret = min(ret, G[i][j]);
      res += ret;
    }
    return (res);
  } else {
    int res = dfs(idx + 1, used);

    bool isnext = true;
    for(int i : used) if(G[idx][i] == 0) isnext = false;
    if(isnext) {
      used.push_back(idx);
      res = max(res, dfs(idx + 1, used));
    }
    return (res);
  }
}

int main()
{
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    --A, --B;
    G[A][B] = G[B][A] = C;
  }

  cout << dfs(0, vector< int >()) << endl;
}

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

int n[9];
char c[9];
int a[9];

bool is_consequence_number(int* p){
    if(n[*p]==n[*(p+1)]+1&&n[*p]==n[*(p+2)]+2) return true;
    else return false;
}

bool is_same_color(int* p){
    if(c[*p]==c[*(p+1)]&&c[*p]==c[*(p+2)]) return true;
    else return false;
}

bool is_same_number(int* p){
    if(n[*p]==n[*(p+1)]&&n[*p]==n[*(p+2)]) return true;
    else return false;
}

bool judge(){
    for(int i=0;i<3;i++){
        if(!(is_same_color(a+3*i)&&(is_same_number(a+3*i)||is_consequence_number(a+3*i)))) return false;
    }
    return true;
}

int solve(){
    for(int i=0;i<9;i++) scanf("%d",n+i);
    for(int i=0;i<9;i++){
        getchar();
        c[i]=getchar();
        a[i]=i;
    }
    do{if(judge()) return 1;}while(next_permutation(a,a+9));
    return 0;
}

int main(){
    int t;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        printf("%d\n",solve());
    }
    return 0;
}

Measured memory_bytes: 1028
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007


int main() {
  int A,B,C,X,ans=0;
  cin >> A >> B >> C >> X;

  rep(i,A+1){
    rep(j,B+1){
      rep(k,C+1){
        if(500*i + 100*j + 50*k == X){
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
def getInput():
    return [int(x) for x in input().split()]

N, M = getInput()
nums = getInput()
nums = sorted(nums)
rep = []
for i in range(M):
    b, c = getInput()
    rep.append((b, c))
rep = sorted(rep, key=lambda x: x[1], reverse=True)
ans = 0
minIndex = 0
isFinished = False
for b, c in rep:
    for _ in range(b):
        if minIndex < len(nums) and nums[minIndex] < c:
            ans += c
            minIndex += 1
        else:
            isFinished = True
            break
    
    if isFinished:
        break
if minIndex < len(nums):
    ans += sum(nums[minIndex:])
print(ans)

Measured memory_bytes: 23288
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, m;
vector<int> a, b;
vector<int> reach;
/**********************************************/

int main(){
    cin >> n >> m;
    a.resize(m+5); b.resize(m+5);
    REP(i, m) cin >> a[i] >> b[i];

    REP(i, m){
        if(a[i] == n) reach.pb(b[i]);
        else if(b[i] == n) reach.pb(a[i]);
    }
    VSORT(reach);
    REP(i, m){
        if(a[i] == 1){
            auto itr = lower_bound(reach.begin(), reach.end(), b[i]);
            if(itr != reach.end() && b[i] == *itr){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }else if(b[i] == 1){
            auto itr = lower_bound(reach.begin(), reach.end(), a[i]);
            if(itr != reach.end() && b[i] == *itr){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 2428
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int x=x2-x1,y=y2-y1;
  cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x<<endl;

}


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

int main(void){
	double a[20],b[20],A,B,C,Z,S;
	int i=0,j;
	
	while(scanf("%lf,%lf",&a[i],&b[i])!=EOF)i++;
	
	for(j=1;j<i-1;j++){
		A=sqrt((a[0]-a[j])*(a[0]-a[j])+(b[0]-b[j])*(b[0]-b[j]));
		B=sqrt((a[j]-a[j+1])*(a[j]-a[j+1])+(b[j]-b[j+1])*(b[j]-b[j+1]));
		C=sqrt((a[0]-a[j+1])*(a[0]-a[j+1])+(b[0]-b[j+1])*(b[0]-b[j+1]));
		Z=(A+B+C)/2;
		S+=sqrt(Z*(Z-A)*(Z-B)*(Z-C));
	}
	printf("%f\n",S);
	
return 0;
}

Measured memory_bytes: 652
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long h = long.Parse(Console.ReadLine());

            long tmp = 1;

            while (true)
            {
                if (tmp > h) break;
                tmp *= 2;
            }

            Console.WriteLine(tmp - 1);
        }
    }
}

Measured memory_bytes: 27528
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC150B solver = new ABC150B();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC150B {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      String s = in.next();
      int cnt = 0;
      for (int i = 0; i < n - 2; i++) {
        if (s.charAt(i) == 'A' &&
            s.charAt(i + 1) == 'B' &&
            s.charAt(i + 2) == 'C') {
          cnt++;
        }
      }
      out.println(cnt);
    }

  }
}



Measured memory_bytes: 21844
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(char, "x", long, "y");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto point = aryread();

    auto t = readln.chomp.map!(x => "rsp".countUntil(x)).array();
    auto janken = new long[][](n, 3);
    foreach (i; iota(n))
    {
        foreach (j; iota(3))
        {
            long getPoint(long machine, long takahashi)
            {
                if (machine == (takahashi + 1) % 3)
                    return point[takahashi];
                else
                    return 0;
            }

            if (i - k < 0)
                janken[i][j] = getPoint(t[i], j);
            else
                janken[i][j] = max(janken[i - k][(j + 1) % 3], janken[i - k][(j + 2) % 3]) + getPoint(t[i],
                        j);
        }
    }
    // janken.each!(x => x.writeln());
    long ans;
    foreach (i; iota(k))
    {
        ans += janken[$ - 1 - i].reduce!(max);
    }
    ans.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 8696
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

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

    ll ans = 0;
  	/*
    for(ll i = 1; i < n+1; i++){
        //ans += (i+1) % (n-i);
      	if(i == n){
          	ans += i % 1;
        }else{
      		ans += i % (i+1);
        }
      
        
      	cout << "ans =  " << ans << endl;

    }
    */
	ans = n*(n-1) /2;
    cout << ans << endl;


}



Measured memory_bytes: 256
N = gets.to_i
abc_list = N.times.map { gets.split.map(&:to_i) }
dp = Array.new(N + 10)
dp[0] = { a: 0, b: 0, c: 0 }
N.times do |i|
  a, b, c = abc_list[i]
  dp[i + 1] = {}
  dp[i + 1][:a] = [
    dp[i][:b] + a,
    dp[i][:c] + a
  ].max
  dp[i + 1][:b] = [
    dp[i][:a] + b,
    dp[i][:c] + b
  ].max
  dp[i + 1][:c] = [
    dp[i][:a] + c,
    dp[i][:b] + c
  ].max
end
puts dp[N].values.max


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll x, y;
    cin >> x >> y;
    ll ans = 0;

    ll diff_abs = abs(y) - abs(x);
    if (diff_abs > 0) {
        if (x < 0) {
            ans++;
        }
        ans += diff_abs;
        x = abs(y);
    } else if (diff_abs < 0) {
        if (x > 0) {
            ans++;
        }
        x = -abs(y);
        ans += -diff_abs;
    }

    if (x != y) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var K = cin.ReadInt;
            var S = cin.Read;

            if (S.Length <= K)
            {
                WriteLine(S);
                return;
            }

            WriteLine(S.Substring(0,K) + "...");
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 27916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

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

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};
class rcompare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<0>(a) < get<0>(b));
	}
};
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == n * 2 - 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		if (n == 2) {
			printf("3\n");
			printf("1\n");
			printf("2\n");
		}
		else if (x == 2) {
			rep(i, n * 2 - 5) {
				printf("%d\n", (i + 1 + (i + 1 >= x - 3 / 2 ? 4 : 0)));
				if (i == n - 3) {
					printf("3\n");
					printf("1\n");
					printf("2\n");
					printf("4\n");
				}
			}
		}
		else {
			rep(i, n * 2 - 5) {
				printf("%d\n", (i + 1 + (i >= x - 3 ? 4 : 0)));
				if (i == n - 3) {
					printf("%d\n", x - 2);
					printf("%d\n", x);
					printf("%d\n", x + 1);
					printf("%d\n", x - 1);
				}
			}
		}
	}


}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
#define WEIGHTSUM weight + i
#define VALUESUM maxValue[i] + value
using namespace std;
bitset <100005> foundWeight;
ll maxValue[100005];

int main() {
	ll n, w, weight, value, result = 0;

	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> weight >> value;

		for (int i = w; i >= 1; i--)
			if (foundWeight[i] && WEIGHTSUM <= w) {
				maxValue[WEIGHTSUM] = max(maxValue[WEIGHTSUM], VALUESUM);
				foundWeight[WEIGHTSUM] = 1;
				//result = max(result, VALUESUM);
			}

		maxValue[weight] = max(maxValue[weight], value);
		foundWeight[weight] = 1;
	}

	for (int i = 1; i <= w; i++)
		result = max(result, maxValue[i]);
    cout << result;

	return 0;
}


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

int main() {

  int N;
  cin >> N;

  set<string> S;

  for (int i = 0; i < N; i++) {
    string S_;
    cin >> S_;
    S.insert(S_);
  }

  if (S.size() == 3) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }

}

Measured memory_bytes: 256