akhauriyash/Code-Regression huggingface dataset:
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n;
    
    
    
    
    cout<< 1-n <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  unordered_map<string, ll> mp;
  rep(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto& p : mp) {
    ll s = p.second;
    ans += (ll)((s * (s-1))/2);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,m;
    cin>>a>>b>>m;
    int arr[a+1];
    int brr[b+1];
    arr[0]=brr[0]=2*(1e6);
    for(int i=1;i<=a;i++)
    {
        cin>>arr[i];
    }
    for(int i=1;i<=b;i++)
    {
        cin>>brr[i];
    }
    int ans = *min_element(arr,arr+a+1)+*min_element(brr,brr+b+1);
    while(m--)
    {
        int x,y,c;
        cin>>x>>y>>c;
        ans = min(ans,arr[x]+brr[y]-c);

    }
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 4432
#include <iostream>
#include <string.h>
using namespace std;


int main() {
	int k;
	cin >> k;
	char input[101];
	cin >> input;
	int length = strlen(input);
	if (length <= k) {
		for (int i = 0; i < length; ++i)
			cout << input[i];
	}
	else {
		for (int i = 0; i < k; ++i)
			cout << input[i];
		cout << "...";
	}
	return 0;
}

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

const int mod = 998244353;

struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

const int N = 200020;
mint dp[N];

signed main() {
  int n,k;
  cin >> n >> k;

  vector<int> l(k), r(k);
  rep(i,k) {
    cin >> l[i] >> r[i];
  }

  dp[1] = 1;
  for (int i = 1; i <= n; i++) {
    mint add = 0;
    for (int j = 0; j < k; j++) {
      int left = l[j];
      int right = r[j];

      if(i - left < 0) continue;
      add = dp[i - left];
      mint sub = 0;
      if(i - right - 1 >= 0) {
        sub = dp[i - right - 1];
      }
      add -= sub;
      dp[i] += add;
    }
    dp[i] += dp[i - 1];
  }

  mint ans = dp[n] - dp[n - 1];
  cout << ans.x << '\n';
}

Measured memory_bytes: 5196
#include <iostream>
#include <iomanip>
#include <cmath>

int main(){
    int q;
    double x;
    std::cout << std::setprecision(6) << std::fixed;
    while(1){
        std::cin >> q;
        if(q == -1){
            return 0;
        }
        x = q / 2.0;
        while(std::abs(x * x * x - q) >= 0.00001d * q){
            x = x * 2 / 3 + q / x / x / 3;
        }
        std::cout << x << std::endl;
    }
}

Measured memory_bytes: 1232
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int a,b,c;

  cin>>a>>b>>c;

  int ans=max<int>({
    10*a+b+c,
    a+10*b+c,
    a+b+10*c,
  });
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('d3.in')


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


def read_str_list():
    return input().split()


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


def read_str():
    return input()


def gen():
  N = 200000
  K = 4000
  p = [6] * N
  print(N, K)
  print(*p)


def main():
    N, K = read_int_list()
    p = read_int_list()
    cp = [0] * (N+1)
    for i in range(N):
      cp[i+1] = cp[i] + (p[i]+1)/2
    # print(p)
    # print(cp)
    # print()
    res = 0    
    for i in range(N-K+1):
      # print(cp[i], cp[i+K], cp[i+K]-cp[i])
      if cp[i+K]-cp[i] > res:
        res = cp[i+K]-cp[i]
    
    print(res)


# gen()
main()


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

int main()
{
  int n,x;
  cin >> n;
  int count = 0;
  for(int i = 1; i <= n ; i++)
  {
     cin >> x;
     count += (i != x);
  }
  cout << ((count <=2) ? "YES" : "NO");
  
}


Measured memory_bytes: 256
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll A, ll B) { cout << (A - 1) * (B - 1) << endl; }

int main() {
  ll A;
  scanf("%lld", &A);
  ll B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

int main()
{
  int N;

  cin >> N;

  vector<Bint> A(N);

  for(int i=0; i<N; ++i){
    cin >> A[i];
  }

  Bint ret1 = 0, ret2 = 0;

  for(int i=0; i<N; ++i){
    ret1 += A[i];
    ret2 += A[i]*A[i];
  }

  cout << ((ret1*ret1-ret2)/2)%1000000007 << endl;

  return 0;
}

Measured memory_bytes: 9608
using System;
using System.Linq;

class Challenge
{
  static void Main()
  {
    var NAB = Console.ReadLine().Split();
    var N = int.Parse(NAB[0]);
    var A = int.Parse(NAB[1]);
    var B = int.Parse(NAB[2]);
    
    var answer = 0;
    for (int i=0; i<=N; i++)
    {
      var n = i.ToString().Select(x => int.Parse(x.ToString())).Sum();
      if ( A <= n & n <= B ) answer += i;
    }
    Console.WriteLine(answer);
  }
}

Measured memory_bytes: 15316
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int a[100005];
int main()
{
    int n,sum=0,i,j;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for(i=0; i<n; i=j)
    {
        if(a[i]==a[n-1]&&(n-i)%2==1)
        {
            sum++;
            break;
        }
        for(j=i+1; j<n; j++)
        {
            if(a[i]!=a[j]&&(j-i)%2==1)
            {
                sum++;
                break;
            }
            else if(a[i]!=a[j]&&(j-i)%2==0)
                break;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int a,b,c,d;
  int count,n;

  while(scanf("%d",&n) != EOF){
    if(n>36){
      printf("0\n");
    }
    else{
      count = 0;
      for(a=0;a<10;a++){
        if (a>n){
          break;
        }
        else{
          for(b=0;b<10;b++){
            if (a+b>n){
              break;
            }
            else{
              for(c=0;c<10;c++){
                if (a+b+c>n){
                  break;
                }
                else{
                  for(d=0;d<10;d++){
                    if (a+b+c+d>n){
                      break;
                    }
                    else if (a+b+c+d==n){
                      count++;
                    }
                  }
                }
              }
            }
          }
        }
      }
      printf("%d\n",count);
    }
  }

  return 0;
}


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

int N;
//int A[210];
vector<int> A(210);

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  cin >> N;
  for(int i=0;i<N;i++)cin >> A.at(i);
  //for(int i=0;i<N;i++)cout << A.at(i) <<' ';

  int res=0;

  while(true){
    bool exist_odd = false;
    for(int i=0;i<N;i++){
      if(A.at(i)%2==1){
        exist_odd = true;
      }
    }
    if(exist_odd) break;
    for(int i=0;i<N;i++){
      A.at(i) /= 2;
    }
    res++;
  }
cout<<res<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
S = list(input().strip())

lc = 0
rc = 0

for i in range(N):
    t = S[i]

    if t == ")":
        if lc > 0:
            lc -= 1
        else:
            rc += 1
    else:
        lc += 1

print("(" * rc + "".join(S) + ")" * lc)

Measured memory_bytes: 3064
/*
 * 組み合わせ
 */
#include <bits/stdc++.h>
using namespace std;

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

    int h, w, d;
    cin >> h >> w >> d;

    pair<int, int> a[h * w + 1];
    int ix;
    for (int j = 1; j <= h; ++j) {
        for (int i = 1; i <= w; ++i) {
            cin >> ix;
            a[ix] = make_pair(i, j);
        }
    }

    int q;
    cin >> q;
    int l[q], r[q];
    for (int i = 0; i < q; ++i) {
        cin >> l[i] >> r[i];
    }

    int dist_cum[h * w + 1];
    memset(dist_cum, 0, sizeof(dist_cum));
    for (int i = 1; i <= h * w - d; ++i) {
        pair<int, int> start = a[i];
        pair<int, int> end = a[i + d];
        int dist = abs(start.first - end.first) + abs(start.second - end.second);
        dist_cum[i + d] = dist_cum[i] + dist;
    }

    for (int i = 0; i < q; ++i) {
        cout << dist_cum[r[i]] - dist_cum[l[i]] << '\n';
    }

    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define f0(i, a, n) for(i = a; i < n; i++)
#define f1(i, a, n) for(i = a; i <= n; i++)
#define tc(t) int t;cin >> t;while(t--)
#define ini(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define ll long long int
#define vi vector<int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define M 1e9+7
#define rr return 0
#define endl '\n'

using namespace std;

void solve() {
    ll n, i, j, r = 0, w = 0, cnt = 0, ans;
    string s;
    cin >> n >> s;

    f0(i, 0, n) {
        if(s[i] == 'R') {
            r++;
        } else {
            w++;
        }
    }

    i = 0;
    j = n - 1;
    while(i < j) {
        if(s[i] == 'W' && s[j] == 'R') {
            swap(s[i++], s[j--]);
            cnt++;
        } else if(s[i] == 'R' && s[j] == 'W') {
            i++;
            j--;
        } else if(s[i] == 'R' && s[j] == 'R') {
            i++;
        } else if(s[i] == 'W' && s[j] == 'W') {
            j--;
        }
    }
    
    ans = min(cnt, min(r, w));
    cout << ans << endl;
}

int main () {
    IOS;
    solve();
    rr;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 8e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 5e5+100;
const int LOG = 19;
const ll mod = 998244353;
const int MX = 5e5+100;

void bad(){
    cout <<"impossible";
    exit(0);
}

void solve() {
    int n,k;
    cin >> n >> k;
    for(int i=1;i<=n;i=i+2){
        k--;
    }

    if(k <= 0){
        cout <<"YES"<<endl;
    } else{
        cout <<"NO"<<endl;
    }


}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
   // freopen("../output.txt","w",stdout);
#else
#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);


    int t = 1;
    while (t--)
        solve();
}

Measured memory_bytes: 256
def manhattan(i, j, x, y):
    # (i, j)中央点の座標，(x, y)既知の座標
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    cand = [0, 0, 0]
    for i in range(101):
        for j in range(101):
            # 既知座標１点を得て，中心座標の高さを決定する
            for k in range(N):
                if H[k] != 0:
                    x, y, h = X[k], Y[k], H[k]
                    hmax = h + manhattan(i, j, x, y)
                    break
            # 残り既知座標N-1点について，矛盾がないか確かめる
            for k in range(N):
                x, y, h = X[k], Y[k], H[k]
                if h == 0:
                    if hmax > manhattan(i, j, x, y):
                        break
                else:
                    if hmax - h != manhattan(i, j, x, y):
                        break
            else:
                if cand[2] < hmax:
                    cand = [i, j, hmax]
    return cand

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

#define P2 pair<int,pint>

int A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,K;
string s,t;

signed main()
{
	IOS();
	cin>>N>>Q;
	vector<P2>v(N);
	rep(i,0,N){
		int a,b,c;
		cin>>a>>b>>c;
		v[i] = {c,{a-c,b-c}};
	}
	sort(all(v));
	multiset<int>st;
	map<int,int>mp;
	rep(i,0,Q){
		int t;
		cin>>t;
		st.insert(t);
		mp[t] = i;
	}
	vector<int>ans(Q,-1);
	rep(i,0,N){
		while(st.size()){
			auto itr = st.lower_bound(v[i].se.fi);
			if(itr == st.end())break;
			if((*itr)>=v[i].se.se)break;
			ans[mp[*itr]] = v[i].fi;
			st.erase(itr);
		}
	}
	rep(i,0,Q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 30080
#include <cstdio>
#include <iostream>
using namespace std;
char c[100001]={0};
char answer[100001]={0};
inline char function_2(char sw)
{
    if(sw=='S')
        return 'W';
    else
        return 'S';
}
inline char function_1(char sw1,char ox2,char sw2)
{
    if(sw2=='S')//真话
    {
        if(ox2=='o')
            return sw1;
        else
            return function_2(sw1);
    }
    else //假话
    {
        if(ox2=='o')
            return function_2(sw1);
        else
            return sw1;
    }
}
bool fz(char a,char b,int l)
{
    c[l+1]=c[0];
    answer[0]=a;answer[1]=b;
    for(int j=2;j<=l+2;j++)
    {
        answer[j]=function_1(answer[j-2],c[j-1],answer[j-1]);
    }
    //printf("%s\n",answer);
    if(answer[l+1]!=a||answer[l+2]!=b)
        return false;
    answer[l+1]=0;
    return true;
}
int main()
{
    int n,i=-1;
    bool tt=false;
    scanf("%d%*c",&n);
    while(n--)
        scanf("%c",&c[++i]);
    if(fz('S','S',i))
    {
        printf("%s\n",answer);
        return 0;
        tt=true;
    }
    if(fz('S','W',i))
    {
        printf("%s\n",answer);
        return 0;
        tt=true;
    }
    if(fz('W','S',i))
    {
        printf("%s\n",answer);
        return 0;
        tt=true;
    }
    if(fz('W','W',i))
    {
        printf("%s\n",answer);
        return 0;
        tt=true;
    }
    if(tt==false)
        printf("-1\n");
    return 0;
}


















Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int k;
    cin >> k;
    queue<ll> Q;
    for(ll i = 1; i < 10; i++) Q.push(i);
    for(int i = 0; i < k-1; i++) {
        ll p = Q.front();
        Q.pop();

        ll now = p%10;
        if(now != 0) Q.push(p*10+now-1);
        Q.push(p*10+now);
        if(now != 9) Q.push(p*10+now+1);
    }

    ll ans = Q.front();
    cout << ans << endl;
}

Measured memory_bytes: 5024
N = int(input())
b = [int(x) for x in input().split()]
ans = []
while len(b) > 1:
    tmp = max(b)
    flag = 0
    if tmp > len(b):
        ans = None
        break
    while flag == 0:
        if b[tmp-1] == tmp: # 数字とインデックスが一致
            ans.append(b.pop(tmp-1))
            flag = 1
        else:
            tmp -= 1
        if tmp == 0:
            flag = -1
            break
    if flag == -1:
        ans = None
        break

if ans == None or b[0] != 1:
    print(-1)
else: 
    ans.append(1)
    for i in ans[::-1]:
        print(i)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
int mod = 1000000007;
inline int MOD(int x) {
	return x >= mod ? x - mod : x;
}
int qpow(int a, int b) {
	int as = 1;
	while(b) {
		if(b & 1) as = 1ll * as * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return as;
}
int a[200005], b[200005], CC[4005][4005];
int n, m;
int F[10005], fc[10005], iv[10005], G[10005];
int& f(int x) {
	return F[x + 3000];
}
int& g(int x) {
	return G[x + 3000];
}
int as;
int C(int n, int m) {
	return CC[n][m];
}
int CCC(int n, int m) {
	return 1ll * fc[n] * iv[m] % mod * iv[n - m] % mod;
}
void init() {
	CC[0][0] = 1;
	rep(i, 1, 4000) {
		CC[i][0] = CC[i][i] = 1;
		rop(j, 1, i) {
			CC[i][j] = MOD(CC[i - 1][j - 1] + CC[i - 1][j]);
		}
	}
	fc[0] = iv[0] = 1;
	rep(i, 1, 10000) fc[i] = 1ll * fc[i - 1] * i % mod;
	iv[10000] = qpow(fc[10000], mod - 2);
	per(i, 9999, 1) iv[i] = 1ll * iv[i + 1] * (i + 1) % mod;
}
int main() {
	init();
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d%d", &a[i], &b[i]);
	rep(i, 1, n) {
		rep(j, -b[i], a[i]) {
			f(j) = MOD(f(j) + C(a[i] + b[i], a[i] - j));
		}
		rep(j, -a[i], b[i]) {
			g(j) = MOD(g(j) + C(a[i] + b[i], a[i] + j));
		}
		as = MOD(as - CCC(a[i] + a[i] + b[i] + b[i], a[i] + a[i]) + mod);
	}
	rep(j, -2000, 2000) as = MOD(as + 1ll * f(j) * g(j) % mod);
	cout << 1ll * as * qpow(2, mod - 2) % mod << endl;
	return 0;
}


Measured memory_bytes: 63232
#include<iostream>
#include<vector>
#include<stack>
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.length();
    if(s[0] == '0' || s[n-1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < (n-1)/2; i++){
        if(s[i] != s[n-2-i]){
            cout << -1 << endl;
            return 0;
        }
    }
    // 1.....10の形であることが保証される
    vector<int> ans;
    stack<int> un;
    un.push(0);
    for(int i = 1; i < n; i++){
        if(s[i] == '1'){
            while(!un.empty()){
                int x = un.top();   un.pop();
                ans.push_back(x); ans.push_back(i);
            }
        }
        un.push(i);
    }
    ans.push_back(n-2); ans.push_back(n-1);
    for(int i = 0; i < n-1; i++){
        cout << ans[2*i]+1 << " " << ans[2*i+1]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 2676
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
int num[maxn];
map<string,int>mp;
int main()
{
    /**int n=read;
    int flag=1;
    for(int i=1;i<=n;i++)
    {
        num[i]=read;
        if(num[i]%2==0){
            if(num[i]%3!=0&&num[i]%5!=0)
                flag=0;
        }
    }
    if(flag==0) printf("DENIED\n");
    if(flag) printf("APPROVED\n");**/
        /**
        int n=read;
    string ss;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        ///scanf("%s",ss);
        cin>>ss;
        mp[ss]++;
    }
    int cnt=0;
    for(auto& v:mp) cnt=max(cnt,v.second);
    for(auto& v:mp){
        if(v.second==cnt)
            ///cout<<v.first<<endl;
            printf("%s\n",v.first);
    }**/
    ll n;
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ///scanf("%s",ss);
        ///getchar();
        string ss;
        cin>>ss;
        mp[ss]++;
    }
    int maxx=-1;
    for(const auto& x : mp){
        int temp=x.second;
        if(temp>maxx) maxx=temp;
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        if(it->second==maxx)
            cout<<it->first<<endl;
    }
	return 0;
}


Measured memory_bytes: 23808
#include<cstdio>
#include<algorithm>
using std::max;
int n,N,a[500100],ans[500100],maxn[500100];
int main(){
	scanf("%d",&n);N=(1<<n)-1;
	for(int i=0;i<=N;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<=N;i++)
		for(int j=i;j<=N;j=(j+1)|i)
			ans[j]=max(ans[j],maxn[j]+a[i]),maxn[j]=max(maxn[j],a[i]);
	for(int i=1;i<=N;i++)
		ans[i]=max(ans[i],ans[i-1]),printf("%d\n",ans[i]);
}

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

int main() {
  int N;
  cin >> N;
  int V[N],C[N];
  for(int i = 0; i < N; i++){
  	cin >> V[i];
  }
  for(int i = 0; i < N; i++){
  	cin >> C[i];
  }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
  	if(V[i] > C[i]){
    	ans += V[i] - C[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#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 <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {

	LL IN = 1e11;
	LL a, b, q; cin >> a >> b >> q;
	vector<LL> s(a);

	for (int i = 0; i < a; i++) {
		cin >> s[i];
	}

	s.push_back(1e13);
	

	vector<LL> t(b);

	for (int i = 0; i < b; i++) {
		cin >> t[i];
	}

	t.push_back(1e13);

	for (int i = 0; i < q; i++) {
		LL x; cin >> x;

		LL ls = IN;
		LL rs = IN;
		
		rs=upper_bound(s.begin(), s.end(), x)-s.begin();
		ls=INF2;
		if (rs != 0) {

			ls = abs(s[rs - 1]-x);
				
		}

		rs = abs(s[rs]-x);
		

		LL lt = IN;
		LL rt = IN;
		
		rt = upper_bound(t.begin(), t.end(), x) - t.begin();
		lt = INF2;
		if (rt != 0) {
			lt = abs(t[rt - 1]-x);
		}

		rt = abs(t[rt]-x);

		LL tmp = INF2;

		tmp = min(tmp,max(ls,lt));
		tmp = min(tmp, max(rs, rt));

		tmp = min(tmp, ls+rt+min(ls,rt));
		tmp = min(tmp, rs+lt+min(rs,lt));
		
		
		cout << tmp << endl;

	}

	return 0;
}

Measured memory_bytes: 3696
N,M=[int(i) for i in input().split(" ")]
X=[int(i) for i in input().split(" ")]
X=sorted(X)
delta=[abs(X[i+1]-X[i]) for i in range(M-1)]
delta=sorted(delta)
if M>N:
    print(sum(delta[:M-N:]))
else:
    print(0)


Measured memory_bytes: 13840
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	ll h, n;
	cin >> h >> n;
	vl a(n);
	ll sum = 0;
	rep (i, n) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum >= h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
N = gets.chomp.to_i
ds = [100000, 10000, 1000, 100, 10, 1]
ans = 0
for i in 1..N
  for d in 0..5
    if i / ds[d] > 0
      ans += 1 if d.odd?
      break
    end
  end
end
puts ans


Measured memory_bytes: 1788
def main():
    n = int(input())
    x,y = 0,0
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0:
            x = i
            y = n // i
    print(max(len(str(x)),len(str(y))))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    print(S.count('1'))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,total=0;
	cin>>n;
	int a[n+1],b[n+1];
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for (int i=1;i<=n;i++)
	{
		if (a[i]!=b[i])  total++;
	}
	if (total==0||total==2)  cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int,int>;
constexpr ll mod = 1000000007;
void pPRINTl(ostream& ost) { ost << endl; }
template <class T>void pPRINTL(ostream& ost,T t){ost<<t<<endl;}
template <class T, class... U>void pPRINTl(ostream& ost, T t, U... u) {ost << t << " ";pPRINTl(ost, u...);}
template <class... T>void PRINTl(T... t) { pPRINTl(cout, t...); }
//#define PRINTl
void pPRINT(ostream& ost) {}
template <class T>void pPRINT(ostream& ost, T t){ost<<t<<" ";}
template <class T, class... U>void pPRINT(ostream& ost, T t, U... u) {ost << t << " ";pPRINT(ost, u...);}
template <class... T>void PRINT(T... t) { pPRINT(cout, t...); }
//#define PRINT

//#define DEBUG PRINTl("DEBUG line:",__LINE__)
#define DEBUG 

constexpr ll MAX = 1e9;

int main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;  cin>>n;
  ll a[n+1],b[n];
  
  REP(i,n+1)cin>>a[i];
  REP(i,n)cin>>b[i];
  
  
  ll score = 0;
  REP(i,n){
    a[i]-=b[i];
    if(a[i]>=0){
      score+=b[i];
    }
    else{
      a[i+1]+=a[i];
      if(a[i+1]>=0){
        score+=b[i];
      }
      else{
        score+=b[i]+a[i+1];
        a[i+1]=0;
      }
    }
  }
  PRINT(score);
  
  return 0;
}

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

using namespace std;

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

int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
bool ok(int x, int y, int w, int h) {
	return x >= 0 && y >= 0 && w > x && h > y;
}

signed main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	map<char, vector<pair<int, int>>> mp;
	rep(y, h) {
		cin >> s[y];
		rep(x, w) {
			if (s[y][x] != '.') {
				mp[s[y][x]].push_back(make_pair(y, x));
			}
		}
	}
	int ans = 0;
	while (1) {
		bool end = true;
		for (char c = 'A'; c <= 'Z'; c++) {
			if (mp[c].size() == 0)continue;
			[&]() {
				rep(i, 4)rep(j, 4) {
					bool rm = false;
					int iy = mp[c][0].first, ix = mp[c][0].second;
					int jy = mp[c][1].first, jx = mp[c][1].second;
					int ay = iy + dy[i], ax = ix + dx[i];
					int by = jy + dy[j], bx = jx + dx[j];

					set<pair<int, int>> av;
					while (ok(ax, ay, w, h)) {
						if (s[ay][ax] == '.') {
							av.insert(make_pair(ay, ax));
							ay += dy[i]; ax += dx[i];
						}
						else break;
					}
					while (ok(bx, by, w, h)) {
						if (s[by][bx] == '.') {
							if (av.count(make_pair(by, bx))) {
								rm = true; break;
							}
							by += dy[j]; bx += dx[j];
						}
						else break;
					}
					if (rm) {
						s[iy][ix] = '.';
						s[jy][jx] = '.';
						mp[c].clear();
						ans += 2;
						end = false;
						return;
					}
				}
			}();
		}
		if (end)break;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, M, tc;
    cin>>n>>k;
    string s;
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(i==k-1)
        {
            if(s[i]>='A' && s[i]<='Z')
            {
                s[i]=s[i]-'A'+'a';
            }
        }
    }
    cout<<s<<endl;
    

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;


int main() {
	double n= 0,k =0,tmp = 0.5,kake=0;
	double ans = 0;
	cin >> n >> k;
	double up = ceil(log2(k));
	int cnt = log2(k) + 1;
	vector<double>table;
	table.push_back(1);
	rep(i, up) {
		table.push_back(tmp);
		tmp *= 0.5;
	}
	for (double i = 1; i <= n; i++) {
		ans += (1 / n) * table[ceil(abs(log2((k > i)?k/i:1)))];
	}
	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}


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

int main()
{
    double a, b, C;
    cin >> a >> b >> C;
    double S, L, h,r;
    r = C*3.14159265359/ 180;
    S = a*b*sin(r) / 2;
    L = sqrt(pow(a, 2) + pow(b, 2) - 2 * a*b*cos(r))+a+b;
    h = S * 2 / a;
    cout << setprecision(10);
    cout << S << endl; cout << setprecision(10); 
    cout << L << endl; cout << setprecision(10);
    cout<< h << endl;
    return 0;
}

Measured memory_bytes: 1284
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [N] = r.nn()
    const P = r.s().replace(/ /g, '')
    const Q = r.s().replace(/ /g, '')

    // console.log(P)
    // console.log(Q)

    const a: number[][] = []

    generatePermutation(a, [], range(1, N), N)

    let start = 0
    let end = 0

    // console.log(a.map(v => v.map(String).join('')))

    a.map(v => v.map(String).join('')).forEach((v, i) => {
      if (v === P) {
        start = i
      }
      if (v === Q) {
        end = i
      }
    })

    return Math.abs(start - end)
  }

  const generatePermutation = function(perm, pre, post, n) {
    var elem, i, rest, len

    if (n > 0)
      for (i = 0, len = post.length; i < len; ++i) {
        rest = post.slice(0)
        elem = rest.splice(i, 1)
        generatePermutation(perm, pre.concat(elem), rest, n - 1)
      }
    else perm.push(pre)
  }

  const range = (a: number, b: number) => {
    const nums: number[] = []

    for (let i = a; i <= b; i++) nums.push(i)
    return nums
  }

  const _range = (n: number) => Array.from(Array(n).keys())
  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}


Measured memory_bytes: 26824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int result;
  int k;
  cin >> k;
  result = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x<=k-x)
        {
            result = result +x*2;
        }
        else if (k-x < x)
        {
            result = result + (k-x)*2;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3532
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    menu=[]
    np_menu=[]
    [menu.append(int(input())) for _ in range(5)]
    np_menu=np.array(menu)
    s_menu=sorted(np_menu,key=lambda x:x%10)
    time_counter=0
    last_add=0

    for time in s_menu:
        if time % 10 ==0:
            time_counter+=time
        elif last_add==0:
            last_add+=time
        else:
            tmp=10-(time%10)
            time_counter+=time+tmp
    time_counter+=last_add
    print(time_counter)

if __name__=="__main__":
    main()

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

template<typename T, T mod>
class Modint {
private:
  T x;

public:
  Modint(): x((T)0) {}
  Modint(T y): x(y >= 0? y % mod: (mod - (-y) % mod) % mod) {}

  T get() {
    return x;
  }

  Modint &operator+=(const Modint &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  Modint &operator-=(const Modint &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  Modint &operator*=(const Modint &p) {
    x = x * p.x % mod;
    return *this;
  }

  Modint &operator/=(const Modint &p) {
    *this *= p.inverse();
    return *this;
  }

  Modint operator-() const { return Modint(-x); }
  Modint operator+(const Modint &p) const {return Modint(*this) += p; }
  Modint operator-(const Modint &p) const {return Modint(*this) -= p; }
  Modint operator*(const Modint &p) const {return Modint(*this) *= p; }
  Modint operator/(const Modint &p) const {return Modint(*this) /= p; }

  bool operator==(const Modint &p) const { return x == p.x; }
  bool operator!=(const Modint &p) const { return x != p.x; }

  Modint inverse() const {
    T a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return Modint(u);
  }

  Modint pow(int e) const {
    T a = 1, p = x;
    while(e > 0) {
      if (e % 2 == 0) {
	p = (p * p) % mod;
	e /= 2;
      } else {
	a = (a * p) % mod;
	e--;
      }
    }
    return Modint(a);
  }
};

constexpr long long MOD = 1000000007;

using mi = Modint<long long, MOD>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }

  vector< vector<mi> > dp(h, vector<mi>(w, mi(0)));
  dp[0][0] += 1;
  for (int i = 1; i < w; ++i) {
    if (s[0][i] == '#') break;
    dp[0][i] += 1;
  }
  for (int i = 1; i < h; ++i) {
    if (s[i][0] == '#') break;
    dp[i][0] += 1;
  }
  for (int i = 1; i < h; ++i) {
    for (int j = 1; j < w; ++j) {
      if (s[i][j] == '#') continue;
      dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
    }
  }

  cout << dp[h - 1][w - 1].get() << '\n';
  return 0;
}


Measured memory_bytes: 12936
//Only the Creator has given me strength!
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
#define pi 3.1415926535897931159979635
#define pb push_back
#define vctr vector < int >
#define vvtr vector < vctr >

using namespace std;

void fastio() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    fastio();
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  sort(a,a+n);
  vi po;
  REP(i,n-1){
    if(a[i]==a[i+1]){
      po.push_back(a[i]);
      i++;
    }
  }
  if(po.size()<=1){
    puts("0");
  }else{
    int l = po.size();
    ll ans = (ll)po[l-1] * po[l-2];
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#138_D
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

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

edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x
    
def dfs(frm, cur):
    for to in edges[cur]:
        if to != frm:
            cnt[to] += cnt[cur]
            dfs(cur, to)
dfs(-1, 0)          
print(*cnt)


Measured memory_bytes: 230888
#include<iostream>
    #include<algorithm>
    #include<cstdlib>
    using namespace std;
     
    int main(){
      int n,z,w;
      int a[100000];
     
      cin>>n>>z>>w;
      
      for(int i=0;i<n;i++)
        cin>>a[i];
     
        if(n==1)
          cout<<abs(a[0]-w)<<endl;
        else
        cout<<max(abs(a[n-1]-w),abs(a[n-2]-a[n-1]))<<endl;
     
      return 0;
    }

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = 0;
		int odd = 0;
		int n = sc.nextInt();
		for(int i=0; i<n; i++){
			a = sc.nextLong();
			if( a%2 != 0 ){
				odd++;
			}
		}
		if( odd%2 == 0 ){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		return;
	}
}

Measured memory_bytes: 33032
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,datetime,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

s = str(input())

if s.lower()==s:
    print('a')
else:
    print('A')


Measured memory_bytes: 69024
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
#define INFTY 500000
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

int color[12000],d[12000];
vector<pair<int,int> > v[12000];
priority_queue<pair<int,int> > PQ;
int n;

void start(int x){
  d[x]=0;
  PQ.push(make_pair(0,0));
  while(!PQ.empty()){
    pair<int,int> f;
    f=PQ.top();
    PQ.pop();
    int u=f.second;
    if(f.first*(-1) > d[u]) continue;
    color[u]=BLACK;
    for(int i=0;i<v[u].size();i++){
      int temp=v[u][i].first;
      if(d[temp]>d[u]+v[u][i].second && color[temp]!=BLACK){
        d[temp]=d[u]+v[u][i].second;
        color[temp]=GRAY;
        PQ.push(make_pair(-1*d[temp],temp));
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<i<<" "<<d[i]<<endl;
  }
}

int main(){
  int u,k,v1,c;
  cin>>n;
  for(int i=0;i<n;i++){
    d[i]=INFTY;
  }
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v1>>c;
      v[u].push_back(make_pair(v1,c)); 
    }
  }
  start(0);
}



Measured memory_bytes: 8052