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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
ll a[SZ];
//ll b[SZ];



int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
    //    ll a, b, d;
    string s, s1, s2;

    cin1(n);
    for1(i, n) cin1(a[i]);

    sort(a+1, a+n+1, greater<ll>());

    t = n-1;

    for1(i, n) {
        (i == 1) ? c = 1 : c = 2;
        while(c > 0 && t > 0) {
            ans += a[i];
            c--;
            t--;
        }
    }

    cot1(ans);

    return 0;
}



Measured memory_bytes: 5204
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    int a[n+1],i,num;
    for(i=1;i<=n;i++){
        scanf("%d",&num);
        if(num==i)a[i]=1;
        else a[i]=0;
    }
    int count=0,point=0;
    for(i=1;i<=n;i++){
        if(a[i]==1){
            count++;
        }else{
            point+=(count+1)/2;
            count=0;
        }
    }
    point+=(count+1)/2;
    count=0;
    
    printf("%d",point);
    
    return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (A, B, X) = listOfDouble()
    val R: Double
    if (A * A * B / 2.0 <= X) {
        val Y = (A * B) - (X / A)
        val C = 2 * Y / A
        R = Math.atan(C / A) * 180.0 / Math.PI
    } else {
        val Y = X / A
        val C = 2 * Y / B
        R = Math.atan(B / C) * 180.0 / Math.PI
    }
    println(R)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfDouble() = listOfString().map { java.lang.Double.parseDouble(it) } //{ it.toDouble() }

Measured memory_bytes: 37796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//int v[100001],v1[100001];

int main()
{
    ll a,b,c,d,e;
    cin>>a>>b;
    c=b-a+1;
    d=b+a-1;
    for(int i=c; i<=d; i++)
    {
        cout<<i;
        if(i!=d)
        {
            cout<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int sum, wa = 0, i, r;
	while(1){
		sum = 0;
		wa = sum;
		scanf("%d", &sum);
		if (sum==0){
			break;
		}
		for (i = 0; i < 9; i++) {
			scanf("%d", &r);
			wa = wa + r;
		}
		sum = sum - wa;
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 2620
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
n = int(input())
b = 26
d = 0
digs = 1
while d + b < n:
    d += b
    b *= 26
    digs += 1
n -= d + 1
ans = []
while n > 0:
    ans.append(chr(ord('a') + n % 26))
    n //= 26
while len(ans) < digs:
    ans.append('a')
print(''.join(reversed(ans)))


Measured memory_bytes: 61956
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>

#define MY_SIZE_MAX 100001
#define MY_VALUE_MAX 100001

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if( a <= b )
	{
		cout << a << endl;
	}
	else
	{
		cout << max( a - 1, 0 ) << endl;
	}
	return 0;
}

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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

    var(int, N, c, k);

    MinHeap<i64> heap;
    rep(i, N) {
        var(i64, t);
        heap.emplace(t);
    }

    i64 res = 0;
    while (!heap.empty()) {
        i64 fr = heap.top();
        heap.pop();
        i64 lim = fr + k;
        i64 loop = c - 1;
        while (loop-- && !heap.empty() && heap.top() <= lim) heap.pop();
        ++res;
    }

    outl(res);

    return 0;
}


Measured memory_bytes: 1400
n,m=map(int,input().split())
h=list(map(int,input().split()))
a,b=[0]*m,[0]*m
ans=[1]*n
for i in range(m):
  a[i],b[i]=map(int,input().split())
  a[i]-=1
  b[i]-=1
for i in range(m):
  if h[a[i]]<h[b[i]]:
    ans[a[i]]=0
  elif h[a[i]]>h[b[i]]:
    ans[b[i]]=0
  else:
    ans[a[i]]=0
    ans[b[i]]=0
print(sum(ans))

Measured memory_bytes: 21852
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n, money = 100000;
	cin >> n;

	for (int i = 0; i < n; i++) {
		money *= 1.05;
		if (money % 1000 == 0) {
			continue;
		}
		money += 1000 - money % 1000;
	}

	cout << money << endl;

	return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
int A[N];

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,m,d,k,T,cas=0;
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>A[i];
    map<int, int> mp;
    for(int i=0;i<m;++i) {
        cin>>a>>b;
        mp[a] = max(mp[a], A[b]);
        mp[b] = max(mp[b], A[a]);
    }
    int cnt=0;
    for(int i=1;i<=n;++i) {
        if(A[i]>mp[i] || mp[i]==0) {
        	cerr<<A[i]<<" "<<mp[i]<<endl;
        	cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 8704
#include<stdio.h>

int main() {
  int n,i,j;
  int Adj[100][100];
  int u,k,v;
  
  scanf("%d",&n);
  
  for( i=0 ; i<n ; i++ ) {
    for( j=0 ; j<n ; j++ ) {
      Adj[i][j] = 0;
    }
  }
 
  for( i=0 ;  i<n ; i++ ) {
    scanf("%d%d", &u, &k);
    for( j=0 ; j<k ; j++ ) {
      scanf("%d", &v);
      Adj[i][v-1] = 1;
    }
  }

  for( i=0 ; i<n ; i++ ) {
    for( j=0 ; j<n ; j++ ) {
      printf("%d", Adj[i][j]);
      if(j != n-1) printf(" ");
    }
    printf("\n");
  }

  return 0;
}

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

int main() {
	int N;
	cin >> N;
  cout << N*N*N << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val (n, m, rr) = readLine()!!.split(" ").map { it.toInt() }
    val r = readLine()!!.split(" ").map { it.toInt() }.toIntArray().sortedArray()
    val g = Array(n+1){IntArray(n+1){ Int.MAX_VALUE / 10} }
    repeat(m){
        val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
        g[a][b] = c
        g[b][a] = c
    }
    for (i in 1..n){
        g[i][i] = 0
    }

    for(k in 1..n){
        for(i in 1..n){
            for(j in 1..n){
                g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j])
            }
        }
    }

    val list = mutableListOf<IntArray>()
    permutation(r, IntArray(0), list)

    var min = Int.MAX_VALUE / 10
    list.forEach {
        var ans = 0
        for(i in 1 until it.size){
            ans += g[it[i-1]][it[i]]
        }
        min = Math.min(min, ans)
    }

    println(min)
}

fun permutation(r1: IntArray, r2: IntArray, list: MutableList<IntArray>){
    if(r1.size <= 1){
        list.add(r2 + r1)
    }else{
        for(i in r1.indices){
            permutation(r1.sliceArray(0 until i) + r1.sliceArray(i+1 until r1.size), r2 + r1[i], list)
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "YES" << endl;}
void no(){ cout << "NO" << endl;}

//-----------------------------------------

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) cin >> a[i];

  sort(ALL(a));
  reverse(ALL(a));

  
  ll ans = a[0];

  ll i = n - 2;
  ll j = 1;

  while(i){
    if(i == 1){
      ans += a[j];
      i--;
    }
    else{
      ans += a[j] * 2;
      j++;
      i -= 2;
    }
  }

  cout << ans <<endl;







  return 0;
}



Measured memory_bytes: 4764
def gcd(a,b):
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def gcd_l(A):
    if len(A) == 1:
        return A[0]
    x = gcd(A[0], A[1])
    if len(A) == 2:
        return x
    for i in range(2, len(A)):
        x = gcd(x, A[i])
    return x

N = int(input())
A = list(map(int, input().split()))
A.sort()

B = []
C = []
x = A[0]
y = A[-1]
for i in range(N):
    x = gcd(x, A[i])
    B.append(x)
    y = gcd(y, A[N-1-i])
    C.append(y)
    
ans = 1

for i in range(1, N-1):
    ans = max(ans, gcd(B[i-1], C[N-2-i]))

ans = max(ans, B[N-2], C[N-2])

print(ans)


Measured memory_bytes: 14584
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int A,B,C,X,Y,s;cin>>A>>B>>C>>X>>Y;s=A*X+B*Y;
  for(int i=0;i<=max(X,Y);i++){
    s=min(s,max(X-i,0)*A+max(Y-i,0)*B+i*2*C);
  }
  cout<<s<<endl;
}

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

ll dp[0][0];

int main()
{
ll n;
cin >> n;
string ans="No";
ll mo;
rep(i,25)rep(j,15){
    mo=4*i+7*j;
    if(mo==n)ans="Yes";
}

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





Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int A,B,C,D;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&D);
  int one,two;
  if(A>B)one=B;
  else one=A;
  if(C>D)two=D;
  else two=C;
  printf("%d\n",one+two);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void C();

int main()
{
	C();
	fflush(stdout);
	return 0;
}

static void C()
{
	LLONG X, K, D;
	get(X, K, D);

	LLONG cnt = tp_abs(X) / tp_abs(D);

	LLONG ans = 0;
	if (cnt >= K) {
		ans = tp_abs(X) - tp_abs(D) * K;
	}
	else {
		LLONG pos = tp_abs(X) - tp_abs(D) * cnt;
		LLONG rest = K - cnt;
		ans = tp_abs(pos);
		if (rest % 2LL) {
			ans = tp_abs(tp_abs(pos) - tp_abs(D));
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3760
N, Q = map(int, raw_input().split())
S = raw_input()
count = 0
ac_list = list()
ac_list.append(0)
for idx in range(1, N):
    if S[idx-1] == 'A' and S[idx] == 'C': count += 1
    ac_list.append(count)
for i in xrange(Q):
    left, right = map(int, raw_input().split())
    print (ac_list[right-1] - ac_list[left-1])
# print ac_list

Measured memory_bytes: 7812
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

//素因数分解unordered_map版　O(√n)
template <typename T>
unordered_map<T, T> pf_um(T n) {
    unordered_map<T, T> res;
    for (long long int i = 2; i * i <= n; i++)
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    if (n != 1) res[n]++;
    return res;
}

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, lint _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};

int main() {
    lint mod = 1e9 + 7;
    int n, m;
    cin >> n >> m;
    combination_mod comb(n + 32, mod);
    unordered_map<int, int> count = pf_um(m);
    lint ans = 1;
    for (auto e : count) {
        int k = e.second;
        ans = (ans * comb.query(n - 1 + k, k)) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#define ll				long long
#define MOD				1000000007

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

typedef struct data {
	int a;
	int b;
} data;

FILE *in, *ans;
int tno;

int out(const char *s) {
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int outi(int i) {
	char s[128];
	sprintf(s, "%d\n", i);
	out(s);
	return 0;
}

int outll(ll l) {
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int geti() {
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll getll() {
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int getstr(char *s) {
	fscanf(in, "%s", s);
	return 0;
}

int fnc() {

	int i;
	int n = geti();
	int v[20];
	for (i = 0; i < n; i++) {
		v[i] = geti();
	}
	int s = 0;
	for (i = 0; i < n; i++) {
		int c = geti();
		v[i] -= c;
		if (v[i] > 0) {
			s += v[i];
		}
	}
	outi(s);

	return 0;
}

int main() {
#ifdef TEST
	for (tno = TEST_SNO; tno <= TEST_ENO; tno++) {
		char str[128];
		sprintf(str, "test%d.txt", tno);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", tno);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


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

#define endl '\n'

using namespace std;
using ll = long long int;

const int mod = 1e9 + 7;

int main(){

    int n;
    cin >> n;

    vector<ll> values(n);
    for (auto &v: values) cin >> v;
    
    ll runningSum = 0, ans = 0;

    for (int i=0; i<n; i++){
        
        ans += values[i] * runningSum;
        ans %= mod;

        runningSum += values[i];
        runningSum %= mod;

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4844
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] T = Console.ReadLine().Split(' ')
                                         .Select(val => int.Parse(val))
                                         .ToArray();
        int[] A = Console.ReadLine().Split(' ')
                                         .Select(val => int.Parse(val))
                                         .ToArray();
        long pat = 1;
        for (int i = 0; i < n; i++)
        {
            if((i == 0 || T[i - 1] != T[i]) && T[i] > A[i]){
                Console.WriteLine(0);
                return;
            }
            if((i == n - 1 || A[i] != A[i + 1]) && T[i] < A[i]){
                Console.WriteLine(0);
                return;
            }
            if(i != 0 && i != n - 1 && T[i - 1] == T[i] && A[i] == A[i + 1]){
                pat = pat * Math.Min(T[i], A[i]) % (long)(1e9 + 7);
            }
        }
        Console.WriteLine(pat);
    }
}


Measured memory_bytes: 26176
# coding: utf-8

(n,m,c) = map(int, input().rstrip().split(" "))

b = list(map(int, input().rstrip().split(" ")))
a = [list(map(int, input().rstrip().split(" "))) for i in range(n)]

ans = [k for k in [sum([ b[i]*j[i] for i in range(m)]) for j in a] if k + c > 0]

print(len(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N,M,X;
    cin >> N >> M >> X;
    ll cost0 = 0,costN = 0;
    REP(i,M){
        int place;
        cin >> place;
        if(place < X){
            cost0++;
        }else{
            costN++;
        }
    }
    cout << min(cost0,costN) << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;
		try (Scanner sc = new Scanner(System.in)) {
			line = sc.nextLine();
			int inputNUm = Integer.parseInt(line);
			System.out.println(inputNUm * inputNUm * inputNUm);

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 26304
N, K = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9 + 7
for i in range(N - K + 1):
	ans = min(ans, x[K-1+i] - x[i] + min( abs(x[K-1+i]) , abs(x[i]) ))
print(ans)


Measured memory_bytes: 62576
#include <iostream>
#include <stdio.h>

using namespace std;

int A, B, X;

int main()
{
	cin >> A;
	cin >> B;
	cin >> X;

	int flg = 0;

	for (int i = 0; i < B; i++) {
		if (A + i == X) {
			flg = 1;
			printf("YES");
			break;
		}
	}

	if (flg == 0) {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n;
string name;
string s;
int main()
{
	scanf("%lld",&n);
	cin>>name;
	ll len=(ll)name.size();
	ll cnt=0;
	for(ll i=0;i<n;i++){
		cin>>s;
		for(ll j=1; j*(name.size()-1)<s.size();j++){
			for(ll k=0;k+j*(name.size()-1)<s.size();k++){
				for(ll x=0;x<len;x++){
					if(s[k+j*x]!=name[x]) goto nex;
				}
				cnt++;
				goto oe;
				nex: ;
			}
		}
		oe: ;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3184
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;

int main()
{
    ll N,K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	
	cout << (N-K+K-2)/(K-1)+1 << endl;
    

    return 0;
}


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

typedef long long ll;
const int MAXN=1e6+7;

using namespace std;
int c[MAXN+5];
int main()
{
    string s,t;
    int n;
    cin>>n;
    cin>>s>>t;
    if(s[0]!=t[0]|| s.length()!=t.length()){return 0*puts("-1");}
    int ans=0,k=0,sum=0;
    for(int i=n-1,j=n-1;i>=0;i--)
    {
        sum+= c[i+k];
        if( j>i || t[i]!=s[j])
        {
            while( j>=0 &&( j>i|| t[i]!=s[j])) j--;
            if(j==i) continue;
            if(j<0)
            {
                return 0*puts("-1");
            }
            k++,sum++;
            c[i+k-1]=0,c[j+k-1]--;
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6024
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int e = abs(a - b);
    int f = abs(b - c);
    int z = abs(a - c);
    if (e <= d&&f <= d||z<=d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

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

	vector<long long int> X(N), Y(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> X[i] >> Y[i];
	}

	int ans = 0;

	for (int i = 0; i < N; ++i)
	{
		double tmp = sqrt((X[i]) * (X[i]) + (Y[i]) * (Y[i]));
		if (tmp <= D) ans++;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 6488
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: i64, k: i64,
        mut aa: [i64; n as usize]
    }
    
    for _ in 0..k {
        let mut memo = vec![0i64; n as usize + 1];
        for i in 0..n {
            let left = max(0, i - aa[i as usize]) as usize;
            let right = min(n, i + aa[i as usize] + 1) as usize;
            memo[left] += 1;
            memo[right] -= 1;
        }
        let mut aa2 = vec![0; n as usize];
        let mut prev = 0;
        for i in 0..n as usize {
            aa2[i] = prev + memo[i];
            prev = aa2[i];
        }
        aa = aa2;
        if aa.iter().all(|v| *v == n) {
            break;
        }
    }
    for v in aa {
        print!("{} ", v);
    }

}


Measured memory_bytes: 7860
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int first = N%10;
        int tenth = (N-first)/10;
        sc.close();
            
        if(first == 9 || tenth == 9){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

void solve()
{
    int n;
    cin >> n;
    n = 3 * n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    ll ans = 0;
    for (int i = 1; i <= n * 2 / 3; i += 2)
    {
        ans += a[i];
    }
    cout << ans << endl;
}

int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 4568
#ifdef LOCAL_BUILD
#include "pch.h"
#define DLOG(msg) cout << "#" << __LINE__ << ":" << msg << endl;
#define DLOG_V(var) \
  cout << "#" << __LINE__ << ":" << #var << " : " << var << endl;
#else
#include <bits/stdc++.h>
#define DLOG(msg)
#define DLOG_V(var)
#endif
using namespace std;

struct Edge {
  int weight;
  int source;
  int destination;
};

int main() {
  int n;
  cin >> n;
  auto cmp = [](const Edge& lhs, const Edge& rhs) {
    return lhs.weight > rhs.weight;
  };
  vector<vector<Edge>> edges(n, vector<Edge>());
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int w;
      cin >> w;
      if (w != -1) {
        Edge e {w, i, j};
        edges[i].push_back(move(e));
      }
    }
  }

  int total_weight = 0;
  unordered_set<int> contained;
  contained.insert(0);
  priority_queue<Edge, vector<Edge>, decltype(cmp)> q(cmp);
  for (auto&& e : edges[0]) {
    q.push(e);
  }
  while (static_cast<int>(contained.size()) < n) {
    auto e = q.top();
    q.pop();
    if (contained.find(e.destination) == contained.end()) {
      total_weight += e.weight;
      contained.insert(e.destination);
      for (auto&& edge : edges[e.destination]) {
        q.push(edge);
      }
    }
  }
  cout << total_weight << endl;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;    

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        int[] hoge=System.Console.ReadLine().Trim().Split(' ').Select(x=>int.Parse(x)).ToArray();
        int[] Ai=System.Console.ReadLine().Trim().Split(' ').Select(x=>int.Parse(x)).ToArray();
        int counta=0,countb=0;
        for(int i=0;i<hoge[1];i++){
            if(hoge[2]>Ai[i]) counta++;
            if(hoge[2]<Ai[i]) countb++;
        }
        if(counta<=countb) System.Console.WriteLine(counta);
        else System.Console.WriteLine(countb);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  vector<int> k(N, 2);
  rep(i, 2, N - 1) {
    k[i] = k[i-1] * -1;
  }
  k[0] = -1;
  if (N % 2)
    k[N-1] = -1;
  else
    k[N-1] = 1;

  sort_(A);
  sort_(k);
  ll ans1 = 0;
  rep(i, 0, N) {
    ans1 += A[i] * k[i];
  }
  rep(i, 0, N) {
    k[i] *= -1;
  }
  sort_(k);
  ll ans2 = 0;
  rep(i, 0, N) {
    ans2 += A[i] * k[i];
  }
  cout << max(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 1340
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;
 
int main(){
    int x,ans = 1;
    cin >> x;
    for(int i=2; i <= x; i++){
        int beki = i*i;
        while(beki<=x){
            ans = max(ans,beki);
            beki *=i;
        }
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main(int argc, char *argv[])
{
    using namespace std;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int g, r;
    cin.ignore();
    cin >> g >>r;
    cout << (((10*g+r)%4==0)?"YES\n":"NO\n");
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){
	ll a,b;cin >> a >> b;cout << (a-1)*(b-1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
int a[100005];
int main() {
	int n;
	scanf("%d", &n);
	set<string> a;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		a.insert(s);
	}
	printf("%d\n", a.size());
	return 0;
}

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

se = set()
dic = dict()

for i in range(N):
    if A[i] in se:
        dic[A[i]] += 1
    else:
        se.add(A[i])
        dic.update({A[i]: 1})

c = 0
for k in dic.keys():
    c += (dic[k])*(dic[k]-1)//2

for i in range(N):
    print(c - dic[A[i]]+1)


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

using i8  = int8_t;using i16 = int16_t;using i32 = int32_t;using i64 = int64_t;using u8  = uint8_t;using u16 = uint16_t;using u32 = uint32_t;using u64 = uint64_t;using f32 = float;using f64 = double;
using vi32 = vector<i32>;using vi64 = vector<i64>;using vvi32 = vector<vi32>;using vvi64 = vector<vi64>;using pi32 = pair<i32,i32>;using pi64 = pair<i64,i64>;

#define FOR(i,a,b) for(i64 i=(a), i##_len=(b); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,x) for(i64 i=1;i<=(i64)(x);i++)
#define RREPS(i,x) for(i64 i=((i64)(x));i>0;i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define SZ(x) ((i64)(x).size())
#define CLR(ar,val) memset(ar, val, sizeof(ar))
#define cauto const auto&
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

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

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


void Main();
i32 main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    //---
    i32 n; cin >> n;
    int arr[n];
    REP(i,n) cin >> arr[i];
    for (i32 i = 0; i < n; i++) cout << arr[i] << (i == (n-1) ? "" : " " );
    cout << endl;
    for (i32 i = 1; i < n; i++) {
        i32 v = arr[i];
        i32 j = i - 1;
        while (j >= 0 && arr[j] > v) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = v;

        for (i32 i = 0; i < n; i++) cout << arr[i] << (i == (n-1) ? "" : " " );
        cout << endl;
    }

    //---
}


Measured memory_bytes: 3172
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n, m;
void solve() {
    cin >> n >> m;
    auto s = n / 2;
    auto t = (n % 2 == 1 ? n : n - 1);
    rep(i, s) {
        auto l = i + 1;
        auto r = s - i;
        if (r <= l) break;
        if (r - l <= m) cout << l << " " << r << '\n';
    }
    rep(i, n - s) {
        auto l = s + i + 1;
        auto r = t - i;
        if (r <= l) break;
        if (r - l <= m) cout << l << " " << r << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3688
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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


    string S;
    cin >> S;

    string T;
    cin >> T;

    cin >> A;
    cin >> B;
    
    string U;
    cin >> U;

    if(S==U){
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " "  << B-1 << endl;

    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int fact[100007];
  fact[0]=1;
  int mod=1e9+7;
  rep(i,n)fact[i+1]=(ll)fact[i]*(1+i)%mod;
  cout<<fact[n]<<endl;

  return 0;

}


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

int main(){
    int N;
    cin >> N;
    vector<string> blue(N);
    for(int i = 0; i < N;i++){
        cin >> blue[i];
    }
    int M;
    cin >> M;
    vector<string> red(M);
    for(int i = 0; i < M;i++){
        cin >> red[i];
    }
    int ans = 0;

    auto calc = [&](string s){
        int buf = 0;
        for(string t: blue) {
            if (t == s) buf++;
             }
         for(string t: red) {
            if (t == s) buf--;
            }
        return buf;
    };

    for(string t:blue){
        ans = max(ans,calc(t));
    }
    cout << ans << endl;
}

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

int main() {
    int64_t N, M;
    cin >> N >> M;
    vector<vector<int64_t>> connect(N);
    for (int64_t i = 0; i < M; i++) {
        int64_t A, B;
        cin >> A >> B;
        A--;
        B--;
        connect[A].push_back(B);
        connect[B].push_back(A);
    }

    vector<int64_t> cost(N, LLONG_MAX);
    struct Element {
        int64_t node, cost;
        bool operator>(const Element& rhs) const {
            return cost > rhs.cost;
        }
    };
    priority_queue<Element, vector<Element>, greater<Element>> pq;

    vector<int64_t> ans(N, -1);

    cost[0] = 0;
    pq.push({ 0, 0 });
    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost > cost[t.node]) {
            continue;
        }

        for (int64_t next_node : connect[t.node]) {
            int64_t new_cost = t.cost + 1;
            if (new_cost < cost[next_node]) {
                pq.push({ next_node, cost[next_node] = new_cost });
                assert(ans[next_node] == -1);
                ans[next_node] = t.node;
            }
        }
    }

    cout << "Yes" << endl;
    for (int64_t i = 1; i < N; i++) {
        cout << ans[i] + 1 << endl;
    }
}

Measured memory_bytes: 14808
#include <stdio.h>
#include <math.h>
int main(){
	int i,n;
	double s[1000],a,sum,A;
	while(1){
		sum=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%lf",&s[i]);
			sum+=s[i];
		}
		A=sum/(double)n;
		sum=0;
		for(i=0;i<n;i++){
			sum+=pow(s[i]-A,2);
		}
		a=sqrt(sum/(double)n);
		printf("%0.8f\n",a);
	}
	return 0;
}


Measured memory_bytes: 1804
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{
    ll n,m,i,j,s=0;
    cin>>n>>m;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    if(n<=m)
    {
        s=0;
        cout<<s<<endl;
    }
    else
    {
        for(i=0;i<n-m;i++)
        {
            s=s+a[i];
        }
        cout<<s<<endl;
    }
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int n, m;
int p[100001], y[100001];
int num[100001];
string ans[100001];

string sol(tuple<int,int,int> a) {
  int nowy, nown, index;
  tie(nowy, nown, index) = a;
  string nn = to_string(nown);
  string yy = to_string(nowy);
  while (nn.size() < 6) {
    nn = "0" + nn;
  }
  while (yy.size() < 6) {
    yy = "0" + yy;
  }
  return nn + yy;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  vector<tuple<int,int,int> > v;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> y[i];
    p[i]--;
    v.push_back(make_tuple(y[i], p[i], i));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) num[i] = 1;
  for (int i = 0; i < m; i++) {
    tuple<int,int,int> tmp = make_tuple(num[get<1>(v[i])], get<1>(v[i]) + 1, i);
    ans[get<2>(v[i])] = sol(tmp);
    num[get<1>(v[i])]++;
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int a = s.compare(0,s.length(),t,0,s.length());
    if(a == 0 && s.length() == (t.length() - 1))
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3600
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val a = readInputLine().split(" ").map{it.toLong()}.toList().toLongArray()
    val b = readInputLine().split(" ").map{it.toLong()}.toList().toLongArray()
    
    var ans = 0L

    for (i in 0 until n) {
        if (b[i] > a[i]) {
            ans += a[i]
            val left = b[i] - a[i]
            if (left >= a[i + 1]) {
                ans += a[i + 1]
                a[i + 1] = 0L
            } else {
                ans += left
                a[i + 1] = a[i + 1] - left
            }
        } else {
            ans += b[i]
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;

int main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    int A[Q];
    int p[N]={};

    int i,j;
    for(i=0;i<Q;i++){
     	int A;
        cin >> A;
      	p[A-1]++;
    }
              
 	/*	DEBUG	*/
  	//r(i=0;i<N;i++){
      //intf("[%2d]=>%d\n",i+1,p[i]);
    //

    for(i=0;i<N;i++){
        int lp=K+(p[i]-Q);	//intf("@[%2d]=%d\n",i+1,lp);
        if(lp>0){
            puts("Yes");
        }else{
            puts("No");
        }
    }
}

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

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

class ASecurity {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s;
	    in >> s;
	    bool flag = true;
	    for(int i = 1 ; i < s.length() ; i++)
	        if(s[i] == s[i-1])
	            flag = false;
	    if(flag)
	        out << "Good";
	    else
	        out << "Bad";
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ASecurity solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

/*
      ___                                 ___           ___           ___
     /  /\        ___         ___        /__/\         /  /\         /__/|
    /  /::\      /__/|       /  /\       \  \:\       /  /::\       |  |:|
   /  /:/\:\    |  |:|      /  /:/        \__\:\     /  /:/\:\      |  |:|
  /  /:/~/:/    |  |:|     /  /:/     ___ /  /::\   /  /:/  \:\   __|__|:|
 /__/:/ /:/   __|__|:|    /  /::\    /__/\  /:/\:\ /__/:/ \__\:\ /__/::::\____
 \  \:\/:/   /__/::::\   /__/:/\:\   \  \:\/:/__\/ \  \:\ /  /:/    ~\~~\::::/
  \  \::/       ~\~~\:\  \__\/  \:\   \  \::/       \  \:\  /:/      |~~|:|~~
   \  \:\         \  \:\      \  \:\   \  \:\        \  \:\/:/       |  |:|
    \  \:\         \__\/       \__\/    \  \:\        \  \::/        |  |:|
     \__\/                               \__\/         \__\/         |__|/

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
vector<int> prime;
void seive(){
    vector<bool > isprime(101,true);
    for(int i=2;i*i<=100;i++){
        if(isprime[i]){
            for(int j=i*i;j<=100;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=100;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans=(n*(n-1))/2ll;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll mod=1000 * 1000 * 1000 + 7;
ll mul(ll a, ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll add(ll a, ll b)
{
	return ((a%mod)+(b%mod))%mod;
}
ll sub(ll a, ll b)
{
	return ((a%mod)-(b%mod)+mod)%mod;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,a,b;
	cin>>n>>a>>b;
	if((b-a)%2==0)
	{
		cout<<(b-a)/2;
	}	
	else
	{
		ll u1=a;
		ll x=b;
		b-=a;
		u1+=(b-1)/2;
		b=x;
		ll u2=n-b+1;
		a+=(n-b+1);
		u2+=abs(n-a)/2;
		cout<<min(u1,u2);
	}
}


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

int main()
{
    
    double n,k;
    cin>>n>>k;
    double sum=0;
    for(int i=1;i<=n;i++){
        double tmp=0;
        tmp=(1.0/n);
        int ind=i;
        while(ind<k){
            tmp/=2;
            ind*=2;
        }
        sum+=tmp;
    }
    printf("%0.12f",sum);
    
}

Measured memory_bytes: 764