akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vvi g(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if (m % 2 == 1) {
        cout << -1 << "\n";
        return 0;
    }
    vector<pii> ret;
    vector<int> deg(n, 0);
    vector<int> depth(n, -1);

    function<void(int, int)> dfs = [&](int v, int p) {
        for (auto &ne : g[v]) {
            if (depth[ne] == -1) {
                depth[ne] = depth[v] + 1;
                dfs(ne, v);
            } else {
                if (depth[ne] > depth[v]) {
                    ret.emplace_back(v, ne);
                    ++deg[v];
                }
            }
        }
        if (deg[v] % 2 == 1) {
            ret.emplace_back(v, p);
            ++deg[v];
        } else {
            if (p != -1) {
                ret.emplace_back(p, v);
                ++deg[p];
            }
        }
    };
    depth[0] = 0;
    dfs(0, -1);
    for (auto &p : ret) {
        cout << p.first + 1 << " " << p.second + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 13300
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
	long count ;
	string str;
	while(cin>>str)
	{
		count= 0;
		for(int i  = 0;i<str.length();++i)
		{
			if(i+1 != str.length())
			{
				if(str[i] == str[i+1])
				{
					count++;
					if(str[i+1] == 48) str[i+1] = 49;
					else str[i+1] = 48;
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
n = int(input()) # 点の総数
path = list() # path[p] : 点pから行ける点のリスト
path.append([])
for _ in range(n):
    tmp = list(map(int, input().split())) # tmp[0]から行ける点はtmp[1]個あり、それはtmp[2:]
    path.append(tmp[2:])

d = [0]*(n+1) # 最初に発見した時刻
f = [0]*(n+1) # 隣接リストを調べ終えた時刻

TIME = 0

def dfs(p, d, f):
    global TIME
    TIME += 1
    d[p] = TIME # 来訪時刻の記録

    for nxt in path[p]: #繋がってる点の内
        if d[nxt] == 0: # 未探索の場合には
            dfs(nxt, d, f) # 先に進む
    
    TIME += 1
    f[p] = TIME # 繋がってる全ての点を探索し終えたらその点でやることは終わり

    
    return     
    
for start in range(1, n+1):
    if d[start] == 0:
        dfs(start, d, f)

for i in range(1, n+1):
    print(i, d[i], f[i])


Measured memory_bytes: 5656
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> P;

int main() {
    ll N, M;
    cin >> N >> M;
    std::vector<ll> v(N);
    for (int i = 0; i < N; ++i){
        v[i] = -1;
    }
    for (int i = 0; i < M; ++i){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        v[b] = max(v[b], a);
    }
    ll cut = -1;
    ll ans=0;
    for (int i = 0; i < N; ++i){
        if(cut < v[i]){
            cut = i-1;
            ans++;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>

using namespace std;

int main(void)
{
    vector<int> prime;
    int n;
    
    prime.push_back(2);
    scanf("%d", &n);
    while (n != 0){
        int i;
        int sum = 0;
        int num;
        for (num = prime[prime.size() - 1] + 1; n > prime.size(); num++){
            for (i = 0; i < prime.size(); i++){
                if (num % prime[i] == 0){
                    break;
                }
            }
            if (i == prime.size()){
                prime.push_back(num);
            }
        }
        for (i = 0; i < n; i++){
            sum += prime[i];
        }
        printf("%d\n", sum);
        
        scanf("%d", &n);
    }
    
    return 0;
}

Measured memory_bytes: 1156
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>
#include<random>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,k,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;


ll fc(ll xa,ll xb){
    if(xa%xb==0)return xa;
    return xa/xb*xb+xb;
}

ll fi(ll xa,ll xb){
    if(xa%xb==0)return xa;
    return xa/xb*xb;
}

int main(){
    
    cin>>k;

    for(int i=k-1;i>=0;i--){ cin>>aa[i]; } // 逆から入力

    c=aa[0]; // c:ゲーム終了後に人が残るパターンの最小数
    z=aa[0]; // z:                           の最大数 ( 厳密には最大数からA[0]-1 を足したもの )
    r=true;

    for(int i=0;i<k-1;i++){
        z=fi(z+aa[i]-1,aa[i+1]);  // 関数 fi(a,b) -> a以上の最小のbの倍数
        c=fc(c,aa[i+1]);          // 関数 fc(a,b) -> a以下の最大のbの倍数
    }

    ll cm=c;
    for(int i=k-1;i>=0;i--){ cm-=cm%aa[i]; } // ゲーム開始時の人数にcを代入して「2」になるかをシュミレーション

    if(cm!=2)r=false; // シュミレーションの値が2になるか？

    // 出力 z
    if(r) C c<<" "<<z+aa[k-1]-1 E; 
    else C -1 E;

    // 説明がうまくできなくてｾﾝｾﾝｼｬﾙ
    
}


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

int n,h[100010];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    h[n+1] = 1000000001;
    for(int i=1;i<=n;i++)
    {
        if(h[i]-1>=h[i-1]) h[i]--;
        else if(h[i]<h[i-1])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, H) = Slice2<long>();
            var ai = new long[N];
            var bi = new long[N];
            for (var i = 0; i < N; ++i)
            {
                var (a, b) = Slice2<long>();
                ai[i] = a;
                bi[i] = b;
            }
            var maxA = ai.Max();
            var Bs = bi.Where(b => maxA < b);
            var num = 0L;
            foreach (var b in Bs.OrderByDescending(b => b))
            {
                ++num;
                H -= b;
                if (H <= 0)
                    break;
            }
            if (0 < H)
                num += (H + maxA - 1) / maxA;
            WriteLine(num);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 50652
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static final int INF = 1 << 29;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		int swaps = INF;
		int i_ = 0;
		for(int i=0;i<m;i++) {
			int x = sc.nextInt();
			for(int j=0;j<x;j++) {
				b[i_] = i%2;
				i_++;
			}
		}
		swaps = Math.min(swaps, swaps(a,b));
		for(int i=0;i<n;i++) {
			b[i] = 1 - b[i];
		}
		swaps = Math.min(swaps, swaps(a,b));
		System.out.println(swaps);
	}

	public static int swaps(int[] a,int[] b) {
		int n = a.length;
		int[] ca = Arrays.copyOf(a, n);
		int[] cb = Arrays.copyOf(b, n);
		int suma = 0,sumb = 0;
		for(int i=0;i<n;i++) {
			suma += ca[i];
			sumb += cb[i];
		}
		if (suma != sumb) {
			return INF;
		}
		int swaps = 0;
		for(int i=0;i<n;i++) {
			if (ca[i] == cb[i]) {
				continue;
			}
			for(int j=i+1;j<n;j++) {
				if (ca[i] == cb[j]) {
					cb[j] = cb[i];
					cb[i] = ca[i];
					swaps += (j-i);
					break;
				}
			}
		}
		return swaps;
	}

}

Measured memory_bytes: 17336
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>

#define ll long long

using namespace std;

const int MINN = 2001;
const int maxn = (int) 2e7 + 100;
const int inf = 1e9 + 7;

vector < int > g[maxn], give, can;
vector < int > v;
pair < int, int > p[maxn];
ll a[7010];

int u[maxn], b[maxn];

string s, t;

int z[maxn];

int main(){
    cin >> s >> t;
    string q = s;
    s += s;
    while(s.size() <= 2 * t.size()){
        s += s;
    }
    s += s;
    string st = t + '#' + s;
    int n = (int)st.size();
    int l = 0, r = 0;
    for(int i = 1; i < n; i++){
        if(i <= r){
            z[i] = min(r - i + 1, z[i - l]);
        }
        while(i + z[i] < n && st[z[i]] == st[z[i] + i])
            z[i]++;
        if(i + z[i] - 1 > r){
            l = i, r = i + z[i] - 1;
        }
    }
    for(int i = t.size() + 1; i < t.size() + 1 + q.size(); i++){
        if(z[i] == t.size()){
            can.push_back(i - t.size() - 1);
            u[i - t.size() - 1] = 1;
            //cout << i - t.size() - 1 << " ";
        }
    }
    if(can.empty()){
        cout << 0;
        return 0;
    }
    for(int i = 0; i < can.size(); i++) {
        if(b[can[i]] == 1){
            continue;
        }
        v.clear();

        int now = can[i];

        b[now] = 1;
        v.push_back(now);
        now += t.size();
        now %= q.size();
        bool qwe = 0;
        while (1) {
            b[now] = 1;
            v.push_back(now);
            now += t.size();
            now %= q.size();
            if (now == can[0]) {
                if (!qwe)
                    qwe = 1;
                else
                    break;
            }
        }
        int cnt = 0, res = 0;
        for (int j : v) {
            if (u[j] == 1) {
                cnt++;
                res = max(cnt, res);
            } else {
                cnt = 0;
            }
        }
        if (res == v.size()) {
            cout << -1;
        } else {
            cout << res;
        }
        return 0;
    }
}



Measured memory_bytes: 516368
//============================================================================
// Name        : template.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int A() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

int B() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, d;
	cin >> n >> d;
	int an = 0;
	while (n--) {
		double x, y; cin >> x >> y;
		double dis = (x * x) + (y * y);
		if (dis <= d * d) {
			an++;
		}
	}
	cout << an << "\n";
	return 0;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k; cin >> k;
	ll x = 0;
	ll ct = 0;
	ll lmt = 10e7;
	bool fd = false;
	while (ct < lmt) {
		ct++;
		x = (x * 10) + 7;
		x %= k;
		if (x == 0) {
			fd = true;
			cout << ct << "\n";
			break;
		}
	}
	if (!fd) {
		cout << -1 << "\n";
	}
	return 0;
}

int D() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s ; cin >> s;
	string org = s;
	int reds = 0;
	forn(i, n) {
		if (s[i] == 'R') reds++;
	}
	int ans = 0;
	forn(i , reds) {
		if (org[i] == 'W') ans++;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  float N;
  float a[100];
  float sum = 0;
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  rep(i, N) {
    sum += a[i];
  }
  int avr = round(sum / N);
  int ans = 0;
  rep(i, N) {
    ans += (a[i] - avr) * (a[i] - avr);
    // cout << ans << " ";
  }
  // cout << endl;
  // cout << avr << endl;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {


	int x1, x2, y1, y2;
	int x3, x4, y3, y4;

	cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2 - x1;
	int dy = y2 - y1;

	cout << x2 - dy << ' ' << y2 + dx << ' ' << x2 - dy - dx << ' ' << y2 + dx - dy NL;


	return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(n=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## const ##
MOD=10**9+7
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    x = IS()
    s_num = t_num = 0
    cnt = 0
    for i, xi in enumerate(x):
        if xi == 'S':
            s_num += 1
        elif xi == 'T':
            if s_num != 0: t_num += 1
            if s_num == t_num:
                cnt += s_num + t_num
                s_num = t_num = 0
    if s_num != 0 and t_num != 0:
        cnt += min(s_num, t_num)*2
    print(len(x)-cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4140
#ABC126B - YYMM or MMYY
S = list(input())
f = int((''.join(S[0:2])))
b = int((''.join(S[2:4])))
def month(m):
    if 1 <= m <= 12:# 0xはxの数値として変換される模様
        return 1
    else:
        return 0
def year(y):
    return 1
ans = [month(f),year(b),year(f),month(b)]#グリット組みたい
#print(ans)
if sum(ans) == 4:
    print('AMBIGUOUS')
elif ans[0] == 1 and ans[1] == 1:
    print('MMYY')
elif ans[2] == 1 and ans[3] == 1:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;
  int maxh = 0;

  cin >> N;

  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H[i];
    if(maxh <= H[i]){
      ans++;
    }
    maxh = max(maxh, H[i]);
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
H, W = gets.chomp.split(" ").map(&:to_i)
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

C = []
A.each_with_index{|a, i|
  a.times{C << (i+1)}
}
ans = []
H.times{|h|
  ans << (h.even? ? C[h*W, W] : C[h*W, W].reverse)
}

ans.each{|a| puts a.join(' ')}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
//const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int mod = 2020;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n, int m) {
  if (n == 0) return 1;
  mint x = f(n/2,m);
  x *= x;
  if (n%2 == 1) x *= m;
  return x;
}

int main() {
    int n; cin >> n;
    int k; cin >> k;
    int ans = 0;
    rep(i,n){
        int a; cin >> a;
        ans += min(a,k-a);
    }
    cout << 2 * ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>

const int MAX_N = 12, INF = 1 << 16;
double dp[1 << MAX_N][MAX_N], rs[MAX_N];
int n;

inline double square(double d){
	return d * d;
}

double rec(int S, int v){
	if(dp[S][v] >= 0){
		return dp[S][v];
	}

	if(S == (1 << n) - 1){
		return rs[v];
	}

	double res = INF;
	for(int u=0;u<n;u++){
		if(!(S >> u & 1)){//未使用
			res = std::min(res, rec(S | (1 << u), u) + sqrt(square(rs[v]+rs[u]) - square(rs[v]-rs[u])));
		}
	}

	return dp[S][v] = res;
}

int main(){
	double box_l, min_l;
	while(std::cin >> box_l){
		if(std::cin.eof()){
			return 0;
		}

		min_l = INF;
		n = 0;

		std::string str;
		std::getline(std::cin, str);

		std::stringstream ss(str);
		while(!ss.eof()){
			int _i;
			ss >> _i;
			rs[n++] = _i;
			ss.ignore();
		}

		for(int i=0;i<n;i++){//iを始めにした最小幅をもとめる
			for(int j=0;j<(1<<MAX_N);j++){
				for(int k=0;k<MAX_N;k++){
					dp[j][k] = -1;
				}
			}

			min_l = std::min(min_l, rec(1 << i, i) + rs[i]);
		}

		if(min_l <= box_l){
			puts("OK");
		}else{
			puts("NA");
		}
	}
}

Measured memory_bytes: 1624
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Li = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Array.Sort(Li);
            var count = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    for (int k = j + 1; k < N; k++)
                    {
                        if ((Li[i] + Li[j] > Li[k]) && ((Li[i] != Li[j]) && (Li[j] != Li[k]))) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27548
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

 
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{


fastio();

ll n;
cin>>n;
ll a[n];



for (int i=0;i<n;i++)
cin>>a[i];


sort(a,a+n);


ll fin_ans=1;

ll x=1e18;

if (a[0]!=0){
for(int i=0;i<=n-1;i++){

ll s=x/fin_ans;

if (a[i]<=s)
fin_ans*=a[i];
else{
fin_ans=-1;
break;
}

}
}

if (a[0]==0)
cout<<0;
else
cout<<fin_ans;

return 0;
}

Measured memory_bytes: 4440
n,m = map(int, input().split())
A = sorted(list(map(int, input().split())),reverse=True)

def cnt(x):
    c = 0
    i = 0
    for j in reversed(range(len(A))):
        while i <n and A[j]+A[i]>=x:
            i += 1
        c += i
    return c

def happiness(x):
    c = 0
    i = 0
    ci = 0
    for j in reversed(range(len(A))):
        while i <n and A[j]+A[i]>=x:
            ci += A[i]
            i += 1
        c += ci + A[j]*i
    return c

def binary_search(l, r):
    mid = (l+r)//2
    c = cnt(mid)
    if c < m:
        return binary_search(l, mid)   
    else:
        if l == mid:
            return(l, c-m)
        return binary_search(mid, r)

x, dm = binary_search(0, A[0]*2+1)
print(happiness(x)-dm*x)

Measured memory_bytes: 14268
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

#include <stack>
int main() {
	in(string, X);
	stack<char> s;
	for (char c : X) {
		if (!s.empty() && s.top() == 'S' && c == 'T')
			s.pop();
		else
			s.push(c);
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 720
/*    三玖天下第一！！！  */
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5,maxm=2e5;
int n,m,lin[maxn+5]={},len=0,dis[maxn+5];bool vis[maxn+5]={};set<int> rail[maxn+5];
struct edge{int y,next,rk;}e[maxm*2+5];
inline void insert(int xx,int yy,int rr){e[++len].next=lin[xx];lin[xx]=len;e[len].y=yy;e[len].rk=rr;} 
inline int dread()
{
	int x=0;bool f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f^=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return f?x:-x;
}
inline void in(){n=dread();m=dread();for(int i=1,a,b,c;i<=m;i++) a=dread(),b=dread(),c=dread(),insert(a,b,c),insert(b,a,c);}
inline void dijkstra()
{
	memset(dis,0x3f,sizeof(dis));priority_queue< pair<int,pair<int,int> > > q;q.push(make_pair(-(dis[1]=0),make_pair(1,0)));
	while(!q.empty())
	{
		pair<int,int> seat=q.top().second;q.pop();if(vis[seat.first]) continue;vis[seat.first]=1;
		for(int i=lin[seat.first],extra=!(rail[seat.first].count(e[i].rk));i;i=e[i].next,extra=!(rail[seat.first].count(e[i].rk)))
		{
			if(dis[e[i].y]>dis[seat.first]+extra) q.push(make_pair(-(dis[e[i].y]=dis[seat.first]+extra),make_pair(e[i].y,e[i].rk))),rail[e[i].y].clear(),rail[e[i].y].insert(e[i].rk);
			else if(dis[e[i].y]==dis[seat.first]+extra) rail[e[i].y].insert(e[i].rk);
		}
	}printf("%d\n",dis[n]==0x3f3f3f3f?-1:dis[n]);
}
int main(){in();dijkstra();return 0;}

Measured memory_bytes: 20408
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<plii> pq;
vector<vector<pii> > graph;
vector<ll> dist;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0,nxt, idx = -1;
    int tc;

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

    cin>>k;

    graph = vector<vector<pii> > (k);
    dist = vector<ll> (k,LINF);

    for(int i=1;i<k;i++){
        for(int j=0;j<10;j++){
            nxt = (10*i+j)%k;
            graph[i].push_back(pii(nxt,j));
        }
    }

    for(int i=1;i<min(k,10);i++){
        dist[i] = i;
        pq.push(plii(-dist[i],i));
    }

    int here,there;
    ll cost,ncost;

    while(!pq.empty()){
        here = pq.top().s;
        cost = -pq.top().f;

        pq.pop();

        if(dist[here]<cost)continue;

        for(int i=0;i<graph[here].size();i++){
            there = graph[here][i].f;
            ncost = cost+graph[here][i].s;
            if(dist[there]<=ncost)continue;
            dist[there] = ncost;
            pq.push(plii(-dist[there],there));
        }
    }

    ll res = dist[0];

    if(k<10)res = min((ll)k,res);

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 23668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0067
{
    public class Program

    {
        static private int[,] map;
        static private bool[,] visited;

        public static void Main(string[] args)
        {

            while (true)
            {
                map = new int[14, 14];
                visited = new bool[14, 14];

                string line;
                for (int i = 1 ; i < 13 ; i++)
                {
                    line = Console.ReadLine();
                    for (int j = 1 ; j < 13 ; j++)
                    {
                        map[i, j] = int.Parse(line[j - 1].ToString());
                    }
                }

                int res = 0;
                for (int i = 1 ; i < 13 ; i++)
                {
                    for (int j = 1 ; j < 13 ; j++)
                    {
                        if (map[i, j] == 1 && visited[i, j] == false)
                        {
                            res++;
                            VisitContinuousArea(i, j);
                        }
                    }
                }
                Console.WriteLine(res);

                line = Console.ReadLine();
                if (line == null) break;
            }
        }

        private static void VisitContinuousArea(int i, int j)
        {
            visited[i, j] = true;
            if (map[i - 1, j] == 1 && visited[i - 1, j] == false) VisitContinuousArea(i - 1, j);
            if (map[i + 1, j] == 1 && visited[i + 1, j] == false) VisitContinuousArea(i + 1, j);
            if (map[i, j - 1] == 1 && visited[i, j - 1] == false) VisitContinuousArea(i, j - 1);
            if (map[i, j + 1] == 1 && visited[i, j + 1] == false) VisitContinuousArea(i, j + 1);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 13924
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,A,B = map(int,read().split())

def F(N,A,B):
    if (B - A) % 2 == 0:
        return (B - A) // 2
    # 左端で止まる
    cand = []
    x = (B - 1) + (A - 1) + 1
    cand.append(x//2)
    x = (N - B) + (N - A) + 1
    cand.append(x//2)
    return min(cand)

answer = F(N,A,B)
print(answer)

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int ans = 0;
  ll N,D; cin >> N >> D;
  for(ll i  = 0; i < N; i++){
    ll x,y; cin >> x >> y;
    if(x*x + y*y <= D*D) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
package main
import "fmt"

func main() {
	var n, d int
  fmt.Scan(&n)
  fmt.Scan(&d)
  fmt.Println(calc(n, d))
}

func calc(n, d int) int{
  cov := (d * 2) + 1
  var ans int
  if n > cov {
    switch {
      	case n % cov == 0 :
      		ans = n / cov
    	case n % cov != 0 :
      		ans = (n / cov) + 1
    }
  }else{
    ans = 1
  }
  return ans
}



Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

// const int kMaxN;

int N, M;
int ans = 0;

map<int, int> PrimeFactor(int n) {
  map<int, int> prime_factor;
  for (int i = 2; i*i <= n; ++i) {
    while (n%i == 0) {
      ++prime_factor[i];
      n /= i;
    }
  }
  if (n != 1) { prime_factor[n] = 1; }
  return prime_factor;
}

void Bfs(map<int, int>& pf, map<int, int>::iterator& it, int n) {
  if (it == pf.end()) {
    if (n >= N) {
      ans = MAX(ans, M/n);
    }
    return;
  }

  int nn = 1;
  FOR(i, 0, it->second) {
    ++it;
    Bfs(pf, it, n*nn);
    --it;
    nn *= it->first;
  }
  return;
}

signed main() {
  cin >> N >> M;
  map<int, int> pf = PrimeFactor(M);

  map<int, int>::iterator it = pf.begin();
  Bfs(pf, it, 1);

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


Measured memory_bytes: 256
#include <iostream>#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int S = 2 * g + b;
  if(S % 4 == 0)
    cout << "YES" << endl;
  if(S % 4 != 0)
    cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            while(a % 2 == 0){
                a /= 2;
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 34224
N, M = map(int, input().split())
cnt = 0
K = list()
L = list()
for m in range(M):
    l = list(map(int, input().split()))
    k = l.pop(0)
    K.append(k)
    L.append(l)
P = list(map(int, input().split()))

for i in range(2**N):
    flag = True
    for j in range(M):
        c = 0
        for l in range(K[j]):
            if (i >> L[j][l]-1) & 1:
                c += 1
        if c % 2 != P[j]:
            flag = False
    if flag:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
S = input()[::-1]
dp = [0]*2019
dp[0] = 1

tmp = 0
for i in range(len(S)):
    tmp += int(S[i])*pow(10, i, 2019)
    tmp %= 2019
    dp[tmp] += 1
ans = 0
for i in dp:
    if i >= 2:
        ans += i*(i-1)//2
print(ans)


Measured memory_bytes: 9132
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
P<int,int> p[200005];
int n,f[200005],b[200005],qz[200005];
signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    int d,a;
	cin>>n>>d>>a;d=(d<<1);
	FOR(i,1,n)cin>>p[i].F>>p[i].S;
	sort(p+1,p+n+1);
	FOR(i,1,n){
		p[i].S=p[i].S/a+(p[i].S%a!=0);b[i]=p[i].F;f[i]=2147483647;
	}
	int sum=0;
	int ans=0;
	FOR(i,1,n){
		f[i]=upper_bound(b+1,b+n+1,b[i]+d)-b-1;
		p[i].S=p[i].S-sum+qz[lower_bound(f+1,f+n+1,i)-f-1];
		if(p[i].S>0){
			ans=ans+p[i].S;
			qz[i]=qz[i-1]+p[i].S;sum=sum+p[i].S;
		}else qz[i]=qz[i-1];
	} 
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 8064
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

void solve() {
  ll l, r;
  cin >> l >> r;
  if (r-l > 2050) { cout << 0 << endl; return; }
  ll min_ = 2018;
  loop(i,l,r) {
    loop(j,i+1,r+1) {
      min_ = min(min_, ((ll)i*(ll)j)%2019);
    }
  }
  cout << min_ << endl;
}


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}


#define N 4000004
ll kai[N];
ll kai2[N];
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}



int main(){fastio
    calc();
    ll k;cin>>k;
    string s;cin>>s;
    ll n=s.size();
    ll ans=0;
    rep(i,n,n+k){
        ll t=comb(n+k,i);
        t=mod(t*po(25,n+k-i));
        Add(ans,t);
    }
    cout<<mod(ans)<<endl;
    
    return 0;
}






Measured memory_bytes: 66768
use std::cmp;
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;
use std::string::String;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}

struct SegmentTree<Monoid, Operator> {
    size: usize,
    node: Vec<Monoid>,
    f: Operator,
    e: Monoid,
}

impl<Monoid, Operator> SegmentTree<Monoid, Operator>
where
    Operator: Fn(Monoid, Monoid) -> Monoid,
    Monoid: Copy,
{
    pub fn new(n: usize, f: Operator, e: Monoid) -> Self {
        let mut size = 1;
        while size < n {
            size *= 2
        }

        SegmentTree {
            size: size,
            node: vec![e; size * 2],
            f: f,
            e: e,
        }
    }

    pub fn update(&mut self, idx: usize, x: Monoid) {
        let mut k = idx + self.size - 1;
        self.node[k] = x;
        while k > 0 {
            k = (k - 1) / 2;
            self.node[k] = (self.f)(self.node[2 * k + 1], self.node[2 * k + 2]);
        }
    }

    pub fn query(&self, a: usize, b: usize) -> Monoid {
        return self._query(a, b, 0, 0, self.size);
    }

    fn _query(&self, a: usize, b: usize, idx: usize, l: usize, r: usize) -> Monoid {
        if r <= a || b <= l {
            return self.e;
        }

        if a <= l && r <= b {
            return self.node[idx];
        }

        let xl: Monoid = self._query(a, b, 2 * idx + 1, l, (l + r) / 2);
        let xr: Monoid = self._query(a, b, 2 * idx + 2, (r + l) / 2, r);

        return (self.f)(xl, xr);
    }
}

fn main() {
    let (_, q): (usize, usize) = (read(), read());
    let mut seg = SegmentTree::<i32, _>::new(100_000, |x, y| x + y, 0);

    for _ in 0..q {
        let (com, x, y): (usize, usize, usize) = (read(), read(), read());

        if com == 0 {
            let k = seg.query(x, x + 1);
            seg.update(x, k + y as i32);
        } else {
            println!("{}", seg.query(x, y + 1));
        }
    }
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  } else if (6 <= a) {
    cout << b / 2 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

namespace AtCoder_solve
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            ulong n = ulong.Parse(data[0]);
            ulong a = ulong.Parse(data[1]);
            ulong b = ulong.Parse(data[2]);
            ulong ans = 0;
            ulong d = b - a;
            ulong[] ds= { a-1, b-1, n - a, n - b };

            if (d % 2 == 1)
            {
                if (ds[1] > ds[2])
                {
                    ans = ds[3] +1+ (d - 1) / 2;

                }
                else if (ds[1] <= ds[2])
                {

                    ans = ds[0] +1+ (d - 1) / 2;


                }
            }
            else
            {

                ans = d / 2;
            }

                

            
                Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[100][100];
	int i, j, k, sum, mul;
	
	i = 0;
	sum = 0;
	while (scanf("%s" , str[i]) != EOF){
		for (j = 0; j < strlen(str[i]); j++){
			if (str[i][j] >= '0' && str[i][j] <= '9'){
				mul = 1;
				for (k = 1; str[i][j+k] - '0' >= 0 && str[i][j+k] - '0' <= 9; k++){
					mul *= 10;
					//printf("%d >%d\n", mul, j);
				}
				sum += (str[i][j] - '0') * mul;
			}
		}
		i++;
	}
	
	printf("%d\n", sum);
	
	return (0);
}

Measured memory_bytes: 556
#include<stdio.h>
int m,a[7],b[7],g,n,i;

int s(int d,int r)
{
	int p,q;
	if(d==m)
		return r==n?1:0;
	for(p=q=0;p<=b[d];p++)
		q+=s(d+1,r+a[d]*p);
	return q;
}

int main()
{
	for(;scanf("%d",&m),m;)
	{
		for(i=0;i<m;i++)
			scanf("%d%d",&a[i],&b[i]);
		for(scanf("%d",&g),i=0;i<g;i++)
		{
			scanf("%d",&n);
			printf("%d\n",s(0,0));
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int K,N;
    cin >> K;
    cin >> N;

    int l,i=0,A[N];
    while(cin>>l){
        A[i] = l;
        i++;
    }

    int MAX=0,result = 0;

    if ( MAX < (abs(K - A[N-1]) + abs(0 - A[0])) ) {
        MAX = (abs(K - A[N-1]) + abs(0 - A[0]));
    }

    for (int i = 0; i < N - 1 ; i++) {
        if ( MAX < abs(A[i] - A[i+1]) ) {
            MAX = abs(A[i] - A[i+1]);
        }
    }

    result = K - MAX;

    cout << result << endl;

    return 0;
} 

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

int main(){
  long N;
  long D;
  cin >> N >> D;
  
  vector<long> X(N);
  vector<long> Y(N);
    
  for(long i = 0; i < N; i++){
    cin >> X.at(i) >> Y.at(i);
  }
  
  long k = 0;
  
  for(long i = 0; i < N; i++){
    if(X.at(i)*X.at(i) + Y.at(i)*Y.at(i) <= D*D){
      k++;
    }
  }
  
  cout << k << endl;
  
}

Measured memory_bytes: 6388