akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
s = [input() for x in range(H)]

for i in range(1, H-1):
    for j in range(1, W-1):
        if (s[i][j] == '#' and s[i][j-1] != '#' and s[i-1][j] != '#' and s[i][j+1] != '#' and s[i+1][j] != '#'):
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

typedef unsigned long long int ll;
using namespace std;

ll q, h, s, d, n;
ll ans = 0;

void dd(ll *n, ll *ans) {
    if (*n / 8) {
        *ans += (*n / 8) * d;
        *n -= (*n / 8) * 8;
    }
}

void ss(ll *n, ll *ans) {
    if (*n / 4) {
        *ans += (*n / 4) * s;
        *n -= (*n / 4) * 4;
    }
}

void hh(ll *n, ll *ans) {
    if (*n / 2) {
        *ans += (*n / 2) * h;
        *n -= (*n / 2) * 2;
    }
}

void qq(ll *n, ll *ans) {
    if (*n / 1) {
        *ans += (*n / 1) * q;
        *n -= (*n / 1) * 1;
    }
}

bool pairCompare(const std::pair<int, int> &firstElem,
                 const std::pair<float, int> &secondElem) {
    return firstElem.second < secondElem.second;
}

int main() {
    cin >> q >> h >> s >> d >> n;
    n *= 4;

    vector<pair<int, int> > qhsd{make_pair(q, q * 4), make_pair(h, h * 2),
                                 make_pair(s, s), make_pair(d, d / 2)};
    sort(qhsd.begin(), qhsd.end(), pairCompare);

    for (auto p : qhsd) {
        if (p.first == q && p.second == q * 4) {
            qq(&n, &ans);
        }
        if (p.first == h && p.second == h * 2) {
            hh(&n, &ans);
        }
        if (p.first == s && p.second == s) {
            ss(&n, &ans);
        }
        if (p.first == d && p.second == d / 2) {
            dd(&n, &ans);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a, b = (int(i) for i in input().split())
c, d = (int(i) for i in input().split())

if d == 1 and c == a+1:
  if a == 4 or 6 or 9 or 11 and b == 30:
    print ('1')
  elif a == 1 or 3 or 5 or 7 or 8 or 10 or 12 and b ==31:
    print ('1')
  elif a == 2 and b == 28:
    print ('1')
  else:
    print('0')
else:
  print('0')

Measured memory_bytes: 3064
// E - Bomber

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

set<pair<int, int>> hw;
unordered_map<int, int> cnt_h;
unordered_map<int, int> cnt_w;
unordered_set<int> max_h_set;
unordered_set<int> max_w_set;

int main() {
	int H, W, M;
	cin >> H >> W >> M;

	int max_cnt_h = 0;
	int max_cnt_w = 0;
	for (int i=0; i<M; i++) {
		int h, w;
		cin >> h >> w;

		hw.insert(make_pair(h, w));

		cnt_h[h]++;
		cnt_w[w]++;

		if (cnt_h[h] > max_cnt_h) {
			max_h_set.clear();
			max_h_set.insert(h);
			max_cnt_h = cnt_h[h];
		} else if (cnt_h[h] == max_cnt_h) {
			max_h_set.insert(h);
		}

		if (cnt_w[w] > max_cnt_w) {
			max_w_set.clear();
			max_w_set.insert(w);
			max_cnt_w = cnt_w[w];
		} else if (cnt_w[w] == max_cnt_w) {
			max_w_set.insert(w);
		}
	}

	bool no_common; // 交点に爆破対象がない場合があるかどうか
	if ((ll)max_h_set.size() * (ll)max_w_set.size() > M) {
		no_common = true;
	} else {
		no_common = false;
		for (int h : max_h_set) {
			for (int w : max_w_set) {
				if (hw.find(make_pair(h, w)) == hw.end()) {
					no_common = true;
				}
			}
		}
	}

	// **** debug ****
	/*
	if (no_common) cout << "no common exists" << endl;
	else cout << "all common" << endl;
	*/

	int ans;
	if (no_common) ans = max_cnt_h + max_cnt_w;
	else ans = max_cnt_h + max_cnt_w - 1;

	cout << ans << endl;

	return 0;
}

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

bool is_prime[10000001];

int main(){

	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<10000001;i++){
		is_prime[i]=true;
	}

	for(int i=2;i*i<10000001;i++){
		if(is_prime[i]){
			for(int j=i*i;j<10000001;j+=i){
				is_prime[j]=false;
			}
		}
	}

	while(true){
		int n;
		cin>>n;

		if(n==0)
			break;

		while(n>=13){
			if((is_prime[n]&is_prime[n-2])&(is_prime[n-6]&is_prime[n-8]))
				break;
			n--;
		}
		cout<<n<<endl;
	}
	return 0; 
}

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

int main(){
  int D, N;
  cin >> D >> N;
  
  if(D==0){
    if (N==100){
      cout << 101 << endl;
    }else{
    cout << N << endl;
    }
  }
  
  else if(D==1){
    if(N==100){
      cout << 10100 << endl;
    }else{
    cout << 100*N << endl;
    }
  }
  
  else if(D==2){
    if(N==100){
      cout << 1010000 << endl;
    }else{
    cout << 10000*N << endl;
    }
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqD = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var sum = seqD.Sum();
        sum *= sum;
        sum -= seqD.Sum(x => x * x);
        sum /= 2;
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13396
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin>>n;
	vector<int> a(n+1);
	map<int, int> o, e;
	for (int i=1; i<=n; ++i){
		 cin>>a[i];
		 if (i%2) o[a[i]]++;
		 else e[a[i]]++;
	 }
	int x, y, u, v, m = 0;
	for (auto i: o){
		if (i.second > m){
			x = i.first;
			m = i.second;
		}
	}
	o.erase(x);
	m = 0;
	for (auto i: o){
		if (i.second > m){
			y = i.first;
			m = i.second;
		}
	}
	m = 0;
	for (auto i: e){
		if (i.second > m){
			u = i.first;
			m = i.second;
		}
	}
	e.erase(u);
	m = 0;
	for (auto i: e){
		if (i.second > m){
			v = i.first;
			m = i.second;
		}
	}
	int p = 0, q = 0;
	if (x != u){
		for (int i=1; i<=n; ++i){
			if (i%2 != 0 && a[i] != x) p++;
			if (i%2 == 0 && a[i] != u) p++;
		}
		cout<<p;
	}else{
		p = 0;
		for (int i=1; i<=n; ++i){
			if (i%2 != 0 && a[i] != x) p++;
			if (i%2 != 0 && a[i] != y) q++;
			if (i%2 == 0 && a[i] != v) p++;
			if (i%2 == 0 && a[i] != u) q++;
		}
		cout<<min(p, q);
	}
	return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		a+= sc.next();
		a+= sc.next();

		int i = Integer.parseInt(a);

		if(i % 4 ==0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}



	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int peo = 1 - N%2;
  bool cando = true;
  for(int i = 0; i < N; i++){
    if(a[i] != peo) {
      cout << 0 << endl;
      return 0;
    }
    if((N%2) ^ (i%2)) peo += 2;
  }
  ll ans = 1;
  for(int i = 0; i < N/2; i++){
    ans *= 2;
    ans %= MOD;
  }
  cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

#define pi acos(-1.0)
#define mod 1000000007

///Library
#define mem(a,b) memset(a,b,sizeof(a))
#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sq(x) (x)*(x)


///vector
#define Lower_bound(vec,value) lower_bound(vec.begin(),vec.end(),value)
#define Upper_bound(vec,value) upper_bound(vec.begin(),vec.end(),value)


//template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
//template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }


int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    fast

    ll a,b,c;
    cin>>a>>b>>c;
    if((a==b && a!=c) || (b==c && b!=a) || (c==a && c!=b))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    
    FOR(i, 0, n){
        cin >> a[i];
        a[i] = a[i] -(i+1);
    }
    
    sort(a.begin(),a.end());
    
    ll b,b1,b2;
    ll ans=0;
    ll ans1=0,ans2=0;
    if(n%2!=0){
        b = a[n/2]; //中央値
        FOR(i, 0, n){
            ans += abs(a[i]-b);
        }
    }else{
        b1 = a[n/2];
        b2 = a[n/2-1];
        FOR(i, 0, n){
            ans1 += abs(a[i]-b1);
            ans2 += abs(a[i]-b2);
        }
        ans = min(ans1,ans2);
    }
    
    cout <<  ans <<  endl;
    
    return 0;
}



Measured memory_bytes: 1792
///cREATED bY BERNARB.01
#include<bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
    string s;
    int q;
    cin >> s >> q;
    bool bl = 0;
    vector<char>v1, v2;
    while(q--){
        int t;
        cin >> t;
        if(t==1) bl=!bl;
        else{
            int f;
            char c;
            cin >> f >> c;
            if(f==1){
                if(!bl) v1.push_back(c);
                else v2.push_back(c);
            }
            else{
                if(!bl) v2.push_back(c);
                else v1.push_back(c);
            }
        }
    }
    if(bl){
        for(int i=v2.size()-1; i>=0; i--) cout << v2[i];
        reverse(s.begin(), s.end());
        cout <<s;
        for(auto x: v1) cout << x;
    }else{
        for(int i=v1.size()-1; i>=0; i--) cout << v1[i];
        cout << s;
        for(auto x: v2) cout << x;
    }
    return 0;
}


Measured memory_bytes: 976
N, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

a.sort()
count = 0
cur = 0
for i in range(N):
    cur += a[i]
    if x < cur:
        break
    elif i == N - 1:
        if cur == x:
            count += 1
    else:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll mod=1e9+7;
const ll N=3005;
ll n,q,a[N],f[N][N],ans;
ll ksm(ll x,ll y){
	ll re=1;
	while(y){
		if(y&1)re=re*x%mod;
		x=x*x%mod;y>>=1;
	}return re;
}
signed main(){
	n=read(),q=read();
	for(ll i=1;i<=n;i++)a[i]=read();
	for(ll i=1;i<=n;i++)for(ll j=1;j<=n;j++)f[i][j]=(a[i]>a[j]);
	ll inv=ksm(2,mod-2),fac=ksm(2,q);
	for(;q--;){
		ll x=read(),y=read();
		f[x][y]=f[y][x]=(f[x][y]+f[y][x])%mod*inv%mod;
		for(ll i=1;i<=n;i++){
			if(i==x||i==y)continue;
			f[i][x]=f[i][y]=(f[i][x]+f[i][y])%mod*inv%mod;
			f[x][i]=f[y][i]=(f[x][i]+f[y][i])%mod*inv%mod;
		}
	}
	for(ll i=1;i<=n;i++)for(ll j=i+1;j<=n;j++)ans=(ans+f[i][j]*fac%mod)%mod;
	return cout<<ans,signed();
}

Measured memory_bytes: 73992
#include <iostream>
#include <vector>
using namespace std;
 
int main(int argc, char *argv[])
{
    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i) 
    {
        cin >> a[i] >> b[i];
    }
 
    long long num = 0;
    for(int i = n - 1; i >= 0; --i)
    {
        num += (b[i] - (a[i] + num) % b[i]) % b[i];
    }
    
    cout << num << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define MOD 1000000007

int N;
long long int ps[1123];
long long int ans = 1;

void d(int v) {
	int a = v, i, j, res = 1;
	for (j = 2; j <= v; ++j)
	{
		for (i = 0; a % j == 0; ++i) { a /= j; }
		ps[j - 1] += i;
	}
}

int main(void)
{
	scanf("%d", &N);

	for (int i = N; i >= 2; --i)
	{
		d(i);
	}
	for (int i = 0; i < N; ++i)
	{
		ans *= ps[i] + 1;
		ans %= MOD;
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int ll;

int main()
{
	int n;
	string s;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		cin >> s;
		sort(s.begin(), s.end());
		ll x = stoll(s);
		reverse(s.begin(), s.end());
		ll y = stoll(s);
		cout << y - x << endl;

	}
	return 0;
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD = 1000000007;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
struct Edge{
    int to,id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v,int c=-1,int p=-1){
    int k = 1;
    for(int i=0;i<g[v].size();i++){
        int u = g[v][i].to,ei = g[v][i].id;
        if(u == p) continue;
        if(c == k) k++;
        ans[ei] = k; k++;
        dfs(u,ans[ei],v);
    }
}

int main(){
    int N;
    cin >> N;
    g.resize(N);
    ans.resize(N);
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }    
    dfs(0);
    int mx = 0;
    for(int i=0;i<N-1;i++){
        mx = max(mx,int(g[i].size()));
    }
    cout << mx << endl;
    for(int i=0;i<N-1;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 8320
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
	public static void main(String[] args) throws Exception {
		int num;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] str = x.split(" "); 
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);
		System.out.println(a*b + " " + 2*(a+b));
	}
}


Measured memory_bytes: 24156
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int  n = sc.nextInt();
		if(n == 1){
			System.out.println(1);
			
		}else {
			int num = 2;
			while(num <= n) {
				num *= 2;
			}
			
			System.out.println(num/2);
		}
		sc.close();
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int n;
//int a[200005];
set<int> st;
set<int> stt;
multiset<int> ms;
void did(int x){
	for(int i=2;i*x<=1000005;i++){
		int tmp = i*x;
		if(st.find(tmp)!=st.end()){
			st.erase(tmp);
		}
	}
}
int main(){
	cin>>n;
	//for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		st.insert(x);
		stt.insert(x);
		ms.insert(x);
	}
	//for(int i:st) cout<<i<<endl;
	if(st.size()==1 and  n>1) {
		cout<<0<<endl;
		return 0;
	}
	if(n==1) {    // WA!!!
		cout<<1<<endl;
		return 0;
	}
	for(int i:st){
		did(i);
	}
	//for(int i:st) cout<<i<<endl;
	int ans = st.size();    // WA  !!!!
	for(int i:st){
		if(ms.count(i)>1) ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 31696
#include <bits/stdc++.h> 
#define MOD 1000000007
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
      #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    int n,k;
    cin >> n >> k;
    int d[k];
    int seen[n] = {0};
    int x;
    for(int i = 0; i < k ; i++){
        cin >> d[i];
        for (int j = 0; j< d[i]; j++){
            cin >> x;
            seen[x-1] = 1;        
        }
    }
    int count = 0;
    for (int i = 0; i < n; i++){
        if (seen[i]==0){
            /* code */count++;
        }
    }
    cout << count;
    
    cout<< endl;
}

Measured memory_bytes: 3656
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
ac=wa=0

for i in range(m):
	p,s=input().split()
	p=int(p)-1
	if s[0]=='A' and a[p]==0:
		a[p]=1
		ac+=1
		wa+=b[p]
	elif s[0]=='W':
		b[p]+=1
print(ac, wa)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<bool> AC(N+1, false);
    vector<int> WA(N+1,0);

    int ACnum = 0, WAnum = 0;
    for(int i = 0; i < M; i++){
        int p;
        string S;
        cin >> p >> S;
        if(AC.at(p) == true) continue;
        if(S == "AC"){
            AC.at(p) = true;
            ACnum++;
            WAnum += WA.at(p);
        }else{
            WA.at(p)++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
}

Measured memory_bytes: 3744
n = int(input())
w = list(map(int, input().split()))

if len(w) == 2:
    print(abs(w[0] - w[1]))
else:
    res = 10000000;
    for i in range(1, n):
        res = min(res, abs(sum(w[:i]) - sum(w[i:])))
    print(res)



Measured memory_bytes: 2940
n, p = map(int, input().split())
a = list(map(int, input().split()))

m = len([x for x in a if x & 1])

if m == 0:
  if p == 0:
    ans = 2 ** n
  else:
    ans = 0
else:
  ans = 2 ** (n - 1)

print(ans)

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

using namespace std;

const int N = (int)1e5 + 5;

int n,w[105],v[105],W;

long long dp[N];

int main(){
     cin >> n >> W;
     for(int i = 1; i <= n; i++){
     	cin >> w[i] >> v[i];
     }
     /// dp[i] -> the maximum total value of items with total weight exactly i
     for(int i = 1; i <= n; i++){
     	for(int j = W - w[i]; j >= 0; j--){
     		dp[j + w[i]] = max(dp[j + w[i]],dp[j] + v[i]);
     	}
     }
     long long ans = 0;
     for(int i = 0; i <= W; i++){
     	ans = max(ans,dp[i]);
     }
     cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    set<char> setS;
    for(auto c:S) setS.insert(c);

    string ans="-1";
    if(setS.size()<26){
        rep(i,0,27){
            char c='a'+i;
            if(setS.count(c)==0){
                ans=S+c; 
                break;
            }
        }
    }else{
        bool escape=false;
        _rep(i,S.size()-1,0){
            char c=S.at(i),right_c=S.at(i)+1;
            setS.erase(c);
            for(char candi=c+1;candi<='z';candi++){
                if(!setS.count(candi)){
                ans=S.substr(0,i)+candi;
                escape=true;
                break;
                }
            }
            if(escape) break;
        }
    }

    cout<<ans<<endl;
}

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

using namespace std;

template <typename T>
T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }

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

	Int ans = 0;
	for (Int a = 1; a <= K; ++a) {
		for (Int b = 1; b <= K; ++b) {
			for (Int c = 1; c <= K; ++c) {
				ans += gcd(gcd(a, b), c);
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3672
using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>

#define INT_MAX       2147483647
#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;

int mincostiter(vi& ht, int n, int k)
{
	vi dp(n + 1, 0);
	dp[2] = abs(ht[1] - ht[0]);
	for (int i = 3; i <= n; ++i) //for stones index
	{
		int minjump = INT_MAX;
		for (int j = 1; j <= k; ++j) //for k jumps
		{
			if (i - j >= 1) // can jump from 1st stone 
			{
				int currjump = dp[i - j] + abs(ht[i - 1] - ht[i - j - 1]);
				minjump = min(minjump, currjump);
			}
		}
		dp[i] = minjump;
	}
	return dp[n];
}
int main()
{
	int n, k;
	cin >> n >> k;
	vi ht(n);
	rep(n)
		cin >> ht[i];

	/*dp.resize(n, -1);
	auto ans = mincost(ht, n, 0, k);
	cout << ans;*/

	auto ans = mincostiter(ht, n, k);
	cout << ans;
	ret(0);
}


Measured memory_bytes: 1024
#include<stdio.h>
#include <stdlib.h>
#define Fi for (i = 0; i < 3; i++) 
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}
int main()
{
	int data[3];
	int i;
	Fi{
		scanf("%d",&data[i]);
	}
	qsort(data, 3, sizeof(int), compare_int);
//	Fi{
		printf("%d %d %d", data[0],data[1],data[2]);
//	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vin p(n),q(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];
    vin r(n);
    rep(i,n)r[i]=i+1;
    sort(all(r));
    int ansp,ansq;
    int j=1;
    int k=1;
    do{
        int i=0;
        bool can1=true;
        bool can2=true;
        for(int a:r){
            if(a!=p[i]){
                can1=false;
                break;
            }
            i++;
        }
        i=0;
        for(int a:r){
            if(a!=q[i]){
                can2=false;
                break;
            }
            i++;
        }
        if(can1){
            ansp=j;
        }
        if(can2){
            ansq=k;
        }
        if(can1&&can2)break;
        j++;
        k++;
    }while(next_permutation(all(r)));
    cout<<abs(ansp-ansq)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
	a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

#define N 200005
 
ll fact[N];
ll ifact[N];

ll ncr(ll n, ll r)
{
    if(r>n)
        return 0;
    ll ans = fact[n];
    ans*=ifact[r];
    ans%=mod;
    ans*=ifact[n-r];
    ans%=mod;
    return ans;
}
int main()
{
   FAST/**/
   
   fact[0] = 1;
   for(ll i=1;i<N;i++)
        fact[i] = fact[i-1]*i, fact[i]%=mod;
   for(ll i=0;i<N;i++)
        ifact[i] = powa(fact[i],mod-2,mod);
   
   ll n,k;
   cin>>n>>k;
   ll ans = 0;
   for(ll i=1;i<=n;i++)
   {
       if(k+i-n>=0)
       {
           ll temp = (ncr(n-1,i-1)*ncr(n,i))%mod;
           ans+=temp;
           ans%=mod;
       }
   }
    
   cout<<ans;
   
   return 0;        
}  
   

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

int main()
{
    string s;
    cin >> s;
    cout << s.at(0) << to_string(s.size() - 2) << s.at(s.size() - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n, m; cin >> n >> m;
    vector<string> a(n + 2, string(m + 2, ' '));
 
    for(int i = 1; i <= n; ++i) {
        string t; cin >> t;
        for(int j = 1; j <= m; ++j) a[i][j] = t[j-1];
    }

    for(int r = 1; r <= n; ++r)
        for(int c = 1; c <= m; ++c)
            if (a[r][c] == '.'){
                int x = 0;
                for(int i = -1; i < 2; ++i)
                    for(int j = -1; j < 2; ++j)
                        if (i | j)
                            x += a[r + i][c + j] == '#';
                a[r][c] = '0' + x;
            }

    for(int i = 1; i <= n; ++i)
        cout << a[i].substr(1, m) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int n;cin>>n;
    rep(i,1,3501){
        rep(j,1,3501){
            int d,e,f;
            d=4*i*j;e=j*n;f=i*n;
            if(d<=e+f)continue;
            else if((n*i*j)%(d-e-f)==0){
                cout<<i<<" "<<j<<" "<<(n*i*j)/(d-e-f)<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int, int>
#define fir first
#define sec second
using namespace std;
priority_queue<pii>pq;
int main()
{
    int n; scanf("%d", &n);
    for (int i = 1, x, L, st, ed; i <= n; i++)
    {
        scanf("%d%d", &x, &L);
        st = x - L; ed = x + L;
        pq.push({-ed, st});
    } 
    int now = -1e9, ans = 0;
    for (int i = 1; i <= n; i++)
    {
        while (pq.size() && now > pq.top().sec) pq.pop();
        if (pq.size()) {now = -pq.top().fir; ans++; pq.pop();}
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1400
from math import factorial
from Queue import PriorityQueue

FACTORIAL=[factorial(i) for i in xrange(13)]
LEFT,UP,RIGHT,DOWN=0,1,2,3
MOVE=[[0] for u in xrange(13)]
MOVE[0] =[-1,-1,-1, 2]
MOVE[1] =[-1,-1, 2, 5]
MOVE[2] =[ 1, 0, 3, 6]
MOVE[3] =[ 2,-1,-1, 7] 
MOVE[4] =[-1,-1, 5,-1]
MOVE[5] =[ 4, 1, 6, 9]
MOVE[6] =[ 5, 2, 7,10]
MOVE[7] =[ 6, 3, 8,11]
MOVE[8] =[ 7,-1,-1,-1]
MOVE[9] =[-1, 5,10,-1]
MOVE[10]=[ 9, 6,11,12]
MOVE[11]=[10, 7,-1,-1]
MOVE[12]=[-1,10,-1,-1]

def hash(cell):
    work = cell[:]
    hash = 0
    for i in xrange(12):
        hash += work[i] * FACTORIAL[13-1-i]
        for ii in xrange(i+1,13):
            if work[ii]>work[i]:
                work[ii]-=1
    return hash

def dehash(key):
    cell=[]
    for i in xrange(13):
        cell.append(key/FACTORIAL[13-1-i])
        key %= FACTORIAL[13-1-i]
    for i in xrange(13-1,-1,-1):
        for ii in xrange(i+1,13):
            if cell[i]<=cell[ii]:
                cell[ii]+=1
    return cell

def evaluate(cell):
    point=[[0,2],
           [1,1],[1,2],[1,3],
           [2,0],[2,1],[2,2],[2,3],[2,4],
           [3,1],[3,2],[3,3],
           [4,2]]
    eva=0
    for i in xrange(0,13):
        if not (cell[i]==0 or cell[i]==12):
            eva+=abs(point[cell[i]][0]-point[i][0])
            eva+=abs(point[cell[i]][1]-point[i][1])
    return eva

ANS_HASH=[hash([0,1,2,3,4,5,6,7,8,9,10,11,12]),hash([12,1,2,3,4,5,6,7,8,9,10,11,0])]          

while True:
    p=[input()]
    if p==[-1]:
        break
    for u in xrange(4):
        for pp in map(int,raw_input().split()):
            p.append(pp)
    p[p.index(0)]=12
    pq = PriorityQueue()
    pq.put([evaluate(p),hash(p),0])
    visited={}
    visited[hash(p)]=True
    ans=0 if hash(p) in ANS_HASH else "NA"
    #cur=[eva,hashkey,step]
    while not pq.empty():
        eva,cur_hash,cur_step=pq.get()
        cur_cell=dehash(cur_hash)
        if not (eva<=20 and ans=="NA"):
            break
        for i in xrange(13):
            if cur_cell[i]==0 or cur_cell[i]==12:
                for ii in [LEFT,UP,RIGHT,DOWN]:
                    if not MOVE[i][ii]==-1:
                        cur_cell[i],cur_cell[MOVE[i][ii]]=cur_cell[MOVE[i][ii]],cur_cell[i]
                        hashkey=hash(cur_cell)
                        if not hashkey in visited:
                            if hashkey in ANS_HASH:
                                ans=cur_step+1
                                break
                            pq.put([evaluate(cur_cell)+cur_step+1,hashkey,cur_step+1])
                            visited[hashkey]=True
                        cur_cell[i],cur_cell[MOVE[i][ii]]=cur_cell[MOVE[i][ii]],cur_cell[i]
    print ans

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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;


int N,K,Q;

vector<unordered_map<int, LL>> E;
vL dis;

void init(){
	dis = vL(N,-1);
	queue<pLL> que;
	que.push(pLL(K,(LL)0));
	dis[K] = 0;
	while(!que.empty()){
		auto p = que.front();
		que.pop();
		LL j = p.first, L = p.second;
		for(auto pr:E[j]) if(dis[pr.first]==-1){
			dis[pr.first] = L + pr.second;
			que.push(pLL((LL)pr.first, L + pr.second));
		}
	}
	return;
}

int main(){
	cin>>N;
	E.resize(N);
	for(int i=0;i<N-1;++i){
		int a,b,c;
		cin>>a>>b>>c;
		E[a-1][b-1] = (LL)c;
		E[b-1][a-1] = (LL)c;
	}
	cin>>Q>>K;
	--K;
	init();
	for(int q=0;q<Q;++q){
		int x,y;
		cin>>x>>y;
		cout<< dis[x-1] + dis[y-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 18944
import bisect

n = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for a in range(n - 1):
    for b in range(a + 1, n):
        r = bisect.bisect_left(L, L[a] + L[b])
        l = b + 1
        cnt += r - l
print(cnt)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1 + a2 + a3;
    if (sum > 21) {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;

			int[][] num = new int[n][3];
			int size = 0;
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int c = scanner.nextInt();
				num[i][0] = a;
				num[i][1] = b;
				num[i][2] = c;
				size = Math.max(size, Math.max(a, b));
			}
			size++;
			int[][] cost = new int[size][size];
			for (int[] t : cost)
				Arrays.fill(t, 1 << 24);
			for (int i = 0; i < n; i++) {
				int a = num[i][0];
				int b = num[i][1];
				int c = num[i][2];
				cost[a][b] = c;
				cost[b][a] = c;

			}
			for (int i = 0; i < size; i++) {
				cost[i][i] = 0;

			}
			for (int i = 0; i < size; i++) {
				for (int j = 0; j < size; j++) {
					if(i==j)
						continue;
					for (int k = j + 1; k < size; k++) {
						cost[j][k] = Math.min(cost[j][k], cost[i][j]
								+ cost[i][k]);
						cost[k][j] = cost[j][k];

					}
				}
			}
			int ans = 0;
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < size; i++) {
				int sum = 0;
				for (int j = 0; j < size; j++) {
					sum += cost[i][j];
				}
				if (sum < min) {
					min = sum;
					ans = i;
				}
			}
			System.out.println(ans + " " + min);
		}

	}

	private void slove(int x, int[][] cost) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		for (int i = 0; i < cost.length; i++) {
			if (cost[i][x] != 1 << 24) {
				deque.offer(i);
			}
		}
		cost[x][x] = 0;
		while (!deque.isEmpty()) {
			int pri = deque.poll();
			for (int i = 0; i < cost.length; i++) {
				if (pri == i)
					continue;
				if (cost[pri][i] != 1 << 24
						&& cost[x][i] > cost[pri][i] + cost[x][pri]) {
					cost[x][i] = cost[pri][i] + cost[x][pri];
					cost[i][x] = cost[pri][i] + cost[x][pri];
					if (!deque.contains(i))
						deque.offer(i);
				}
			}
		}

	}
}

Measured memory_bytes: 19508
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
}

int gcd(int x, int y) {
    int tmp;
    if(x > y)
        return gcd(y, x);
    int r;
    while((r = x % y)) {
        x = y;
        y = r;
    }
    return y;
}

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

int main() {
    int N, co = 0;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    bool flag = 1;
    while(flag) {
        flag = 0;
        for(int j = N - 1; j > 0; j--) {
            if(A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                co++;
                flag = 1;
            }
        }
    }
    vecout(A);
    cout << co << endl;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std; 
#define int long long int 
map<int,list<int>> m ;
int dp[1000001][2]; 
#define mod 1000000007 

int fn(int u,int color, int pr )
{


	if(dp[u][color] !=-1)
	{
		return dp[u][color] ; 
	}

	int ans1=1;
	int ans2 =1; 
	int ans3=1 ; 
	int ans=0 ; 

	if(color==0)
	{
		for(auto i : m[u])
		{
			if(i!=pr)
			{
				ans1=(ans1*fn(i,0,u))%mod; 
				ans2=(ans2*fn(i,1,u))%mod; 
			}
		}
		ans= (ans+ans2+ans1)%mod ; 
	}
	else
	{
		for(auto i : m[u])
		{
			if(i!=pr)
			ans3=(ans3*fn(i,0,u))%mod; 
		}

		ans= (ans+ans3)%mod ; 
	}

	return dp[u][color]=  ans%mod ; 

}




int32_t main()
{

	int n ; 
	cin>>n; 
	for(int i = 0; i < n-1; i++)
	{
		int x,y; 
		cin>>x>>y ; 
		m[x].push_back(y) ;
		m[y].push_back(x) ; 
	}
	memset(dp, -1, sizeof(dp)) ; 


	int h= fn(1, 0, -1) ; 

	cout<<h ; 

}

Measured memory_bytes: 44340
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    a.push_back(a[0]+k);
    int l=0;
    for(int i=0; i<n; i++){
        l = max(l,a[i+1]-a[i]);
    }
    int ans;
    ans = k-l;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  float T, X;
  cin >> T >> X;

  cout << T / X << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

const int MAX = 2000005;
               
            
//---------------------------------------------------------------------------------------------------
LL f[MAX];
void init() 
{
    f[0] = 1;
    for(int i = 1; i < MAX; ++i) f[i] = (f[i - 1] * i) % MOD;
}

//---------------------------------------------------------------------------------------------------
LL inv(LL x) 
{
    LL res = 1;
    LL k = MOD - 2;
    LL y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
LL comb(int n, int k) 
{
    LL a = f[n]; // = n!
    LL b = f[n-k]; // = (n-k)!
    LL c = f[k]; // = k!

    LL bc = (b * c) % MOD;

    return (a * inv(bc)) % MOD;
}


class Mint {
public:
  typedef long long val_type;

  Mint(val_type x=0, int m=MOD) : val((x%m+m)%m), mod(m) {}
  val_type value() const { return val; }
  Mint& operator+=(const Mint a) {
    if ((val += a.val) >= mod) val -= mod;
    return *this;
  }
  Mint& operator-=(const Mint a) {
    if ((val += mod-a.val) >= mod) val -= mod;
    return *this;
  }
  Mint& operator*=(const Mint a) {
    (val *= a.val) %= mod;
    return *this;
  }
  Mint operator+(const Mint a) const {
    Mint res(*this);
    return res+=a;
  }
  Mint operator-(const Mint a) const {
    Mint res(*this);
    return res-=a;
  }
  Mint operator*(const Mint a) const {
    Mint res(*this);
    return res*=a;
  }
  Mint pow(val_type t) const {
    if (!t) return 1;
    Mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

private:
  val_type val;
  int mod;
};


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

    init();

    string S;
    int N, K;
    cin >> K >> S;
    N = S.length();

    Mint ans(0);
    for (int x = 0; x <= K; ++x) {

        ans += Mint(comb(N+K-x-1, N-1)) * Mint(25).pow(K-x) * Mint(26).pow(x);
    }
    cout << ans.value() << endl;

    return 0;
}


Measured memory_bytes: 19832
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

typedef unsigned long long int ull;
typedef long long int ll;

using namespace std;

int main(void) {
    int a,b;
    cin >> a >> b;
    if(a * b % 2 == 0)cout << "Even" << endl;
    else cout << "Odd" << endl;
}


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

class Height {
    public:
        Height(int n,int p) : num{n}, h{p} {}
        int number() const { return num; }
        int takasa() const { return h; }
        void setHeight(int n,int p) { num = n; h = p; return; }
    private:
        int num;
        int h;
};

bool compare(const Height& Elem1, const Height& Elem2)
{
    return Elem1.takasa() < Elem2.takasa();
}

int main()
{
    int n,t,a,h;
    vector<Height> hyoukou;
    vector<double> tH;
    Height temp(0,0);
    

    cin >> n;
    cin >> t >> a;
    for(auto i=0; i<n; i++)
    {
        cin >> h;
        temp.setHeight(i+1,h);
        hyoukou.push_back(temp);
    }
    stable_sort(hyoukou.begin(),hyoukou.end(),compare);
    for (auto i=0; i<n; i++)
    {
        tH.push_back( t - hyoukou[i].takasa()*0.006 );
    }
    for (auto i=0; i<n; i++)
    {
        if (i == 0 && tH[i] < a)
        {
            cout << hyoukou[i].number() << endl;
            break;
        }
        else if ((tH[i] + tH[i+1]) / 2.0 < a && a <= tH[i])
        {
            cout << hyoukou[i].number() << endl;
            break;
        }
        else if (tH[i+1] <= a && a < (tH[i] + tH[i+1]) / 2.0)
        {
            cout << hyoukou[i+1].number() << endl;
            break;
        }
        else if (i == n-1 && a < tH[i])
        {
            cout << hyoukou[i].number() << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {

  int H, W;
  while(cin >> H >> W && (H|W)) {
    int a[W]; memset(a, 0, sizeof a);
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++) {
        int b; cin >> b;
        a[j] |= (b << i);
      }
    
    int ans = 0;
    for(int i=0; i<(1<<H); i++) {
      int tmp = 0;
      for(int j=0; j<W; j++) {
        int t1 = 0, t2 = 0;
        for(int k=0; k<H; k++) {
          t1 += (a[j] >> k & 1) ^ (i >> k & 1);
        }
        for(int k=0; k<H; k++) {
          t2 += (a[j] >> k & 1) ^ (!(i >> k & 1));
        }
        tmp += max(t1, t2);
      }
      ans = max(ans, tmp);
    }
    
    cout << ans << endl;
    
  }
  
  return 0;
}

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

int main(){
	double n;
	int k = 0;
	int out[1000];
	while(cin >> n){
		double v, t;
		for(int i = 1; i < 1000; i++){	
			t = sqrt((5*i-5)/4.9);
			v = 9.8*t;
			if(v >= n){
				out[k] = i;
				break;
			}
		}
		k++;
	}
	for(int i = 0; i < k; i++){
		cout << out[i] << endl;
	}
}

Measured memory_bytes: 1236
#include <stdio.h>
#include<string.h>
char exchange(char c) {
	if('A' <= c && c <= 'Z') {
    	return c + ('a' - 'A');
	}
  /* 同様に c が小文字なら大文字に変換する条件を追加 */
	else if ('a' <= c && c <= 'z') {
		return c - ('a' - 'A');
	}
	return c;
}

int main(void) 
{
	int i, len;
	char s[4096];  /* 1200バイト以上 */
  // scanf("%s", s) は セキュリティ上よろしくない
	fgets(s, sizeof(s), stdin);
	len = strlen(s);   // 文字列の長さをえる
	for(int i = 0; i < len;i++) {
    	s[i] = exchange(s[i]);
	}
	printf("%s",s);
	return 0;
}



Measured memory_bytes: 2144
/*input

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define pb push_back
#define print(a) cout<<a<<endl
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define all(x) x.begin(), x.end()
#define loop(i,n) for(int i = 0; i < n; i++)
//#define int long long int
 
const int MOD = 1e9 + 7;

int fastexpo(int x, int y) 
{ 
    int res = 1;
    x = x % MOD;
    while (y) 
    { 
        if (y & 1) res = (res*x) % MOD; 
        y = y>>1;
        x = (x*x) % MOD;   
    } 
    return res; 
}

int mod(int x, int y){
    return (x%y + y)%y;
}

void solve();

signed main(){
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

const int MAXN = 1e5 + 10;

vector<int> graph[MAXN];
bool vis[MAXN];

void dfs(int node){
    if(vis[node])
        return;
    vis[node] = true;
    for(auto u : graph[node])
        dfs(u);
}

void solve(){
    mem(vis, 0);
    int n, m;
    cin>> n >> m;
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin>> u >> v >> w;
        graph[u].append(v);
        graph[v].append(u);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            ans++;
            dfs(i);
        }
    }
    print(ans);
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> v, c;
    int sum=0;
    for (int i = 0; i < N; i++)
    {
        int v_;
        cin >> v_;
        v.push_back(v_);
    }
    for (int i = 0; i < N; i++)
    {
        int c_;
        cin >> c_;
        c.push_back(c_);
    }
    for (int i = 0; i < v.size();i++){
        int x_y = v[i] - c[i];
        //cout << v[i] << " " << c[i] << " " << x_y << endl;
        if (x_y > 0)
            sum += x_y;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
using namespace std;

#define N 3

char s[N];

int main()
{
	cin >> s;

	int v = 0;
	for( int i = 0; i < N; i++ ) {
		if( s[i] == 'o' ) {
			v += 100;
		}
	}

	cout << v + 700 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 150
#define MAXM
#define MOD
#define INF (1<<25)
#define eps (1e-6)
#define all(name, p, it) for(name :: iterator (it) = (p).begin(); (it) != (p).end(); ++(it))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair <int, int> pii;
typedef pair <LL, int> pli;
typedef pair <int, LL> pil;
typedef pair <LL, LL> pll;
int n, a[MAXN], ind;
set <double> s;
double x;
double Abs(double x) {
	return x > 0 ? x : -x;
}
int main() {
	scanf("%d", &n);
	for(ri i = 0; i < n; ++i) scanf("%d", &a[i]), x += a[i];
	x /= n;
	ind = 0;
	for(ri i = 1; i < n; ++i) if(Abs(a[ind]-x) > Abs(a[i]-x)) ind = i;
	cout<<ind<<endl;
	return 0;
}

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

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

	int tmp = 0;
	int maxIndex;
	vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; 		
		if (tmp < a[i]) {
			tmp = a[i];
			maxIndex = i;
		}	
	}

	tmp = 0;
	int secondMaxIndex;
	for (int i = 0; i < n; i++) {
		if (i == maxIndex) continue;
		if (tmp < a[i]) {
				tmp = a[i];
				secondMaxIndex = i;
		}
	}
	
	for (int i = 0; i < n; i++) {

		if (i == maxIndex) {
			cout << a[secondMaxIndex] << endl;
		}
		else { // i != maxIndex
			cout << a[maxIndex] << endl;
		}	

	}

	return 0;
}

Measured memory_bytes: 2432
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    String[] s=  br.readLine().split(" ");
    int r = Integer.parseInt(s[0]);
    int g = Integer.parseInt(s[1]);
    int b = Integer.parseInt(s[2]);
    int val = 100*r + 10*g + b;
    if (val%4==0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21460