akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i],i+1] for i in range(26)]

	ak = 0

	for j in range(26):
		if i != 0:
			ak -= c[j] * (i-day[i-1][j]+1)
		else:
			ak -= c[j]

	ma = [-1,-1]
	for j in range(26):
		if i != 0:
			if ma[0] <= c[j] * (i-day[i-1][j]+1) + s[-1][j]:
				ma[0] = c[j] + (i-day[i-1][j]+1) + s[-1][j]
				ma[1] = j
		else:
			if ma[0] <= c[j] + s[-1][j]:
				ma[0] = c[j] + s[-1][j]
				ma[1] = j
	ans += ma[0] + ak
	sel[i] = ma[1]+1

	for j in range(26):
		if j == ma[1]:
			day[i][j] = i
		else:
			day[i][j] = day[i-1][j] if i - 1 >= 0 else 0



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i]-c[i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = po[random.randrange(10)][1]
		if sel[ima] != data:
			break
	data = data-1
	ppp = 0
	now = sel[ima]-1
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]
	ppp += s[ima][data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp -= (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	ppp -= s[ima][now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = ima - 1 if ima != 0 else 0
		for i in range(ima,365):
			if day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1
		ans += ppp

for i in sel:
	print(i)


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

int main() {

	int n; string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++) {
		int a=s[i]+n;
		if(a>90) 
			a=64+((a-64)%26);
		if((a-64)%26==0)
			a=90;
		s[i]=a;
	}
	cout<<s;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0; i<(s.length()/2); i++) {
        if (s[i]!=s[s.length()-1-i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    char op;
   int result=0;
    cin>>a>>op>>b;
    if(op=='+')
        result=a+b;
    else
        if(op=='-')
        result=a-b;
    cout<<result;
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);
    String card;
    while (!(card = reader.next()).equals("-")) {
      int n = reader.nextInt();
      for (int i = 0; i < n; i++) {
        int m = reader.nextInt();
        String card1 = card.substring(0, m);
        String card2 = card.substring(m, card.length());
        card = card2 + card1;
      }
      System.out.println(card);
    }
  }
}

Measured memory_bytes: 26504
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	ll a[n], b[n];
	for(ll i = 0; i < n; i++) cin >> a[i];
	for(ll i = 0; i < n; i++) cin >> b[i];
	ll suma = 0, sumb = 0;
	for(ll i = 0; i < n; i++){
		suma += a[i];
		sumb += b[i];
	}
	ll kaisu = sumb - suma;
	ll A = kaisu, B = kaisu;
	if(kaisu < 0){
		cout << "No\n";
		return 0;
	}
	for(ll i = 0; i < n; i++){
		if(a[i] < b[i]){
			ll sa = b[i] - a[i];
			if((b[i] - a[i]) & 1){
				B -= 1;
				sa++;
			}
			A -= sa / 2;
		}else if(b[i] < a[i]){
			B -= a[i] - b[i];
		}
		if(A < 0 || B < 0){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-12;

struct Edge {
    int id;
    int to;
    int color;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<Edge>> G(N);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back({i, b, 0});
        G[b].push_back({i, a, 0});
    }
    int cmax = 0;
    vector<bool> visited(N, false);
    queue<pair<int, int>> que;
    que.emplace(0, 0);
    visited[0] = true;
    while (!que.empty()) {
        int now = que.front().first;
        int prev_color = que.front().second;
        que.pop();
        int c = 1;
        for (int i = 0; i < (int)G[now].size(); ++i) {
            int next = G[now][i].to;
            if (visited[next]) continue;
            if (c == prev_color) ++c;
            visited[next] = true;
            G[now][i].color = c;
            que.emplace(next, c);
            cmax = max(cmax, c);
            ++c;
        }
    }
    cout << cmax << endl;
    vector<int> ans(N - 1, 0);
    for (int i = 0; i < N; ++i) {
        for (Edge p : G[i]) {
            ans[p.id] = max(ans[p.id], p.color);
        }
    }
    for (int i = 0; i < N - 1; ++i) cout << ans[i] << "\n";
    cout << endl;
}


Measured memory_bytes: 7552
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int k;
    string s;
    cin>>k;
    cin>>s;
    
    int n = s.length();
    if(n<=k)    cout<<s<<endl;
    else{
        for(int i=0;i<k;i++)    cout<<s[i];
        cout<<"...\n";
    }
    return 0;
}



Measured memory_bytes: 3652
using System;


namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string ABC = Console.ReadLine();
            string[] WHxyr = (ABC.Split(' '));
            int W = int.Parse(WHxyr[0]);
            int H = int.Parse(WHxyr[1]);
            int x = int.Parse(WHxyr[2]);
            int y = int.Parse(WHxyr[3]);
            int r = int.Parse(WHxyr[4]);
            int t, f;

            t = x + r;
            f = y + r;
            if (0 < x && 0 < y)
            {
                if (t <= W && f <= H)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 8908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100003;
const int mod =1000000007;

int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };
int n;
int a;
string s;
int main() {
	//freopen("input.txt", "r", stdin);
scanf("%d",&n);
cin>>s;
cin>>s;
ll ans=3;
int st=0,pre=0;
if(s[0]==s[1]){
	ans=6;
	pre=1;
	st=2;
}
else{
	st=1;
	pre=0;
	ans=3;
}
for(int i=st;i<s.size();i++){
	if(s[i]==s[i+1]){
		if(pre)
		ans=(ans*3)%mod;
		else
			ans=(ans*2)%mod;
		i++;
		pre=1;
	}
	else{
		if(pre)
				ans=(ans*1)%mod;
				else
					ans=(ans*2)%mod;
pre=0;

	}
}
cout<<ans%mod<<endl;

}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d\n",&n);
    int i;
    int seq[n];
    for(i=0;i<n;i++)
        scanf("%d",&seq[i]);
    int sum = 0;
    for(i=2;i<n;i++) {
        if(seq[i-1]<seq[i] && seq[i-2]<seq[i-1])
            sum++;
        else if(seq[i-1]<seq[i-2] && seq[i]<seq[i-1])
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
using System;

class program
{
    static long ans = 0;

    static void solv(long A, long B, long C)
    {
        long p, q, r;
        while (A%2==0 && B%2==0 && C%2==0)
        {
            ans++;
            p = (B + C) / 2;
            q = (C + A) / 2;
            r = (A + B) / 2;
            A = p;
            B = q;
            C = r;
        }
        return;
    }

    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split();
        long A = long.Parse(inputs[0]);
        long B = long.Parse(inputs[1]);
        long C = long.Parse(inputs[2]);

        if (A == B && B == C && A%2==0) Console.WriteLine(-1);
        else
        {
            solv(A, B, C);
            Console.WriteLine(ans);
        }
        
    }
}

Measured memory_bytes: 13140
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

void Init() {
	std::cin.tie(0); std::ios::sync_with_stdio(false);
	struct Init_caller { Init_caller() { Init(); } }caller;
}

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using ppi = pair<pi, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;
using vppi = vector<ppi>;

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

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

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 


/*****************************************************************************/
signed main(void) {
	int n, m;
	cin >> n >> m;

	vi a(m), b(m), c(m);
	f(i, 0, m) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}
	vvi d(n, vi(n, ll_INF));
	f(i, 0, n) {
		d[i][i] = 0;
	}
	f(i, 0, m) {
		d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
		d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
	}
	f(k, 0, n) {
		f(i, 0, n) {
			f(j, 0, n) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int ans = m;
	f(i, 0, m) {
		bool shortest = false;
		f(j, 0, n) {
			if (d[j][a[i]] + c[i] == d[j][b[i]]) {
				shortest = true;
			}
		}
		if (shortest) {
			ans -= 1;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
from bisect import bisect_right
import sys
input = sys.stdin.buffer.readline

class BIT:
    def __init__(self, size, values):
        self.size = size
        self.tree = [0] * (size + 1)

        self.values = values
        self.values.sort()
        self.vToI = {v: i for i, v in enumerate(self.values, start=1)}

    def lowerValueIndex(self, v):
        return self.vToI[self.values[bisect_right(self.values, v) - 1]]

    def add(self, index):
        index = self.vToI[index]
        while index <= self.size:
            self.tree[index] += 1
            index += index & (-index)

    def sum(self, index):
        index = self.lowerValueIndex(index)
        ret = 0
        while index:
            ret += self.tree[index]
            index -= index & (-index)
        return ret

    def search(self, value):
        i = 0
        s = 0
        step = 1 << (self.size.bit_length() - 1)
        while step:
            if i + step <= self.size and s + self.tree[i + step] < value:
                i += step
                s += self.tree[i]
            step //= 2
        return i + 1

N, K = map(int, input().split())
A = [int(input()) - K for _ in range(N)]

accA = [0] * (N + 1)
for i, a in enumerate(A, start=1):
    accA[i] = accA[i - 1] + a

values = accA + [10**18]
values += [-v for v in values]
values = list(set(values))
tree = BIT(len(values), values)

ans = 0
for i, a in enumerate(accA):
    ans += i - tree.sum(-a - 1)
    tree.add(-a)
print(ans)


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

using namespace std;

const int maxi = 1e6+10;
const int inf = 1e9+10;

int tree[maxi];
int lazy[maxi];
int a[maxi], b[maxi], ans[maxi];
int h, w;
int sz;

void build()
{
    sz = 1;
    while(sz<w) sz*=2;
}

void push(int node, int l, int r)
{
    int sz = r - l + 1;
    if (!lazy[node]) return;

   if (lazy[node] >= 1e6) lazy[node]*=-1;
    if (sz == 1)
    {
        tree[node] = l - lazy[node];
        lazy[node] = 0;
        return;
    }

    tree[node] = l - lazy[node];

    if (abs(lazy[node]) >= 1e6) lazy[node]*=-1;

    lazy[2*node] = lazy[node];
    lazy[2*node + 1] = lazy[node];
    lazy[node] = 0;

}

void update(int node, int tl, int tr, int l, int r, int val)
{
    push(node, tl, tr);

    if (tl>r || tr<l) return;

    if (tl>=l && tr<=r)
    {
        lazy[node] = val;
        push(node, tl, tr);
        return;
    }

    int mid = tl + tr >> 1;

    update(2*node, tl ,mid, l, r, val);
    update(2*node + 1, mid + 1, tr, l ,r , val);

    tree[node] = min(tree[2*node], tree[2*node + 1]);
}

int get(int node, int tl, int tr, int l, int r)
{
    push(node, tl, tr);

    if (tl > r || tr < l) return inf;

    if (tl >= l && tr <=r) return tree[node];

    int mid = tl + tr>>1;
    int val1 = get(2*node, tl, mid, l, r);
    int val2 = get(2*node + 1, mid + 1, tr, l, r);

    tree[node] = min(tree[2*node], tree[2*node + 1]);

    return min(val1, val2);
}


int main()
{
   cin>>h>>w;

   for (int i = 1;i<=h;i++)
    scanf("%d%d",&a[i],&b[i]);

   build();

   for (int i = 1;i<=h;i++)
   {
      int val;
      if (a[i] == 1) val = inf; else { val = get(1, 1, sz, a[i]-1, a[i]-1);}

      val = a[i] -1 - val;

      update(1, 1, sz, a[i], b[i], val);

      ans[i] = get(1, 1, sz, 1, w) + i;

      if (ans[i] >= 1e6) ans[i] =  -1;
   }

   for (int i = 1;i<=h;i++)
    printf("%d\n", ans[i]);
}


Measured memory_bytes: 9156
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  var waitTime = calc();
  for(var i = 0, len = input.length - 1; i < len;i++){
    console.log(waitTime[parseInt(input[i], 10)]);
  }
}

function calc(){
  var seats = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  var groupMembers = [2,5,2,2,2];
  var eatTimes = [19,39,25,36,22,42];
  
  var headGroup = -1;
  var pastMinutes = 0;
  var waitTime = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  var lastMembers = 100;
  
  while(true){
    // たべおわる
    var i;
    for(i = 17; i--;){
      seats[i] = max(--seats[i], 0);
    }
    
    // 来店
    if(headGroup == -1 && pastMinutes % 5 == 0){
      headGroup = pastMinutes / 5;
    }
    
    // ちゃくせき
    while(headGroup != -1 && i != 17){
      var needsSequencialSeats = groupMembers[headGroup % 5];
      var sequencialSeats = 0;
      var startIndex = -1;
      
      for(i = 0, len = seats.length; i < len; i++){
        sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;
        
        if(sequencialSeats == needsSequencialSeats){
          var eatTime = eatTimes[headGroup % 6];

          startIndex = i - (needsSequencialSeats - 1);
          // すわれるみたい
          waitTime[headGroup] = pastMinutes - (headGroup * 5);
          for(var j = startIndex, len = (needsSequencialSeats + startIndex); j < len; j++){
            seats[j] = eatTime;
          }
          
          headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
          if(!(--lastMembers)){
            // 100グループ着席
            return waitTime;
          }
          break;
        }
      }
    }
    
    pastMinutes++;
  }
  
}

function max(a, b){
  var t = (a - b);
  return a - (t & (t >> 31));
}

Measured memory_bytes: 8436
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s[0]!=s[1] &&s[1]!=s[2] && s[2]!=s[0]){
        cout<<"Yes"<<endl;
    }// Your code here!
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 256
n = int(input())
s = ["0"] + sorted(list(input()))
for _ in range(n - 1):
    t = ["0"] + sorted(list(input()))
    u = []
    p = s.pop()
    q = t.pop()
    while True:
        if p == "0" or q == "0":
            s = ["0"] + sorted(u)
            break
        if p == q:
            u.append(p)
            p = s.pop()
            q = t.pop()
        elif p > q:
            p = s.pop()
        else:
            q = t.pop()
s.remove("0")
print("".join(s))

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
res = 0
new_color = max(a) + 1
for i in range(1, len(a) - 1):
    prev_slime = a[i - 1]
    next_slime = a[i + 1]
    if a[i] == prev_slime and a[i] == next_slime:
        a[i] = new_color
        new_color += 1
        res += 1
for i in range(1, len(a)):
    prev_slime = a[i - 1]
    if a[i] == prev_slime:
        a[i] = new_color
        new_color += 1
        res += 1
print(res)


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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll n,x,t;
    cin >> n >> x >> t;
    ll a=n/x;
    if(n%x!=0)
    {
        a++;
    }
    cout << a*t << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  string alpha = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < alpha.size() - 1; i++) {
    if (c == alpha.at(i)) {
      cout << alpha.at(i + 1) << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int ans = 0;
	string s;
	cin >> s;

	for (auto c: s) {
		ans += c == '+' ? 1 : -1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define  oo 1e15
#define limit (int)(1e9+7)
#define two pair<int,int>
#define ll long long int
#define int long long int
#define double long double
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define speedforces std::ios::sync_with_stdio(false)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file  freopen("output.txt", "w", stdout);

int n;
int arr[22][22];
int dp[22][1ll<<21];

int solve(int i,int bitmask){
  if(dp[i][bitmask] != -1) return dp[i][bitmask];
  //show(i,bitmask);
  if(i == 1){
     for(int j=0;j<n;j++)
      if(arr[i][j+1] == 1 && (bitmask&(1ll<<j))) return dp[i][bitmask] = 1;
     return dp[i][bitmask] = 0;
  }
  dp[i][bitmask] = 0;
  for(int j=0;j<n;j++){
    int x = 1ll<<j;
    if(arr[i][j+1] == 1 && (bitmask&x))
     dp[i][bitmask] += solve(i-1,bitmask-x);
     dp[i][bitmask] %= limit;
  }
  //show(dp[i][bitmask]);
  return dp[i][bitmask];
}

signed main(){
  //input_from_file;
  cin>>n;
  int x = (1ll<<n)-1;
  for(int i=1;i<=n;i++)
  for(int j=1;j<=n;j++) cin>>arr[i][j];
  for(int i=0;i<=n;i++)
  for(int j=0;j<=x;j++) dp[i][j] = -1;
  cout<<solve(n,x)<<endl;
}


Measured memory_bytes: 360704
#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    int s_size = s.size();
    long int k;
    scanf("%ld", &k);
    
    for(int i = 0; i < s_size; i++){
        if(s[i] != '1'){
            cout << s[i] << '\n';
            return 0;
        }else{
            if(i == k - 1){
                cout << '1' << '\n';
                return 0;
            }
        }
    }
    
    
}

Measured memory_bytes: 256
def main():
    from math import ceil
    N = int(input())
    while N != 0:
        dp = [0] * (N+1)
        dp[0] = 1
        for i in range(1, N + 1):
            res = 0
            for j in range(1, 4):
                if i-j < 0:
                    continue
                res += (dp[i - j])
            dp[i] = res
        print(ceil(ceil(dp[-1]/10) / 365))
        N = int(input())


if __name__ == '__main__':
    main()



Measured memory_bytes: 5664
#include <stdio.h>
#include <math.h>

int main()
{
    int A, B, C, K;
    int max;
    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &K);
    max = A;
    if (max < B) max = B;
    if (max < C) max = C;
    printf("%d", A+B+C+(int)(pow(2,K)-1)*max);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ab(M), ba(M);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        ab.at(i) = make_pair(a, b);
        ba.at(i) = make_pair(b, a);
    }
    sort(ab.begin(), ab.end());
    sort(ba.begin(), ba.end());
    reverse(ba.begin(), ba.end());
    
    vector<bool> keiyu(N);
    int i = 0;
    while(i<M && ab.at(i).first==0) {
        keiyu.at(ab.at(i).second) = true;
        i++;
    }
    i = 0;
    string ans = "IMPOSSIBLE";
    while(i<M && ba.at(i).first==N-1) {
        if(keiyu.at(ba.at(i).second)) ans = "POSSIBLE";
        i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3456
c=[]
d=[0,0,0,0]
for i in range(3):
  a,b=map(int,input().split())
  c.append(a)
  c.append(b)

for i in range(6):
  d[c[i]-1]+=1
d.sort()
if d==[1,1,2,2]:
  print("YES")
else:
  print("NO")

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

int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
int main(){
    using namespace std;
    long long int a,b;
    cin >> a >> b;
    long long int ans1,ans2;
    double ans3;
    ans1 = a/b;
    ans2 = a%b;
    ans3 = (double)a/b;
    cout << ans1 << " " << ans2 << " " << fixed << setprecision(12) <<  ans3 << endl;
    return 0;
}

Measured memory_bytes: 3272
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h = inn()
w = inn()
n = inn()
m = max(h,w)
print((n+m-1)//m)


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Y;
    cin >> N >> Y;
    rep(i, N + 1) {
        REP(j, 0, N - i) {
            REP(k, 0, N - (i + j)) {
                if (i + j + k != N) continue;
                if (i * 10000 + j * 5000 + k * 1000 == Y) {
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    List<Statement>[] statements = new List[N];
    for (int i = 0; i < N; i++) statements[i] = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt();
      for (int j = 0; j < a; j++) {
        int x = scanner.nextInt() - 1;
        int h = scanner.nextInt();
        statements[i].add(new Statement(x, h == 1));
      }
    }

    int max = 0;
    for (int i = 0; i < 1 << N; i++) if (possible(i, N, statements)) max = Math.max(max, Integer.bitCount(i));
    System.out.println(max);
  }

  private static boolean possible(int a, int N, List<Statement>[] statements) {
    for (int i = 0; i < N; i++) {
      if ((1 & (a >> i)) == 1) {
        for (Statement s : statements[i]) {
          if (s.h && (1 & (a >> s.x)) != 1) return false;
          if (!s.h && (1 & (a >> s.x)) != 0) return false;
        }
      }
    }
    return true;
  }

  private static class Statement {
    private final int x;
    private final boolean h;

    private Statement(int x, boolean h) {
      this.x = x;
      this.h = h;
    }
  }
}


Measured memory_bytes: 28116
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
	int a[100005],n,i,j;
	cin>>n;
	memset(a,0,sizeof(a));
	int big=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x>big)
		big=x;
		a[x]++;
		if(x>=1)
		a[x-1]++;
		a[x+1]++;
	}
	int zd=0;
	for(int i=0;i<=big+1;i++)
		if(a[i]>zd)
			zd=a[i];
	cout<<zd<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
int n,c=0,i,j,a=0;
cin>>n;
for(i=n;i>0;i--){
        j=i;
while(j>0)
{
j=j/10;
a++;
}
if(a%2==1){
    c++;
}
a=0;}
cout << c;
return 0;
}


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

int main() {
  double a,b,x,p=3.141592653589;
  cin>>a>>b>>x;
  double v=a*a*b,TAN;
  if(x<=v/2) TAN = (2*x)/(a*b*b);
  else TAN = (a*a*a)/(2*(a*a*b-x));
  cout<<setprecision(12)<<90-atan(TAN)*180/p;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lps(i,j,n) for(int i=j;i<n;i++)
#define lp(i,n) lps(i,0,n)
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long

pair<int,int> l[1000001],l2[1000001];

int nx[501],ny[501],ux[501],uy[501],nn1,nn2,uu1,uu2;

signed main(){
  int n,u,v,m;
  cin>>n>>u>>v>>m;
  lp(z,2){
    lp(i,n){
      lp(j,n){
	int a;
	cin>>a;
	if(z==0){
	  l[a]=make_pair(i+1,j+1);
	}
	if(z==1){
	  l2[a]=make_pair(i+1,j+1);
	}
      }
    }
  }
  int us=0,nek=0,stat=0;
  lp(i,m){
    int a;
    cin>>a;
    if(stat==1) continue;
    pair<int,int> usrg=l[a];
    pair<int,int> nekrg=l2[a];
    if(usrg.first!=0||usrg.second!=0){
      ux[usrg.first]++;
      if(ux[usrg.first]==n) us++;
      uy[usrg.second]++;
      if(uy[usrg.second]==n) us++;
      if(usrg.first==usrg.second){
	uu1++;
	if(uu1==n) us++;
      }
      if(usrg.first+usrg.second==n+1){
	uu2++;
	if(uu2==n) us++;
      }
    }
    if(nekrg.first!=0||nekrg.second!=0){
      nx[nekrg.first]++;
      if(nx[nekrg.first]==n) nek++;
      ny[nekrg.second]++;
      if(ny[nekrg.second]==n) nek++;
      if(nekrg.first==nekrg.second){
	nn1++;
	if(nn1==n) nek++;
      }
      if(nekrg.first+nekrg.second==n+1){
	nn2++;
	if(nn2==n) nek++;
      }
    }
    if(n==1){
      if(nek!=0) nek=1;
      if(us!=0) us=1;
    }
    if(us>=u&&nek<v){
      cout<<"USAGI"<<endl;
      stat=1;;
    }
    if(us>=u&& nek>=v){
      cout<<"DRAW"<<endl;
      stat=1;
    }
    if(us<u&&nek>=v){
      cout<<"NEKO"<<endl;
      stat=1;
    }
    //cout<<us<<" "<<nek<<endl;
  }
  if(stat==0){
    cout<<"DRAW"<<endl;
  }
  return 0;
  
}



Measured memory_bytes: 34360
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

void inspect(vector<int> hoge){
	int s = hoge.size();
	for(int i=0; i<=s-1; i++){
		cout << hoge[i];
	}
	cout << endl;
	return;
}

int pow(int n){
	return n*n;
}


int main (){
	double mysum = 0;
	int pnum = 0;
	int num_town;
	cin >> num_town;
	vector< vector<int> > towns(num_town);
	for(int i=0; i<=num_town-1; i++){
		(towns[i]).resize(2);
		scanf("%d %d",&(towns[i][0]),&(towns[i][1]));
	}
	vector<int> perm(num_town);
	for(int i=0; i<=num_town-1; i++){
		perm[i] = i;
	}
	
	for(int i=0; i<=num_town-1; i++){
		//cout << towns[i][0] << " " << towns[i][1] << endl;
	}
	do {
		//inspect(perm);
		pnum++;
		for(int i=0; i<=num_town-2; i++){

			double summand = sqrt(pow(towns[perm[i+1]][0] - towns[perm[i]][0]) + pow(towns[perm[i+1]][1] - towns[perm[i]][1]) );
			mysum += summand;
			//cout << summand << endl;
		}
	} while (next_permutation(perm.begin(), perm.end()));
	printf("%10.10lf",mysum /((double)pnum));
	//cout << pnum << endl;

  return 0;
}


Measured memory_bytes: 888
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def prime_decomposition(n):
  i = 2
  d = {}
  while i * i <= n:
    while n % i == 0:
      n //= i
      if i not in d:
          d[i] = 0
      d[i] += 1
    i += 1
  if n > 1:
    if n not in d:
        d[n] = 1
  return d

def eratosthenes(n):
    if n < 2:
        return []
    prime = []
    limit = n**0.5
    numbers = [i for i in range(2,n+1)]
    while True:
        p = numbers[0]
        if limit <= p:
            return prime + numbers
        prime.append(p)
        numbers = [i for i in numbers if i%p != 0]
    return prime

def ok(p):
    if A[0]%p != 0:
        return False
    B = [A[i]%p for i in range(1,N+1)]
    mod = [0]*(p-1)
    for i in range(N):
        mod[i%(p-1)] += B[i]
        mod[i%(p-1)] %= p
    return sum(mod)==0

N = int(input())
A = [int(input()) for i in range(N+1)][::-1]
g = abs(A[0])
for a in A:
     g = gcd(g,abs(a))
d = prime_decomposition(g)
ans = [p for p in d]

prime = eratosthenes(N+1)

for p in prime:
    if ok(p):
        ans.append(p)

ans = list(set(ans))
ans.sort()

for p in ans:
    print(p)

Measured memory_bytes: 59224
import itertools
# H, W = [int(_) for _ in input().split()]
N = int(input())

comb = itertools.combinations_with_replacement([str(i) for i in range(1, 10)], 2)
count = 0
for c in comb:
    A = c[0]
    B = c[1]
    count_1 = 0
    count_2 = 0
    for i in range(1, N+1):
        if str(i)[0] == A and str(i)[-1] == B:
            count_1 += 1
        elif str(i)[0] == B and str(i)[-1] == A:
            count_2 += 1
    if A == B:
        count += count_1 ** 2
    else:
        count += count_1 * count_2 * 2
print(count)


Measured memory_bytes: 45404
/*
 * @Autor: valk
 * @Date: 2020-07-17 16:50:40
 * @LastEditTime: 2020-09-19 21:21:45
 * @Description: 如果邪恶  是华丽残酷的乐章 它的终场 我会亲手写上 晨曦的光 风干最后一行忧伤 黑色的墨 染上安详
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#define emplace_back push_back
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int seed = 12289;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;

vector<int> vec[N], pos[N];
int arr[N];
int __gcd(int x, int y)
{
    if (x % y == 0)
        return y;
    return __gcd(y, x % y);
}

int vis[N], pri[N], tot;
void solve(int n)
{
    for (int i = 2; i <= n; i++) {
        if (!vis[i])
            pri[++tot] = i;
        for (int j = 1; j <= tot; j++) {
            if (i * pri[j] > n)
                break;
            vis[i * pri[j]] = pri[j]; //纪录最小的素因子
            if (i % pri[j] == 0)
                break;
        }
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    solve(1000010);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &arr[i]);
    }
    int flag = 1;
    for (int i = n; i; i--) {
        int temp = arr[i];
        int sign = 1;
        for (int j = 2; j * j <= temp; j++) {
            if (temp % j == 0) {
                pos[j].pb(i);
                if (pos[j].size() != 1) {
                    sign = 0;
                    break;
                }
                while (temp % j == 0) {
                    temp /= j;
                }
            }
        }
        if (temp > 1) {
            pos[temp].pb(i);
            if (pos[temp].size() != 1) {
                sign = 0;
            }
        }
        if (sign == 0) {
            flag = 0;
            break;
        }
    }
    int gcd = arr[1];
    for (int i = 1; i <= n; i++) {
        gcd = __gcd(gcd, arr[i]);
    }
    if (flag == 0 && gcd == 1) {
        puts("setwise coprime");
    } else if (flag == 1) {
        puts("pairwise coprime");
    } else {
        puts("not coprime");
    }
    return 0;
}

Measured memory_bytes: 58088
#include <bits/stdc++.h>
#include <time.h>
#define first fi
#define second se


using namespace std;

typedef long long ll;
typedef double db;
int xx[4] = {1,-1,0,0};
int yy[4] = {0,0,1,-1};
const double eps = 1e-9;
typedef pair<int,int>  P;
const int maxn = 2e6 + 5000;
const ll mod = 1e9 + 7;
inline int sign(db a) { return a < -eps ? -1 : a > eps;}
inline int cmp(db a,db b){ return sign(a - b);}
ll mul(ll a,ll b,ll c) { ll res = 1; while(b) {  if(b & 1) res *= a,res %= c;  a *= a,a %= c,b >>= 1;  }  return res;}
ll phi(ll x) {  ll res = x;  for(ll i = 2; i * i <= x; i++) { if(x % i == 0) res = x / i * (i - 1);   while(x % i == 0) x /= i;   }  if(x > 1) res = res / x  * (x - 1);    return res;}
ll c,n,k;
int main() {
    ios::sync_with_stdio(false);
    ll a,b;
    while(cin >> a >> b >> k){
            int num = 0;
        for(ll i = min(a,b); i >= 1;i--){
            if(a % i == 0 && b % i == 0) num++;
            if(num == k){
                cout << i << endl;
                break;
            }
        }
    }
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 256
l,r=map(int,input().split())
n=2019

if r-l>=2019:
    print(0)
    exit()
else:
    x=[]
    for p in range(l,r):
        if p%n==0:
            print(0)
            exit()
        else:
            for q in range(p+1,r+1):
                x.append(p*q%n)
print(min(x))


Measured memory_bytes: 75380
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;

vector<vector<int>> g(55);

void dfs(int u,P M,vector<bool> &memo){
  memo[u]=1;
  rep(i,g[u].size()){
    int to=g[u][i];
    P p1={u,to};
    P p2={to,u};
    if(memo[to]||p1==M||p2==M) continue;
    dfs(to,M,memo);
  }
}

int main(){
  int n,m; cin>>n>>m;
  vector<P> M(m);

  rep(i,m){
    int u,v; cin>>u>>v;
    u--;v--;
    M[i]={u,v};
    g[u].push_back(v);
    g[v].push_back(u);
  }

  int ans=0;
  rep(i,m){
    vector<bool> memo(n,0);
    dfs(0,M[i],memo);
    rep(j,n){
      if(!(memo[j])){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c > 21) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  writeln(readln.chomp.uniq.array.length==1?"No":"Yes");
}


Measured memory_bytes: 256
import std.stdio;

int[111] book;
int n, m;

void main(){
	int left, right, mid;
	while (readf("%d %d\n", &m, &n), [m,n] != [0, 0]) {
		foreach (i; 0..n) readf("%d\n", &book[i]);
		left = 0;
		right = 1500000;
		while (left < right - 1) {
			mid = (left + right) / 2;
			if (countShelf(mid) > m) left = mid; 
			else right = mid;
		}
		writeln(right);
	}
}

int countShelf(int mid){
	int sum = 0;
	int res = 1;
	foreach (i; 0..n) {
		if (book[i] > mid) return 9999999;
		if (sum + book[i] > mid) {
			res++;
			sum = 0;
		}
		sum += book[i];
	}
	return res;
}

Measured memory_bytes: 1012
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cassert>


using namespace std;
using ll = long long int;

#define rep(i, n) for(ll i = 0; i < (n); i++)
#define MOD 1000000007LL


ll pow(ll n, ll k) {
  ll r = 1;

  while (k > 0) {
    if (k % 2 == 1) {
      r = r * n % MOD;
    }
    n = n * n % MOD;
    k /= 2;
  }
  return r;
}

ll fac[3000000];

ll inv(ll x) {
  return pow(x, MOD - 2);
}


ll C(ll n, ll k) {
  if (k > 0) {
    return fac[n] * inv(fac[n - k]) % MOD * inv(fac[k]) % MOD;
  } else {
    return 1;
  }
}

void solve(ll k, ll n) {
  ll ans = 0;
  rep(i, k+1) {
    ll c = C(i + n - 1, n - 1);
    ll p25 = pow(25, i);
    ll p26 = pow(26, k - i);
    ll tmp = p25 * c % MOD * p26 % MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  ll K;
  string S;
  ll N;
  cin >> K >> S;
  N = S.size();

  fac[0] = 1;
  ll f = 1;
  for (ll i = 1; i < 3000000; i++) {
    f *= i;
    f %= MOD;
    fac[i] = f;
  }

  solve(K, N);
  return 0;
}

Measured memory_bytes: 27620
a = []
b = []
c = []
a = gets.split.map(&:to_i)
for i in 0..a[0]-1
  b.push(gets.chomp.split.map(&:to_i))
end
for j in 0..a[1]-1
  c.push(gets.chomp.split.map(&:to_i))
end
#p b
#p c
for i in 0..a[0]-1 #人
  f = 0
  l = 4 * (10 ** 8)
  cnt = 0
  (0..a[1]-1).reverse_each do |j|
    f = (b[i][0]-c[j][0]).abs + (b[i][1] - c[j][1]).abs
    #puts "#{i} #{j}"
    #puts "#{b[i][0]} #{c[j][0]} #{b[i][1]} #{c[j][1]}"
    #puts c[0][0]
    
    if f <= l 
      #puts f
      #puts l
      l = f
      cnt = j + 1
      #puts "t"
    end
    #puts "#{j} j"
  end
  puts cnt
end
  

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, m, p, d[100010], ans = INF;

int main() {
	cin >> n >> m >> p;
	for (int i = 0;i < m;i++) {
		cin >> d[i];
	}
	if (m == 1) {
		if (d[0] > p)cout << min(d[0] - p, p + n - d[0]) * 100 << endl;
		else cout << min(p - d[0], n + d[0] - p) * 100 << endl;
		return 0;
	}
	sort(d, d + m);
	if (lower_bound(d, d + m, p) - d == 0)ans = min(d[m - 1] - p, p + n - d[0]);
	else if (lower_bound(d, d + m, p) - d == m)ans = min(p - d[0], n - p + d[m - 1]);
	else {
		ans = min(ans, n - p + d[lower_bound(d, d + m, p) - d - 1]);
		ans = min(ans, p + n - d[lower_bound(d, d + m, p) - d]);
	}
	for (int i = 0;i < m;i++) {
		if (p > d[i]) {
			if (i == 0&& lower_bound(d, d + m, p) - d != m)ans = min(ans, min(p - d[i], d[(i + m - 1) % m] - p) * 2 + max(p - d[i], d[(i + m - 1) % m] - p));
			else ans = min(ans, min(p - d[i], d[(i + m - 1) % m] + n - p) * 2 + max(p - d[i], d[(i + m - 1) % m] + n - p));
		}
		else {
			if (i == m - 1&& lower_bound(d, d + m, p) - d != 0)ans = min(ans, min(d[i] - p, p + n - d[(i + 1) % m]) * 2 + max(d[i] - p, p + n - d[(i + 1) % m]));
			else ans = min(ans, min(d[i] - p, p + n - d[(i + 1) % m]) * 2 + max(d[i] - p, p + n - d[(i + 1) % m]));
		}
	}
	cout << ans * 100 << endl;
	return 0;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
int main(void){
    string s;cin>>s;
    ll r=0,b=0;
    rep(i,s.size()){
        if(s[i]=='0')r++;
        else b++;
    }
    ll res=min(r,b);
    cout<<res*2<<endl;
}


Measured memory_bytes: 512
#include <cstdio>


int load(int n,int k,int p,int *arr) {
	int sum = 0;
	int i = 0;
	for (int j = 0;j<k;j++) {
		while (i < n && sum + arr[i] <= p) {
			sum += arr[i];
			i++;
		}
		sum = 0;
	}
	return i;
}

int main() {
	int n,k;
	scanf("%d %d",&n,&k);
	int *arr = new int[n];
	for (int i=0;i<n;i++) {
		scanf("%d",arr+i);
	}
	
	long left = 1,right = 1000000000;
	while (left < right) {
		long m = (left + right) / 2;
		int r = load(n,k,m,arr);
		if (r < n) {
			left = m+1;
		} else if (r == n) {
			right = m;
		}
	}
	printf("%d\n",right);
} 


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	cin>>x;
	int k=x/100;
	for(int i=1;i<=k;i++){
		int tmp=x-i*100;
		int tt;
		if(tmp%5==0){
			tt=tmp/5;
		}else{
			tt=tmp/5+1;
		}
		if(tt<=i){
			cout<<1;
			return 0;
		}
	}
	cout<<0;
	return 0;
}

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())
ans=0
tmp=[str(100*a),'0']
for i in range(1,2**4):
  l=[0]*4
  water=0
  sugar=0
  for j in range(4):
    if i>>j&1:
      l[j]=1
  if l[0]==1:
    water+=100*a
  if l[1]==1:
    water+=100*b
  if water==0:
    pass
  else:
    rest=f-water
    if rest<=0 or (l[2]==l[3]==0):
      pass
    else:
      max_sugar=e*(water//100)
      if l[2]==1 and l[3]==0:
        sugar+=c*(min(rest,max_sugar)//c)
      elif l[3]==1 and l[2]==0:
        sugar+=d*(min(rest,max_sugar)//d)
      elif l[2]==l[3]==1:
        d_max=min(rest,max_sugar)//d
        t=d*d_max
        for i in range(d_max,-1,-1):
          REST=rest-i*d
          Max_sugar=max_sugar-i*d
          t_max=i*d+c*(min(REST,Max_sugar)//c)
          t=max(t,t_max)
        sugar+=t
      tot=sugar+water
      if sugar/tot>ans:
        ans=sugar/tot
        tmp=[str(tot),str(sugar)]
print(' '.join(tmp))

Measured memory_bytes: 3064
from operator import itemgetter

N, M = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(N)]

# N = 2
# M = 5
# A = [[4, 9], [2, 4]]

A.sort(key=itemgetter(0))

sum = 0
for shop in A:
    num = min(shop[1], M)
    sum += shop[0] * num
    M -= num
    # print(num, shop[0] * num, M)

    if M <= 0:
        break
print(sum)


Measured memory_bytes: 22824
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
//#include "mylibrary.hpp"



using namespace std;

string S;
int S_len;
bool check_kaibun(int  begin, int end){
    int middle = (end - begin)/2;
    for(int i=begin; i<=middle; i++){
        if(S[i] != S[end-i]) return false;
    }
    return true;
}

int main(){
    cin >> S;
    S_len = (int)S.length();
    bool flag1,flag2,flag3;
    flag1 = check_kaibun(0,S_len-1);
    flag2 = check_kaibun(0,((S_len/2)-1));
    flag3 = check_kaibun((S_len/2)+1, S_len-1);
    
    if(flag1 && flag2 && flag3){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main() {
  ll N, K, S;
  cin >> N >> K >> S;
  vector<ll> A(N);
  if (S != 1000000000) {
    rep(i, N) {
      if (i < K) {
        A[i] = S;
      } else {
        A[i] = S + 1;
      }
    }
  } else {
    rep(i, N) {
      if (i < K) {
        A[i] = S;
      } else {
        A[i] = 1;
      }
    }
  }
  rep(i, N) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll arr[n];
    for (ll i=0;i<n;i++)
        cin>>arr[i];
    ll rem,tmp,cur=1000;
    for (ll i=1;i<n;i++){
        if (arr[i]>=arr[i-1]){
            tmp=cur/arr[i-1];
            rem=cur%arr[i-1];
            cur=(tmp*arr[i])+rem;
        }
    }
    cout<<cur;

    return 0;
}


Measured memory_bytes: 3628