akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(ABC):
    if ABC[0] == ABC[1] == ABC[2]:
        return 'Yes'
    return 'No'


def main():
    ABC = read_int_n()
    print(slv(ABC))


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    string S;
    int N, K;
    cin >> N >> K >> S;
    for(int i = 0; i < N; i++)
    {
        if(i != K - 1) cout << S.at(i);
        else if(i == K - 1 && S.at(i) == 'A') cout << 'a';
        else if(i == K - 1 && S.at(i) == 'B') cout << 'b';
        else if(i == K - 1 && S.at(i) == 'C') cout << 'c';
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

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

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 3e5 + 5, md = 1e9 + 7;

inline int add(int x, int y) {
    x += y;
    if(x >= md) x -= md;
    return x;
}

inline int sub(int x, int y) {
    x -= y;
    if(x < 0) x += md;
    return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

inline int fpow(int x, int y) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = mul(ans, x);
        y >>= 1; x = mul(x, x);
    }
    return ans;
}

ll a[N];
int n, ans;

int main() {
    read(n);
    for(register int i = 1; i <= n; i++) read(a[i]);
    for(register int bit = 0; bit < 60; bit++) {
        int cnt = 0;
        for(register int i = 1; i <= n; i++) cnt += ((a[i] >> bit) & 1);
        ans = add(ans, mul((1ll << bit) % md, mul(cnt, n - cnt)));
    }
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  string s;
  cin >> s;
  int res = 0;
  // cout << s << endl;
  // cout << stoi(s.substr(0,1)) << endl;
  for(int i = 0;i <(1<< 3);i++){
    // cout << "i = " << i << endl;
    res = stoi(s.substr(0,1));
    vector<char> op(3);
    for(int j = 0; j < 3; j ++){
      // cout << s.substr(j+1,1) << ", "<< (i&(1<<j))<< endl;
      if(i&(1<<j)){
	// cout << s.substr(j + 1,1) << "res" << endl;
	res += stoi(s.substr(j+1,1));
	op[j] = '+';
      }else{
	// cout << s.substr(j + 1,1) << "res" << endl;
	res -= stoi(s.substr(j + 1,1));
	op[j] = '-';
      }
      // cout << res << endl;
    }
    if(res == 7){
      cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] <<s[3] << "=7"<< endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){ int N; cin >> N; 
 string S; cin >> S;
  vector<int> B(N+1,0); vector<int> W(N+1,0);
  //'.'が白、'#'が黒を表す 
  //左端からの黒の個数をB,右端からの白の個数をWに保存する
  
  for(int i = 0; i < N; i++){
    if(S[i] == '#'){ B[i+1] = B[i]+1;}
    else{ B[i+1] = B[i];}
                 }
  for(int j = N-1; j >= 0; j--){
    if(S[j] == '.'){ W[j] = W[j+1] + 1;}
    else{ W[j] = W[j+1];}
  }
                 
 int ans = 1e9;
 for(int i = 0; i <= N; i++){ ans = min( ans, B[i]+W[i]);}
 cout << ans << endl; return 0;}                
                 

Measured memory_bytes: 2180
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <unordered_map>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
#define MOD 1000000007

template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int n;
ll k;

vector<vector<ll>> matmul(vector<vector<ll>> &a, vector<vector<ll>>&b, int n){
  vector<vector<ll>> ret(n, vector<ll>(n, 0));

  for(int i=0;i<n;++i)
  {
    for(int j=0;j<n;++j)
    {
      for(int k=0;k<n;++k)
      {
        ret[i][j] += a[i][k] * b[k][j];
        ret[i][j] %= MOD;
      }
    }
  }

  return ret;
}

vector<vector<ll>> pow(vector<vector<ll>> m, ll x, int n)
{
  vector<vector<ll>> ret(n, vector<ll>(n, 0));

  for(int i=0;i<n;++i)
  {
    ret[i][i] = 1;
  }

  while(k > 0)
  {
    if(k&1) ret = matmul(ret, m, n);
    m = matmul(m, m, n);
    k >>= 1;
  }

  return ret;
}

int main(){
    std::ios::sync_with_stdio(false);
    cin >> n >> k;
    vector<vector<ll>> a(n, vector<ll>(n, 0));
    for(int i=0;i<n;++i)
    {
      for(int j=0;j<n;++j)
      {
        cin >> a[i][j];
      }
    }
    a = pow(a, k, n);

    ll res = 0;
    for(int i=0;i<n;++i)
    {
      for(int j=0;j<n;++j)
      {
        res += a[i][j];
        res %= MOD;
      }
    }
    cout << res << endl;
}

Measured memory_bytes: 384
def main():
    N, X = map(int, input().split())
    m = [int(input()) for _ in range(N)]
    #print(m)
    m.sort()
    #print(m)
    count = 0
    for i in range(N):
        if X - m[i] < 0:
            break
        X -= m[i]
        count += 1
    while True:
        if X - m[0] < 0:
            break
        X -= m[0]
        count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=B[A[0]-1]

for i in range(1,N):
    ans=ans+B[A[i]-1]
    if A[i]==A[i-1]+1:
        ans+=C[A[i-1]-1]

print(ans)

Measured memory_bytes: 3064
def typical_stairs():
    n, m, *dangerous = map(int, open(0).read().split())
    dangerous = set(dangerous)
    mod = 1000000007
    dp = [0] * (n + 1)
    dp[0] = 1
    if 1 not in dangerous:
        dp[1] = 1
    for i in range(2, n + 1):
        if i not in dangerous:
            dp[i] = (dp[i - 2] + dp[i - 1]) % mod
    print(dp[-1])


if __name__ == '__main__':
    typical_stairs()


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

int main(){
  vector<int> D(3); cin>>D[0]>>D[1]>>D[2];
  sort(D.begin(),D.end());
  int cnt;
  if(D[0]%2==D[1]%2){
    cnt += (D[1]-D[0])/2;
    cnt += (D[2]-D[1]);
  }else if(D[0]%2==D[2]%2){
    cnt += (D[2]-D[0])/2;
    cnt += (D[2]-D[1])/2;
    cnt += 2;
  }else{
    cnt += (D[2]-D[1])/2;
    cnt += (D[2]-D[0])/2;
    cnt += 2;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = (1 << 18) + 10;
const int MAX = 1e5;
typedef long long ll;

int n, q;
#define pii pair<int,int>
pii a[maxN];
#define V first
#define W second

ll pre[maxN];
ll dp[512][MAX+1];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].V >> a[i].W;
  }

  const int limit = 512;
  for (int j = 0; j <= MAX; ++j)
    dp[1][j] = (a[1].W > j ? 0 : a[1].V);

  for (int i = 2; i < min(limit, n+1); ++i) {
    int par = i / 2;
    for (int j = 0; j <= MAX; ++j){
      dp[i][j] = dp[par][j];
      if (j >= a[i].W) dp[i][j] = max(dp[i][j], dp[par][j-a[i].W] + a[i].V);
    }
  }

  cin >> q;
  while (q--) {
    int x, L;
    cin >> x >> L;
    vector<int> node;

    while (x >= limit) {
      node.push_back(x);
      x /= 2;
    }
    ll ans = 0;
    int sz = node.size();
    for (int i = 0; i < (1 << sz); ++i) {
      ll Le = 0; int Ri = 0;
      for (int j = 0; j < sz; j++)
      if ((i >> j) & 1) {
        Le = Le + a[node[j]].V; Ri = Ri + a[node[j]].W;
      }
      if (Ri <= L) ans = max(ans, dp[x][L - Ri] + Le);
    }
    cout << ans << '\n';
  }
  return 0;
}


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

int main(){
  long long a,b,c;
  cin>>a>>b>>c;
  if(a%2&&b%2&&c%2){
    if(c<b)swap(b,c);
    if(b<a)swap(a,b);
    if(c<b)swap(b,c);
    cout<<a*b<<endl;
  }else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	int a[3]={0,0,0};
	ll res=1;
	for(int i=0;i<n;i++){
		int x,t=0;
		cin>>x;
		bool B=1;
		for(int j=0;j<3;j++){
			if(a[j]==x){
				if(B) a[j]++,B=0;
				t++;
			}
		}
		(res*=t)%=mod;
	}
	cout<<res<<endl;
	
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()
i = int(X**(1/2))
while i*(i+1)//2 < X:
	i += 1
print(i)


Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
//const int N=4e5+10;
#define ll long long
//#define d double
#define F first
#define S second
#define FastIO ios_base::sync_with_stdio(false),cin.tie(0)
#define fix std::fixed<<setprecision(10)
#define M 100000007
#define f(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define cl(n,m) (ceil(double(n)/double(m)))
#define T() int t; cin>>t; while(t--)

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

int main()
{
    FastIO;
    int n,x;
    cin>>n;
    vector<double>arr;
    f(n)
    {
        cin>>x;
        arr.pb(x);
    }
    sort(arr.begin(),arr.end());
    while(arr.size()!=1)
    {
        double x=arr[0];
        double y=arr[1];
        double z=(x+y)/2;
        arr.erase(arr.begin());
        arr.erase(arr.begin());
        arr.pb(z);
        sort(arr.begin(),arr.end());
    }
cout<<arr[0];
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

vector<PII> v;
int x, y, z, a, b, c;

inline void work() {
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; ++i) {
        cin >> z;
        v.emplace_back(z, 1);
    }
    for (int i = 0; i < b; ++i) {
        cin >> z;
        v.emplace_back(z, 2);
    }
    for (int i = 0; i < c; ++i) {
        cin >> z;
        v.emplace_back(z, 3);
    }
    sort(v.begin(), v.end(), greater<PII>());
    int geta = 0, getb = 0, getc = 0;
    LL ans = 0;
    for (int i = 0; geta + getb + getc < x + y; ++i) {
        if (v[i].second == 1) {
            if (geta < x) {
                ++geta;
                ans += v[i].first;
            }
        }
        else if (v[i].second == 2) {
            if (getb < y) {
                ++getb;
                ans += v[i].first;
            }
        }
        else {
            ++getc;
            ans += v[i].first;
        }
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

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

int main(){
string s;
  cin >> s;
  cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;

	return 0;
}


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

typedef long long ll;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  ll A, B;
  std::cin >> N >> A >> B;

  if (A != B && N == 1) {
    print(0);
    return 0;
  }

  ll ans = 0;
  if (A <= B) {
    ll min_val = B + (N - 1) * A;
    ll max_val = A + (N - 1) * B;
    ans = max_val - min_val + 1;
  }

  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
 
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a + b) < (c + d)) {
    cout << "Right" << endl;
  } else if ((a + b) > (c + d)) {
    cout << "Left" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

string s; int d; int dp[10001][101][2];
int main()
{
	cin>>s>>d; 
	int l = s.size();
	for(int i = 0; i<s[0]-'0'; i++)
	{
		dp[0][i%d][0]++;
	}
	dp[0][(s[0]-'0')%d][1]++; 
	for(int i = 1 ; i<l; i++)
	{
	 int v = s[i]-'0'; 
	 for(int j = 0 ; j<d; j++)
	 {
	 	for(int k = 0 ;k<=9; k++)
	 	{
	 		if(k==v)
	 		dp[i][(j+k)%d][1] = (dp[i][(j+k)%d][1]+ dp[i-1][j][1])%mo;
	 		else if(k<v)
	 		dp[i][(j+k)%d][0]= (dp[i][(j+k)%d][0]+ dp[i-1][j][1])%mo;
	 		
	 		dp[i][(j+k)%d][0] = (dp[i][(j+k)%d][0]+ dp[i-1][j][0])%mo;
		 }
	 }
	}

	cout<<((dp[l-1][0][0]+dp[l-1][0][1]-1)%mo+mo)%mo; 
}


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

int main() {
   int n, k;
   cin >> n >> k;
   vector<int>a(n);
   rep(i, 0, n)cin >> a[i];
   int ans = (n-k)/(k-1)+1;
   if((n-k)%(k-1)!=0)ans++;
   cout << ans << endl;
}

Measured memory_bytes: 640
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>

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

using namespace std;
// using P = pair<int, int>;

signed main() {
  int n; cin >> n;
  // vector<int> a(n);
  map<int, int> mem;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    mem[a]++;
  }

  int num = 0;
  for (const auto& [key, value] : mem) {
    if (key != value) {
      if (value > key) num += value - key;
      else num += value;
    }
  }

  cout << num << endl;

  return 0;
}


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

int main()
{
  int x,y;
  
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0){
      break;
    }
    if(x>y){
      cout << y << " " << x << endl;
    }else{
      cout << x << " " << y << endl;
    }
  }
  
  return 0;
} 

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;

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

	int n; cin >> n;
	if (n & 1)cout << n / 2 + 1 << '\n';
	else cout << n / 2 << '\n';





}




Measured memory_bytes: 256
n = int(input().strip())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)

for i in range(1, n, 1):
    if (a[i - 1] == (a[i] - 1)):
        ans += c[a[i] - 2]

print(ans)


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

using namespace std;

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

    for (int x = 0; x <= N; ++x) {
        if (10000 * x > Y) continue;
        for (int y = 0; y <= N - x; ++y) {
            if (10000 * x + 5000 * y > Y) continue;
            for (int z = 0; z <= N - y; ++z) {
                if (10000 * x + 5000 * y + 1000 * z != Y) continue;
                if (x + y + z == N) {
                    cout << x << " " << y << " " << z << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200001],c[200002],n,k;
int main()
{
	cin>>n>>k;
	register int i,j,t,s,f;
	for (i=1;i<=n;++i) {
		cin>>a[i];
	}
	for (j=1;j<=k;++j) {
		memset(c,0,sizeof(c));
		for (i=1;i<=n;++i) {
			++c[max(1,i-a[i])];
			--c[min(n+1,i+a[i]+1)];
		}
		s=0,f=1;
		for (i=1;i<=n;++i) {
			a[i]=s+=c[i];
			if (a[i]<n) f=0;
		}
		if (f)break;
	}
	for(i=1;i<=n;++i) {
		cout<<a[i]<<" ";
	}
}

Measured memory_bytes: 5188
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var x = IO.RSInt;
            int[] a = new int[n];
            Array.Copy(x, a, n);
            Array.Sort(x);

            var right = x[n / 2];
            var left = x[n / 2 - 1];

            for (int i = 0; i < n; i++)
            {
                if (a[i] <= left) WriteLine(right);
                else WriteLine(left);
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 38236
N,X,Y=map(int,input().split())
ans=0
right=X-1
cycle=Y-X+1
left=N-Y
import copy
ring=copy.copy(cycle)
branchr=copy.copy(right)
if right>0:
    branchr+=1
branchl=copy.copy(left)
if left>0:
    branchl+=1
ring_branchr=0
ring_branchl=0
branchrl=0
count=0
if cycle%2==0:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k==cycle//2:
            ring = cycle//2
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2:
                ring_branchr-=2*(k-cycle//2)-1
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2:
                ring_branchl-=2*(k-cycle//2)-1
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
if cycle%2==1:
    for k in range(1,max(left+cycle//2,right+cycle//2,left+right+1)+1):
        if k>cycle//2:
            ring = 0
        if right>0:
            branchr-=1
            if k>right:
                branchr=0
        if left>0:
            branchl-=1
            if k>left:
                branchl=0
        if right>0:
            ring_branchr=min(2*(k-1),right*2)
            if k>cycle//2+1:
                ring_branchr-=2*(k-cycle//2-1)
            if ring_branchr<0:
                ring_branchr=0
        if left>0:
            ring_branchl=min(2*(k-1),left*2)
            if k>cycle//2+1:
                ring_branchl-=2*(k-cycle//2-1)
            if ring_branchl<0:
                ring_branchl=0
        if right>0 and left>0:
            if 3<=k<min(right,left)+3:
                branchrl+=1
            if k>max(right,left)+2:
                branchrl-=1
            if branchrl<0:
                branchrl=0
        ans=ring+branchr+branchl+ring_branchr+ring_branchl+branchrl
        print(ans)
        count+=1
for k in range(count+1,N):
    print(0)

Measured memory_bytes: 3828
import Data.Bits 

main = do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    print $ solve a b

solve :: Int -> Int -> Int
solve a b
    | a == b = b
    | even a && even num = if odd $ num `div` 2 then 1 else 0
    | even a && odd num = if odd $ (num-1) `div` 2 then xor 1 b else b
    | otherwise = xor a $ solve (a+1) b
        where
            num = b-a+1

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int main(){
    ll N; cin>>N;
    N%=1000;
    if(!N) cout<<0<<endl;
    else cout<<1000-N<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define INF 1e9+5
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(ll i=a;i<(ll)b;i++)
#define ff first
#define ss second
#define int long long
int32_t main()
{
	IOS;
	int n,s;
	cin>>n>>s;
	int arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	int dp[n+1][s+1];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=s;j++)
			dp[i][j]=0;
	for(int i=1;i<=n;i++)
		if(arr[i]<=s)
			dp[i][arr[i]]=i;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=s;j++)
		{
			if(j>=arr[i])
				dp[i][j]=(0LL+dp[i][j]+dp[i-1][j-arr[i]])%mod;
			if(i>1)
				dp[i][j]=(0LL+dp[i][j]+dp[i-1][j])%mod;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=(0LL + ans + dp[i][s])%mod;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 70656
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  double r;
  cin >> r;
  cout << 2.0 * M_PI * r << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3804
S = list(input())
s = 0

for i in range (0,len(S),2):
    if S[i] == "L":
        s = 1
        break

for i in range (1,len(S),2):
    if S[i] == "R":
        s = 1
        break

if s == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38256
import std.algorithm;
import std.stdio;

void main ()
{
	int n, k;
	while (readf (" %s %s", &n, &k) > 0)
	{
		auto a = new int [] [n];
		foreach (i; 0..n - 1)
		{
			int u, v;
			readf (" %s %s", &u, &v);
			u--;
			v--;
			a[u] ~= v;
			a[v] ~= u;
		}

		int res = 0;
		int leaves;
		auto b = new bool [n];

		void recur (int v, int p, int d)
		{
			if (d < 0)
			{
				leaves += 1;
				return;
			}

			b[v] = true;
			int c = 0;
			foreach (u; a[v])
			{
				if (u != p)
				{
					c += 1;
					recur (u, v, d - 1);
				}
			}
		}

		foreach (v; 0..n)
		{
			b[] = false;
			int add = 0;
			b[v] = true;
			foreach (u; a[v])
			{
				leaves = 0;
				recur (u, v, k / 2 - 1);
				add = max (add, leaves);
			}
			res = max (res, sum (b) + (k & 1) * add);
		}

		if (k == 1)
		{
			res = 2;
		}

		writeln (n - res);
	}
}


Measured memory_bytes: 380
#!/usr/bin/env python3
class UnionFind:
    __slots__ = ['id','sz']

    def __init__(self, n):
        self.id = [-1] * n

    def root(self, x):
        if self.id[x] < 0:
            return x
        else:
            self.id[x] = self.root(self.id[x])
            return self.id[x]

    def find(self, x, y):
        return uf.root(x) == uf.root(y)

    def union(self, x, y):
        s1, s2 = self.root(x), self.root(y)
        if s1 != s2:
            if self.id[s1] <= self.id[s2]:
                self.id[s1] += self.id[s2]
                self.id[s2] = s1
            else:
                self.id[s2] += self.id[s1]
                self.id[s1] = s2
            return True
        return False

n = int(input())
a = list(map(int,input().split()))
uf = UnionFind(n)
ans=0
data=[0]*n
b=[0]*(n+1)
for i in range(n):
    b[a[i]]=i
for i in range(n,0,-1):
    r,l=0,0
    data[b[i]]=i
    if b[i]+1 <= n-1:
        if data[b[i]+1]>0:
            uf.union(b[i],b[i]+1)
    r=-uf.id[uf.root(b[i])]

    if b[i]-1>=0 and data[b[i]-1]>0:
        uf.union(b[i],b[i]-1)
    l=1-uf.id[uf.root(b[i])]-r
    ans+=(r*l)*i
print(ans)




Measured memory_bytes: 132944
#include <stdio.h>
  
using namespace std;
  
void outPut(int Array[],char mark){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n",mark,i);
    }
}
  
int main(){
    char mark[2];
    int n,S[14],H[14],C[14],D[14],tmp;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    scanf("%d",&n);
  
    for(int i = 0; i < n; i++){
        scanf("%s %d",mark,&tmp);
        switch(mark[0]){
        case 'S':
            S[tmp] = 1;
            break;
        case 'H':
            H[tmp] = 1;
            break;
        case 'C':
            C[tmp] = 1;
            break;
        case 'D':
            D[tmp] = 1;
            break;
        }
    }
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}





Measured memory_bytes: 2672
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5 2");
            WillReturn.Add("1 1 2 2 5");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 4");
            WillReturn.Add("1 1 2 2");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("10 3");
            WillReturn.Add("5 1 3 2 4 1 1 2 3 4");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int K = wkArr[1];

        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();

        int Answer = 0;
        var Query = AArr.GroupBy(X => X).OrderByDescending(X => X.Count()).Skip(K);
        foreach (var EachItem in Query) {
            Answer += EachItem.Count();
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 47032
import sys
from math import gcd
input = sys.stdin.readline

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            if i == j and k == i:
                ans += gcd(gcd(i, j), k)
            elif i == j or k == i or j == k:
                ans += 3 * gcd(gcd(i, j), k)
            else:
                ans += 6 * gcd(gcd(i, j), k)

print(ans)


Measured memory_bytes: 68168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n, k;
    cin >> n >> k;
    int sum = 0;
    while(n--){
        int x;
        cin >> x;
        sum += min(x, k-x);
    }
    cout << sum * 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,t;cin>>n>>t;
  int s[n];
  for(int i=0;i<n;i++)cin>>s[i];
  int res=t;
  for(int i=0;i<n-1;i++){
    res+=min(s[i+1]-s[i],t);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  char a;
  int b,c,i,j,k,m,n,gx[20],gy[20],rx,ry;

  while(scanf("%d\n",&n)){
    if(n==0) break;
    rx=10;ry=10;c=0;
    for(i=0;i<n;i++) scanf("%d %d\n",&gx[i],&gy[i]);
    scanf("%d\n",&m);
    for(i=0;i<m;i++){
      scanf("%c %d\n",&a,&b);
      for(j=0;j<b;j++){
        switch(a){
          case 'N': ry++; break;
          case 'E': rx++; break;
          case 'W': rx--; break;
          case 'S': ry--; break;
        }
        for(k=0;k<n;k++){
          if(gx[k]==rx && gy[k]==ry){ 
            c++;
            gx[k]=-1;gy[k]=-1;
            break;
          }
        }
      }
    }
    if(c==n) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 588
numbers = Array.new(10**5+1,0)
check = Array.new(10**5+1,0)
prime = [2]
1.upto(10**5/2-1) do |i|
  n = i*2 + 1
  r = n ** 0.5
  flag = true
  j = 0
  while flag && j < prime.length && prime[j] <= r
    flag = false if n % prime[j] == 0
    j += 1
  end
  prime << n if flag
end

prime.each do |i|
  numbers[i] = 1
end
(10**5+1).times do |i|
  check[i] = 1 if i%2 == 1 && numbers[i] == 1 && numbers[(i+1)/2] == 1
end

(10**5+1).times do |i|
  check[i] += check[i-1]
end

n = gets.to_i
n.times do
  a,b = gets.split.map(&:to_i)
  puts check[b] - check [a-1]
end
#p prime[0..15]


Measured memory_bytes: 4092
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        k:usize,
        a:[i64;n],
    }
    let modulo = 1e9 as i64 + 7;
    let num_zero = a.iter().filter(|&&x| x == 0).count();
    if n - num_zero < k {
        println!("{}", 0);
        return;
    }
    let mut plus = a.iter().filter(|&&x| x > 0).copied().collect::<Vec<_>>();
    let mut minus = a.iter().filter(|&&x| x < 0).copied().collect::<Vec<_>>();
    let all_minus = plus.len() == 0;
    let minus_odd = minus.len() % 2 != 0;
    let just_k = plus.len() + minus.len() == k;
    let is_not_plus = (all_minus && k % 2 != 0) || (just_k && minus_odd);
    if is_not_plus {
        //絶対0以下になる場合
        let ans = if num_zero == 0 {
            let mut cand = plus.iter().chain(minus.iter()).copied().collect::<Vec<_>>();
            cand.sort_by_key(|&x| x.abs());
            let mut res = cand.iter().take(k).fold(1, |acc, &x| acc * x % modulo);
            if res < 0 {
                res = (res % modulo + modulo) % modulo;
            }
            res
        } else {
            0
        };
        println!("{}", ans)
    } else {
        let mut k = k;
        plus.sort_by_key(|&x| -x);
        minus.sort();
        let ans = if k % 2 == 0 {
            1
        } else {
            k -= 1;
            plus.remove(0)
        };
        let mut cand = vec![];
        for i in 0.. {
            if 2 * i + 1 >= plus.len() {
                break;
            }
            cand.push(plus[2 * i] * plus[2 * i + 1]);
        }
        for i in 0.. {
            if 2 * i + 1 >= minus.len() {
                break;
            }
            cand.push(minus[2 * i] * minus[2 * i + 1]);
        }
        cand.sort_by_key(|x| -x);
        let ans = cand
            .iter()
            .take(k / 2)
            .fold(ans, |acc, &x| x % modulo * acc % modulo);
        let ans = if ans < 0 {
            (ans % modulo + modulo) % modulo
        } else {
            ans % modulo
        };
        println!("{}", ans)
    }
}

Measured memory_bytes: 9524
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

signed main()
{
    int N; cin>>N; N++;
    vector<int> x(N);
    REP(i,N) cin>>x[i];

    sort(ALL(x));

    int ans=x[1]-x[0];
    REP(i,N-1){
        ans=gcd(ans,x[i+1]-x[i]);
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
struct job{
  	int time;
  	int end;
};
bool compare(job a, job b){return a.end < b.end;}
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
  int nb;
  	cin >> nb;
  	job j[nb];
  	for(int i = 0; i <nb ; i++)
    {
      	cin >> j[i].time >> j[i].end;
    }
  	sort(j, j+nb, compare);
  int t=0;	
  for(int i=0; i < nb; i++)
  {
    	if(t > j[i].end)
        {
          	cout << "No\n";
          return 0;
        }
    	t+=j[i].time;
    	if(t > j[i].end)
        {
          	cout << "No\n";
          return 0;
        }
  }
  cout << "Yes\n";
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class DStringEquivalence {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n;
	    in >> n;

	    set<string> res;
        function<void(string, int)> dfs = [&](string s, int mx) {
            if(s.size() == n){
                res.insert(s);
                return;
            }
            char c = s.back();
            for(int i=0; i<=mx+1; i++){
                dfs(s + char('a'+i), max(mx, i));
            }
        };

        dfs("a", 0);
        for(auto& e : res){
            out << e << endl;
        }
	}
};


int main() {
	DStringEquivalence solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

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

    cout << "0 0 ";
    ll k = 1000000000;
    if(s == k*k){
        cout << k << " " << 0 << " " << 0 << " " << k << "\n";
        return 0;
    }
    ll l = k-s%k;
    ll m = (s+k)/k;
    cout << k << " " << 1 << " " << l << " " << m << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
//
//template<class T> using Tree = tree<T, null_type, less<T>, rb_t_tag,t_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;
//const long long mod = 998244353;

// watch this
//using ll = long long;
//typedef long long LL;
#define ll long long
#undef ll

const int mxN = 100010;

vector<int> g[mxN];
vector<int> tree[mxN];

struct DSU {
	vector<int> p, sz;
	DSU(int N) {
		p.resize(N);
		sz.resize(N, 1);
		for (int i = 0; i < N; i++)
			p[i] = i;
	}
	int par(int x) {
		if (x == p[x])
			return x;
		return p[x] = par(p[x]);
	}
	bool mrg(int x, int y) {
		x = par(x), y = par(y);
		if (x == y)
			return false;
//		if (sz[x] < sz[y]) {
//			swap(x, y);
//		}
		p[y] = p[x];
		sz[x] += sz[y];
		return true;
	}
};

long long A[mxN], B[mxN], srt[mxN];
long long dp[mxN];
long long sum[mxN];

void dfs(int u) {
	sum[u] = B[u];
	for (auto v : tree[u])
		dfs(v), sum[u] += sum[v];
	dp[u] = max(0ll, A[u] - B[u]);
	for (auto v : tree[u]) {
		dp[u] = min(dp[u], max(dp[v], A[u] - B[u] - sum[v]));
	}
//	cerr << u << ' ' << dp[u] << '\n';
}

bool can[mxN];

int main(int argc, char** argv) {
	//#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//#endif

	int N, M, u, v;
	cin >> N >> M;
	vector<int> ord(N);
	for (int i = 1; i <= N; i++)
		cin >> A[i] >> B[i], srt[i] = max(A[i] - B[i], 0ll), ord[i - 1] = i;
	sort(begin(ord), end(ord), [&](int a,int b) {return srt[a] < srt[b];});
//	swap(ord[1], ord[2]);
	for (int i = 0; i < M; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	DSU dsu(N + 1);
	for (int i = 0; i < N; i++) {
		for (auto o : g[ord[i]])
			if (can[o]) {
				int p = dsu.par(o);
				if (p != ord[i])
					tree[ord[i]].push_back(p), dsu.mrg(ord[i], p);
			}
		can[ord[i]] = true;
//		cerr << ord[i] << ":\n";
//		for (auto o : tree[ord[i]])
//			cerr << o << ' ';
//		cerr << '\n';
	}
	for (int i = 1; i <= N; i++)
		if (dsu.par(i) == i)
			dfs(i), cout << dp[i] + sum[i] << '\n';
	return 0;
}


Measured memory_bytes: 19068
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
using namespace std;
// int inf = INFINITY;
int main(){

  string C1,C2;

  bool ans = true;
  cin>>C1>>C2;
  if(C1[0]==C2[2] && C1[1]==C2[1] && C1[2]==C2[0]){
    ans = true;
  }
  else{
    ans = false;
  }
  if(ans){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
count = 0
for i in range(0, 1000):
    pin = '{0:03d}'.format(i)
    pos1 = s.find(pin[0])
    pos2 = s.find(pin[1], pos1 + 1)
    pos3 = s.find(pin[2], pos2 + 1)
    if pos1 != -1 and pos2 != -1 and pos3 != -1:
        count += 1
print(count)


Measured memory_bytes: 3188
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
for i in range(1, n):
    l[i] += l[i-1]
_max = 0
if n == k:
    _max = l[-1]
else:
    for i in range(n-k):
        _max = max(_max, l[i+k]-l[i])
print((_max+k)/2)

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

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

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

	printf("%d\n", n - ans);

	return 0;
}

Measured memory_bytes: 1024
import math
N=10**9 + 1
n=int(input())
a=list(map(int,input().split()))

def merge(a,left,mid,right):
    global cnt
    n=mid-left
    m=right-mid
    l=a[left:left + n]
    o=a[mid:mid + m]
    l.append(N)
    o.append(N)
    i=0
    j=0
    for k in range(left,right):
        cnt+=1
        if l[i]<=o[j]:
            a[k]=l[i]
            i+=1
        else:
            a[k]=o[j]
            j+=1

def mergesort(a,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergesort(a,left,mid)
        mergesort(a,mid,right)
        merge(a,left,mid,right)





cnt=0
mergesort(a,0,len(a))
print(*a)
print(cnt)



Measured memory_bytes: 67552