akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  vector<queue<int>>ca(N);
  for (int i = 0; i < M; i ++) {
    int a, b;
    cin >> a >> b;
    a --;
    b --;
    ca[a].push(b);
    ca[b].push(a);
  }
  vector<bool>vis(N, false);
  queue<int>que;
  que.push(0);
  vector<int>ans(N, -1);
  while(!que.empty()) {
    int u = que.front();
    //cout << u << "  ";
    que.pop();
    vis[u] = true;
    int n = ca[u].size();
    for (int i = 0; i < n; i ++) {
      int v = ca[u].front();
     // cout << v << ' ';
      ca[u].pop();
      //ca[u].push(v);
      if (vis[v]) continue;
      if (ans[v] == -1) ans[v] = u;
      que.push(v);
    }
    //cout << endl;
  }
  cout << "Yes" << endl;
  for (int i = 1; i < N; i ++) cout << ans[i] + 1 << endl;
}



Measured memory_bytes: 71360
require 'prime'
require 'set'
a, b = gets.split.map(&:to_i)

mods_a = Set.new
mods_b = Set.new

2.upto( Math.sqrt(a) ) do |i|
  if a % i == 0
    mods_a.add(i)
    a = a / i while a % i == 0
  end
  if b % i == 0
    mods_b.add(i)
    b = b / i while b % i == 0
  end
end
mods_a.add(a) if a.prime?
mods_b.add(b) if b.prime?

puts (mods_a & mods_b).size + 1

Measured memory_bytes: 2300
#include<iostream>
using namespace std;
int main(){
  int n,n2,in[4],in2[4],hit,blow,d;
  while(cin>>n>>n2){
    if(n==0&&n2==0) break;
    d = 1000;
    //cout << n << " " << n2 << endl;
     for(int i=0;i<4;i++){
      in[i] = n / d;
      in2[i] = n2 / d;
      n -= in[i] * d;
      n2 -= in2[i] * d;
      d /= 10;
      //cout << in[i] << endl << in2[i] << endl;  
    } 
    hit = 0;
    blow = 0;    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
      if(in[i]==in2[j]&&i==j) hit++;
      else if(in[i]==in2[j]) blow++;
      }
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
l[4],r[4],i;main(){float a,b;for(;~scanf("%f%f",&a,&b);l[a<0.2?3:a<0.6?2:a<1.1?1:0]++,r[b<0.2?3:b<0.6?2:b<1.1?1:0]++);for(;i<4;printf("%d %d\n",l[i],r[i]),i++);exit(0);}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll m = 0;
    vector<ll> s(n);
    vector<ll> t;
    ll ans = 0;
    for(i = 0;i < n;++i){
        cin >> s.at(i);
        ans += s.at(i);
        if(s.at(i)%10 == 0) ++m;
        else t.push_back(s.at(i));
    }
    if(ans%10){
        cout << ans << endl;
        return 0;
    }else if(m == n){
        cout << 0 << endl;
        return 0;
    }else{
        sort(all(t));
        cout << ans - t.front() << endl;
    }


    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi 2*acos(0.0)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int a, b;
		cin >> a >> b;
		cout << max(a-2*b,0ll);
	
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int r;
  cin >> r;
  double ans = acos(-1)*r*2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3748
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

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

    char **a = (char**)malloc(H * sizeof(char*));
    int *h = (int*)malloc(H * sizeof(int));
    int i, j;
    for(i=0; i<H; i++) {
        a[i] = (char*)malloc(W * sizeof(char));
        h[i] = 0;
    }

    for(i=0; i<H; i++) {
            scanf("%s", a[i]);
    }

    for(i=0; i<H; i++) {
        int sum = 0;
        for(j=0; j<W; j++) {
            if(a[i][j] == '.') {
                sum++;
            }
        }
        if(sum == W) {
            for(j=0; j<W; j++) {
                a[i][j] = '-';
            }
            h[i] = 1;
        }
    }
    
    for(i=0; i<W; i++) {
        int sum = 0;
        for(j=0; j<H; j++) {
            if(a[j][i] == '.' || a[j][i] == '-') {
                sum++;
            }
        }
        if(sum == H) {
            for(j=0; j<H; j++) {
                a[j][i] = '-';
            }
        }
    }
    
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++) {
            if(a[i][j] != '-') {
                printf("%c", a[i][j]);
            }
        }
        if(h[i] == 0) {
            printf("\n");
        }
    }

    for(i=0; i<H; i++) {
        free(a[i]);
    }

    
    free(a);
    free(h);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int a,b,c,d;
  auto mlcm=[](Int p,Int q){return p/__gcd(p,q)*q;};

  auto calc=
    [&](Int x){
      Int p=x/c;
      Int q=x/d;
      Int r=x/mlcm(c,d);
      return x-p-q+r;
    };

  cin>>a>>b>>c>>d;
  cout<<calc(b)-calc(a-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
char S[15];
int len;
ll ans=0;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%s",S+1);
	len=strlen(S+1);
	int s=1<<len;
	for(int t=0;t<=s-1;t++) {
		ll tmp=0;
		for(int i=0;i<len;i++) {
			if((1<<i)&t) {
				ans+=tmp;
				tmp=S[i+1]-'0';
			} else tmp=tmp*10+S[i+1]-'0';
		}
		ans+=tmp;
	}
	printf("%lld\n",ans/2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll now=INF;
    ll money=1000;
    rep(i,n){
        if(now>=a[i]) now=a[i];
        else{
            money=(money/now)*a[i]+money-(money/now)*now;
            now=a[i];
        }
    }

    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
const int N=2e6+20;
const ll inf=2e15;
ll n,m,num;
map<ll,ll> mp[N];
vector<ii> e[N];
ll inq[N],d[N];
queue<int> q;
int getid(int u,int c)
{
	if(mp[u][c]==0)
		mp[u][c]=++num;
	return mp[u][c];
}
void SPFA(int s,int t)
{
	for(int i=1;i<=num;i++)
		d[i]=inf,inq[i]=0;
	q.push(s);
	d[s]=0,inq[s]=1;
	while(!q.empty())
	{
		int u=q.front();
		q.pop(),inq[u]=0;
		for(int i=0;i<e[u].size();i++)
		{
			int v=e[u][i].first,w=e[u][i].second;
			if(d[v]>d[u]+w)
			{
				d[v]=d[u]+w;
				if(!inq[v])
					inq[v]=1,q.push(v);
			}
		}
	}
	printf("%lld\n",d[t]>=inf?-1:d[t]/2);
}
int main()
{
	while(cin>>n>>m)
	{
		for(int i=0;i<=n;i++)
			e[i].clear();
		int u,v,c;
		num=n;
		while(m--)
		{
			scanf("%d%d%d",&u,&v,&c);
			int uc=getid(u,c);
			int vc=getid(v,c);
			e[u].push_back(ii(uc,1));
			e[uc].push_back(ii(u,1));
			e[v].push_back(ii(vc,1));
			e[vc].push_back(ii(v,1));
			
			e[uc].push_back(ii(vc,0));
			e[vc].push_back(ii(uc,0));		
		}
		SPFA(1,n);
		
		for(int i=0;i<=num;i++)
			mp[i].clear();
	}
	return 0;
}


Measured memory_bytes: 205696
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;

int gcd( int a, int b ){
int temp;
if( a < b ) { temp = a; a = b; b = temp; }
if( b < 1 ) return -1;
if( a % b == 0 ) return b;
return gcd( b, a % b );}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    REP(i,n){
        cin>>a[i];
    }
    int ans = gcd(a[0],a[1]);
    FOR(i,2,n){
        ans = gcd(ans,a[i]);
    }
    print(ans);
    return 0;
}

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

using namespace std;
int N, A[1000001];
map<int, int> COUNT;
bool is_prime[1001];
vector<int> B[1000001];

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int> primes;
    fill(is_prime, is_prime + 1001, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 0; i <= 1000; i++) {
        if (is_prime[i]) {
            primes.push_back(i);
            int k = 2;
            while (i * k <= 1000) {
                is_prime[i * k] = false;
                k++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        int k = A[i];
        for (int p : primes) {
            if (k % p == 0){
                B[i].push_back(p);
                COUNT[p]++;
                while (k > 1 && k % p == 0) k /= p;
            }
        }
        if (k != 1){
            B[i].push_back(k);
            COUNT[k]++;
        }
    }


    bool pairwise = true, setwise = true;
    for (auto k : COUNT) {
        if (k.second == N) setwise = false;
        if (k.second != 1) pairwise = false;
    }

    if (pairwise) cout << "pairwise coprime" << '\n';
    else if (setwise) cout << "setwise coprime" << '\n';
    else cout << "not coprime" << '\n';
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

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

	ll r=1;
	int n[2];
	cin >> n[0] >> n[1];
	for (int i=0;i<2;i++) {
		ll f=0;
		for (int j=0;j<n[i];j++) {
			ll x;
			cin >> x;
			f=(f+x*(j-(n[i]-1-j)))%mod;
		}
		r=r*f%mod;
	}
	if (r<0) r+=mod;
	cout << r << endl;
}

Measured memory_bytes: 256
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null, null);

    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null, null);
      while (x != null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      newNode.parent = y;
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  printByPreorder(n = this.root) {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.map((line) => line.split(' ')).forEach(function(cmd) {
    switch(cmd[0].charAt(0)) {
    case 'i': tree.insert(Number(cmd[1])); break;
    default: tree.print();
    }
  });

})();



Measured memory_bytes: 269032
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	long long a,b,c,s;
	scanf("%lld %lld %lld",&a,&b,&c);
	s=a/(b+c)*b;
	if(a%(b+c)>b){
		s+=b;
	}
	else{
		s+=a%(b+c);
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 1712
n, k = map(int, input().split())
s = input()
if s[k-1] == 'A':
  print(s[:k-1] + 'a' + s[k:])
elif s[k-1] == 'B':
  print(s[:k-1] + 'b' + s[k:])
else:
  print(s[:k-1] + 'c' + s[k:])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll n;

int main(){
	cin >> n;
	vector<ll> vl(n,0);
	rep(i,n)cin >> vl[i];
	sort(ALL(vl));
	ll ans = vl.back()/2;
	rep(i,n-1)ans += vl[i];
	cout << ans << endl;
}

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

const int p = 70;
int A[1000009], B[1000009];

int f(int x) {
	return max(x, -x);
}

int main() {
	int N; scanf("%d", &N);
	for(int i=1; i<=N; i++) scanf("%1d", &A[i]);
	for(int i=1; i<=min(p, N-1); i++) {
		for(int j=1; j<=N-i; j++) A[j] = f(A[j] - A[j+1]);
	}
	if(N <= p+1) printf("%d", A[1]);
	else {
		N -= p;
		for(int i=1; i<=N; i++) B[i] = A[i];
		sort(B+1, B+N+1);
		if(B[N] == B[1]) puts("0");
		else if(B[N] == 2) {
			int c = 0;
			for(int i=1; i<=N; i++) if(A[i] == 2) {
				if(((N-i) & (i-1)) == 0) c ^= 1;
			}
			if(c) puts("2");
			else puts("0");
		}
		else {
			int c = 0;
			for(int i=1; i<=N; i++) if(A[i] == 1) {
				if(((N-i) & (i-1)) == 0) c ^= 1;
			}
			if(c) puts("1");
			else puts("0");
		}
	}
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int x,y,z;
	cin>>x>>y>>z;
	x-=z;
	y+=z;
	cout<<x/y<<endl; 

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n;
    string s;
    cin >> n >> s;
    i64 r = count(begin(s), end(s), 'R');
    i64 g = count(begin(s), end(s), 'G');
    i64 b = count(begin(s), end(s), 'B');
    i64 ans = r * g * b;
    for (i64 d = 1; d <= n; ++d) {
        for (i64 i = 0; i + 2 * d < n; ++i) {
            int j = i + d, k = i + 2 * d;
            if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) --ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import scala.io.StdIn._

object Main extends App {

  val Array(n,la,lb,lc) = readLine().split(" ").map(_.toInt)
  val l = Array.fill(n)(readInt())

  def solve() = {
    dfs(0,0,0,0)
  }

  def dfs(depth: Int, a: Int, b: Int, c: Int): Int = {
    if(depth == n) {
      if(a == 0 || b == 0 || c == 0) return 1e9.toInt
      else return (la - a).abs + (lb - b).abs + (lc - c).abs - 30
    }
    val ret0 = dfs(depth+1, a, b, c)
    val ret1 = dfs(depth+1, a +l(depth), b, c) + 10
    val ret2 = dfs(depth+1, a, b +l(depth), c) + 10
    val ret3 = dfs(depth+1, a, b, c +l(depth)) + 10
    Seq(ret0, ret1, ret2, ret3).min
  }

  println(solve())

}



Measured memory_bytes: 60376
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int bi[64];ll a,b,p2[64],ans;
ll calc(ll x,int y){
	ll num=x/(p2[y]*2),ev=x%(p2[y]*2)+1;
	return num*p2[y]+max(ev-p2[y],0ll);
}
int main()
{
	scanf("%lld%lld",&a,&b);
	p2[0]=1;
	for(int i=1;i<50;i++) p2[i]=p2[i-1]*2;
	for(int i=0;i<50;i++) bi[i]=(calc(b,i)-calc(a-1,i))&1;
	for(int i=0;i<50;i++) ans+=p2[i]*bi[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

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

  uint64_t A, B, C;
  int X, Y;
  std::cin >> A >> B >> C >> X >> Y;
  int diff = std::abs(X - Y);
  int common = std::min(X, Y);
  int cd = C * 2;
  int ab = A + B;
  

  if (cd <= ab) {
    int base = cd * common;
    if (X > Y && cd > A) {
      std::cout << base + diff * A << std::endl;
    } else if (Y > X && cd > B) {
      std::cout << base + diff * B << std::endl;
    } else {
      std::cout << base + diff * cd << std::endl;
    }
  } else {
    std::cout << A * X + B * Y << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b[ohara],c[ohara],d,tmp,tmpp,m,h,w,x,y,sum,pos,k,ma,mb;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dp[100][500][500];
//dp@[aaaaa][i][j]:=i [g] : j [g] の時、最小何円

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n>>ma>>mb;
    rep(i,50){
        rep(j,500){
            rep(k,500){
                dp[i][j][k]=LINF;
            }
        }
    }
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0][0]=0;
    rrep(i,1,n+1){
        rrep(j,0,500-10){
            rrep(k,0,500-10){
                if(j>=a[i-1]&&k>=b[i-1])dp[i][j][k]=min({dp[i][j][k],dp[i-1][j][k],dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1]});
                else dp[i][j][k]=min({dp[i][j][k],dp[i-1][j][k]});
            }
        }
    }
    ll kake=1;
    ans=LINF;
    while(1){
        ans=min(ans,dp[n][ma*kake][mb*kake]);
        kake++;
        if(ma*kake>500-10||mb*kake>500-10)break;
    }
    if(ans!=LINF)Cout(ans);
    else Cout(-1);
    return 0;
}


Measured memory_bytes: 104704
N = int(input())
V_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))
diff_list = []
for i in range(len(V_list)):
    if V_list[i] - C_list[i] > 0:
        diff_list.append( V_list[i] - C_list[i])

print(sum(diff_list))

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

typedef long long ll;
typedef long double ld;

using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll ans = 0;
    ll n = s.size();
    vector<ll> a;
    for (int i = 0; i  < n; i++) {
        int t = 1;
        while (i + 1 < n && s[i] == s[i + 1]) {
            i++;
            t++;
        }
        a.push_back(t);
    }
    if (a.size() == 1) {
        cout << (n * k) / 2;
        return 0;
    }
    if (s[0] == s[n - 1]) {
        for (int i = 1; i + 1 < a.size(); i++) {
            ans += a[i] / 2;
        }
        ans *= k;
        ans += a[0] / 2;
        ans += a.back() / 2;
        ans += ((a[0] + a.back()) / 2) * (k - 1);
        cout << ans;
    } else {
        for (ll aa : a) {
            ans += aa / 2;
        }
        ans *= k;
        cout << ans;
    }
    return 0;
}

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

int main(){
  string s; cin >> s;
  int prev;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i == 0) prev = s[i];
    if (prev != s[i]) {
      prev = s[i];
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 512
import fractions

N, X = map(int, input().split())
x_list = list(map(int, input().split()))

if N == 1:
    if X < x_list[0]:
        x_list.insert(0, X)
    else:
        x_list.insert(1, X)
else:
    for i in range(N-1):
        if x_list[i] < X < x_list[i+1]:
            x_list.insert(i+1, X)
        else:
            x_list.append(X)

x_list.sort()

x_diff = [0]*N
for i in range(N):
    x_diff[i] = x_list[i+1] - x_list[i]

ans = x_diff[0]
for i in range(1, N):
    ans = fractions.gcd(ans, x_diff[i])
print(ans)


Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    if((a<c&&c<b)||(b<c&&c<a)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100005;
int a[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int i = n, w = 0, h = 0;
	for (; i; i--)
		if (a[i] == a[i - 1])
		{
			w = a[i];
			i -= 2;
			break;
		}
	for (; i; i--)
		if (a[i] == a[i - 1])
		{
			h = a[i];
			break;
		}
	cout << 1ll * w * h << endl;
	return 0;
}

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

int main(){
    int A, T, N, temp, min, index;
    cin >> N >> T >> A;
    vector<int> box(N);
    min = 1000000;
    index = 0;
    for(int i = 0; i < N; i++){
        cin >> temp;
        box.at(i) = T*1000 - temp*6;
        if(min > abs(box.at(i) - A*1000)){
            min = abs(A*1000 - box.at(i));
            index = i+1;
        }
    }

    cout << index <<endl;
}

Measured memory_bytes: 256
N=int(input())
g=[[] for i in range(N)] 
cnt=0
for i in range(N):
  s=input()
  for j in range(N):
    if s[j]=='1':
      g[i].append(j)
      cnt+=1
w=cnt//2

color=[0]*N #color[i]:点iの色(1 or -1)。但し塗られていないときは0とする

def f(v,c):
    #頂点vに隣接する頂点全てを塗るあるいは判定する
    color[v] = c
    for i in range(len(g[v])):
        if color[g[v][i]]==c:
            return False
        elif color[g[v][i]]==0 and not f(g[v][i],-c):
            #(g[v][i]がまだ塗られていない　かつ　そこを-cで塗っても問題ない) ではないなら
            return False
    return True

def warshall(d,n):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

k=1
for i in range(N):
  if color[i]==0:
    if not f(i,1):
      k=-1

if k==-1:
  print(-1)
else:
  d=[[float('inf')]*N for i in range(N)]
  for i in range(N):
    for j in g[i]:
      d[i][j]=1
  for i in range(N):
    d[i][i]=0
  A=warshall(d,N)
  ans=0
  for i in range(N):
    for j in range(N):
      ans=max(ans,d[i][j])
  print(ans+1)

Measured memory_bytes: 56668
N = int(input())


def dfs(s):
    if int(s) > N:
        return 0
    f = []
    for n in '753':
        if n in s:
            f.append(True)
        else:
            f.append(False)
    ans = 1 if all(f) else 0
    for n in '753':
        ans += dfs(s + n)
    return ans


print(dfs('0'))


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void solve() {
  int k;
  cin>>k;
  vi a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  out(a[k-1]);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] p = new double[N + 1];
        for (int i = 1; i <= N; i++) {
            p[i] = sc.nextDouble();
        }

        double[][] dp = new double[N + 1][N + 1];
        dp[0][0] = 1.0;
        for (int i = 1; i <= N; i++) {
            dp[i][0] = dp[i - 1][0] * (1 - p[i]);
            for (int j = 1; j <= i; j++) {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
            }
        }

        double res = 0.0;

        for (int i = N; i > N - i; i--) {
            res += dp[N][i];
        }



        System.out.println(res);
    }
}


Measured memory_bytes: 122676
//ABC 155 B
#include <bits/stdc++.h>
using namespace std;

int main(){
   int n, x, f=1;
   cin >> n;
   
   for (int i=0; i<n; ++i){
   	  cin >> x;
   	  if (x%2==0){
   	  	  if (!(x%3==0||x%5==0)){
   	  	  	  f = 0;
   	  	  	  break;
   	  	  }
   	  }
   }
   
   if (f==1)
      cout << "APPROVED";
   else
      cout << "DENIED";
   return 0;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;


int main() {
	int N, Y;
	cin >> N >> Y;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++) {
			int k = N - (i + j);
			if (10000 * i + 5000 * j + 1000 * k == Y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

    string str;
    while(getline(cin,str)){
        if(str=="0")break;
        int a=0,b=0;
        for(int i=1;i<str.size();i++){
            if(str[i]=='A')a++;
            if(str[i]=='B')b++;
        }
        if(a>b)a++;
        else b++;
        cout<<a<<" "<<b<<endl;
    }

    return 0;
}

Measured memory_bytes: 1176
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<usize> = (0..(N - 1))
        .map(
            |_| {
                let mut line: String = String::new();
                std::io::stdin().read_line(&mut line).unwrap();
                line.trim().parse().unwrap()
            }
        )
        .collect();

    // DAGを構成し、DPにより解を求める
    let mut G = vec![vec![]; N + 1];
    for i in 2..(N + 1) {
        G[a[i - 2]].push(i);
    }
    fn f(i: usize, G: &Vec<Vec<usize>>) -> usize {
        if G[i].is_empty() {
            0
        } else {
            let mut xs: Vec<_> = G[i].iter()
                .map(|&c| f(c, &G))
                .collect();
            xs.sort();
            xs.iter().fold(0, |acc, &x| std::cmp::max(acc, x) + 1)
        }
    }
    let ans = f(1, &G);
    println!("{}", ans);
}



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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


#define PRINT(c,n) for(ll i=0;i<(n);i++)cout<<c

int main(){

    ll sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

    ll x = tx-sx;
    ll y = ty-sy;

    PRINT('U',y);    
    PRINT('R',x);    
    PRINT('D',y);    
    PRINT('L',x+1);    
    PRINT('U',y+1);    
    PRINT('R',x+1);    
    PRINT('D',1);    
    PRINT('R',1);    
    PRINT('D',y+1);    
    PRINT('L',x+1);    
    PRINT('U',1);    
    cout << endl;

    return 0;
}

Measured memory_bytes: 3624
import math
MOD=10**9+7
N=int(input())
x=list(map(int, input().split()))
y=[x[i+1]-x[i] for i in range(N-1)]
N_1=N-1
upp=math.factorial(N_1)%MOD
  
b=[0]*(N_1)
b[0]=upp
tmp=upp
out=b[0]*y[0]%MOD
for i in range(1, N_1):
  a=tmp*pow(i+1, MOD-2, MOD)%MOD
  b[i]=(b[i-1]+a)%MOD
  out+=b[i]*y[i]%MOD
  out%=MOD
print(out)

Measured memory_bytes: 15196
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

int n;
vector<int> v(4);
vector<string> u = {"AC", "WA", "TLE", "RE"};

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n;
    rep(i,n) {
        string s; cin>>s;
        switch (s[0])
        {
        case 'A':
            v[0]++;
            break;
        case 'W':
            v[1]++;
            break;
        case 'T':
            v[2]++;
            break;
        case 'R':
            v[3]++;
            break;
        }
    }
    rep(i,4) {
        cout << u[i] << " x " << v[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3656
_, s, _, t = readlines.map(&:chomp)
s = s.split.map(&:to_i)
t = t.split.map(&:to_i)

def include?(a, e)
  l = 0
  r = a.size - 1
  while(l <= r)
    m = (l + r) / 2
    return true if a[m] == e
    if a[m] < e
      l = m + 1
    else
      r = m - 1
    end
  end
  false
end

p t.count {|e| include?(s, e)}


Measured memory_bytes: 15924
n = int(input())
s = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
t = [input() for i in range(n)]
p = []
for i in range(n):
    p.append(sorted(list(t[i])))
st = [51 for i in range(len(s))]

for i in range(len(s)):
    for j in range(n):
        cnt = 0
        for k in range(len(p[j])):
            if p[j][k] == s[i]:
                cnt += 1
        st[i] = min(st[i], cnt)
for i in range(len(st)):
    if st[i] == 51:
        st[i] = 0
for i in range(len(s)):
    for j in range(st[i]):
       print(s[i], end='')
print()

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

int main()
{
    int N;
    cin >> N;
    vector<int> bossNumber(N);
    for (int i = 1; i < N; i++)
    {
        cin >> bossNumber.at(i);
    }
    vector<int> numberOfStuff(N);
    for (int i = 1; i < N; i++)
    {
        numberOfStuff.at(bossNumber.at(i) - 1)++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << numberOfStuff.at(i) << endl;
    }
}

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

int main() {
	char ch[(int)1e5 << 1];
	scanf("%s", ch);
	int len = strlen(ch);
	int ans = 0;
	for(int i = 1; i < len; i++)
		if(ch[i] != ch[i - 1])
			++ans; printf("%d\n", ans);
}

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

namespace id_0075cs
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp;
            while((tmp = Console.ReadLine()) != null)
            {
                var vs = tmp.Split(',').Select(double.Parse).ToArray();
                var weight = vs[1];
                var height = vs[2];
                var bmi = weight / height / height;
                if(bmi >= 25)
                {
                    Console.WriteLine((int)vs[0]);
                }

            }
        }
    }
}



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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 2e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll fac[maxn], inv[maxn];

ll qpow(ll a, ll b, ll mod = MOD) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void init() {
    fac[0] = 1;
    for (int i = 1; i < maxn; i++) fac[i] = fac[i - 1] * i % MOD;
    inv[maxn - 1] = qpow(fac[maxn - 1], MOD - 2);
    for (int i = maxn - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % MOD;
}

ll C(int n, int m) {
    return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

void solve() {
    int k;
    string s;
    cin >> k >> s;
    init();
    ll res = 0;
    int n = s.size();
    for (int i = 0; i <= k; i++) {
        int last = k - i;
        res += qpow(26, i) * qpow(25, last) % MOD * C(last + n - 1, n - 1) % MOD;
        res %= MOD;
    }
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 35656
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	char s[19];
	for (int i = 0; i < 19; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < 5; i++) {
		cout << s[i];
	}
	cout << ' ';
	for (int i = 6; i < 13; i++) {
		cout << s[i];
	}
	cout << ' ';
	for (int i = 14; i < 19; i++) {
		cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#define CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<vector>
#include<utility>
#include<functional>
#include<iostream>
#define sqr(x) x*x
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)

using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string W[3] = {"Alice","Borys","Draw"};
	int N,A,B,b;
	cin >> N >> A >> B;
	b = abs(A - B - 1);
	if (b%2==1) {
		cout << W[0] << endl;
	}
	if (b%2==0) {
		cout << W[1] << endl;
	}
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) {
        cin >> A[i];
        A[i] = A[i] - i-1;
    }

    sortup(A);

    ll b;
    if(N%2) b = A[N/2];
    else b = (A[N/2]+A[(N+1)/2]) / 2;

    ll ans=0;
    rep(i, N) ans += abs(A[i] - b);
    cout << ans << nl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
//bitset<365> a;const double PI = acos(-1);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
const int INF = 1e9 + 5;
int main() {
    vector<int> ans(3);
    ll N, a, b, c, tmp1, tmp2, tmp3;
    cin >> N;
    cin >> a >> b >> c;
    ans[0] = a, ans[1] = b, ans[2] = c;
    for(int i = 1; i < N; ++i) {
        cin >> a >> b >> c;
        tmp1 = ans[0], tmp2 = ans[1], tmp3 = ans[2];
        ans[0] = max(tmp2, tmp3) + a;
        ans[1] = max(tmp1, tmp3) + b;
        ans[2] = max(tmp1, tmp2) + c;
    }
    cout << max({ans[0], ans[1], ans[2]}) << endl;
}


Measured memory_bytes: 256
//tenka1_2019_c.cpp
//Tue Apr 30 21:39:30 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int blacktotal[n];
	if (s[0]=='#'){
		blacktotal[0]=1;
	}else {
		blacktotal[0]=0;
	}
	for (int i=1;i<n;i++){
		if (s[i]=='#'){
			blacktotal[i]=blacktotal[i-1]+1;
		}else {
			blacktotal[i]=blacktotal[i-1];
		}
	}

	int whitetotal[n];
	if (s[n-1]=='.'){
		whitetotal[n-1]=1;
	}else {
		whitetotal[n-1]=0;
	}
	for (int i=n-2;i>=0;i--){
		if (s[i] == '.'){
			whitetotal[i] = whitetotal[i+1]+1;
		}else {
			whitetotal[i] = whitetotal[i+1];
		}
	}

	int ans = whitetotal[0];
	for (int i=0;i<n-1;i++){
		int temp = blacktotal[i]+whitetotal[i+1];
		if (temp < ans){
			ans = temp;
		}
	}
	if (ans > blacktotal[n-1]){
		ans = blacktotal[n-1];
	}
	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll ans = a/(b+c);
    if(a%(b+c) < c) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;
 
void solve(){
    double r;
    cin >> r;
    double ans=2*r*3.1415926535;
    printf("%.12f\n",ans);
}
 
int main(){
    solve();
}

Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int n,a[4];

void solve() {
  int step=0,coin=32;
  while(1) {
    if(step % 2 == 0) {
      coin -= (coin-1)%5;
      cout << coin << endl;
      step++;
    }
    else if(step % 2 != 0){
      coin -= a[(step/2) % n];
      if(coin <= 0) {
        cout << "0" << endl;
        break;
      }
      cout << coin << endl;
      step++;
    }
  }
  return;
}

int main() {
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> a[i];
    }
    solve();
  }
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct UnionFind
{
  vector<int> data;
  UnionFind(){}
  UnionFind(int sz):data(sz, -1){};
  int size(int x) { return -data[find(x)]; }
  int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
  bool same(int x, int y) { return find(x) == find(y); }
  int unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] > data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return -data[x];
  }
};

int N;
vector<Pi> ps;
vector<Pi> vx, vy;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    ps.emplace_back(x, y);
    vx.emplace_back(x, i);
    vy.emplace_back(y, i);
  }
  sort(all(vx));
  sort(all(vy));

  UnionFind uf(N);
  priority_queue<Ti, vector<Ti>, greater<Ti> > que;
  rep(i, N-1) {
    que.emplace(abs(vx[i+1].first-vx[i].first), vx[i+1].second, vx[i].second);
  }
  rep(i, N-1) {
    que.emplace(abs(vy[i+1].first-vy[i].first), vy[i+1].second, vy[i].second);
  }
  int ans = 0;
  while(!que.empty()) {
    Ti t = que.top(); que.pop();
    int cost, i, j;
    tie(cost, i, j) = t;
    if(!uf.same(i, j)) {
      ans += cost;
      uf.unite(i, j);
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int K, N, D, X, ans=0, tmp;   
    cin >> N >>D>>X;
    vector<int> A(N);
    ans+=X;
    for(int i=0; i<N; i++){
	cin>>tmp;
	ans+=(D-1)/tmp+1;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256