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

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<int> a(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater<int>());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            alice += a[i];
        }
        else {
            bob += a[i];
        }
    }

    cout << (alice - bob) << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long
const int N = 1e6 + 233;
const int M = N * 4;
struct E {
    int from, to, w;
}e[M]; int e_cnt = 0;

int n, q, inf, pre[N], suf[N];

inline void link(int x, int y, int w) {
    if (w == inf) return ;
    // cout << x - 1 << " " << y - 1 << " " << w << "\n";
    e[++e_cnt] = (E) {x, y, w};
}

namespace dsu {
    int pre[N];
    inline int find(int x) {
	return pre[x] == x ? x : pre[x] = find(pre[x]);
    }
    inline void init(int n) {
	rep (i, n) pre[i] = i;
    }
    inline void make(int x, int y) {
	pre[find(x)] = find(y);
    }
}

inline void doit() {
    sort(e + 1, e + e_cnt + 1, [](E a, E b) {
				   return a.w < b.w;
			       });
    dsu::init(n);
    int ans = 0;
    rep (i, e_cnt) {
	int fx = dsu::find(e[i].from);
	int fy = dsu::find(e[i].to);
	if (fx != fy) {
	    ans += e[i].w;
	    dsu::make(fx, fy);
	}
    }
    cout << ans << "\n";
}

signed main(void) {
    read(n); read(q);
    memset(pre, 38, sizeof pre);
    memset(suf, 38, sizeof suf);
    inf = pre[0];
    rep (i, q) {
	int x, y, w; read(x); read(y); read(w);
	++x; ++y;
	link(x, y, w);
	// if (x < y) {
	pre[x] = min(pre[x], w + 1);
	pre[y] = min(pre[y], w + 2);
	// } else {
	//     pre[x] = min(pre[x], w + 2);
	//     pre[y] = min(pre[y], w + 1);
	// }
    }
    for (int i = 1; i <= n + n; i++) {
	pre[i] = min(pre[i], pre[i - 1] + 2);
    }
    // for (int i = n + n; i >= 1; i--) {
    // 	suf[i] = min(suf[i], suf[i + 1] + 2);
    // }
    // for (int i = 1; i <= n + n; i++)
    // 	cout << pre[i] << " \n"[i == n + n];
    for (int i = 1; i <= n + n - 1; i++) {
	int x = i, y = i + 1;
	if (x > n) x -= n;
	if (y > n) y -= n;
	link(x, y, pre[i]);
	// link(x, y, suf[i + 1]);
    }
    doit();
}


Measured memory_bytes: 36480
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(n<k || k==1)
        printf("0\n");
    else
        printf("%d\n",n-k);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
    int students;               //人数

    while( true )
    {
        double sum1 = 0, sum2 = 0;  //合計
        double ave = 0;             //平均
        double dev = 0;             //偏差

        cin >> students;

        if( students == 0 )
            break;

        double points[students];    //点数

        for( int i = 0; i < students; i++ )             //平均の計算
        {
            cin >> points[i];
            sum1 += points[i];
        }

        ave = sum1 / students;

        for( int i = 0; i < students; i++ )             //分散手前の計算
            sum2 += pow( (points[i] - ave), 2 );

        sum2 /= students;                               //分散

        dev = sqrt(sum2);                               //標準偏差

        cout << fixed;
        cout << setprecision(10) << dev << endl;
    }

    return 0;
}


Measured memory_bytes: 3240
N, Q = map(int, input().split(' '))
S = '0' + input() + '0'
A = [list(input().split(' ')) for _ in range(Q)]
l = 0
r = N+1
for i in range(Q-1, -1, -1):
  t, d = A[i]
  if t == S[l] and d == 'R':
    l -= 1
  elif t == S[l+1] and d == 'L':
    l += 1
    
  if t == S[r] and d == 'L':
    r += 1
  elif t == S[r-1] and d == 'R':
    r -= 1
print(max(0, r-l-1))

Measured memory_bytes: 26832
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int A_MAX = 200000;

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    int succeeded_index = -1;
    for(int i=0;i<n;++i) {
        bool ok = true;
        for(int j=0;j<m;++j) {
            ok &= (s[i+j] == '?' || s[i+j] == t[j]);
        }
        if(ok) {
            succeeded_index = i;
        }
    }

    if(succeeded_index == -1) {
        cout << "UNRESTORABLE\n";
        return 0;
    }
    for(int i=0;i<n;++i) {
        if(succeeded_index <= i && i < succeeded_index+m) {
            cout << t[i-succeeded_index];
        } else if(s[i] == '?') {
            cout << 'a';
        } else {
            cout << s[i];
        }
    }
}


Measured memory_bytes: 3620
#include<iostream>
#include<array>
using namespace std;
int main() {
	
	/*int n;
	int b[101], c[101];
	cin >> n;
	int i,j,k;
	for (i = 1; i <= n; i++) {
		cin >> b[i];
	}
	int maxa, maxb;

	for (i = n; i >= 1; i--) {
		for (j = i; j >= 1; j--) {
			if (b[j] > j) {
				cout << -1;
				return 0;
			}
			else if (b[j] == j) {
				c[i] = j;
				for (k = j; k < n; k++) {
					b[k] = b[k + 1];
				}
				break;
			}
		}
	}
	for (i = 1; i <= n; i++) {
		cout << c[i];
		cout << '\n';
	}
	return 0;*/
	//B
	int n,m;
	cin >> n;
	int i, j;
	if (n % 2 == 0) {
		m = (n * (n - 1)) / 2 - n / 2;
		cout << m;
		cout << '\n';
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				if ((i + j) == n + 1) {

				}
				else {
					cout << i;
					cout << ' ';
					cout << j;
					cout << '\n';
				}
			}
		}
	}
	else {
		//n%2 == 1;
		m = (n * (n - 1)) / 2 - (n-1) / 2;
		cout << m;
		cout << '\n';
		for (i = 1; i <= n-1; i++) {
			for (j = i + 1; j <= n-1; j++) {
				if ((i + j) == n) {

				}
				else {
					cout << i;
					cout << ' ';
					cout << j;
					cout << '\n';
				}
			}
			cout << i;
			cout << ' ';
			cout << n;
			cout << '\n';
		}
		
	}

	return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    static long[] Separate(string s)
    {
        long N = s.Length;
        long count = 0;
        var counts = new List<long>();
        for (int i = 0; i < N; ++i)
        {
            ++count;
            if (i + 1 == N || s[i] != s[i + 1])
            {
                counts.Add(count);
                count = 0;
            }
        }
        return counts.ToArray();
    }

    static long Solve(string S, long K)
    {
        var counts = Separate(S);
        if (S.First() != S.Last())
        {
            return counts.Sum(count => count / 2) * K;
        }
        else if (counts.Length > 1)
        {
            long sum = 0;
            for (int i = 1; i < counts.Length - 1; ++i)
            {
                sum += counts[i] / 2;
            }
            long A = counts.First();
            long B = counts.Last();
            return sum * K + (A + B) / 2 * (K - 1) + A / 2 + B / 2;
        }
        else
        {
            return counts[0] * K / 2;
        }
    }

    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        long K = long.Parse(Console.ReadLine());
        Console.WriteLine(Solve(S, K));
    }
}


Measured memory_bytes: 11348
n = int(input())
b = list(map(int,input().split(" ")))
a = []
for i in range(n):#0,1,2
    if i == 0:
        a.append(b[0])
        # print(a)
        # print("1こめ")
    if i > 0 and i < n-1:
        c = min([b[i],b[i-1]])
        a.append(c)
        # print(a)
        # print("2こめ")
    if i == n-1:
        a.append(b[n-2])
        # print(a)
        # print("3こめ")
print(sum(a))

Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

    for (ll a = -1000; a <= 1000; a++)
    {
        ll a5 = a * a * a * a * a;

        for (ll b = -1000; b <= 1000; b++)
        {
            ll b5 = b * b * b * b * b;

            if (a5 - b5 == X)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3632
import sys
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
if m==1:
  print(1)
  sys.exit()
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
Max=max(list(pf.values()))
f_mod=[1]*(Max+n+1)
f_mod_inverse=[1]*(Max+n+1)
for i in range(1,Max+n+1):
  f_mod[i]=(f_mod[i-1]*i)%MOD
  f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD  
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)


Measured memory_bytes: 11076
N = int(input())
A = list(map(int, input().split()))
mod = int(1e9) + 7
def inved(a):
    x, y, u, v, k, l = 1, 0, 0, 1, a, mod
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return x % mod
L = [0 for _ in range(N)]
L[0] = A[0]
for i in range(1, N):
    L[i] = (L[i-1] + A[i]) % mod

fact = [1 for _ in range(N+10)]
invN = [inved(_) for _ in range(N+10)]
for i in range(N+9):
    fact[i+1] = (fact[i] * (i + 1)) % mod
S1, S2, S3, S4 = 0, 0, 0, (fact[N] * L[-1]) % mod
Y1, Y2, Y3, Y4 = 0, 0, 0, 0
S = 0

X1 = 0
X2, X3, X4 = 0, 0, 0
for i in range(1, N-1):
    X1 -= 2 * fact[N] * (L[-2] - L[i-1]) * invN[N-i+1] % mod
    X1 %= mod
for i in range(N-2):
    X1 += 2 * fact[N] * (L[-2] - L[i]) * invN[i+2] % mod
    X1 %= mod
for i in range(N-1):
    X2 += fact[N] * (L[i]) * invN[i+2] % mod
    X2 %= mod
for i in range(1, N):
    X3 += fact[N] * (L[-1] - L[i-1]) * invN[N-i+1] % mod
    X3 %= mod
X4 = fact[N] * L[-1] % mod
print((X1+X2+X3+X4) % mod)

Measured memory_bytes: 19060
d, g = map(int, input().split(' '))
p = []
c = []
for _ in range(d):
    p_, c_ = map(int, input().split(' '))
    p.append(p_)
    c.append(c_)

sum_p = []
for i in range(d):
    sum_p.append((i + 1) * 100 * p[i] + c[i])


def ans(g, t):
    if t <= 0:
        return float('inf')
    n = min(int(g / (100 * t)), p[t-1])
    s = 100 * t * n

    if n == p[t-1]:
        s = sum_p[t-1]
    if g > s:
        n += ans(g - s, t - 1)

    return min(n, ans(g, t - 1))


print(ans(g, d))


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

int main(){
    int N,l,r,num,sum;

    cin >> N;
    sum = 0;

    rep(i,N){
        num = 0;
        cin >> l >> r;
        num = r - l + 1;
        sum += num;
    }
    cout << sum;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long K, std::vector<long long> A){
  vector<ll> cpy_A=A;
  sort(cpy_A.begin(),cpy_A.end());
  cpy_A.erase(unique(cpy_A.begin(),cpy_A.end()),cpy_A.end());
  if(cpy_A.size()==A.size()){
    K=(K-1)%(N+1);
    dump(K);
    dump(A);
    FOR(i,K,A.size()){
      cout<<A[i]<<" ";
    }
    cout<<endl;
    return ;
  }
  vector<vector<ll>> idxs(200000);
  REP(N){
    idxs[A[i]].push_back(i);
  }
  ll loop=0;
  ll pprev=0;
  vector<ll> loops;
  loops.push_back(N);
  do{
    auto itr=lower_bound(idxs[A[pprev]].begin(),idxs[A[pprev]].end(),pprev);
    itr=next(itr);
    if(itr==idxs[A[pprev]].end()){
      loops.push_back(*prev(itr));
      ++loop;
      pprev=(idxs[A[pprev]].front()+1)%N;
    }else{
      pprev=(*itr+1)%N;
    }
  }while(pprev!=0);
  ++loop;
  dump(loop);
  dump(loops);
  K=K%loop;
  if(K==0){
    cout<<endl;
    return;
  }else{
    ll l=loops[K];
    vector<ll> ans;
    for(int i=l;i<N;++i){
      auto itr=idxs[A[i]].begin();
      if((itr=upper_bound(idxs[A[i]].begin(),idxs[A[i]].end(),i))!=idxs[A[i]].end()){
        i=*itr;
      }else{
        ans.push_back(A[i]);
      }
    }
    REP(ans.size()){
      cout<<ans[i];
      if(ans.size()-1==i){
        cout<<endl;
      }else{
        cout<<" ";
      }
    }
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 13436
answers = []
n = gets.chomp.to_i
for i in 1..n
  if i%3 == 0
    answers.push(i)
  # elsif i%10 == 3
  #   answers.push(i)
  # end
  elsif i.to_s.include?("3")
    answers.push(i)
  end
end
print " "
puts answers.join(' ')

Measured memory_bytes: 8836
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
void solve(){
	map<pair<ll,ll> ,ll> mapa;
	map<ll,ll> cnt;
	ll x = 'R'^'G'^'B';
	vector<ll> chars;
	chars.pb('R');
	chars.pb('G');
	chars.pb('B');
	ll n, ans=0;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=n-1;i>=0;i--){
		for(auto x : chars ){
			mapa[{x,i}]=cnt[x];
		}
		cnt[s[i]]++;
	}
	rep(i,0,n){
		rep(j,0,i){
			if(s[j]!=s[i]){
				char c = (i+(i-j)<n)?s[i+i-j]:'*';
				//cout<<c<<" ";
				ans+=mapa[{s[j]^s[i]^x,i}]-(c==(char)(s[j]^s[i]^x));
				//cout<<"s[i]: "<<s[i]<<" s[j]: "<<s[j]<<" rem: "<<mapa[{s[i]^s[j]^x,i+1}]<<"\n";
			}
		}
	}
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4332
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var M = sc.nextInt();
        var broken = new int[N + 1];
        for (int i = 0; i < M; i++) {
            var a = sc.nextInt();
            broken[a] = 1;
        }
        var dp = new int[N + 2];
        dp[N] = 1;
        for (int i = N-1; i >= 0; i--) {
            if (broken[i] == 1) {
                dp[i] = 0;
                continue;
            }
            dp[i] = (dp[i + 1] + dp[i + 2]) % 1000000007;
        }
        WriteLine(dp[0]);
    }
}

class Combination {
    static int mod = 1000000007;

    public static long Calc(int a, int b) {
        if (b > a - b) return Calc(a, a - b);

        long ansMul = 1;
        long ansDiv = 1;
        for (int i = 0; i < b; i++) {
            ansMul *= (a - i);
            ansDiv *= (i + 1);
            ansMul %= mod;
            ansDiv %= mod;
        }
        return ansMul * ModPow(ansDiv, mod - 2) % mod;
    }

    private static long ModPow(long a, int p) {
        if (p == 0) return 1;
        if (p % 2 == 0) {
            long half = ModPow(a, p / 2);
            return half * half % mod;
        } else {
            return a * ModPow(a, p - 1) % mod;
        }
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 15836
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#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 out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int N,tmp,cnt;

int main(){
    cin>>N;
    int a[N+1],b[N+1];
    rep(i,N+1){
        a[i]=b[i]=0;
    }
    repi(i,1,N+1)cin>>a[i];
    for(int i=N;i>=1;i--){
        tmp=0;
        for(int j=i;j<=N;j+=i){
            tmp+=b[j];
        }
        if(tmp%2==a[i])b[i]=0;
        else{
            cnt++;
            b[i]=1;
        }
    }
    if(cnt==0){
        out(0);
        return 0;
    }
    out(cnt);
    repi(i,1,N+1){
        if(b[i])out(i);
    }

    

}


Measured memory_bytes: 2432
#include <cstdio>
#include <string>
using namespace std;

int main() {
	int N;
	int countl = 0;
	string buf = "";
	scanf("%d\n", &N);
	for (int i = 0; i < N; i++) {
		char chr;
		scanf("%c", &chr);
		if (chr == '(') {
			buf += chr;
			countl++;
			// printf("a\n");
		} else if (chr == ')' && countl == 0) {
			buf = '(' + buf + chr;
			// printf("b\n");
		} else if (chr == ')') {
			buf += chr;
			countl--;
			// printf("c\n");
		}
	}
	printf("%s", buf.c_str());
	for (int i = 0; i < countl; i++) {
		printf(")");
	}
	printf("\n");
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dp[2010][2010],n,m,k;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<k;++i)
		dp[i][k-i]=1;
	for(int i=1;i<=max(n,m);++i)
		for(int j=1;j<=max(n,m);++j)
			if(!dp[i][j]&&(i+j-1)%(k-1)==0){
				dp[i][j]=1;
				for(int l=0;l<k;++l)
					if(i-l>=1&&j-(k-1-l)>=1)
						dp[i][j]=(1ll*dp[i][j]+dp[i-l][j-(k-1-l)])%mod;
			}
	printf("%d",dp[n][m]);
}

Measured memory_bytes: 16000
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#include <string>
using namespace std;

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main() {
	int m;
	cin >> m;
	cout << 24 - m + 24 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<int, int>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
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;}
ll INF = 1e+18;
int iINF = 1e9;

int main()
{
  int N, K; cin >> N >> K;
  vector<int> arr(N);
  rep(i, 0, N) cin >> arr[i];
  vector<bool> dp(K + 1, false);

  repe(i, 1, K){
    rep(k, 0, N){
      if(i - arr[k] >= 0){
        if(!dp[i - arr[k]]) dp[i] = true;
      }
    }
  }

  if(dp[K]) cout << "First" << endl;
  else cout << "Second" << endl;
}


Measured memory_bytes: 3596
N = int(input())
a = list(map(int, input().split()))
count = 0
skip = False

if N == 2:
    if a[0] == a[1]:
        count += 1
else:
    for i in range(N-1):
        if skip:
            skip = False
            continue
        else:
            if a[i] == a[i+1]:
                count += 1
                skip = True

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, m, t[100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    int sol = 0;
    for (int i = 0; i < n; ++i)
        cin >> t[i], sol += t[i];
    cin >> m;
    for (int i = 0; i < m; ++i)
    {
        int p, x;
        cin >> p >> x;
        p--;
        cout << sol - t[p] + x << '\n';
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, c0, c1, c2, c3 int
	fmt.Scan(&n)
	s := scanStrings(n)
	for i := 0; i < n; i++ {
		if s[i] == "AC" {
			c0 = c0 + 1
		} else if s[i] == "WA" {
			c1 = c1 + 1
		} else if s[i] == "TLE" {
			c2 = c2 + 1
		} else if s[i] == "RE" {
			c3 = c3 + 1
		}
	}
	fmt.Println("AC x ", c0)
	fmt.Println("WA x ", c1)
	fmt.Println("TLE x ", c2)
	fmt.Printf("RE x %d", c3)
}

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 10880
<?php
while(1){
  $n=trim(fgets(STDIN));
  if(!$n) break;

  $N=explode(' ',trim(fgets(STDIN)),$n);

  $x=0;foreach($N as $p) $x+=$p;

  $m=$x/$n;
  $y=0;foreach($N as $p) $y+=pow($p-$m,2);

  echo sqrt($y/$n),PHP_EOL;
}

Measured memory_bytes: 15748
import sys,heapq,math,resource
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def setrlim():
  sys.setrecursionlimit(250000)
  soft,hard = resource.getrlimit(RLIMIT_STACK)
  # setrlimit works on ubuntu (and atcoder), but not on WSL
  #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard))

a,b = inm()
x = max([a+b,a-b,a*b])
print(x)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x;
    cin >> x;

    if (5 <= x && x < 500) {
        cout << (x / 5) * 5 << endl;
    } else if (x < 5) {
        cout << 0 << endl;
    } else if (500 <= x) {
        cout << (x / 500) * 1000 + (x % 500) / 5 * 5 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

void work() {
    int n; cin>>n;
    vector<ll> v(1e5+1, 0);
    ll s = 0;
    for (int i = 0; i < n; ++i) {
        ll a; cin>>a;
        ++v[a];
        s += a;
    }
    int q; cin>>q;
    while (q--) {
        ll b, c; cin>>b>>c;
        s -= v[b] * b;
        s += v[b] * c;
        v[c] += v[b];
        v[b] = 0;
        cout << s << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


Measured memory_bytes: 3980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
int main() {
     string s, t;
     cin >> s >> t;
     int cnt = 0;
     for (int i = 0; i < s.size(); i++) {
          if(s[i] == t[i])
               cnt++;
     }
     cout << cnt;
}


Measured memory_bytes: 256
# ABC167c


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n, m, x = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]
    rikaido = [0]*m

    def dfs(i, su):
        if i == n:
            for al in rikaido:
                if al < x:
                    return 10 ** 12
            return su
        for j in range(m):
            rikaido[j] += a[i][j+1]
        t = dfs(i + 1, su + a[i][0])
        for j in range(m):
            rikaido[j] -= a[i][j+1]
        return min(t, dfs(i+1, su))

    ans = dfs(0, 0)

    print(ans if ans != 10 ** 12 else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9236
// F - Intervals on Tree
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n, x, y;
	cin >> n;
	long long ans = 0;
	for (long long i = 1; i <= n; i++) ans += (i + 1) * i / 2;
	for (int i = 0; i < n - 1; i++) {
		cin >> x >> y;
		if (x > y) swap(x, y);
		ans -= x * (n - y + 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=2005;
int a[N];
inline int duck(int x){return x<0?-x:x;}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
	int n,x,y,i,j;
	scanf("%d%d%d",&n,&x,&y);
	rep(i,1,n)rep(j,i+1,n)++a[min(j-i,duck(i-x)+duck(j-y)+1)];
	REP(i,1,n)printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 256
n = int(input())

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

while True:
    a.sort()
    flag = True
    j = 0
    while a[j] == 0:
        j += 1
    for i in range(j+1,n):
        a[i] %= a[j]
        if a[i] != 0:
            flag = False
    if flag:
        break 

print(a[j])

Measured memory_bytes: 14252
n=int(input())
s=input()

#はじめ全員Wであると仮定
E_right,W_left=s.count('E'),0
mi=n #最小値
for i in range(n):
    if s[i]=='E': E_right-=1 #Eならデクリメント
    if W_left+E_right<mi: mi=W_left+E_right #更新
    if s[i]=='W': W_left+=1 #Wならインクリメント
print(mi)

Measured memory_bytes: 41432
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

uint64_t size(uint64_t n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        return size(n - 1) * 2 + 3;
    }
}

uint64_t full_patty(uint64_t n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        return full_patty(n - 1) * 2 + 1;
    }
}

uint64_t patty(uint64_t n, uint64_t x)
{
    if (n == 0)
    {
        return 1;
    }
    else if (size(n) <= x)
    {
        return full_patty(n);
    }
    else
    {
        auto prev_size = size(n - 1);
        if (x <= 1)
        {
            return 0;
        }
        else if (x <= prev_size + 1)
        {
            return patty(n - 1, x - 1);
        }
        else if (x == prev_size + 2)
        {
            return patty(n - 1, x - 1) + 1;
        }
        else if (x <= 2 * prev_size + 2)
        {
            return full_patty(n - 1) + 1 + patty(n - 1, x - prev_size - 2);
        }
        else
        {
            return full_patty(n - 1) * 2;
        }
    }
}

int main()
{
    uint64_t n, x;
    cin >> n >> x;

    cout << patty(n, x) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
int rv[30];
struct node{
  int id,left,right,par,sib,deg,dep,hei;
  string type;
  node(){par=sib=-1;}
  string val(){
    string res;
    res+="node "+to_string(id);
    res+=": parent = " +to_string(par);
    res+=", sibling = "+to_string(sib);
    res+=", degree = " +to_string(deg);
    res+=", depth = "  +to_string(dep);
    res+=", height = " +to_string(hei);
    res+=", "+type;
    return res;
  }
};
node t[30];
int dfs(int v,int d){
  t[v].dep=d;
  t[v].type="internal node";
  if(~t[v].left&&~t[v].right){
    t[rv[t[v].left ]].sib=t[v].right;
    t[rv[t[v].right]].sib=t[v].left;
    t[v].deg=2;
    return t[v].hei=max(dfs(rv[t[v].left],d+1),dfs(rv[t[v].right],d+1))+1;
  }else if(~t[v].left){
    t[v].deg=1;
    return t[v].hei=dfs(rv[t[v].left ],d+1)+1;
  }else if(~t[v].right){
    t[v].deg=1;
    return t[v].hei=dfs(rv[t[v].right],d+1)+1;
  }else{
    t[v].type="leaf";
    t[v].deg=0;
    return t[v].hei=0;
  }
}
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>t[i].id>>t[i].left>>t[i].right;
  for(int i=0;i<n;i++) rv[t[i].id]=i;
  for(int i=0;i<n;i++){
    //cout<<t[i].id<<":"<<t[i].left<<":"<<t[i].right<<endl;
    if(~t[i].left)  t[rv[t[i].left ]].par=t[i].id;
    if(~t[i].right) t[rv[t[i].right]].par=t[i].id;
  }
  for(int i=0;i<n;i++) if(t[i].par==-1) dfs(i,0),t[i].type="root";
  for(int i=0;i<n;i++) cout<<t[rv[i]].val()<<endl;
  return 0;
}

Measured memory_bytes: 3248
import re

S = input().rstrip()
K = int(input())

reg = re.search(r'[2-9]', S)
if reg:
    i = reg.start()
else:
    i = len(S) + 1


if K < i + 1:
    print(1)
else:
    if S[0] == '1':
        print(S[i])
    else:
        print(S[0])


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i;
    string s;
    cin>>s;
    s='#'+s;
    int k;
    cin>>k;
    char ch=s[k];
    for(i=1;i<=n;i++)
    {
        if(s[i]!=ch)
        {
            s[i]='*';
        }
    }
    for(i=1;i<=n;i++)
    {
        cout<<s[i];
    }
    cout<<endl;
}



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

int main() {
	int n, sx, sy, sh = 0, H, k;
	cin >> n;
	vector<int> x(n), y(n), h(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] && !sh) {
			sx = x[i];
			sy = y[i];
			sh = h[i];
		}
	}

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			H = abs(i - sx) + abs(j - sy) + sh;
			for (k = 0; k < n; k++)
				if (max(H - abs(x[k] - i) - abs(y[k] - j), 0) != h[k])
					k = n + 1;
			if (k != n + 2) {
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
#define MAX 210000
int main(){
    int n;
    long long int N[MAX];
    long long int maxv= -20000000000000;
    long long int minv= 100000000000000;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> N[i];
        maxv = max(maxv,N[i] - minv);
        minv = min(minv,N[i]);
    }
    cout << maxv << endl;
    return 0;
}


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

int main(){
  double A, B;
  cin >> A >> B;

  double K;
  K = (A + B)/ 2;

  if((K - (int)K) == 0){
    cout << (int)K << endl;
    return 0;
  }

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

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pair<double, double> > Pdd;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int K;
double R,L,P,E,T;


double dfs(int k, double r, double l){
  if(T-E <= r && l <= T+E) return 1;
  if(r > T+E || l < T-E) return 0;

  if(k==0){
    if(T-E<=(r+l)/2 && (r+l)/2 <= T+E) return 1;
    return 0;
  }
  double res = 0;
  double mid = (r+l)/2;
  if(mid < T){
    res = dfs(k-1, mid, l)*(1-P) + dfs(k-1, r, mid)*P;
  }else{
    res = dfs(k-1, mid, l)*P + dfs(k-1, r, mid)*(1-P);
  }
  return res;
}

int main(){
  scanf("%d%lf%lf%lf%lf%lf", &K, &R, &L, &P, &E, &T);
  printf("%.20lf\n", dfs(K, R, L));
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cstdio>
#include <algorithm>

#define INF (1e+9)

#define MAX_N 20

using namespace std;

int cost[MAX_N + 1][MAX_N + 1];

int N,M;


void init(){
	for(int i = 0;i <= MAX_N;i++){
		for(int j = 0;j <= MAX_N;j++){
			if(i == j) cost[i][j] = 0;
			else cost[i][j] = INF;
		}
	}
	return ;
}

void solve(){
	for(int k = 1;k <= N;k++){
		for(int i = 1;i <= N;i++){
			for(int j = 1;j <= N;j++){
				cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
			}
		}
	}

	return ;
}

int main(){
	init();
	scanf("%d%d",&N,&M);
	int _u,_v;
	int _cost0;
	int _cost1;
	for(int i = 0;i < M;i++){
		scanf("%d,%d,%d,%d",&_u,&_v,&_cost0,&_cost1);
		cost[_u][_v] = _cost0;
		cost[_v][_u] = _cost1;
	}
	
	solve();

	int rest,price;
	scanf("%d,%d,%d,%d",&_u,&_v,&rest,&price);
	int ans = rest - price - cost[_u][_v] - cost[_v][_u];
	printf("%d\n",ans);


	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll k;
    cin >> k;
    string n;
    cin >> n;
    ll ans = 0;
    vector<ll> bik(3000000);
    bik[0] = 1;
    ll m = n.size() - 1;
    for (ll i = 1; i < 3000000; i++) {
        bik[i] = bik[i - 1] * i % 1000000007;
    }
    for (int i = 0; i < k+1; i++) {
        ll zans = modpow(26, k-i, 1000000007) * modpow(25, i, 1000000007)%1000000007;
        zans *= bik[i + m] * modinv(bik[m], 1000000007) % 1000000007 * modinv(bik[i], 1000000007) % 1000000007;
        zans %= 1000000007;
        ans += zans;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 27632
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    string s;
    cin >> s;
    bool rull=false,onz=false;
    REP(i,LEN(s)){
        if(s[i]=='C') rull = true;
        if(rull&&s[i]=='F') onz = true;
    }
    puts(onz?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

ll sm1[MAX_N],sm2[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
	vi vec(3*n);
	rep(i,3*n){
		cin >> vec[i];
	}
	priority_queue<int,vector<int>,greater<int> > que;
	priority_queue<int> que2;
	ll sm = 0;
	rep(i,n){
		sm += vec[i];
		que.push(vec[i]);
	}
	sm1[0] = sm;
	rep(i,n){
		que.push(vec[i+n]);
		sm += vec[i+n];
		int val = que.top();
		que.pop();
		sm -= val;
		sm1[i+1] = sm;
	}
	sm = 0;
	srep(i,2*n,3*n){
		sm += vec[i];
		que2.push(vec[i]);
	}
	sm2[0] = sm;
	rep(i,n){
		que2.push(vec[2*n-1-i]);
		sm += vec[2*n-1-i];
		int val = que2.top();
		que2.pop();
		sm -= val;
		sm2[i+1] = sm;
	}
	// rep(i,n+1){
	// 	cout << i << " " << sm1[i] << " " << sm2[i] << "\n";
	// }
	ll mx = -(1LL << 60);
	rep(i,n+1){
		cmx(mx,sm1[i]-sm2[n-i]);
	}
	cout << mx << "\n";
    return 0;
}


Measured memory_bytes: 3960
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct {
    int cost;
    int point;
}result;
result search(vector<vector<int> >& vx, result r, int size, int target){
    if( r.point >= target ) return r;
    bool found=false;
    result max, tmp;
    for(int i=0; i<size; i++){
        if(vx[i][2]==1) continue;
        if( target - r.point < 100*(i+1)*vx[i][0] ){
            tmp.cost = r.cost+((target-r.point)/(100*(i+1)));
            if(((target-r.point)%(100*(i+1)))!=0) tmp.cost++;
            tmp.point = target;
            if( found==false ){ found=true; max=tmp; }
            else if(tmp.cost < max.cost) max = tmp;        
        }else{
            tmp = r;
            tmp.cost += vx[i][0], tmp.point += 100*(i+1)*vx[i][0]+vx[i][1];
            vx[i][2] = 1;
            tmp = search(vx, tmp, size, target);
            vx[i][2] = 0;
            if( found==false ){ found=true; max=tmp; }
            else if( (tmp.point >= target) && (tmp.cost < max.cost)) max = tmp;
        }
    }
    return max;
}
int main(){
    result r={0,0};
    vector<vector<int> >  vx(30, vector<int>(3,0));
    int d,g;
    cin >> d >> g;
    for(int i=0; i<d; i++) cin >> vx[i][0] >> vx[i][1];
    r = search(vx, r, d, g);
    cout << r.cost << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn gousei(a: f64, b: f64) -> f64 {
    (a + b) / 2.0
}
fn main() {
    let n = get!(usize);
    let mut v = get!([usize]);
    //eprintln!("n: {}, v: {:?}", n, v);
    //eprintln!("{}", gousei(v[0], v[1]));
    v.sort();
    if n == 2 {
        let ans = gousei(v[0] as f64, v[1] as f64);
        println!("{}", ans);
        return;
    }
    let mut ans: f64 = gousei(v[0] as f64, v[1] as f64);
    for i in 2..n {
        ans = gousei(ans, v[i] as f64);
        //eprintln!("ans: {}", ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String s = sc.next();
        char[] ary = s.toCharArray();
        int ans = 0;
        for (int i = 0; i < n - 1; i++) {
            if (ary[i] == ary[i + 1]) {
                ans++;
            }
        }
        ans += k * 2;
        if (n - 1 < ans) {
            ans = n - 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 200005;

int main()
{
	int l,r,d,ans=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++){
		if(i%d==0)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cassert>
#include<vector>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long inf = 1145141919810000;
typedef pair<int, int> P;
int h[114514];
vector<int>Z;
vector<int>Pt;
signed main() {
	int n, x; cin >> n >> x;
	rep(i, 51) {
		Z.push_back((1ll << (i + 2) )- 3);
		Pt.push_back((1ll << (i + 1) )- 1);
	}
	int ans = 0;
	int as = Z[n];
	while (x) {
		x--;
		if (x >= Z[n - 1]) {
			ans += Pt[n - 1];
			x -= Z[n - 1];
			if (x >= 1) {
				x--;
				ans++;
			}
		}
		
		if (x >= Z[n - 1]) {
			ans += Pt[n - 1];
			x -= Z[n - 1];
			if (x >= 1)x--;
		}
		
		n--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256