akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N,M;
	cin>>N>>M;
	vector<P> v(M);
	vector<int> BoxN(N,1);
	vector<bool> InRed(N,false);
	InRed[0] = true;
	rep(i,M){
		int x,y;
		cin>>x>>y;
		x--;y--;
		if(InRed[x]){
			if(BoxN[x]==1){
				InRed[x] = false;
				InRed[y] = true;
			}
			else{
				InRed[x] = true;
				InRed[y] = true;
			}
		}
		BoxN[x]--;
		BoxN[y]++;
	}
	int ans = 0;
	rep(i,N){
		if(InRed[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

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


int main(){
    int a[3]; cin >> a[0] >> a[1] >> a[2];
    int five = 0;
    int seven = 0;
    rep(i,3){
        if(a[i] == 5) five++;
        if(a[i] == 7) seven++;
    }
    if(five == 2 && seven == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());

    if((a*b) % 2 == 0) {
    	System.out.println("Even");
    } else {
    	System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int y,m,d;
 char c1,c2;
 cin >> y >> c1 >> m >> c2 >> d;
 if(m>4){
   cout << "TBD" << endl;
 }else{
   cout << "Heisei" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector< pair<long long,long long> > v;
long long ans[100005],pre[100005],tag[100005];
long long find(long long x)
{
    long long r=x;
    while(pre[r] != r)
          r=pre[r];
    long long i=x,j;
    while(i!=r)
    {
         j = pre[i];
         pre[i]= r ;
         i=j;
    }
    return r;
}
void join(long long x,long long y)                                                                                                       
{
    long long fx=find(x),fy=find(y);
    if(fx!=fy) pre[fy]=fx,tag[fx]+=tag[fy];
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) pre[i]=i;
    for(int i=0;i<m;i++)
    {
    	int x,y;
    	scanf("%d%d",&x,&y);
    	v.push_back(make_pair(x,y));
	}
	for(int i=1;i<=n;i++) tag[i]=1;
	long long ans1=(long long )n*((long long)n-(long long)1)/(long long)2;
	for(int i=m;i>=1;i--)
	{
		if(i!=m)
		{
			pair<long long,long long> x=v[i];
			int xx=find(x.first);
			int yy=find(x.second);
		if(xx!=yy)
		{
			ans1-=tag[xx]*tag[yy];
			join(x.first,x.second);
		}
		}
		ans[i]=ans1;
	}
	for(int i=1;i<=m;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 5360
#include<cstdio>
#include<cstdlib>
#include<ctime>
int last[500];
long long s[500][30];
long long c[30];
int tt[500];
int out[500];
int vis[30];
int bit[500][500];
long long sum[500];

void change(int t,int p,int v,int n){
    while(p<=n){
        bit[p][t] += v;
        p += (p&-p);
    }
}

int ask(int t,int p){
    int res = 0;
    while(p!=0){
        res += bit[p][t];
        p -= (p&-p);
    }
    return res;
}

int getAfter(int t,int p){
    int base = ask(t,p);
    if(ask(t,365)==base) return 366;
    else{
        int l = p+1, r = 365;
        int res = -1;
        while(l<=r){
            int m = (l+r)/2;
            if(ask(t,m)>base){
                res = m;
                r = m-1;
            }
            else l = m+1;
        }
        return res;
    }
}

int getBefore(int t,int p){
    int base = ask(t,p-1);
    if(base==0) return 0;
    else{
        base = ask(t,p-1);
        int l = 1, r = p-1;
        int res = -1;
        while(l<=r){
            int m = (l+r)/2;
            if(ask(t,m)>=base){
                res = m;
                r = m-1;
            }
            else l = m+1;
        }
        return res;
    }
}

long long getD(int d){
    for(int i = 1; i <= 26; i++) last[i] = 0;
    long long cur = 0;
    for(int i = 1; i <= d; i++){
        int t = tt[i];
        cur += s[i][t];
        last[t] = i;
        for(int j = 1; j <= 26; j++) cur -= c[j]*(i-last[j]);
    }
    return  cur;
}

int main(){
    sum[0] = 1;
    for(int i = 1; i <= 366; i++) sum[i] = sum[i-1]+i;
    srand(time(NULL));
    int d;
    scanf("%d",&d);
    for(int i = 1; i <= 26; i++) scanf("%lld",&c[i]);
    for(int i = 1; i <= d; i++){
        for(int j = 1; j <= 26; j++) scanf("%lld",&s[i][j]);
    }
    for(int i = 1; i <= d; i++){
        int find = 1;
        for(int j = 2; j <= 26; j++) if(s[i][j]>s[i][find]) find = j;
        tt[i] = find;
        change(find,i,1,365);
    }
    for(int i = 0; i < 100000; i++){
        int p = rand()%365+1;
        int a = tt[p], keep = tt[p];
        int last = getBefore(a,p), next = getAfter(a,p);
        long long base = -(sum[next-last-1]-sum[p-last-1]-sum[next-p-1])*c[a];
        long long add = 0;
        for(int j = 1; j <= 10; j++){
            int b = rand()%26+1;
            int last = getBefore(a,p), next = getAfter(a,p);
            last = getBefore(b,p), next = getAfter(b,p);
            long long cur = (sum[next-last-1]-sum[p-last-1]-sum[next-p-1])*c[b]+base+s[p][b]-s[p][a];
            if(cur>add){
                add = cur;
                keep = b;
            }
        }
        tt[p] = keep;       
        change(a,p,-1,365);
        change(keep,p,1,365);
    }
    for(int i = 1; i <= d; i++) printf("%d\n",tt[i]);
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

const int D = 60;
const int MAX_N = 200005;

int to[D][MAX_N];

int main()
{
    string n;
    cin >> n;

    char num = n[n.size() - 1];
    if (num == '3')
    {
        cout << "bon" << endl;
    }
    else if (num == '0' || num == '1' || num == '6' || num == '8')
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }

    return 0;
}


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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();
    vector<string> vs;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 1; j <= k; ++j)
            vs.push_back(s.substr(i, j));
    }
    sort(all(vs));
    vs.resize(unique(all(vs)) - vs.begin());
    cout << vs[k - 1];
}


Measured memory_bytes: 1660
n,k = map(int ,input().split(" "))
h = [int(x) for x in input().split(" ")]
INF = 10**9
dp = [INF] * n
dp[0] = 0

for i in range(1,n):
    h_i = h[i]
    s = i-k if i-k > 0 else 0
    dp[i] = min(d_j + abs(h_i - h_j)for d_j, h_j in zip(dp[s:i], h[s:i]))

print(dp[-1])

Measured memory_bytes: 13980
#include <iostream>

int main()
{
    int A = 0, B = 0;
    std::cin >> A >> B;

    if (A >= 1 && A <= 9 && B >= 1 && B <= 9)
        std::cout << A * B << std::endl;
    else
        std::cout << -1 << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
void arraycout(int *arrayy,int n){
    for(int u=0;u<n;u++){//出力
        if(u==n-1){
            cout<<arrayy[u]<<endl;
        }else{
            cout<<arrayy[u]<<' ';
        }
    }
    
}


void insertionSort(int* sou,int n){//挿入ソート
    for(int i=0;i<n;i++){

        int v=sou[i];
        int j=i-1;
        while(j>=0&&v<sou[j]){
            sou[j+1]=sou[j];
            j--;
        }
        sou[j+1]=v;
                arraycout(sou,n);
        
    }
}
int Bubble(int* sou,int n){
    int flag=1;
    int ans=0;
    while(flag){
        flag=0;
        for(int i=n-1;i>0;i--){
            if(sou[i]<sou[i-1]){
                flag=1;
                swap(sou[i],sou[i-1]);
                ans++;
            }
        }
    }
    return ans;
    
}

int main(){
    
    int n;
    cin>>n;
    int sou[n];
    for(int i=0;i<n;i++){
        cin>>sou[i];
    }
    int ans=Bubble(sou,n);
    arraycout(sou,n);
    cout<<ans<<endl;
   // insertionSort(sou,n);
   // arraycout(sou,n);
    
    return 0;
}



Measured memory_bytes: 3140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 36

struct Card{
  char str[2];
  int num;
};

int main()
{
  int N,i,flag=1,j,minj,judge=0;
  struct Card A[MAX],temp,B[MAX];
  char *moji;

  scanf("%d",&N);
  if( N < 1 || MAX < N ) exit(2);

  for( i = 0 ; i < N ; i++ )
    {
      scanf("%s",&A[i].str);
      A[i].num = atoi(&A[i].str[1]);
         if( A[i].str[0] != 'H' && A[i].str[0] != 'S' &&
    A[i].str[0] != 'D' && A[i].str[0] != 'C') exit(3);
    if( A[i].num < 1 || 9 < A[i].num ) exit(4);
      B[i] = A[i];
    }
 


  i = 0;
  while( flag != 0 )
    {
      flag = 0;
      for( j = N-1 ; j >= i+1 ; j-- )
	{
	  if( A[j].num < A[j-1].num )
	    {	
	      temp = A[j];
	      A[j] = A[j-1];
	      A[j-1] = temp;
	      flag = 1;
	    } 
	}
      i++;
    }

  for( i = 0 ; i < N ; i++ )
    {
      minj=i;
      for( j = i+1 ; j < N ; j++ )
	{
	  if( B[j].num < B[minj].num )
	    minj = j;
	}
      if( i != minj )
	{
	  temp = B[i];
	  B[i] = B[minj];
	  B[minj] = temp;
	}
    }
  
  for( i = 0 ; i < N ; i++ )
    {
      if( strcmp(A[i].str,B[i].str)  != 0)
	{
 moji = "Not stable";
 judge=1;
 break;
	}
    }
  if(judge == 0 ) moji = "Stable";
  for( i = 0 ; i < N-1 ; i++ ) 
    {
      printf("%c%d ",A[i].str[0],A[i].num);
    }
  printf("%c%d\nStable\n",A[i].str[0],A[i].num);

 for( i = 0 ; i < N-1 ; i++ ) 
    {
      printf("%c%d ",B[i].str[0],B[i].num);
    }
 printf("%c%d\n%s\n",B[i].str[0],B[i].num,moji);

  return 0;
}

Measured memory_bytes: 604
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{x:i64, y:i64};
    let mut x = x;

    let mut ans:i64 = 1;
    loop {
        if x*2 <= y { ans += 1; }
        else {break}
        x = x*2;
    }

    println!("{}", ans);

}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int N;
int l, r;

signed main()
{
    cin >> N;
    int ans = 0;
    REP(i,N) {
        cin >> l >> r;
        ans += r - l + 1;
    }
    
    cout << ans << endl;
}


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


list = [[[0] * 10 for i in range(3)] for j in range(10)]


for i in range(n):
    b, f, r, v = map(int, input().split())
    list[b-1][f-1][r-1] += v

for i in range(4):
    if i!=0:
        print('#'*20)
    for j in range(3):
        for k in range(10):
            print(' %d' % (list[i][j][k]), end='')
        print()








Measured memory_bytes: 5624
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N,K,X,Y;

  cin>>N>>K>>X>>Y;

  int ans=0;

  if(N>K){
    ans=X*(K)+Y*(N-K);
  }else{
    ans=X*N;
  }

  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 256
import sys

DBG_FLAG = 0

def p_dbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

def get_row():
    array = []
    txt = raw_input()

    for char in txt:
        array.append(char)

    return array

# defined & initial arrays
cells_top = []
cells_bottom = []

# get cells
cells_top = get_row()
cells_bottom = get_row()

p_dbg(cells_top)
p_dbg(cells_bottom)

# reverse
cells_top.reverse()

p_dbg(cells_top)

# Decision
if(cells_top == cells_bottom):
    print 'YES'
else:
    print 'NO'


Measured memory_bytes: 2568
#include <stdio.h>

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b){
        if(a!=c){
            printf("Yes");
        } else {
            printf("No");
        }
    } else {
        if(a==c || b==c){
            printf("Yes");
        } else {
            printf("No");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, X, Y;
  cin >> N >> X >> Y;
  vector<long> data(N + 1);
  for(long i = 1; i <= N; i++){
    for(long j = i + 1; j <= N; j++){
      data.at(min(j - i, abs(X - i) + abs(Y - j) + 1))++;
    }
  }
  for(int i = 1; i < N; i++)cout << data.at(i) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
    int N;
    int a;
    vector<int> d;

    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> a;
        d.push_back(a);
    }    
    sort(d.begin(), d.end());
    cout << d.at(N/2) - d.at(N/2 - 1) << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

int main(){
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  vector<bool> exist(110,false);
  rep(i,N){
    cin >> p.at(i);
    exist.at(p.at(i)) = true;
  }
  int ans;
  int tmp = 200;
  for(int i=0; i<=101; i++){
    if(tmp>abs(X-i)&&!exist.at(i)){
      ans = i;
      tmp = abs(X-i);
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3608
// She is Pretty pretty!
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1100;
ll n, a[N],f[N][N], sum[N];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0);
    cin >> n;
    memset(f, 0x3f, sizeof f);
    for(int i = 1; i <= n; i++){
        f[i][i] = 0;
        cin >> a[i];
        sum[i] = sum[i-1]+a[i];
    }
    for(int len = 2; len <= n; len++){
        for(int l = 1; l+len-1 <= n; l++){
            int r = l+len-1;
            for(int k = l; k< r; k++){
                f[l][r] = min(f[l][r], f[l][k]+f[k+1][r]);
            }
            f[l][r] += sum[r]-sum[l-1];
        }
    }  
    cout <<f[1][n] <<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()

ll calc(string s) {
	char prv = ' ';
	int cnt = 0;
	ll ans = 0;
	for (char c: s) {
		if (c == prv) {
			cnt++;
		} else {
			ans += cnt / 2;
			cnt = 1;
			prv = c;
		}
	}
	ans += cnt / 2;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll k, n;
	cin >> k;
	n = s.size();
	set<char> st;
	for (char c: s) {
		st.insert(c);
	}
	if (st.size() == 1) {
		cout << n * k / 2 << endl;
	} else if (k < 6) {
		string tmp;
		for (int i = 0; i < k; ++i) {
			tmp += s;
		}
		cout << calc(tmp) << endl;
	} else {
		string tmp;
		for (int i = 0; i < 5; ++i) {
			tmp += s;
		}
		ll old = calc(tmp);
		tmp += s;
		ll add = calc(tmp) - old;
		cout << old + add * (k - 5) << endl;
	}
}

Measured memory_bytes: 256
// Believe in yourself...
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) (c).size()
#define REP(i,n)  for(ll i=0;i<n;i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)

#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf=4e18;
const ll maxn=3e5+10;

#pragma GCC Optimize("Ofast")

ll a[maxn],b[maxn];

int main(){
	ll n;cin>>n;
	string s;cin>>s;
	FOR(i,1,n)
		a[i]=a[i-1]+(s[i-1]=='W');
	FORD(i,n,1)
		b[i]=b[i+1]+(s[i-1]=='E');
	ll ans=inf;
	FOR(i,1,n)
		ans=min(ans,a[i-1]+b[i+1]);
	cout<<ans;
}

Measured memory_bytes: 5380
pf = {}
ans = 1
m = int(input())
for i in range(2, m+1):
    for j in range(2, int(i**0.5)+1):
        while i%j==0:
            pf[j]=pf.get(j,0)+1
            i//=j
    if i>1:
        if i in pf.keys():
            pf[i]+=1
        else:
            pf[i]=1

for v in pf.values():
    ans *= v+1
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=10010;
int head[N],ecnt;
struct ed {
	int to,next;
}e[N<<1];
void ad(int x,int y) {	
	e[++ecnt]=(ed){y,head[x]}; head[x]=ecnt;
	e[++ecnt]=(ed){x,head[y]}; head[y]=ecnt;
}
int d[N],c[N];
int du[N];
struct nod {
	int id,d;
	friend bool operator < (nod A,nod B) { return A.d==B.d?A.id<B.id:A.d<B.d; }
};
set<nod> s;
int n;
int main() {
	rd(n);
	int x,y;
	for(int i=1;i<n;++i) {
		rd(x),rd(y),ad(x,y);
		du[x]++,du[y]++;
	}
	for(int i=1;i<=n;++i) rd(c[i]);
	for(int i=1;i<=n;++i) s.insert((nod){i,du[i]});
	sort(c+1,c+n+1);
	ll ans=0;
	for(int i=1;i<=n;++i) {
		nod a=*s.begin();
		int u=a.id;
		s.erase(a);
		ans+=c[i]*(ll)du[u];
		d[u]=c[i];
		du[u]=-1;
		for(int k=head[u];k;k=e[k].next) {
			int v=e[k].to; if(du[v]==-1) continue;
			s.erase((nod){v,du[v]});
			du[v]--;
			s.insert((nod){v,du[v]});
		}
	}
	printf("%lld\n",ans);
	for(int i=1;i<=n;++i) printf("%d ",d[i]);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <climits>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);

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

  int count = 1;
  int look = 1;
  for(int i=1; i<N; i++){
    int look = 1;
    for(int j=0; j<i; j++){
      if(H[j] > H[i]){
        look = 0;
      }
    }
    if(look == 1){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int S,h,m,s;
	scanf("%d", &S);
	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 7;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int main()
{
  int n, m;
  cin >> n >> m;
  cout << pow_mod(n, m, Mod) << endl;
  return 0;
}

Measured memory_bytes: 1160
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
	//this is a sample overloading function for sorting stl
	bool operator()(pii const &a, pii const &b)
	{
		if(a.F==b.F)
			return (a.S<b.S);
		return (a.F<b.F);
	}
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int l,r,d,cnt=0;
        cin>>l>>r>>d;
        int st=ceil((1.0*l)/(1.0*d));
        st=st*d;
        //cout<<st<<endl;
        for(int i=st;i<=r;i+=d) cnt++;
        cout<<cnt<<endl;

    }
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int i;
    if(s=="RRR")
        i=3;
    else if(s=="SSS")
        i=0;
    else if(s=="RRS"||s=="SRR")
        i=2;
    else if(s=="RSR"||s=="RSS"||s=="SRS"||s=="SSR")
        i=1;
    cout<<i<<endl;
    return 0;
}


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

int a, b;

int main() {
	cin >> a >> b;
	
	for (int x = 1; x <= 100000; x++) {
		if (x * 8 / 100 == a && x * 10 / 100 == b) {
			cout << x << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
import math

n=int(input())
f=["AC","WA","TLE","RE"]
d=[0]*4
for i in range(n):
        s=input()
        if s=="AC":
                d[0]+=1
        elif s=="WA":
                d[1]+=1
        elif s=="TLE":
                d[2]+=1
        else:
                d[3]+=1
for i in range(len(f)):
        print(f[i],"x",d[i])


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

	int main() {      
		int N, L, R, X, A, D;
    	cin >> N;    	
        while (A < N) {
            cin >> L >> R;
            D = R - L + 1;
        	X += D;
        	A++;
        }cout << X << endl; 
    } 	

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

ll modPow(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}

int main() {
	int N; cin >> N;
	ll ans = modPow(10, N, mod);
	ans = (ans - 2 * modPow(9, N, mod)) % mod;
	if(ans < 0) ans += mod;\
	ans = (ans + modPow(8, N, mod)) % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#define DEBUG(...)
/*                        Strip me down and go to town                        */
/*                          Lick me over upside down                          */
/*                     Pound and pound and pound and pound                    */
/*                        Baby make me make that sound                        */
/*                Aaah, aaah, aaah, aaah, aaaaaaaaaaaaaaaaaah!                */
#include<stdio.h>
#include<vector>
#include<queue>

using namespace std;

const int maxN = 100000;
const int INF = 1000000;

int N;
vector<int>adj[maxN * 3];
int vis[maxN * 3];
priority_queue<pair<int,int>>pq;

int conv(int x, int p) {
  return x + p*N;
}

int main() {
  int m;
  scanf("%d %d", &N, &m);
  for (int i = 0; i < N*3; i++) {
    vis[i] = INF;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    for (int j = 0; j < 3; j++) {
      adj[conv(a-1, j)].push_back(conv(b-1, (j+1)%3));
    }
  }
  int S, T;
  scanf("%d %d", &S, &T);
  pq.push(pair<int,int>(0, S-1));
  while (!pq.empty()) {
    int v = pq.top().second;
    int c = pq.top().first;
    pq.pop();
    if (vis[v] != INF) continue;
    DEBUG(printf("on %d %d\n", v, c);)
    vis[v] = c;
    for (int x : adj[v]) {
      if (vis[x] == INF) {
        pq.push(pair<int,int>(c - 1, x));
      }
    }
  }
  int ans = vis[conv(T-1, 0)];
  if (ans == INF) {
    ans = 3;
  }
  printf("%d\n", -ans / 3);
  return 0;
}

Measured memory_bytes: 17792
import collections

n = int(input())

div = []

for i in range(1,n+1):
    for j in range(2,int(n**0.5)+1):
        while i % j == 0:
            div.append(j)
            i //= j
    if i > 1:
        div.append(i)

c = collections.Counter(div)
    
n2,n4,n14,n24,n74 = 0,0,0,0,0

for k,v in c.items():
    if v >= 2:
        n2 += 1
    if v >= 4:
        n4 += 1
    if v >= 14:
        n14 += 1
    if v >= 24:
        n24 += 1
    if v >= 74:
        n74 += 1

ans = n74 + n24*(n2-1) + n14*(n4-1) + n4*(n4-1)*(n2-2)//2

print(ans)




Measured memory_bytes: 9728
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

/*nをa進数にしたときの、i桁目の数*/
ll a_base(ll n, ll a, ll i){return i==1?n%a:a_base(n/a,a,i-1);}

ll n;

/*
a=9 b=8 7 6 5 4 3 2 1 0
*/

void run(ll n, ll dig){
    rrep(i,dig-1,-1){
        printf("%c",(char) (a_base(n,10,i+1)*(-1) +106  )  );
    }
    printf("\n");
}

void dfs(ll x, ll y, ll dig, ll mx){
    if(dig==n){
        run(x*10+y,dig);
    }else{
        rrep(i,9,mx-2){
            dfs(x*10+y,i,dig+1,min2(mx,i));
        }
    }
}

int main(void){
    // ll n;
    scanf("%lld",&n);
    dfs(0,9,1,9);
    return 0;
}


Measured memory_bytes: 1408
MAX_N_LOADS = 100000
MAX_WEIGHT  = 10000

def loadable_num(n_trucks, load_weights, capacity)
  w_loaded = 0
  n_trucks_loaded = 0
  load_weights.each_with_index do |weight, i|
    return i if capacity < weight
    w_loaded += weight
    if capacity < w_loaded
      w_loaded = weight
      n_trucks_loaded += 1
      return i if n_trucks == n_trucks_loaded
    end
  end
  load_weights.size
end

def find_min_capacity(n_trucks, load_weights)
  left    = 0
  right   = MAX_N_LOADS * MAX_WEIGHT
  n_loads = load_weights.size
  while left < right
    mid = (left + right) / 2
    n_loadables = loadable_num(n_trucks, load_weights, mid)
    if n_loadables < n_loads
      left = mid + 1
    else
      right = mid
    end
  end
  right
end

n_loads, n_trucks = gets.split.map &:to_i
load_weights = n_loads.times.map do
  gets.chomp.to_i
end

puts find_min_capacity(n_trucks, load_weights)

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

using namespace std;

#define ll long long
#define ff first

ll i,j;

int main()
{

	ll h,w;
	cin>>h>>w;

	ll ans=0;
	
	string s[h];
	
	for(i = 0 ; i < h ; i++)
	{
		cin>>s[i];
	}
	
	ll l[h][w],r[h][w],u[h][w],d[h][w];
	
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(s[i][j]=='#')
			{
				l[i][j]=0;
				u[i][j]=0;
			}
			else 
			{	
				l[i][j]=1;
				u[i][j]=1;
				
				if(j-1>=0)
				{
					l[i][j]+=l[i][j-1];
				}
				
				if(i-1>=0)
				{
					u[i][j]+=u[i-1][j];
				}
			}
		}
	}

	for(i = h - 1 ; i >= 0 ; i--)
	{
		for(j = w - 1 ; j >= 0 ; j--)
		{
			if(s[i][j]=='#')
			{
				r[i][j]=0;
				d[i][j]=0;
			}
			else
			{
				r[i][j]=1;
				d[i][j]=1;
			
				if(j+1<w)
				{
					r[i][j]+=r[i][j+1];
				}
			
				if(i+1<h)
				{
					d[i][j]+=d[i+1][j];
				}
			}
		}
	}

	for(i = 0 ; i < h ; i++)
	{
		for(j = 0 ; j < w ; j++)
		{
			if(s[i][j]=='.')
			{
				ans = max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
			}
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 129408
# 2 "2298.cpp"
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>


namespace solution {
   using namespace std;

   typedef istringstream ISS;
   typedef ostringstream OSS;
   typedef vector<string> VS;
   typedef long long LL;
   typedef int INT;
   typedef vector<INT> VI;
   typedef vector<VI> VVI;
   typedef pair<INT, INT> II;

   const int SIZE = 201;
   const int MAX_LENGTH = 10001;
   const int NONE = -1.0;
   const double EPS = 1e-9;
   int N;
   int K;
   int T;
   int U;
   int V;
   int L;
   bool D[MAX_LENGTH];

   typedef pair <II, int> State;
   typedef pair <double, State> Node;
   typedef queue <Node> Queue;
   Queue Q;

   void BFS_init() {
      Q = Queue();
   }


   bool lessthan_equal( double a, double b ) {
      if ( fabs( a - b ) < EPS ) return true;
      return a < b;
   }

   double BFS( int start, int goal ) {
      BFS_init();

      Node start_node( 0.0, State( II( start, 0 ), 0 ) );
      Q.push( start_node );

      double base = 1.0 / U;
      double fast = 1.0 / V;

      while ( ! Q.empty() ) {
         Node node = Q.front();
         Q.pop();

         double cost = node.first;
         int id = node.second.first.first;
         int remains = node.second.first.second;
         int carrots = node.second.second;

         if ( id == goal ) {
            return cost;
         }


         if ( D[id] ) {
            if ( carrots == K ) {
               remains = T * V;
            } else {
               carrots ++;
               if ( remains == 0 ) {
                  remains = T * V;
                  carrots --;
               }
            }
         }

         double t = base;
         if ( remains ) {
            t = min( t, fast );
            remains --;
         }
         if ( remains == 0 && carrots ) {
            remains = T * V;
            carrots --;
         }
         Q.push( Node( cost + t, State( II( id + 1, remains ), carrots ) ) );
      }
      return NONE;
   }

   class Solution {
   private:
      void init() {
         for ( int i = 0; i < MAX_LENGTH; ++ i ) {
            D[i] = false;
         }
      }

      bool input() {
         if ( ! ( cin >> N >> K >> T >> U >> V >> L ) ) return false;
         for ( int i = 0; i < N; ++ i ) {
            int d;
            cin >> d;
            D[d] = true;
         }
         return true;
      }

      double solve() {
         return BFS( 0, L );
      }

   public:
      int run() {
         while ( init(), input() ) {
            printf( "%.9f\n", solve() );
         }
         return 0;
      }
   };
}

int main() {
   using namespace solution;
   Solution s;
   return s.run();
}

Measured memory_bytes: 1252
import javax.management.MBeanRegistration;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.lang.Integer;
import java.util.HashMap;

public class Main {
    // driver function to test the above functions
    public static void main(String args[]) throws IOException {

        Reader.init(System.in);
        int n=  Reader.nextInt();
        int k = Reader.nextInt();

        if (k==n+1){
            System.out.println(1);
        }

        else {
            long[] arr =new long[n+1];
            long prev = 0;
            arr[0] = prev;
            for(int i=1; i<=n; i++){
                arr[i] = i+prev;
                prev=arr[i];
            }
            long ans =0;
            for (int i=k; i<=n; i++){
                long min = arr[i-1];
                long max = arr[n] - arr[n-i];

                ans = (ans+(max-min+1))%(1000000007);

            }
            System.out.println(ans+1);
        }

    }
}

class Node{
    char val;
    Node nxt = null;
    Node prev=null;


}



class solu{
    int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

}

/** Class for buffered reading int and double values */
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static String line() throws IOException {
        return reader.readLine();
    }
}

Measured memory_bytes: 34264
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

string s;

ll gogo(int n, string &k){
    if(n==0) {
        int now=0;
        for(int j=0;j<k.size();j++){
            if(now>=s.size()) break;
            if(k[j]==s[now]){
                now++;
            }
        }
        return now>=s.size();
    }
    ll ans=0;
    for(char i='a';i<='z';i++){
        k+=i;
        ans+=gogo(n-1, k);
        k.erase(k.end()-1);
    }
    return ans;
}


ll pwm(ll xx, ll pow, ll MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return mlt;
}

int inv(ll r, int _mod) {
    return pwm(r % _mod, _mod - 2, _mod);
}

vector<ll> fact;
vector<ll> invfact;

void factorial(int n, ll mod) {
    fact.resize(n);
    invfact.resize(n);
    fact[0] = 1;
    for (int i = 1; i < n; ++i) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
    invfact[n - 1] = inv(fact[n - 1], mod);
    for (int i = n - 2; i >= 0; i--) {
        invfact[i] = invfact[i + 1] * (i + 1);
        invfact[i] %= mod;
    }
}

int mod=1e9+7;
ll cnk(int k, int n){
    return ((fact[n]*invfact[n-k])%mod*invfact[k])%mod;
}
void solve() {
    factorial(2e6+1, mod);
    int n;
    cin>>n;
    cin>>s;
    int k=s.size();
    n+=s.size();
    vector<ll> degs(n+1);
    degs[0]=1;
    for(int i=1;i<n+1;i++){
        degs[i]=degs[i-1]*25;
        degs[i]%=mod;
    }
    ll ans=0;
    for(int i=0;i<k;i++){
        ans+=(cnk(i, n)*degs[n-i])%mod;
        ans%=mod;
    }
    ans=pwm(26, n, mod) -ans;
    ans=(ans%mod+mod)%mod;
    cout<<ans<<endl;
    //cout<<gogo(n, now);
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int &e: A) cin >> e;
  sort(A.begin(), A.end());
  
  int p = 200000000;
  for (int i = A[0]; i <= A[N-1]; i++) {
    int c = 0;
    for (int j = 0; j < N; j++) c += (A[j]-i)*(A[j]-i);
    p = min(p,c);
  }
  cout << p << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int M = 100100;
int x, k, r[M], q, ans[M];
struct Query {
	int t, a, id;
}qry[M * 2];

bool cmp(Query a, Query b) {
	return a.t < b.t;
}

int main() {
	scanf("%d%d", &x, &k);
	for(int i = 1; i <= k; i++) {
		scanf("%d", &qry[i].t);
		qry[i].id = 0;
	}
	scanf("%d", &q);
	for(int i = 1; i <= q; i++) {
		scanf("%d%d", &qry[i + k].t, &qry[i + k].a);
		qry[i + k].id = i;
	}
	sort(qry + 1, qry + q + k + 1, cmp);
	int j = 1;
	int a = 0, a_len = 1, b = x, cge = -1;
	for(int i = 1; i <= q + k; i++) {
		int cp = qry[i].t - qry[i - 1].t;
		if(cge == -1) {
			if(cp > a) {
				a_len += cp - a;
				a = 0;
				
			} else a -= cp;
			b -= cp;
			if(a_len > x + 1) a_len = x + 1;
			if(b < 0) b = 0, a_len = x + 1;
			if(a < 0) a = 0;
		} else {
			a += cp;
			b += cp;
			if(b > x) b = x;
			if(a > x) a = x, a_len = x + 1;
		}
		if(qry[i].id == 0) cge = -cge; 
		else {
			//
			if(qry[i].a < a_len) ans[qry[i].id] = a;
			else if(qry[i].a < a_len + b - a) ans[qry[i].id] = qry[i].a - a_len + a + 1;
			else ans[qry[i].id] = b;
		}//printf("%d %d %d\n", a, a_len, b);
	}
	for(int i = 1; i <= q; i++) printf("%d\n", ans[i]);
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> m(n,vector<int>(26));
    rep(i,n) {
        string s;
        cin >> s;
        for(char x : s) {
            int temp = x-'a';
            m[i][temp]++;
        }
    }
    string ans = "";
    rep(i,26){
        int c = 100;
        rep(j,n){
            c = min(c, m[j][i]);
        }
        if(c!=0){
            rep(k,c) ans.push_back('a'+i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>

using namespace std;

int main(void){
	char str[128];
	int A=0;
	int B=0;
	int O=0;
	int AB=0;
	while( scanf("%s", str) != EOF ){
		
		int n = strlen(str)-1;
		
		if(str[n-1] == 'A')AB++;
		else if(str[n] == 'A')A++;
		else if(str[n] == 'B')B++;
		else if(str[n] == 'O')O++;
		
	}
	printf("%d\n%d\n%d\n%d\n", A, B, AB, O);
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#define N 10
using namespace std;

vector<int> map[200000 + 1];
int memo[200000 + 1];

int dfs(int now) {
    memo[now] = 1;
    int res = 1;
    for (auto x: map[now]) {
        if (memo[x] == 0) {
            res += dfs(x);
        }
    }
    return res;
}

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    memset(memo, 0, sizeof(memo));
    int a, b;
    for (int i = 0; i < m; i ++) {
        cin >> a >> b;
        map[--a].push_back(--b);
        map[b].push_back(a);
    }
    int group = 0;
    for (int i = 0; i < n; i ++) {
        if (memo[i] == 0) {
            group = max(dfs(i), group);
        }
    }
    cout << group << endl;
    return 0;
}

Measured memory_bytes: 24580
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
  	int A,B;
  	if(a==2) A=3;
  	else if(a==4 || a==6 || a==9 || a==11) A=2;
  	else A=1;
  	if(b==2) B=3;
  	else if(b==4 || b==6 || b==9 || b==11) B=2;
  	else B=1;
  	if(A==B) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

const long long INF = 10000000000000000;

using namespace std;

int N,M;
vector<bool> used;
vector<vector<int> > edge;
vector<vector<int> > dist;

int dijkstra(int from, int to){
	int Max=(int)1e9;
	vector<int> d(N);
	vector<bool> check(N);
	for(int i=0;i<N;i++){
		d[i]=Max;
		check[i]=false;
	}
	d[from]=0;
	for(int i=0;i<N;i++){
		int now=0;
		int cdist=Max;
		for(int j=0;j<N;j++){
			if(cdist>d[j] && !check[j]){
				cdist=d[j];
				now=j;
			}
		}
		if(cdist==Max) break;
		check[now]=true;
		int tmp=-1;
		for(int j=0;j<edge[now].size();j++){
			int next=edge[now][j];
			int dnext=d[now]+dist[now][next];
			//cout<<next<<" "<<dnext<<" "<<d[next]<<endl;
			if(dnext<d[next]){
				d[next]=dnext;
			}
		}
	}

	return d[to];
}

int main(){


	cin>>N>>M;
	used.resize(N);
	edge.resize(N);
	for(int i=0;i<N;i++){
		used[i]=false;
	}
	vector<int> a(M),b(M),c(M);
	dist.resize(N);
	for(int i=0;i<N;i++){
		dist[i].resize(N);
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			dist[i][j]=(int)1e9;
		}
	}

	for(int i=0;i<M;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=0;i<M;i++){
		edge[a[i]-1].push_back(b[i]-1);
		edge[b[i]-1].push_back(a[i]-1);
		dist[a[i]-1][b[i]-1]=c[i];
		dist[b[i]-1][a[i]-1]=c[i];
	}
	//for(int i=0;i<N;i++){
	//	for(int j=0;j<edge[i].size();j++){
	//		cout<<edge[i][j]<<" ";
	//	}
	//	cout<<endl;
	//}
	//cout<<" "<<endl;
	//for(int i=0;i<N;i++){
	//	for(int j=0;j<N;j++){
	//		cout<<dist[i][j]<<" ";
	//	}
	//	cout<<endl;
	//}
	//cout<<" "<<endl;
	int ans=0;
	for(int i=0;i<M;i++){
			if(dijkstra(a[i]-1,b[i]-1)<c[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}



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


using namespace std;
long long MOD = 1000000007LL;

int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 1000; ++i) {
		int k = 0;
		char v[5] = { 0 };
		sprintf(v, "%03d", i);
		for (int j = 0; j < N; ++j) {
			if (s[j] == v[k]) {
				if (k == 2) {
					++count;
					break;
				}
				++k;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256