akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll n, m;
string s, t;

inline ll lcm(ll a, ll b)
{
    return (long long)a * (long long)b / __gcd(a, b);
}

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

    cin >> n >> m >> s >> t;

    ll len = lcm(n, m);

    vector< pair< ll, ll > > tab;

    ll x = len / n;
    ll v = 0;
    ll i = 0;
    while (v < len)
    {
        tab.push_back({v, i++});
        v += x;
    }

    x = len / m;
    v = 0;
    i = 0;

    while (v < len)
    {
        auto it = lower_bound(begin(tab), end(tab), make_pair(v, -1ll));
        if (it != end(tab) and (*it).first == v)
            if (s[(*it).second] != t[i])
                return cout << -1 << '\n', 0;
        v += x; ++i;
    }

    cout << len << '\n';
}



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

int main() {
    
    int body;
    int foot;
    
    cin >> body >> foot;
    
    rep(i, body+1){
        int sum=0;
        
        sum += 2 * i;
        sum += 4 * (body - i);
        
        if(sum == foot){
            cout << "Yes" << endl;
            return 0;
        }
        
    }
    
    cout << "No" << endl;
    
    return 0;
}

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

public static class Program
{
    public static void Main(string[] args)
    {
        var abk = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var tmp = (long)0;
        if (abk[0] > 0 && abk[2] > 0)
        {
            if (abk[2] - abk[0] > 0)
            {
                abk[2] -= abk[0];
                abk[0] = 0;
            }
            else
            {
                abk[0] -= abk[2];
                Console.WriteLine(string.Join(" ", abk[0], abk[1]));
                return;
            }
        }
        if (abk[1] > 0 && abk[2] > 0)
        {
            if (abk[2] - abk[1] > 0)
            {
                abk[2] -= abk[1];
                abk[1] = 0;
            }
            else
            {
                abk[1] -= abk[2];
                Console.WriteLine(string.Join(" ", abk[0], abk[1]));
                return;
            }
        }
        Console.WriteLine(string.Join(" ", abk[0], abk[1]));
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int h,w;
  cin>>h>>w;
  int k;
  cin>>k;
  
  char grid[h+1][w+1];
  int num[h+1][w+1];
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      grid[i][j]=0;
      num[i][j]=0;
      char qqq;
      cin>>qqq;
      grid[i][j]=qqq;
    }
  }
  
  int cs[h+1];
  for(int i=1;i<=h;i++){
    cs[i]=0;
  }
  
  
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
     if(grid[i][j]=='#'){
       cs[i]++;}
    }
  }
  
  int cnt=1;
  int ue[w+1];
  int hd[h+1];
for(int i=1;i<=w;i++){
  ue[i]=-1;
  hd[i]=-1;}
  
  for(int i=1;i<=h;i++){

    int tk=-1;
    for(int j=1;j<=w;j++){
      //
      if(grid[i][j]=='.'){
      if(tk==-1){
        tk=j;}
        if(ue[j]==-1){
          ue[j]=i;}
      }
   //
      if(grid[i][j]=='#'){
   int l;
        if(tk==-1){
          l=j;}
        else{
          l=tk;}
        int uem=0;
        for(int t=l;t<=j;t++){
          if(ue[t]==-1){
            uem=i;
            break;}
          uem=max(uem,ue[t]);
        }
          
        for(int k=uem;k<=i;k++){
          for(int h=l;h<=j;h++){
            num[k][h]=cnt;
     
          }
        }
       cnt++; 
        for(int k=l;k<=j;k++){
          ue[k]=-1;
        }
        tk=-1;
         hd[i]=j;
      }
      //

    }
   
    
    }

  
    for(int i=1;i<=h;i++){
      for(int j=2;j<=w;j++){
        if(num[i][j]==0&&num[i][j-1]!=0){
          if(i>=2){
            if(num[i-1][j-1]==num[i][j-1]&&num[i-1][j-1]==num[i-1][j]){
              continue;}
          }
          num[i][j]=num[i][j-1];}
        }
      }
    


    for(int i=1;i<=w;i++){
      for(int j=2;j<=h;j++){
          if(num[j][i]==0&&num[j-1][i]!=0){
            num[j][i]=num[j-1][i];}
      }
    }
  
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
        if(j<=w-1){
        cout<<num[i][j]<<" ";}
        else{
      cout<<num[i][j]<<endl;}
    }
    }
    
    return 0;
    
    
 
 
}

Measured memory_bytes: 1152
while True:
  x, y, s = map(int, input().split())
  if x == 0:
    break
  ans = 0
  for i in range(1, s+1):
    for j in range(i, s+1):
      t = i + j + (i*x)//100 + (j*x)//100
      if t > s:
        break
      if t != s:
        continue
      t = i + j + (i*y)//100 + (j*y)//100
      if t > ans:
        ans = t
  print(ans)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define pb push-back
#define all(x) x.begin(),x.end()

using ll = long long int;
#define rep0(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)

using namespace std;

ll power(ll n, ll k)
{
	ll res = 1;
	while(k){
		if(k & 1){
			res *= n;
			k--;
		}
		else{
			n *= n;
			k /= 2;
		}
	}
	return res;
}

const ll mod = 1000000007;
void solve()
{
	ll n; cin >> n;
	ll ar[n+1];
	rep1(i,n+1) cin >> ar[i];
	
  ll pre[n+1];
  memset(pre,0,sizeof(pre));
  
  rep1(i,n+1)
    pre[i] = (pre[i-1] + ar[i]) % mod;

  ll ans = 0;
  rep1(i,n+1)
    ans = (ans + (pre[i-1] * ar[i]) % mod) % mod;
 cout << ans << "\n";
}

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

// ©beast_sr


Measured memory_bytes: 6756
from collections import Counter
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    sum_list = [0]
    for i in range(N):
        sum_list.append((sum_list[i]+a[i])%M)
    c = list(Counter(sum_list).items())
    ans = 0
    for i in range(len(c)):
        if c[i][1] >= 2:
            ans += (c[i][1]*(c[i][1]-1))//2
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 19836
#!/usr/bin/python
import sys

n=int(sys.stdin.readline())
for i in range(0,n):
	a=map(int,sys.stdin.readline().split())
	a[0]-=1;a[1]-=1;
	print 196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2]

Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << setprecision(12) << fixed;
  if (x==W/2&&y==H/2) cout << W*H/2 << " " << 1 << endl;
  else  cout << W*H/2 << " " << 0 << endl;
}

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

long long n;
long long a[100002];

long long md = 1000000007ll;

map<pair<pair<int,int> , pair<int,int> > ,long long>mp;

long long slv(int id,int rd,int bl,int gr){
	//cout<<id<<" "<<rd<<" "<<bl<<" "<<gr<<endl;
	if(id==-1){
		if(rd<=0 && bl<=0 && gr<=0)return 1ll;
		else return 0ll;
	}
	if(id+1<rd || id+1<bl || id+1<gr)return(0ll);
	long long hoge=0;
	if(rd!=-1)hoge+=rd;if(bl!=-1)hoge+=bl;if(gr!=-1)hoge+=gr;
	if(id+1<hoge)return(0ll);

	pair<pair<int,int> , pair<int,int> >p = make_pair(make_pair(id,rd),make_pair(bl,gr));
	if(mp.count(p))return(mp[p]);

	long long ret = 0ll;

	// rd
	if(rd == -1 || rd-1==a[id]){
		if(rd==-1)ret += slv(id-1,a[id],bl,gr);
		else ret += slv(id-1,rd-1,bl,gr);
	}
	// bl
	if(bl == -1 || bl-1==a[id]){
		if(bl==-1)ret += slv(id-1,rd,a[id],gr);
		else ret += slv(id-1,rd,bl-1,gr);
	}

	// gr
	if(gr == -1 || gr-1==a[id]){
		if(gr==-1)ret += slv(id-1,rd,bl,a[id]);
		else ret += slv(id-1,rd,bl,gr-1);
	}

	return (mp[p] = ret%md);
}

int main(){

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

}

Measured memory_bytes: 49280
#include<bits/stdc++.h>
typedef long long ll;
typedef double db;
typedef long double ld;
using namespace std;
const int N=1e5+5;
int h,n,i,k,a[N];
int main()
{
	cin>>h>>n;
	for (i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		k+=a[i];
	}
	
	if (k>=h) puts("Yes");
	else puts("No");
}

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


int factorial(int n)
{ 
  int c = 1;
  for ( int i = 1; i <= n; ++i) c *= i;
  return c;
}


//
//  1 2 3 4 5 -- 0 * 4!
//  2 1 3 4 5 -- 1 * 4!
int main()
{
  int n;
  cin >> n;
  
  vector<int> p(n), q(n);
  for ( int i = 0; i < n; ++i ) cin >> p[i];
  for ( int i = 0; i < n; ++i ) cin >> q[i];

  int order_p = 0;
  for ( int i = 0; i < n - 1; ++i)
  {
    order_p += (p[i]-1) * factorial(n-1-i);
    for ( int j = i; j < n; ++j ) 
      if ( p[j] > p[i] ) --p[j];
  }

  int order_q = 0;
  for ( int i = 0; i < n - 1; ++i)
  {
    order_q += (q[i]-1) * factorial(n-1-i);
    for ( int j = i; j < n; ++j ) 
      if ( q[j] > q[i] ) --q[j];
  }
  
  //cout << order_p << "\n";
  //cout << order_q << "\n";
  cout << abs(order_p - order_q);
  return 0;
}


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

int main(void) {
    int N, X;
    cin >> N >> X;
    
    vector<int> L(N);
    vector<int> D(N+1);
    for(int i=0;i<N+1;i++) {
        if(i==0) D.at(i) = 0;
        else { 
            cin >> L.at(i-1);
            D.at(i) = D.at(i-1) + L.at(i-1);
        }
    }

    int cnt=0;
    for(int i=0;i<N+1;i++) {
        if(X>=D.at(i)) cnt++;
    }

    cout << cnt << endl;

    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s;
  cin>>s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]

xs1total = 0 # ((
xs2 = [] # )((
xs3 = [] # ))(
xs4total = 0 # ))

for s in S:
    n = 0
    m = 0
    for c in s:
        if c == "(":
            n += 1
        elif c == ")":
            n -= 1
            m = min(m, n)
    k = n - m
    if m == 0 and k == 0:
        continue
    elif m == 0:
        xs1total += k
    elif k == 0:
        xs4total += -m
    else:
        if -m < k:
            xs2.append((-m, k))
        else:
            xs3.append((-m, k))

xs2.sort()
xs3.sort(key=lambda x:-(x[1] - x[0]))

def check(xs1total, xs2, xs3, xs4total):
    t = xs1total
    for x in xs2:
        if t < x[0]:
            return False
        t = t - x[0] + x[1]
    for x in xs3:
        if t < x[0]:
            return False
        t = t - x[0] + x[1]
    return t == xs4total

#print(xs1total, xs2, xs3, xs4total)

if check(xs1total, xs2, xs3, xs4total):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 52116
#include<iostream>
int main()
{
	int sum = 0, average = 0, cnt = 0;
	while (true)
	{
		int a, b;
		char c;
		std::cin >> a >> c >> b;
		if (std::cin.eof())
		{
			break;
		}
		sum += a * b;
		average += b;
		cnt++;
	}
	std::cout << sum << std::endl;
	std::cout << (int)((double)average / cnt + 0.5) << std::endl;
}


Measured memory_bytes: 3068
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N, Q; cin >> N >> Q;
	string s; cin >> s;
	vector<int> res(N, 0);
	int cur = 0;
	bool hasA = false;
	REP(i, N) {
		if (s[i] == 'A') hasA = true;
		else if (s[i] == 'C') {
			if (hasA) {
				cur++;
			}
			hasA = false;
		}
		else hasA = false;
		res[i] = cur;
	}


	vector<int>out(Q);

	REP(i, Q) {
		int l, r; cin >> l >> r;
		l--; r--;
		out[i] = res[r] - res[l];
	}
	REP(i, Q) {
		cout << out[i] << endl;
	}





	return 0;
}


Measured memory_bytes: 1792
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    n = ii()
    p = li()
    m = p[0]
    cnt = 0
    for i in p:
        m = min(i,m)
        if m == i:
            cnt+=1

    print(cnt)
        



main()


Measured memory_bytes: 27088
l9 = []
l9.append(1)
tmp = 1
while tmp <= 10**5:
  tmp *= 9
  l9.append(tmp)
l6 = []
l6.append(1)
tmp = 1
while tmp <= 10**5:
  tmp *= 6
  l6.append(tmp)

  
import bisect 
n = int(input())
ans = 10**6

for i in range(0, n+1):

  a = i
  b = n - i
  p = 0
  while a > 0:
    idx = bisect.bisect_left(l6, a)
    if a == l6[idx]:
      a -= l6[idx]
    else:
      a -= l6[idx-1]
    p += 1
    
  q = 0
  while b > 0:
    idx = bisect.bisect_left(l9, b)
    if b == l9[idx]:
      b -= l9[idx]
    else:
      b -= l9[idx-1]
    q += 1
    
  ans = min(ans, p+q)

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<ll> enum_div(ll n) {
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<string> S(N);
    cin >> S;

    int a = 0, b = 0, c = 0;
    int ans = 0;
    REP(i, N) {
        REP(j, S[i].length()) {
            if (S[i].substr(j, 2) == "AB") ans++;
        }
        if (S[i].back() == 'A') a++;
        if (S[i].front() == 'B') b++;
        if (S[i].back() == 'A' && S[i].front() == 'B') c++;
    }

    a -= c;
    b -= c;
    if (c == 0) { ans += min(a, b); }
    else if (a + b > 0) {
        ans += c + min(a, b);
    }
    else {
        ans += c - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  ll res = (b - 1) / (a - 1);
  if((b - 1) % (a - 1) != 0)res++;
  cout << res << endl;
}


Measured memory_bytes: 3576
import math

a, b, h, m = map(float, input().split())
ap = bp = ax = ay = bx = by = d = 0
ap = h * 30 + m * 0.5
bp = m * 6

ax = a * math.cos(math.radians(ap))
ay = a * math.sin(math.radians(ap))

bx = b * math.cos(math.radians(bp))
by = b * math.sin(math.radians(bp))

d = abs(ax - bx) ** 2 + abs(ay - by) ** 2

print(math.sqrt(d))

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

string s;
ll N;

bool check(ll k){
    if (k>N)
        return false;
    ll r = k-1, l = N-k;

    if (l>=r)
        return true;

    rep(i,l,r){
        if (s[i]!=s[i+1])
            return false;
    }
    return true;
}

signed main() {
    cin>>s;
    N = s.size();

    ll ok=1, ng=1ll << 59;
    while(ok+1<ng){
        ll m = (ok+ng)/2;
        if (check(m)){
            ok = m;
        }else{
            ng = m;
        }
    }
    cout<<ok<<endl;

    return 0;
}


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

A = []
for i in range(n):
    A.append(input())

import collections
import itertools

counter = collections.Counter(A)
mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

# print(*(k for k, v in it))
B = []
for k, v in it:
    B.append(k)
B = sorted(B)
for i in B:
    print(i)

Measured memory_bytes: 122248
def resolve():
    '''
    code here
    Sを先頭　真ん中　お尻の三分割する
    連結した場合を考えると以下の場合分け
    先頭　お尻　真ん中×K　（先頭₊お尻）×（K-1）
    同じ文字が続いたらn//2個の文字変更が必要
    以上で解けるはず

    '''
    S = input()
    K = int(input())

    S_head = ''
    head = S[0]
    for s in S:
        if s == head:
            S_head += s
        else:
            break
    
    S_tail = ''
    tail = S[-1]
    for s in S[::-1]:
        if s == tail:
            S_tail += s
        else:
            break
    S_tail = S_tail[::-1]

    S_body = S[len(S_head):-1 * len(S_tail)]
    
    def double_counter(S):
        cnt = 0
        if len(S) >= 2:
            prev = S[0]
            for item in S[1:]:
                if item == prev:
                    cnt += 1
                    prev = -1
                else:
                    prev = item

        return cnt
    
    if len(S) >= 2 and len(S) != len(S_head):
        res = len(S_head)//2\
            + len(S_tail)//2\
            + double_counter(S_body) * K\
            + double_counter(S_tail+S_head) * (K-1)
    elif len(S) == 1:
        res = K // 2
    elif len(S) == len(S_head):
        res = (K * len(S)) // 2

    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;

int N;
int par[100050];

int ans;

void init(int N) {
    rep(i,N) par[i] = i;
}

int root(int x){
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
}

void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    par[x] = y;
    ans--;
}

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

int M;
cin >> N >> M;

ans = N;
init(N);

rep(i,M) {
    int x,y,z;
    cin >> x >> y >> z;
    unite(x,y);
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<complex>
#define inf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int> 
const int N=1e6+10;
const int mod=998244353;
using namespace std;
 
int n,x,y,ans[N];
int cal(int i, int j){
  int res=j-i;
  if(j<=x||i>=y) return j-i;
  if(i<=x&&j>=y) return j-i-(y-x-1);
  if(x<=i&&j<=y) return min(j-i, i-x+1+y-j);
  if(i<=x&&j<=y) return x-i+min(j-x, 1+y-j);
  if(i<=y&&y<=j) return j-y+min(y-i, 1+i-x);
  return res;
} 
void solve(){
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;++i){
      for(int j=i+1;j<=n;++j){
        ans[cal(i,j)]++;
      }
    }
    for(int i=1;i<n;++i) printf("%d\n",ans[i]);

}
int main() 
{
    int _=1;  //scanf("%d",&_);
    while(_--) solve();
return 0;
}
/*
*/
 

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



int main() {
    int K,count=0;
    cin>>K;
    vector<int> ans(1);
    rep(count,K){
        ans.at(0)++;
        int point=0;

        while(point<ans.size()-1 && (ans.at(point)>ans.at(point+1)+1 || ans.at(point)==10)){
            ans.at(point)=0;
            ans.at(point+1)++;
            point++;
        }

        /*while(point<ans.size()-1 && ans.at(point)>ans.at(point+1)+1){
            ans.at(point)=0;
            ans.at(point+1)++;
            point++;
        }*/

        if(point==ans.size()-1 && ans.at(point)==10){
            rep(j,ans.size()){
                ans.at(j)=0;
            }
            ans.push_back(1);
        }
        for(int p=point-1;p>=0;p--){
            if(ans.at(p+1)==0){ans.at(p)=0;}
            else{ans.at(p)=ans.at(p+1)-1;}
        }
    }

    for(int i=ans.size()-1;i>=0;i--){
        if(i==ans.size()-1 && ans.at(i)==0)continue;
        cout<<ans.at(i);
    }
    cout<<endl;
}

Measured memory_bytes: 256
import math
N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))[::-1]
Cs = [a*b for a, b in zip(As, Bs)]
BCs = list(zip(Bs, Cs))

def func(target):
    r = 0
    for b, c in BCs:
        r += math.ceil(max(0, c - target) / b)
    return r <= K

if __name__ == '__main__':
    min_i, max_i, index = 0, max(Cs)+1, 1
    while True:
        if func(index):
            index, max_i = (index-1 + min_i)//2, index-1
        else:
            index, min_i = (index+1 + max_i)//2, index+1
        if min_i > max_i:
            print(min_i)
            break

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

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

    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    int x3,y3,x4,y4;
    int len=0;

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

    x3=x2-dy;
    y3=y2+dx;
    x4=x3-dx;
    y4=y3-dy;

    printf("%d %d %d %d",x3,y3,x4,y4);
    

    return 0;
}


Measured memory_bytes: 3740
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
ll longinf=1ll<<60;
int inf=1<<29;

int N,K;


int main(){
    cin>>N;
    rep0(i,30){
        rep0(j,20){
            if(4*i+7*j==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


N = int(input())
N %= 10
if N in (2, 4, 5, 7, 9):
    print('hon')
elif N in (0, 1, 6, 8):
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9172
h, w = list(map(int, input().split(" ")))
board = [w*[0] for i in range(h)]
for i in range(h):
    for j, a in enumerate(list(map(int, input().split(" ")))):
        board[i][j] = a

ans = []
for i in range(h):
    for j in range(w):
        if(board[i][j] % 2 == 1):
            if(i != 0):
                if(board[i-1][j] % 2 == 1):
                    board[i][j] -= 1
                    board[i-1][j] += 1
                    ans.append("%d %d %d %d" %(i+1, j+1, i, j+1))
                    continue
            if(i != h-1):
                if(board[i+1][j] % 2 == 1):
                    board[i][j] -= 1
                    board[i+1][j] += 1
                    ans.append("%d %d %d %d" %(i+1, j+1, i+2, j+1))
                    continue
            if(j != 0):
                if(board[i][j-1] % 2 == 1):
                    board[i][j] -= 1
                    board[i][j-1] += 1
                    ans.append("%d %d %d %d" %(i+1, j+1, i+1, j))
                    continue
            if(j != w-1):
                if(board[i][j+1] % 2 == 1):
                    board[i][j] -= 1
                    board[i][j+1] += 1
                    ans.append("%d %d %d %d" %(i+1, j+1, i+1, j+2))
                    continue
            if(h-i >= w-j):
                if(i != h-1):
                    board[i][j] -= 1
                    board[i+1][j] += 1
                    ans.append("%d %d %d %d" %(i+1, j+1, i+2, j+1))
                    continue
            else:
                if(j != w-1):
                    board[i][j] -= 1
                    board[i][j+1] += 1
                    ans.append("%d %d %d %d" %(i+1, j+1, i+1, j+2))
                    continue

print(len(ans))
for i in ans:
    print(i)

Measured memory_bytes: 15940
n=int(input())
card=[[0 for i in range(13)] for j in range(4) ]
mk={0:"S",1:"H",2:"C",3:"D"}
for i in range(n) :
    mark,number=input().split()
    number=int(number)
    if mark=="S" : mark=int(0)
    elif mark=="H" : mark=int(1)
    elif mark=="C" : mark=int(2)
    elif mark=="D" : mark=int(3)
    card[mark][number-1]=1
for m in range(4) :
    for num in range(13) :
        if card[m][num]==0 :
            print("{} {}".format(mk[m],num+1))


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S == "SUN") cout << 7 << endl;
  else if(S == "MON") cout << 6 << endl;
  else if(S == "TUE") cout << 5 << endl;
  else if(S == "WED") cout << 4 << endl;
  else if(S == "THU") cout << 3 << endl;
  else if(S == "FRI") cout << 2 << endl;
  else if(S == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, a[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	int count = 0;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] == a[i + 1]) {
			count++;
			i++;
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll x, cnt;

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%lld", &x);
    cnt = (x / 11);
    x -= cnt * 11;

    if (x == 0) {
        printf("%lld", 2LL * cnt);
        return 0;
    }

    if (x <= 6)
        printf("%lld", 2LL * cnt + 1);
    else
        printf("%lld", 2LL * cnt + 2);



    return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())

P = input().split()
P = "".join(P)

Q = input().split()
Q = "".join(Q)

dictionary = list(itertools.permutations([str(j+1) for j in range(N)], N))
dictionary = list(map("".join, dictionary))
print(abs(dictionary.index(P)-dictionary.index(Q)))


Measured memory_bytes: 45168
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define pll              pair<long long,long long>
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
              const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.se >b.se);
    }
    else
        return (a.fi<b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
       ll k,n,i=0,j=0,c=0,d=0,e=0,f=0,g=0,h=0,maxi=0,sum=0;
         cin>>n;
         if(n>=30)
            cout<<"Yes"<<endl;
         else
            cout<<"No"<<endl;

     }
}


Measured memory_bytes: 3564
/*
 *
 * Author: Hamkor
 *
 */

#include <bits/stdc++.h>

using namespace std;

int main(){
	int r, d, x; cin>>r>>d>>x;
	for (int i=1; i<=10; ++i){
		cout<<r*x - d<<"\n";
		x = r*x - d;
	}
	
	return 0;
}


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

L=[3,5,7]
def is_753(x, N):
  tmp=0
  for i in L:
    p=x*10+i
    if p<=N:
      if set([int(c) for c in str(p)])==set(L):
        tmp+=is_753(p, N)+1
      else:
        tmp+=is_753(p, N)
  return tmp

print(is_753(0, N))

Measured memory_bytes: 3064
def pow_k(x, n,mod = 10**9+7):
    x %= mod
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K * x % mod

def solve(n,mod = 10**9+7):
    total = pow_k(10,n)
    not_include_0 = pow_k(9,n)
    not_include_9 = not_include_0
    not_include_0_and_9 = pow_k(8,n)
    return (total%mod-(not_include_0 + not_include_9 - not_include_0_and_9)%mod)%mod

def main():
    n = int(input())
    print(solve(n))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include<stdio.h>
int main(void){
	int s,t,u=0;
	scanf("%d",&s);
	t=s%100;
	s/=100;
	if(1<=s&&s<=12)u+=1;
	if(1<=t&&t<=12)u+=2;
	switch(u){
	case 0:
		printf("NA");
		break;
	case 1:
		printf("MMYY");
		break;
	case 2:
		printf("YYMM");
		break;
	case 3:
		printf("AMBIGUOUS");
		break;
	}
	return 0;
}

Measured memory_bytes: 1720
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.*;

public class Main {
    public static ArrayList<Integer> divisors(int n) {
        ArrayList<Integer> divs = new ArrayList<Integer>();
        for (int i=1; i<=(int)Math.pow(n, 0.5); i++) {
            if (n % i == 0) {
                divs.add(i);
                if (i*i != n) {
                    divs.add(n/i);
                }
            }
        }
        return divs;
    }

	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N     = reader.nextInt();
		int[] A   = new int[N+1];
		int[] cnt = new int[N+1];
		ArrayList<Integer> ans = new ArrayList<Integer>();
		for (int i=1; i<=N; i++) {
		    A[i] = reader.nextInt();
		}
		for (int i=N; i>0; i--) {
		    if (A[i] != cnt[i]) {
		        ans.add(i);
		        ArrayList<Integer> div = divisors(i);
		        for (int it : div) {
		            cnt[it] ^= 1;
		        }
		    }
		}
		System.out.println(ans.size());
		for (int i=0; i<ans.size(); i++) {
		    System.out.print(ans.get(i));
		    if (i == ans.size()-1) System.out.println();
		    else System.out.print(" ");
		}
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 65096
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    char s; cin>>s;
    string hoge="aeiou";
    rep(i,hoge.size())if(s==hoge[i])return puts("vowel")*0;
    cout<<"consonant"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan =new Scanner(System.in);
		int n = scan.nextInt();
		String s = scan.next();
		String ans ="";
		for(int i = 0 ;i < s.length(); i++) {
			int ch = (s.charAt(i) + n - 65)%26 + 65 ;
			char c = (char) ch;
			ans = ans  + Character.toString(c);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 147832
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    set<string> words;

    int n;
    cin >> n;
    bool res = true;
    string last = "";
    while (n-- > 0) {
        string s;
        cin >> s;
        if (words.count(s)) {
            res = false;
        } else {
            words.insert(s);

            if (last.empty() || last.back() == s.front()) {

            } else {
                res = false;
            }
        }
        last = s;
    }

    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, ans = 1;
  bool flg = false;
  cin >> x;
  for (int i = 1; i <= x; i++) {
    for (int j = 2; j < i; j++) {
      long double tmpi = i;
      flg = false;
      if (i % j == 0) {
        long double tmpj = (long double)j;
        while (1) {
          if (tmpi == tmpj) {
            //cout << tmpi << " " << tmpj << endl;
            flg = true;
            break;
          }
          tmpi /= tmpj;
          if (tmpi < tmpj) {
            flg = false;
            break;
          }
        }
      }
      if (flg) {
        if (ans < i) {
          ans = i;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
import sys

input = sys.stdin.readline
n = int(input())
a_list = list(map(int, input().split()))
cost1, cost2 = 0, 0
a_sum1 = a_list[0]
if a_sum1 <= 0:
    cost1 += abs(a_sum1)+1
    a_sum1 = 1
flag1 = 1
a_sum2 = a_list[0]
if a_sum2 >= 0:
    cost2 += a_sum2+1
    a_sum2 = -1
flag2 = -1
for i in range(1, n):
    a_sum1 += a_list[i]
    if flag1 == 1:
        if a_sum1 >= 0:
            cost1 += a_sum1+1
            a_sum1 = -1
        flag1 = -1
    else:
        if a_sum1 <= 0:
            cost1 += abs(a_sum1)+1
            a_sum1 = 1
        flag1 = 1
    a_sum2 += a_list[i]
    if flag2 == 1:
        if a_sum2 >= 0:
            cost2 += a_sum2+1
            a_sum2 = -1
        flag2 = -1
    else:
        if a_sum2 <= 0:
            cost2 += abs(a_sum2)+1
            a_sum2 = 1
        flag2 = 1
print(min(cost1, cost2))


Measured memory_bytes: 15100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep (i, n) {
    cin >> a[i];
  }
  ll min = 0;
  sort(a.begin(), a.end());
  rep (i, k) {
    min += a[i];
  }

  cout << min << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<stack>
using namespace std;
int main()
{
  int n;
  for(;cin>>n,n;)
    {
      stack<pair<int,int> > data;
      data.push(make_pair(0,-1));
      for(int i=1;i<=n;i++)
	{
	  int tmp;
	  cin>>tmp;
	  pair<int,int> tt = data.top();
	  data.pop();
	  if(i%2!=0)
	    {
	      if(tt.second==tmp)
		data.push(make_pair(tt.first+1,tmp));
	      else
		{
		  data.push(tt);
		  data.push(make_pair(1,tmp));
		}
	    }
	  else
	      data.push(make_pair(tt.first+1,tmp));
	  //	  for(int xx=0;xx<data.size();xx++)
	  //	    cout<<"<"<<data[xx].first<<" "<<data[xx].second<<"> ";
	  //	  cout<<endl;
	  if(data.size()>1)
	    {
	      pair<int,int> t1 = data.top();
	      data.pop();
	      pair<int,int> t2 = data.top();
	      data.pop();
	      if(t1.second==t2.second)
		data.push(make_pair(t1.first+t2.first,t1.second));
	      else
		{
		  data.push(t2);
		  data.push(t1);
		}
	    }

	}
      int ans=0;
      while(!data.empty())
	{
	  pair<int,int> tt = data.top();
	  data.pop();
	  //	  cout<<tt.first<<" "<<tt.second<<endl;
	  if(tt.second==0)
	    ans+=tt.first;
	}
      cout<<ans<<endl;
    }

}

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

int main()

{
    int a,b,k;
    cin>>a>>b>>k;
    if(a+k-1 >=abs(b-k)+1 )
        for(int i=a;i<=b;i++) cout<<i<<endl;
    else
    {
        for(int i=a;i<a+k;i++)
            cout<<i<<endl;
        for(int i=b-k+1;i<=b;i++)
            cout<<i<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lp;
typedef pair<ll,pair<ll,ll>> lpp;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};
typedef ModInt<1000000007> mint;

mint pow(ll a, ll n){
	mint r=1, x=a;
		while(n){
			r*=((n%2)?x:1);
			x*=x;
			n>>=1;
		}
		return r;
}

vector<mint> fact, factinv;
void nCr_computeFactinv(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	reg(i, 1, N) fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for (int i = N; i >= 1; i --) factinv[i - 1] = factinv[i] * i;
}
mint nCr(int n, int r) {
	if (n >= mint::Mod)
		return nCr(n % mint::Mod, r % mint::Mod) * nCr(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}
mint nPr(int n, int r) {
	if (r<0)return 0;
	return r > n ? 0 : fact[n] * factinv[n-r];
}
mint nHr(int n, int r) { return r == 0 ? 1 : nCr(n + r - 1, r); }

/*
*/

ll k;
string s;
mint ans;

int main(void){
	cin>>k>>s;
	nCr_computeFactinv(2000010);
	reg(i,0,k){
		ans += nCr(k+s.size()-i-1, s.size()-1) * pow((ll)25,k-i) * pow((ll)26,i);
	}
	cout<<ans.get()<<endl;
	return 0;
}

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

const int N = 1e6+5;

const int mod = 1e9 + 7;

int fac[N], rfac[N], inv[N];

int main() {
    fac[0] = rfac[0] = fac[1] = rfac[1] = 1;
    inv[0] = 0, inv[1] = 1;
    for (int i = 2; i < N; i ++) {
        fac[i] = 1ll * fac[i-1] * i % mod;
        inv[i] = 1ll * (mod / i) * (mod - inv[mod%i]) % mod;
        rfac[i] = 1ll * rfac[i-1] * inv[i] % mod;
    }
    int x, y;
    scanf("%d %d", &x, &y);
    if ((x+y) % 3) puts("0");
    else {
        int b = x - (x + y) / 3;
        int a = y - (x + y) / 3;
        if (a < 0 || b < 0) puts("0");
        else {
			cerr << a << " " << b << endl;
            int ans = 1ll * fac[a+b] * rfac[b] % mod * rfac[a] % mod;
            cout << ans << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 15460
#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
    ll k;
    cin>>k;
    ll t=0;
    ll n=0;
    while(t<1e7)
    {
        n=(n*10+7)%k;
        t++;
        if(n==0)
        {
            cout<<t<<endl;
            return 0;
        }


    }
    cout<<"-1"<<endl;
    return 0;
}

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

int main(){
  int X;
  cin >> X;
  
  while (true){
    int num = 2;
    while (num <= pow(X, 0.5)){
      if (X % num == 0){
        X++;
        break;
      }
      num++;
    }
    
    if (num > pow(X, 0.5)){
      break;
    }
  }
  
  cout << X << endl;
      
}

Measured memory_bytes: 4040
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <utility>
using namespace std;

bool binaryserch(int S[], int n, int key) {
	int left = 0;
	int right = n;
	while (left < right) {
		int mid = (left+right)/2;
		if (S[mid] == key) {
			return true;
		} else if (S[mid] > key) {
			right = mid;
		} else {
			left = mid+1;
		}
	}
	return false;
}

int main() {
	int n, q;
	int S[100010];
	scanf("%d", &n);
	for (int i=0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	int key;
	int count = 0;
	for (int i=0; i < q; i++) {
		scanf("%d", &key);
		if (binaryserch(S, n, key)) {
			count++;
		}
	}
	
	printf("%d\n", count);
	
	
	return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N, M;
  int ans = 0;
  cin >> N >> M;
  vector<vector<int> > v(N);
  vector<bool> seen(N, true);
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    v[A].pb(B);
    v[B].pb(A);
  }

  rep(i, N) {
    if (seen[i]) {
      ans++;
      int p = i;
      queue<int> que;
      que.push(p);
      seen[p] = false;
      while (!que.empty()) {
        p = que.front();
        // cout << p << ' ' << cnt << endl;
        que.pop();
        for (int i = 0; i < v[p].size(); i++) {
          int t = v[p][i];
          if (seen[t] == true) {
            que.push(t);
            seen[t] = false;
          }
        }
      }
      // cout << endl;
    }
  }
  cout << ans-1 << endl;
}


Measured memory_bytes: 8436