akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    
    k = int(input())
    s = input()
    n = len(s)
    mod = 10**9+7
    p25 = [0]*(k+1)
    p26 = [0]*(k+1)
    c = [0]*(k+1)

    p25[0], p26[0] = 1, 1
    c[0]= 1
    for i in range(1, k+1):
        p25[i] = p25[i-1]*25
        p25[i] %= mod
        p26[i] = p26[i-1]*26
        p26[i] %= mod
        c[i] = (n+i-1)*c[i-1]
        c[i] *= pow(i, mod-2, mod)
        c[i] %= mod
    p25.reverse()
    c.reverse()
    ans = 0
    for i in range(k+1):
        tmp = p25[i]*p26[i]*c[i]
        tmp %= mod
        ans += tmp
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 193088
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n>>m;
	VI a(n),b(n);
	rep(i,n) cin>>a[i];
	SORT(a);

	res=accumulate(a.begin(),a.begin()+m,(ll)0);
	

	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

int main(void)
{
    // bits/stdc++.h をincludeしているときは定数M_PIが使えます
    const double PI=3.14159265358979323846;
    double a,b,x;
    cin >> a >> b >> x;
    double s = x / a;
    double ans = 0;
    double a2 = 0;
    // コーナーケース
    if ( s == a * b) {
        ans = 0;
    } else {
        if (s > b * a / 2) {
            // 台形の時
            // 上底bu
            double bu = 2 * s / a - b;
            s -= a * bu;
            b -= bu;
            a2 = 2 * s / b;
        } else {
            // 三角形の時
            a2 = 2 * s / b;
        }
        // アークタンジェント計算(結果はラジアン)
        double r = atan(b/a2);
        // ラジアン-角度変換
        ans = r * (180.0 / PI); 
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import copy
S=input()
N=len(S)
SS=[]
for i in range(N):
    SS.append(S[i])

T=input()
M=len(T)
TT=[]

for i in range(M):
    TT.append(T[i])

if N<M:
    print("UNRESTORABLE")
else:
    for i in range(N-M+1):
        flag=True
        tmp=copy.deepcopy(SS)
        for j in range(M):
            #print(SS[N-1-i-j],TT[M-1-j])
            if SS[N-1-i-j]==TT[M-1-j] or SS[N-1-i-j]=="?":
                tmp[N-1-i-j]=TT[M-1-j]
            else:
                flag=False
                break
        
        if flag==True:
            Z=[str(a) for a in tmp]
            Z="".join(Z)
            #print(Z)

            ans=Z.replace("?","a")
            print(ans)
            exit()
    print("UNRESTORABLE")    
        

Measured memory_bytes: 9220
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = [int(input()) for _ in range(M)]

for i in range(N):
    cnt = 0
    for j in range(M):
        cnt += A[i][j] * B[j]
    print(cnt)


Measured memory_bytes: 6016
#include <vector>
#include <cstdio>
#include <algorithm>
 
typedef long long ll;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int Mod = 1e9 + 7;
int n, m, ans;
std :: vector <int> v, g;
inline int pow(int x, int k) {
	ll res = 1, r = x % Mod;
	for (; k; k >>= 1, r = r * r % Mod) 
		if (k & 1) res = res * r % Mod;
	return res;
}
int main() {
	n = Get(), m = Get();
	for (int i = 1; (ll)i * i <= n; ++i)
		if (!(n % i)) {
			v.push_back(i), g.push_back(0);
			if (n / i != i) v.push_back(n / i), g.push_back(0);
		}
	
	std :: sort(v.begin(), v.end());
	for (int i = 0, sze = v.size(), x; i < sze; ++i) {
		x = v[i], g[i] = pow(m, x + (x & 1) >> 1);
		for (int j = 0; j < i; ++j)
			if (!(x % v[j])) g[i] = (g[i] - g[j] + Mod) % Mod;
	} 
	
	for (int i = 0, sze = v.size(), x; i < sze; ++i)
		x = v[i], (ans += (ll)((x & 1) ? x : x >> 1) * g[i] % Mod) %= Mod;
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
string s; cin>>s;
bool ans = false;
    for(int i = 0; i<s.size();){
        if(s[i] == 'h'){
            i++;
            if(s[i]=='i'){
                if(i == s.size()-1)ans = true;
                i++; 
            }else break;
        }else break;
    }
    cout<<((ans)?"Yes":"No")<<endl;
    return   0;

}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			long[][] dp = new long[n+1][n+1];
			for(int i=0;i<n+1;i++){
				for(int j=0;j<n+1;j++){
					if(i==j){
						dp[i][j] =0;
					}else{
						dp[i][j] = 1000000000;
					}
				}
			}
			int city1,city2, dis;
			int node=0;//ノード数
			int temp_max;
			for(int i=0;i<n;i++){
				city1 = sc.nextInt();
				city2 = sc.nextInt();
				temp_max = Math.max(city1, city2);
				node = Math.max(temp_max, node);
				dis = sc.nextInt();
				dp[city1][city2] = dis;
				dp[city2][city1] = dis;
			}
			node++;//index揃え
			for(int k=0;k<node;k++){
				for(int i=0;i<node;i++){
					for(int j=0;j<node;j++){
						dp[i][j] = Math.min(dp[i][j], dp[i][k]+dp[k][j]);
					}
				}
			}
			int[] max_dis = new int[node];
			int temp_max_dis=0;
			long temp_min=1000000000;
			int temp_i=0;
			for(int i=0;i<node;i++){
				for(int j=0;j<node;j++){
					temp_max_dis +=dp[i][j];
					//	System.out.print(dp[i][j]+" ");
				}
				max_dis[i] = temp_max_dis;
				if(temp_min==temp_max_dis){
					//同じなら前のインデックス, temp_iを更新しない
				}else{
					temp_min = Math.min(temp_min, temp_max_dis);
					if(temp_min==max_dis[i]) temp_i = i;
				}
				temp_max_dis = 0;
				//System.out.println();
			}
			System.out.println(temp_i+" "+ temp_min);
		}
	}
}

Measured memory_bytes: 19688
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<utility>
#include<algorithm>
using namespace std;

typedef long long ll;
int a[1010];

int main()
{
	ios::sync_with_stdio(false);
	int n, m;
	while (scanf("%d%d", &n, &m) == 2 && n&&m)
	{
		for (int i = 1; i <= n; i++)
			scanf("%d", &a[i]);
		int sum = -1;
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				if (a[i] + a[j] <= m) sum = max(sum, a[i] + a[j]);
		if (sum == -1) printf("NONE\n");
		else printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define pq
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2;
typedef pair<int, P2> P3; typedef long long ll; typedef long double ld;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact; constexpr Prime<10> prime;
constexpr int comb(int a, int b){long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

int main(){
	int n, m;
	while(cin >> n >> m,n){
		int a[110], b[110], A = 0, B = 0;
		for(int i = 0; i < n; i++) cin >> a[i], A += a[i]; sort(a, a + n);
		for(int i = 0; i < m; i++) cin >> b[i], B += b[i]; sort(b, b + m);
		
		bool f = true;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				if(A - a[i] + b[j] == B - b[j] + a[i]){
					cout << a[i] << " " << b[j] << endl;
					i = j = INF; f = false;
				}
			}
		}
		
		if(f) cout << -1 << endl;
	}
	
	return 0;
}



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

int inf = 1234567890;

int kaijo(int n){
  int k=1;
  for(int i=1;i<=n;i++){
    k*=i;
  }
  return k;
}
int main(){
int n;
cin>>n;

vector<vector<int>> xy(n, vector<int>(2));
for(int i=0;i<n;i++){
  int x,y;
  cin>>x>>y,
  xy[i][0]=x;
  xy[i][1]=y;
}
vector<vector<double>> kyori(n, vector<double>(n));
for(int i=0;i<n;i++) for(int j=0;j<n;j++){
  kyori[i][j]= sqrt((xy[i][0]-xy[j][0])*(xy[i][0]-xy[j][0])+(xy[i][1]-xy[j][1])*(xy[i][1]-xy[j][1]));
}
double sum=0;
for(int i=0;i<n;i++) for(int j=0;j<n;j++){
sum+=kyori[i][j];
//cout<<kyori[i][j]<<endl;;
}
cout<<setprecision(8)<<(double)(sum)/double(kaijo(n))*(double)(kaijo(n-1))<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
inline ll read(){
	ll x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	ll i,j,k,m,n;
	n=read();
	for(i=1;i<=3500;i++)
		for(j=1;j<=3500;j++){
			if(1.0/i+1.0/j>4.0/n)continue;
			ll sum1=0,sum2,sum3=0;
			sum2=n*(i*j/gcd(i,j))/gcd(n,i*j/gcd(i,j));
			sum1+=(sum2/n)*4;
			sum3+=sum2/i;
			sum3+=sum2/j;
			if(sum3>=sum1)continue;
			if(gcd(sum1-sum3,sum2)==sum1-sum3){
				printf("%lld %lld %lld\n",i,j,sum2/(sum1-sum3));
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
const Main = (input) => {
    // array = input.split('\n')
    // N = array.shift()
    // array.pop()
    // array = array[0].split(' ')
    // arrayInt = array.map(item => parseInt(item))
    console.log(F(input, 100))
}

const F = (total, initial) => {
    count = 0
    price = initial
    for (i = 0; price < total; i++) {
        // console.log(price, total)
        price *= 1.01
        price = Math.floor(price)
        count = i + 1
    }
    return count
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29764
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 500000+2
int AA[MAXN],TT[MAXN];
int n,g=0;
void input(){
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>AA[i];
	}
}
void syf(int *A,int x,int y,int *T){
	if(y-x>1){
		int m=(x+y)/2;
		int i=x,p=x,q=m;
		syf(A,x,m,T);
		syf(A,m,y,T);
		while(p<m||q<y){
			if(q>=y||(p<m&&A[p]<=A[q])) T[i++]=A[p++];
			else T[i++]=A[q++];
			g++;
		}
		for(int i=x;i<y;++i){
			A[i]=T[i];
			AA[i]=T[i];
		}
	}
}
int main(){
	input();
	syf(AA,0,n,TT);
	for(int i=0;i<n-1;++i){
		cout<<AA[i]<<" ";
	}
	cout<<AA[n-1]<<endl;
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 6844
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std ;




int main(){

    int N;
    int K;

    cin >> N >> K ;

    if(K==1){
        cout << 0 << endl;
    }
    else{
        cout << N-K << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,H[17],W[17];
int c[5][5];
int dist[1<<16];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N)cin>>H[i]>>W[i];
	rep(i,4)rep(j,4){
		char C;
		cin>>C;
		c[i][j] = C=='R' ? 0 : C=='G' ? 1 : 2;
	}
	rep(i,1<<16)dist[i] = INF;
	dist[0] = 0;
	queue<int> Q;
	Q.push(0);
	while(sz(Q)){
		int mask = Q.front(); Q.pop();
		if(mask == (1<<16)-1){
			return cout<<dist[mask]<<endl,0;
		}
		int done[4][4][4][4][3] = {};
		rep(i,N){
			rep2(y,-H[i]+1,4)rep2(x,-W[i]+1,4)rep(color,3){
				int nmask = mask;
				int y0 = max(0, y);
				int x0 = max(0, x);
				int y1 = min(3, y+H[i]-1);
				int x1 = min(3, x+W[i]-1);
				if(done[y0][x0][y1][x1][color])continue;
				done[y0][x0][y1][x1][color] = 1;
				rep(ii,H[i])rep(jj,W[i]){
					int Y = y+ii, X = x+jj;
					if(Y<0 || Y>=4 || X<0 || X>=4)continue;
					if(c[Y][X] == color) nmask |= 1<<Y*4+X;
					else nmask &= ~(1<<Y*4+X);
				}
				if(dist[nmask] > dist[mask] + 1){
					dist[nmask] = dist[mask] + 1;
					Q.push(nmask);
				}
			}
		}
	}
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

vector<lint> cand;

void rec(int i, lint x, int p) {
    cand.push_back(x);
    if (i == 9) return;

    if (p > 0) rec(i+1, x*10 + p - 1, p-1);
    rec(i+1, x*10 + p, p);
    if (p < 9) rec(i+1, x*10 + p + 1, p+1);
}

int main() {
    int K;
    cin >> K;

    for_(i,1,10) rec(0, i, i);

    sort(ALL(cand));
    cout << cand[K-1] << endl;
}

Measured memory_bytes: 2420
/*
 *  参考:
 *    AtCoder用 C++テンプレート - ctyl's problem solving
 *    http://ctylim.hatenablog.com/entry/2015/08/30/191553
 */

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

int fn(int i) {
  int ret = 0;
  
  while(i > 0) {
    ret += i % 10;
    i /= 10;
  }
  
  return ret;
}

int main(int argc, const char* argv[]) {
  int a, b, n, ret;
  cin >> n >> a >> b;
  ret = 0;
  
  for(int i = 1; i <= n; i++) {
    int sum = fn(i);
    //cout << "i: " << i << ", sum: " << sum << endl;
    if(a <= sum && sum <= b) {
      ret += i;
    }
  }
  
  cout << ret;
    
  return 0;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll N;

int main(){
    string S;
    cin >> N >> S;
    ll cnt = 0;
    char pre;
    for(char ch:S)
    {
        if(cnt==0){cnt++;}
        else{
            if(pre==ch)continue;
            else cnt++;
        }
        pre=ch;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(void){
    int r, D, x;
    cin >> r >> D >> x;

    int x_i = x;
    int x_ii;
    for(int i=0; i<10; i++){
        x_ii = r*x_i - D;
        cout << x_ii << endl;
        x_i = x_ii;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    map<string, ll> mp;
     rep(i,n){
         string str;
         cin >> str;
         if (mp.count(str) != 0){
             mp[str] += 1;
         }else{
             mp[str] = 1;
         }
     }
    cout << mp.size() << endl;
    

}

Measured memory_bytes: 19228
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    string S;
    cin >> N >> S;
    for(auto &c:S){
        c += N;
        if(c > 'Z')c -= 26;
    }
    cout << S << endl;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, w;
    cin >> n >> w;
    vector<pair<int, int>> items;
    for(int i=0; i<n; i++){
        int vi, wi;
        cin >> vi >> wi;
        items.push_back(make_pair(vi, wi));
    }

    // O(nw^2) ~ 100*10000^2 = 10^10 で TLE

    // これだと普通に O(nw) ~ 10^6
    vector<int> knap(w+1, 0);
    for(int i=0; i<=w; i++){
        knap[i] = i/items[0].second * items[0].first;
    }

    for(int i=1; i<n; i++){
        for(int j=items[i].second; j<=w; j++){
            int new_val = knap[j-items[i].second] + items[i].first;
            if(knap[j-items[i].second] + items[i].first > knap[j]){
                knap[j] = new_val;
            }            
        }
    }
    cout << knap[w] << endl;
    
    return 0;
}


Measured memory_bytes: 3184
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define db double
#define LL long long
#define inf 0x3f3f3f3f
using namespace std;
int gi()
{
    int res=0,s=1; char ch;
    for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=res*10+ch-48;
    return res*s;
}

int n,mo,k;
int dp[305][305],sum[305][305],C[305][305];

int main()
{
    n=gi(),k=gi(),mo=gi();
    for(int i=0;i<=k;++i) dp[1][i]=1;
    C[0][0]=1;
    for(int i=1;i<=n;++i) {
	C[i][0]=C[i][i]=1;
	for(int j=1;j<i;++j)
	    C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
    }
    for(int i=k;i>=0;--i) {
	for(int j=1;j<=n+1;++j)
	    for(int s=1;s<j;++s)
		(dp[j][i]+=(LL)dp[j-s][i]*sum[s][i+1]%mo*C[j-2][s-1]%mo)%=mo;
	for(int j=1;j<=n+1;++j)
	    sum[j][i]=(sum[j][i+1]+dp[j][i])%mo;
    }
    printf("%d",dp[n+1][0]);
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T &x) { cout << x << "\n"; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    deque<int> A;
    REP(i, N)
    {
        int a;
        cin >> a;
        if (i % 2 == 0)
        {
            A.push_back(a);
        }
        else
        {
            A.push_front(a);
        }
    }

    if (N % 2 == 1)
    {
        reverse(ALL(A));
    }
    for (auto x : A)
        cout << x << " ";
    cout << "\n";
}

Measured memory_bytes: 3840
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n = int(input())
a = sorted(list(map(int,input().split())))
print(a[-1]-a[0])

Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

const int MAX = 1000000;
bool isPrime[MAX+1];
int sum[MAX+1];

int main() {
	fill(isPrime, isPrime + MAX + 1, true);
	fill(sum, sum + MAX + 1, 0);
	for(int i = 2; i <= MAX; i++) {
		sum[i] = sum[i - 1];
		if(isPrime[i]) {
			sum[i]++;
			if(i*i <= MAX) {
				for(int j = 2 * i; j <= MAX; j += i)
					isPrime[j] = false;
			}
		}
	}
#if 0
	for(int i = 0; i < 20; i++) {
		cout << i << " " << isPrime[i] << " " << sum[i] << endl;
	}
#endif
	for(int n; cin >> n;) {
		cout << sum[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n, k, s = map(int, input().split())
flag = False
if s == 10**9:
    flag = True

for i in range(k):
    print(s, end=" ")
for i in range(n - k):
    if flag:
        if i != n - k - 1:
            print(1, end=" ")
        else:
            print(1)
    else:
        if i != n - k - 1:
            print(s + 1, end=" ")
        else:
            print(s + 1)


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

using namespace std;

int main(){
    int r,c;
    cin >> r >> c;
    vector<vector<int>> matrix(r+1,vector<int>(c+1,0));
    
    for(int rr = 0;rr < r;rr++){
        int sum_row = 0;
        for(int cc = 0;cc < c;cc++){
            cin >> matrix[rr][cc];
            sum_row += matrix[rr][cc];
            cout << matrix[rr][cc] << " ";
        }
        matrix[rr][c] = sum_row;
        cout << matrix[rr][c]  << "\n";
    }
    
    for(int cc = 0; cc < c;cc++){
        int sum_col = 0;
        for(int rr = 0; rr < r; rr++){
            sum_col += matrix[rr][cc];
        }
        matrix[r][cc] = sum_col;
        cout << matrix[r][cc] << " ";
    }
    
    int sum = 0;
    for(int rr = 0; rr < r; rr++){
        sum += matrix[rr][c];
    }
    matrix[r][c] = sum;
    cout << matrix[r][c] << "\n";

    return 0;   
}



Measured memory_bytes: 3180
def solve():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))
    c = 10000
    ci = 0
    for i, x in enumerate(h):
        tmp = abs(a - (t - x * 0.006))
        if c > tmp:
            c = tmp
            ci = i
    print(ci + 1)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9208
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
typedef pair<ll,ll> P;
ll n;
P m[200000];
ll c[200000];
ll k;
int main(){
	cin >> n >> k;
	REP(i,n)
		cin >> m[i].fi >> m[i].sc;
	sort(m,m + n);

	ll sum = 0;

	REP(i,n) {
		sum += m[i].sc;
		if(sum >= k) {
			cout << m[i].fi << endl;
			break;
		}
	}
	
	return 0;
}


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

int main() {
  int N, A = 0, B = 0, j = 0, p = 0, l;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);

  while (j < N / 2 + 1) {
    for (int i = 0; i < N; i++) if (a.at(i) > p) p = a.at(i), l = i;
    A += p, a.at(l) = 0, p = 0;
    for (int i = 0; i < N; i++) if (a.at(i) > p) p = a.at(i), l = i;
    B += p, a.at(l) = 0, p = 0;

    j++;
  }

  cout << A - B << endl;
}

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

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin.exceptions(cin.failbit);
     
    long long n,a,b;
    cin >> n >> a >> b;
    long long time = n / (a+b);
    long long res = a*time;
    res += min(a,n-time*(a+b));
    cout << res << '\n';
	
	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;


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

	int N;
	cin >> N;

	vector<string> s(N);
	map<string, ll> m;
	rep(i, N) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());

		m[s[i]]++;
	}
	
	for (auto p: m) {
		ans += p.second * (p.second - 1) / 2;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 16640
#include<cstdio>

using namespace std;

const int N = 1e9;


int main(){
	//freopen("in","r",stdin);
	int n,k,s;
	scanf("%d%d%d",&n,&k,&s);
	for(int i = 0;i < k;i++) printf("%d ", s);
	for(int i = k;i < n;i++) if(s==N)printf("%d ", s-1);else printf("%d ", s+1);
	printf("\n");
}

Measured memory_bytes: 1280
n = int(input())
friendry = list(map(int,input().split()))
friendry.sort()
friendry.reverse()
# print(friendry)
ans = 0
t = n-1
for i in range(n-1):
    lim = 2
    if(i == 0):
        lim = 1
    for j in range(lim):
        if(t > 0):
            ans += friendry[i]
            t -= 1

print(ans)



Measured memory_bytes: 31552
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<queue>
#include<unordered_map>
using namespace std;
 
int main() {
    long long N;
    cin >> N;
    long long ans;
    ans = N * (N - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

def solve(a, b, c, d):
    if a < b or d < b:
        return False
    if b < c:
        return True

    g = gcd(b, d)
    return (b + a % g - g) <= c

T, *L = map(int, open(0).read().split())

print("\n".join("Yes" if solve(*t) else "No" for t in  zip(*[iter(L)] * 4)))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    //SCC decomposition
    void dfs(int v, vector<bool> &used, vec &vs){
        used[v] = true;
        REP(i, G[v].size()){
            if(!used[G[v][i].to]) dfs(G[v][i].to, used, vs);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k, vector<bool> &used, vec &cmp){
        used[v] = true;
        cmp[v] = k;
        REP(i, G[v].size()){
            if(!used[G[v][i].to]) rdfs(G[v][i].to, k, used, cmp);
        }
    }
    vec scc(int &k){
        vector<bool> used(V, false);
        vec vs(0), cmp(V);
        REP(i, V){
            if(!used[i]) dfs(i, used, vs); 
        }
        //reverse graph
        Graph rG(V);
        REP(v, V) REP(i, G[v].size()) rG.add_edge(G[v][i].to, v, G[v][i].cost);

        fill(used.begin(), used.end(), false);
        k = 0;
        IREP(i, vs.size()){
            if(!used[vs[i]]) rG.rdfs(vs[i], k++, used, cmp);
        }
        return cmp;
    }

};

signed main(){

    int N, M; cin >> N >> M;
    Graph G(N);
    int A, B;
    mat cand(N, vec(0));

    REP(i, N + M - 1){
        cin >> A >> B;
        G.add_edge(A - 1, B - 1, 0);
        cand[B - 1].push_back(A - 1);
    }
    int k;
    vec cmp = G.scc(k);
    //cout << k << endl;
    //REP(i, N) cout << cmp[i] << endl;
    REP(i, N){
        int ans = -1, mm = -1;
        for(int c: cand[i]){
            if(cmp[c] > mm){
                mm = cmp[c];
                ans = c;
            }
        }
        cout << ans + 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 19576
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    ll sum = 3*n*(k-1) + 3*n*(3*n+1)/2;
    ll usum= n*(k+2*n-1) + n*(n+1)/2;
    if (usum*2 < sum){
        cout << -1 << endl;
        return 0;
    }
    dump(usum)
    dump(sum)
    int top;
    int mid;
    int low;
    set <int> q;
    for(ll i=k; i<k+3*n; i++){
        q.insert(i);
    }
    for(ll i=0; i<(n+1)/2; i++) {
        top = k + 3 * n - 1 - 2 * i;
        mid = k + 2 * n - 1 - i;
        low = top - mid;
        q.erase(top); q.erase(mid); q.erase(low);
        cout << low << " " << mid << " " << top << endl;
    }
    for(ll i=0; i<n/2; i++){
        top = k + 3*n - 2 - 2*i;
        mid = k + 2*n - (n+1)/2 - 1 - i;
        q.erase(top); q.erase(mid);
    }
    for(ll i=0; i<n/2; i++){
        top = k + 3*n - 2 - 2*i;
        mid = k + 2*n - (n+1)/2 - 1 - i;
        low = *(q.rbegin());
        q.erase(low);
        cout << low << " " << mid << " " << top << endl;
    }
    return 0;
}

Measured memory_bytes: 17024
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);

		int sum1=0;
		int sum2=0;

		for(int i=0; i<4;i++)
			sum1 += sc.nextInt();
		for(int i=0; i<4;i++)
			sum2 += sc.nextInt();
		
			System.out.println(Math.max(sum1, sum2));
	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>

using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;

	vector<string> s;
	string t;

	for (int i = 0; i < n; i++) {
		cin >> t;
		s.push_back(t);
	}

	sort(s.begin(), s.end());

	for (int i = 0; i < n; i++)
		cout << s[i];
	cout << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


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

	if (N <= M)
		for (int i = 0; i < M; i++)printf("%d", N);
	else
		for (int i = 0; i < N; i++)printf("%d", M);
	return 0;
}

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

int main()
{
   string s,res="";
   cin>>s;
   for(int i=0,n=s.length();i<n;i++)
   {
       if(i%2==0)
            res+=s[i];
   }
   cout<<res<<endl;
return 0;
}


Measured memory_bytes: 512
open Printf
open Scanf

let (++) = Int64.add
let (--) = Int64.sub
let ( ** ) = Int64.mul
let (//) = Int64.div
let (%%) = Int64.rem
let landl = Int64.logand
let lorl = Int64.logor
let lnotl = Int64.lognot
let lxorl = Int64.logxor
let lsll = Int64.shift_left
let lsrl = Int64.shift_right_logical
let long = Int64.of_int
let succl = Int64.succ
let predl = Int64.pred

let read_int _ = scanf " %d " (fun x -> x)
let read_long _ = scanf " %Ld " (fun x -> x)
let read_str _ = scanf " %s " (fun x -> x)
let read_double _ = scanf " %f " (fun x -> x)

let m = 1_000_000_007L

let rec gcd a b = if b = 0L then a else gcd b (a %% b)

let rec mod_pow a = function
  | 0L -> 1L
  | b -> (if b %% 2L = 0L then 1L else a) ** mod_pow (a ** a %% m) (b//2L) %% m

let readln _ = scanf " %f %s " (fun x y ->
    if y = "BTC" then x *. 380000.0 else x
  )

let () =
  let n = read_int () in
  let xu = Array.init n readln in
  printf "%.10f\n" @@ Array.fold_left (+.) 0.0 xu


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
// a^n mod を計算する
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;
}
vector<int> f = {1},fi = {1};
int fact(int x){
    while((int)f.size() <=x)f.push_back((f.back()*f.size())%mod);
    return f[x];
}
int ifact(int x){
    return modpow(fact(x),mod-2,mod);
}
int C(int x,int y){
    if(x < y)return 0;
    return fact(x)*ifact(y)%mod*ifact(x-y)%mod;
}
signed main(){
    int k;cin >> k;
    string s;cin >> s;
    int ret = 0;
    int n = s.size();
    rep(x,k+1){
        int tmp = C(n+k-x-1,n-1)*modpow(25,k-x,mod)%mod;
        tmp =(tmp*modpow(26,x,mod))%mod;
        ret = (ret + tmp)%mod;
    }
    cout << ret  << endl;

    return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int a,b,c,x,y;
int main(){
	cin >> a >> b >> c >> x >> y;
	int ans = INTMAX;
	for(int i = 0; i <= 2 * max(x,y); i=i+2){
		int tmp = i * c;
		tmp += max((x - i/2),0) * a;
		tmp += max((y - i/2),0) * b;
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
object Main {
	def main(args: Array[String]): Unit = {
		val sc = new java.util.Scanner(System.in)

    	val n: Int = sc.nextLine.toInt
    	val ts: Array[Int] = sc.nextLine.split(" ").map(_.toInt)
    	val m: Int = sc.nextLine.toInt
    	val pxs = for (_ <- 0 until m) yield {
    		sc.nextLine.split(" ").map(_.toInt)
    	}

    	for (px <- pxs) {
    		var t_net = 0
    		for ((t, i) <- ts.zipWithIndex) {
    			val t_ = if (px(0) == (i+1)) px(1) else t
    			t_net += t_
    		}
    		println(t_net)
    	}
	}
}

Measured memory_bytes: 23016
n = gets.chomp.to_i
a = Array.new(n,0)

a = a.map do
    s = gets.split(".")
    res = s[0].to_i*1000000000
    if s.size >1
        res += s[1].to_i*(10**(10-s[1].size))
    end
    res
end
cnt = Array.new(22).map{Array.new(22,0)}
dp = Array.new(22).map{Array.new(22,0)}
p = a.map do |e|
    c2 = c5 = 0
    while e%2==0
        e /= 2
        c2 += 1
    end
    
    while e%5==0
        e /= 5
        c5 += 1
    end
    cnt[[20,c2].min][[20,c5].min] += 1
    [c2,c5]
end

for i in 0..20
    for j in 0..20
        dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j]-dp[i][j]+cnt[i][j];
    end
    # pp dp[i+1]
end
ans = 0
p.each do |e|
    c2,c5 = e
    t2 = [0,18-c2].max
    t5 = [0,18-c5].max
    ans += n-dp[t2][21]-dp[21][t5]+dp[t2][t5]
    ans -= 1 if c2 >= 9 && c5 >= 9
    # pp ans
end

puts ans/2



Measured memory_bytes: 25644
import Data.Char

pick :: String -> [Int]
pick [] = []
pick x@(xh:xs)
  | isDigit(xh) =
      let num = read $ takeWhile isDigit x
          res = dropWhile (isDigit) x
      in
        num:(pick res)
  | otherwise = pick xs

ans x = sum $ pick x

main = do
  c <- getContents
  let o = ans c
  print o

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

using namespace std;

typedef long long LL;

const LL maxn = 100005;
const LL inf = 0x3f3f3f3f;

LL op[maxn];
LL a[maxn];
LL qzhh[maxn];
LL yuan[maxn];
LL lstt[maxn];
char s[3];
LL n;

int main()
{
	scanf("%lld", &n);
	scanf("%lld", &a[1]);
	qzhh[1] = yuan[1] = a[1];
	op[1] = 1;
	LL ans = 0;
	for(LL i = 2; i <= n; ++i)
	{
		scanf("%s%lld", s, &a[i]);
		op[i] = (s[0] == '+');
		qzhh[i] = qzhh[i - 1] + a[i];
		yuan[i] = yuan[i - 1] + (op[i] ? a[i] : -a[i]);
	}
	op[n + 1] = op[n + 2] = 0;
	qzhh[n + 1] = qzhh[n + 2] = qzhh[n];
	yuan[n + 1] = yuan[n + 2] = yuan[n];
	n += 2;
	LL lst = n + 1;
	for(LL i = n; i; --i)
	{
		if(!op[i])
		{
			lstt[i] = lst;
			lst = i;
		}
	}
//	cout << "qzhh = ";
//	for(LL i = 1; i <= n; ++i)
//		cout << qzhh[i] << ' ';
//	cout << endl;
//	cout << "yuan = ";
//	for(LL i = 1; i <= n; ++i)
//		cout << yuan[i] << ' ';
//	cout << endl;
//	cout << "lstt = ";
//	for(LL i = 1; i <= n; ++i)
//		cout << lstt[i] << ' ';
//	cout << endl;
	for(LL i = lst; lstt[i] <= n; i = lstt[i])
	{
		LL l = i, r = lstt[i];
		ans = max(ans, yuan[l - 1] - (qzhh[r - 1] - qzhh[l - 1]) + qzhh[n] - qzhh[r - 1]);
//		cout << l << ' ' << r << ' ' << ans << endl;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4096
from math import sqrt
n=int(input())
x=[0]
y=[0]
k=1
s=0
m=2
for i in range(1,n+1):
    a,b=map(int,input().split())
    x.append(a)
    y.append(b)
    k*=i
    m*=i
m//=n
for i in range(1,n+1):
    for j in range(i+1,n+1):
        s+=sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)*m
v=round(s/k,10)
print(v)


Measured memory_bytes: 3064
a, b, c, d, e, f = map(int, input().split())
max_cnc = 0

Water = []
for i in range(0, f // (a * 100) + 1):
  for j in range(0, f // (b * 100) + 1):
    if (i * a + j * b) * 100 <= f:
      Water.append((i * a + j * b) * 100)
#print(list(set(Water)))

import math
Solt = []
for i in range(0, math.ceil((f * e / 100) / c) + 1):
  for j in range(0, math.ceil((f * e / 100) / d) + 1):
    if i * c + j * d <= (f * e / 100):
      Solt.append(i * c + j * d)
#print(list(set(Solt)))

max_cnc = 0
champ_w = 0
champ_s = 0
from itertools import product 
for pair in product(list(set(Water[1:])), list(set(Solt))):
#  print(pair[0], pair[1])
  vol = pair[0] + pair[1]
  if vol > f:
    continue
  if pair[1] * 100 / pair[0] > e:
    continue
  cnc = pair[1] * 100 / (pair[0] + pair[1])
#  print(pair[0], pair[1], cnc)
  max_cnc = max(cnc, max_cnc)
  if cnc == max_cnc:
    champ_w = pair[0]
    champ_s = pair[1]
print(champ_w + champ_s, champ_s)

Measured memory_bytes: 52108
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

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

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int a[8];
string s, gl = "01234567";
int d[4] = {1, -4, 4, -1};
map<string, int> S;

int solve(){
  queue< pair<string, int> > Q;
  Q.push(mp("01234567", 0));
  S.insert(mp("01234567", 0));

  for(int i, j, k;!Q.empty();){
    pair<string, int> tmp = Q.front();
    Q.pop();

    rep(i, 8)if(tmp.X[i] == '0')break;
    rep(k, 4)if(0 <= i + d[k] && i + d[k] < 8){
      if(i == 3 && i + d[k] == 4)continue;
      if(i == 4 && i + d[k] == 3)continue;
      swap(tmp.X[i], tmp.X[i + d[k]]);
      if(S.find(tmp.X) == S.end()){
        ++tmp.Y;
        Q.push(tmp); S.insert(tmp);
        --tmp.Y;
      }
      swap(tmp.X[i], tmp.X[i + d[k]]);
    }
  }
  return -1;
}

signed main(void){
  int i, j;
  s.resize(8);
  solve();
  for(int testcase = 0;testcase >= 0;testcase++){
    rep(i, 8){
      if(scanf("%d", &a[i]) == -1)return 0;
      s[i] = (char)('0' + a[i]);
    }
    pri(S.at(s));


//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 5348
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define pb push_back
typedef pair<ll,ll> pp;

ll mod = 1e9+7;
ll INF = 1e15;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

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





void solve()
{
  int k,a,b,flag = 0;
  cin>>k>>a>>b;
  for(int i = a;i<=b;i++)
  {
    if(i%k == 0)
    flag = 1;
  }
  if(flag)cout<<"OK\n";
  else cout<<"NG\n";


}



int main()
{
  int tc;
  // cin>>tc;
  tc = 1;
  while(tc--)
  {
    solve();
  }
}


Measured memory_bytes: 3652
HW = list(map(int, input().split()))

if (HW[0] == 1 and HW[1] == 1):
	count = 1
elif (HW[0] == 1 or HW[1] == 1):
	count = HW[0] * HW[1] - 2
else:
	count = (HW[0] - 2) * (HW[1] - 2)

print(count)

Measured memory_bytes: 3060
n, m = list(map(int, input().split()))

def f(n):
    ans = n
    for i in range(1, n):
        ans *= i
        ans %= 1000000007
    return ans

if n == m:
    print(((f(n))**2 *2)%1000000007)
elif n == m+1 or m == n+1:
    print((f(n)*f(m))%1000000007)
else:
    print(0)

Measured memory_bytes: 9020