akhauriyash/Code-Regression huggingface dataset:
import math

def CalcCoordinate(xa, ya, xb, yb):
    arg = math.atan2(yb-ya, xb-xa) #角度
    d = math.sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya)) #AとBの距離
    xc = d/2 #ピタゴラスの定理より
    #S = math.sqrt(3)*d*d/2
    #正三角形にヘロンの公式を適用(3辺の長さが同じなので3*d)
    yc = math.sqrt(3)*d/2

    #if(yb <= ya):
    ux = xc*math.cos(arg) - yc*math.sin(arg) + xa
    uy = xc*math.sin(arg) + yc*math.cos(arg) + ya
    return ux, uy
    """
    else:
        ux = xc*math.cos(arg) + yc*math.sin(arg) + xa
        uy = xc*math.sin(arg) - yc*math.cos(arg) + ya
        return ux, uy
"""

def MakeTriangle(x1, y1, x2, y2, n):
    if(n != 0):
        sx = (2*x1 + x2) / 3
        sy = (2*y1 + y2) / 3
        tx = (x1 + 2*x2) / 3
        ty = (y1 + 2*y2) / 3
        ux, uy = CalcCoordinate(sx, sy, tx, ty)
        MakeTriangle(x1, y1, sx, sy, n-1)
        print(sx, sy)
        MakeTriangle(sx, sy, ux, uy, n-1)
        print(ux, uy)
        MakeTriangle(ux, uy, tx, ty, n-1)
        print(tx, ty)
        MakeTriangle(tx, ty, x2, y2, n-1)
    else:
        return
        
  

x1 = 0
y1 = 0
x2 = 100
y2 = 0

n = int(input())

print(x1, y1)
MakeTriangle(x1, y1, x2, y2, n)
print(x2, y2)


Measured memory_bytes: 5848
#include <queue>
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
#include <set>
using namespace std;

const int calc(const string &s){
  const int a = s[0] - '0';
  const int b = s[1] - '0';
  const int c = s[3] - '0';
  const int d = s[4] - '0';
  return (a * 10 + b) * 60 + (c * 10 + d);
}

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

  string prev_name = "";
  int prev_time = -1;

  vector<pair<string, int> > ans;

  REP(i,n){
    string st_time, st_name, ar_time, ar_name;
    cin >> st_time >> st_name >> ar_time >> ar_name;

    const int st = calc(st_time);
    const int ar = calc(ar_time);

    if(prev_time != -1 && st - prev_time >= t)
      ans.push_back(make_pair(st_name, st - prev_time));

    prev_time = ar;
  }

  cout << ans.size() << endl;

  REP(i,ans.size()){
    const pair<string, int> a = ans[i];
    cout << a.first << " " << a.second << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val n: Long = line.toLong()
    val line2 = readLine()!!.trim()
    val nums: List<Long> = line2.split(" ").map {it.toLong()}.take(n.toInt())

    var prod: Long = 1L

    var maxNum: Long = 1L
    for (i in (0..17)) {
        maxNum *= 10L
    }

    if (nums.size == 0 || nums.contains(0L)) {
        prod = 0L
    } else {
        for (i in nums) {

            // val resultKeta: Int = result.toString().length
            // val iKeta: Int = i.toString().length

            if (i > maxNum / prod) {
                prod = -1
                break
            }

            prod *= i
        }

    }


    println(prod)
}

Measured memory_bytes: 63324
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s;
  cin>>t;
  int ans=1000; 
  for (int i = 0;i<s.size()-t.size()+1; i++) { 
      int x= 0; 
      for (int j = 0; j <t.size(); j++) { 
          if (t[j] != s[i+j])
              x++;
        }
    ans=min(x,ans);
	}
  cout<<ans;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int dp[1010][(1<<12) + 10];

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<int> c(m, 0);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        for (int j = 0; j < b[i]; ++j) {
            int c_;
            cin >> c_;
            c_--;
            c[i] |= (1<<c_);
        }
    }

    for (int i = 0; i <= m; ++i) {
        for (int j = 0; j < (1<<n); ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < (1<<n); ++j) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j|c[i]], dp[i][j] + a[i]);
        }
    }
    int res = dp[m][(1<<n) - 1];
    cout << (res == INF ? -1 : res) << endl;
}

Measured memory_bytes: 19584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		x *= 2;
		for (int i = 1; i < x; i++) {
			if (i * (i + 1) >= x) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int D;
VI c(26);
VVI s;
VI t;
VI best;
ll sc;
set<int> days[26];

const double TIME_LIMIT = 1.8;
clock_t time_start;

inline uint32_t rnd(void) {
    static uint32_t y = 2463534242;
    y = y ^ (y << 13);
    y = y ^ (y >> 17);
    return y = y ^ (y << 5);
}

void read_input() {
    cin >> D;
    for (int i = 0; i < 26; i++) cin >> c[i];
    s = VVI(D, VI(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) cin >> s[i][j];
    }
}

void init() {
    for (int i = 0; i < 26; i++) days[i].insert(-1);
    for (int i = 0; i < D; i++) {
        days[t[i]].insert(i);
    }
    for (int i = 0; i < 26; i++) days[i].insert(D);
}

void init_by_input() {
    t = VI(D);
    for (int i = 0; i < D; i++) {
        cin >> t[i];
        t[i]--;
    }
    for (int i = 0; i < 26; i++) days[i].insert(-1);
    for (int i = 0; i < D; i++) {
        days[t[i]].insert(i);
    }
    for (int i = 0; i < 26; i++) days[i].insert(D);
}

void init_by_greedy() {
    t = VI(D);
    ll sum_sc = 0;
    set<int> se[26];
    for (int i = 0; i < 26; i++) se[i].insert(-1);
    for (int i = 0; i < D; i++) {
        ll dif = 0;
        for (int j = 0; j < 26; j++) {
            dif -= c[j] * (i - *se[j].rbegin());
        }
        sum_sc += dif;
        ll dm = -inf;
        int fl = -1;
        for (int j = 0; j < 26; j++) {
            if (chmax(dm, s[i][j] + c[j] * (i - *se[j].rbegin()))) fl = j;
        }
        t[i] = fl;
        se[fl].insert(i);
    }
}

ll calc_score() {
    ll plus = 0;
    ll minus = 0;
    for (int i = 0; i < D; i++) {
        plus += s[i][t[i]];
    }
    for (int i = 0; i < 26; i++) {
        for (auto it = ++days[i].begin(); it != days[i].end(); ++it) {
            int lapse = *it - (*--it);
            minus += c[i] * lapse * (lapse - 1) / 2;
            ++it;
        }
    }
    return plus - minus;
}

void output() {
    for (int i = 0; i < D; i++) {
        cout << t[i] + 1 << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    time_start = clock();
    read_input();
    // init_by_input();
    init_by_greedy();
    init();
    output();
    // cout << calc_score() << endl;
}

Measured memory_bytes: 3792
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

int n,m;
vector<vector<int>> edges;
vector<int> visited,dist,indeg;

void dfs(int x){
    visited[x] = 1;
    for(int y : edges[x]){
        dist[y] = max(dist[y],dist[x]+1);
        indeg[y]--;
        if(indeg[y]==0)
            dfs(y);
    }
}


void mymain(){
  cin >> n >> m;
  edges.resize(n+1,vi());
  visited.resize(n+1,0);dist.resize(n+1,0);indeg.resize(n+1,0);
  for(int i=0;i<m;i++){
    int x,y;
    cin >> x >> y;
    edges[x].pb(y);
    indeg[y]++;
  }
  for(int i=1;i<=n;i++)
    edges[0].pb(i);
  for(int i = 1;i<=n;i++){
    if(!visited[i] && indeg[i] == 0){
        dfs(i);
    }
  }
    int ans = -1;
    for(int i=1;i<=n;i++)
        ans = max(ans,dist[i]);
    cout << ans << endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


Measured memory_bytes: 12148
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int> a(1000001);
  int k;
  cin >> k;
  a[1] = 7 % k;
  for(int i = 2; i <= 1000000; i++){
    a[i] = (a[i - 1] * 10 + 7) % k;
  }
  for(int i = 1; i <= 1000000; i++){
    if(a[i] == 0){
      cout << i <<endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 7036
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <set>

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	A();

}

void A() {

	string day;
	cin >> day;

	int daysAways = 0;
	
	if (day == "SUN") daysAways = 7;
	if (day == "MON") daysAways = 6;
	if (day == "TUE") daysAways = 5;
	if (day == "WED") daysAways = 4;
	if (day == "THU") daysAways = 3;
	if (day == "FRI") daysAways = 2;
	if (day == "SAT") daysAways = 1;


	int result = 0;


	cout << daysAways << endl;

	
}

void B() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void C() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void D() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void E() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void F() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}



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

using namespace std;

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

  T = S;
  // sort(S.begin(), S.end());
  
  // int alpha[26] = {};
  // for(int i = 0; i < S.size(); i++) {
  //   if(S[i] == 'x') continue;
  //   alpha[S[i] - 'a']++;
  // }

  // bool flag = false;
  // for(int i = 0; i < 26; i++) {
  //   if(alpha[i] % 2 == 1) {
  //     if(flag == false) flag = true;
  //     else {
  // 	cout << -1 << endl;
  // 	return 0;
  //     }
  //   }
  // }

  int back = S.size() - 1;
  int front = 0;
  int ans = 0;
  while(1) {
    if(front >= back) break;

    if(T[front] == T[back]) {
      front++;
      back--;
    }
    else if(T[front] == 'x') {
      front++;
      ans++;
    }
    else if(T[back] == 'x') {
      back--;
      ans++;
    } 
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 5100
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    string s1,s2;
    cin >> s1 >> s2;
    ll ans = 3;
    bool yoko = false;
    rep(i,n){
        if(s1[i] == s2[i]){
            if(i==0) continue;
            if(!yoko){
                ans *= 2;
                ans %= MOD;
            }
            yoko = false;
        }else{
            if(yoko){
                ans *= 3;
                ans %= MOD;
            }else{
                ans *= 2;
                ans %= MOD;
            }
            yoko = true;
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A
# Rooted Trees
# Result:
import sys

class Node(object):
    def __init__(self, id_):
        super(Node, self).__init__()
        self.id_ = id_
        self.parent = -1
        self.depth = 0
        self.children = []

    def add_child(self, child_):
        self.children.append(child_)

    def set_parent(self, parent):
        assert self.parent == -1
        self.parent = parent

    def __str__(self):
        str_ = 'node %d: ' % (self.id_)
        str_ += 'parent = %d, ' % (self.parent)
        str_ += 'depth = %d, ' % (self.depth)
        if self.parent == -1:
            str_ += 'root, '
        elif len(self.children) > 0:
            str_ += 'internal node, '
        else:
            str_ += 'leaf, '
        str_ += '[%s]' % (', '.join([str(x) for x in self.children]))
        return str_

def set_depth(nodes_, node_id_):
    for child_id_ in nodes_[node_id_].children:
        nodes_[child_id_].depth = nodes_[node_id_].depth + 1
        set_depth(nodes_, child_id_)


nnodes = int(sys.stdin.readline())
nodes = []
for i in range(0, nnodes):
    nodes.append(Node(i))

# set parent and child
for _ in range(0, nnodes):
    vals = sys.stdin.readline().rstrip().split(' ')
    node_id = int(vals[0])
    node = nodes[node_id]
    nchild = int(vals[1])
    for i in range(0, nchild):
        child_id = int(vals[2+i])
        node.add_child(child_id)
        child = nodes[child_id]
        child.set_parent(node_id)

root = 0
# find root
if nodes[root].parent != -1:
    for node in nodes:
        if node.parent == -1:
            root = node.id_
            break
    assert root != 0

# set depth
set_depth(nodes, root)

for n in nodes:
    print n

Measured memory_bytes: 65004
def solve():
    (sx,sy,tx,ty) = [int(x) for x in input().split()]

    dx = tx - sx
    dy = ty - sy

    ans = "U" * dy
    ans += ("R" * dx)
    ans += ("D" * dy)
    ans += ("L" * dx)
    dx += 1
    dy += 1
    ans += "L" + ("U" * dy)
    ans += ("R" * dx) + "D"
    ans += "R" + ("D" * dy)
    ans += ("L" * dx) + "U"

    return ans


def main():
    ans = solve()
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

int main(){
	ll N, A, B; cin >> N >> A >> B;
	if(A%2 == B%2) cout << (B-A)/2 << endl;
	else{
		ll c1 = A+(B-A-1)/2;
		ll c2 = N-B+1+(B-A-1)/2;
		if(c1 > c2) cout << c2 << endl;
		else cout << c1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll INF=1e18;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}

void solve()
{
     ll n;
     cin>>n;
     vector<ll> v(n+1);
     ll i,j,k;
     for(i=1;i<=n;i++)
          cin>>v[i];
     sort(v.begin(),v.end());
     ll ans =0;
     for(i=1;i<=n;i++)
     {
          for(j=i+1;j<=n;j++)
          {
               for(k=j+1;k<=n;k++)
               {
                    if(v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k] && v[i]+v[j]>v[k])
                         ans+=1;
               }
          }
     }
     cout<<ans;
}


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

Measured memory_bytes: 3600
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val expression = readLine.trim.split('+')
  val count = ('a' to 'z').map{c ⇒ expression.count{_.head == c}}.toArray
  println(
    if (n == 1) 1 else (1 to 9).map{size ⇒ count.count{_ == size}.let{term ⇒ if (term == 0) 0 else if (size == 1) term else if (term == 1) 3 else term + 4}}.sum + count.count{_ != 0} - 1
  )
  implicit class Extension[T](val value: T) extends AnyVal {
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
    @inline def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 44976
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1], reverse=True)
limit = ab[0][1] - ab[0][0]
for a, b in ab[1:]:
    limit = min(limit, b) - a
    if limit < 0:
        print("No")
        break
else:
    if limit < 0:
        print("No")
    else:
        print("Yes")



Measured memory_bytes: 53852
n = int(input())
s = []
t = []
for i in range(n):
    a, b = input().split(' ')
    s.append(a)
    t.append(int(b))
x = input()
i = s.index(x) + 1
r = 0
for i in range(i, n):
    r += t[i]
print(r)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[0]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s1,s2;
    vector<int> v;
    cin>>n>>m>>p>>q;
    if(q<=n){
        cout<<q<<endl;
        return 0;
    }
    else if(q<=n+m){
        cout<<n<<endl;
    }
    else if(q<=n+m+p){
        cout<<n-(q-n-m)<<endl;
    }
    else{
        cout<<n-p<<endl;
    }
    
    
}


Measured memory_bytes: 3624
<?php

define("BOX_SIZE", 8);
define("BOMB_POWER", 3);	// ??????????¨????


$datasetnum = fgets(STDIN);	// ????????????????????°(???????£???°???)

for($i = 1; $i <= $datasetnum; $i++){
	$line = fgets(STDIN);	// ??????(???????£???°???)
	
	$arr = array();
	for($j = 0; $j < BOX_SIZE; $j++){
		$arr[$j] = trim(fgets(STDIN));
	}
	$x = intval(fgets(STDIN));
	$y = intval(fgets(STDIN));
	explosion($arr, $x - 1, $y - 1);
	
	echo "Data {$i}:\n";
	for($j = 0; $j < 8; $j++){
		echo $arr[$j]."\n";
	}
}


/**
 * ???????¨????
 */
function explosion(&$arr, $x, $y){
	if($x < 0 || BOX_SIZE <= $x || $y < 0 || BOX_SIZE <= $y){
		// ?????????
		return;
	}
	if($arr[$y][$x] == "0"){
		// ???????????????
		return;
	}
	
	$arr[$y][$x] = "0";
	
	// ???
	for($i = 1; $i <= BOMB_POWER; $i++){
		explosion($arr, $x, $y - $i);
	}
	
	// ???
	for($i = 1; $i <= BOMB_POWER; $i++){
		explosion($arr, $x + $i, $y);
	}
	
	// ???
	for($i = 1; $i <= BOMB_POWER; $i++){
		explosion($arr, $x, $y + $i);
	}
	
	// ???
	for($i = 1; $i <= BOMB_POWER; $i++){
		explosion($arr, $x - $i, $y);
	}
}

Measured memory_bytes: 15516
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    print(f(n))
elif n==b:
    print(f(n-1))
elif n>b:
    #t = n
    #u = b - 1
    #print(max(f(t),f(u)))
    print(f(b-1))


Measured memory_bytes: 61804
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define MAX 100005
 
typedef long long ll;
typedef std::pair<int, int> pr;

int main(int, char**)
{
    int n, m;
    cin >> n >> m;

    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >>  h[i];
    }

    vector<bool> is_maxh(n, true);
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--; b--;
        if (h[a] >= h[b]) is_maxh[b] = false;
        if (h[b] >= h[a]) is_maxh[a] = false;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (is_maxh[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sum=0;
    int a[n];
    int max =10001;
    REP(i,n){
        int t;
        cin >> t;
        a[i]=t*n;
        sum+=t;
    }
    int ans =0;
    REP(i,n){
        if(abs(a[i]-sum)<max){
            ans = i;
            max=abs(a[i]-sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def read():
    H, W, K = list(map(int, input().strip().split()))
    S = list()
    for i in range(H):
        s = list(map(int, input()))
        S.append(s)
    return H, W, K, S


def init_n_splits(H, ptn):
    n_splits = 0
    for h in range(1, H):
        if ptn & 1 == 1:
            n_splits += 1
        ptn >>= 1
    return n_splits


def check_first_column(w, H, K, ptn, S):
    k = [0 for h in range(H)]
    k[0] = S[0][w]
    if k[0] > K:
        return [-1 for h in range(H)]
    for h in range(1, H):
        if ptn & 1 == 1:
            k[h] = S[h][w]
        else:
            k[h] = S[h][w] + k[h-1]
        if k[h] > K:
            return [-1 for h in range(H)]
        ptn >>= 1
    return k


def check_next_column(w, H, K, ptn, S, prev):
    k = [0 for h in range(H)]
    k[0] = S[0][w]
    if k[0] + prev[0] > K:
        return [-1 for h in range(H)]
    for h in range(1, H):
        if ptn & 1 == 1:
            k[h] = S[h][w]
        else:
            k[h] = S[h][w] + k[h-1]
        if k[h] + prev[h] > K:
            return [-1 for h in range(H)]
        ptn >>= 1
    return [i + j for i, j in zip(k, prev)]


def solve(H, W, K, S, INF=10000000):
    ptns = 2 ** (H-1)
    min_n_splits = W * H
    for ptn in range(ptns):
        update = True
        n_splits = init_n_splits(H, ptn)
        ret = check_first_column(0, H, K, ptn, S)
        if ret[0] == -1:
            update = False
        else:
            for w in range(1, W):
                prev = ret
                ret = check_next_column(w, H, K, ptn, S, prev)
                if ret[0] == -1:
                    n_splits += 1
                    ret = check_first_column(w, H, K, ptn, S)
                    if ret[0] == -1:
                        update = False
                        break
        if update:
            min_n_splits = min(n_splits, min_n_splits)
    return min_n_splits

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


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

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

  cout << (n - 1) * (m - 1) << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
map<ll, vector<l_l>> mp;
ll A[205000];
ll sum[205000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X, D;
    cin >> N >> X >> D;
    if(D == 0) {
        if(X == 0) cout << 1 << endl;
        else cout << N + 1 << endl;
        return 0;
    }
    if(D < 0) {
        D *= -1;
        X *= -1;
    }
    A[0] = X - D;
    for(int i = 1; i <= N; i++) {
        A[i] = A[i-1] + D;
        sum[i] = sum[i-1] + A[i];
        //cerr << A[i] << " " << sum[i] << endl;
    }
    for(ll d = 0; d <= N; d++) {
        ll mini = sum[d] - sum[0];
        ll maxi = sum[N] - sum[N-d];
        //cerr << d << " " << mini << " " << maxi << endl;
        mp[(mini % D + D) % D].push_back({mini, maxi + D});
    }
    ll ans = 0;
    for(auto a : mp) {
        vector<l_l> v = a.second;
        sort(v.begin(), v.end());
        //for(auto val : v) cerr << val.first << " " << val.second << endl;
        ll before = v[0].first;
        for(auto val : v) {
            //cerr << before << " "<< val.first << " " << val.second;
            chmax(val.first, before);
            ll num = (val.second - val.first) / D;
            //cerr << " " << num << endl;
            if(num > 0) ans += num;
            chmax(before, val.second);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
#define max(i,b) (i>b)?i:b
int main(void)
{
	int array[200000];
	int temp[200000];
	int N,tmp,m1,m2;
	cin>>N;
	rep(i,N){cin>>array[i];temp[i]=array[i];}
	sort(temp,temp+N);
	m1=temp[N-1];
	m2=temp[N-2];

	rep(i,N){
		if(array[i]==m1) cout<<m2<<endl;
		else cout<<m1<<endl;
	}
//	printf("%s",check(array,array+N)?"Yes":"No");
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  string s,t;
  cin >> s >> t;
  ll n = s.size();
  vector<vector<int>> v(26);
  rep(i,n)v[s[i]-'a'].push_back(i);
  ll cnt = 0,pos = 0;
  rep(i,t.size()){
    auto iter = lower_bound(ALL(v[t[i]-'a']),pos);
    if(iter == v[t[i]-'a'].end()){
      cnt++;
      pos = 0;
      auto iter_ = lower_bound(ALL(v[t[i]-'a']),pos);
      if(iter_ == v[t[i]-'a'].end()){
        cout  << -1 << endl;
        return 0;
      }
      pos = *iter_+1;
      continue;
    }
    pos = *iter+1;
  }
  cout << cnt*n+pos << endl;





  return 0;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, A, B; cin >> N >> A >> B;
    if((B - A) % 2 == 0){
        cout << "Alice";
    }else{
        cout << "Borys";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n, k, d, a, ans = 0;
    int chk[101] = {};
    cin >> n >> k;
    for(int i = 0; i < k; i++) {
        cin >> d;
        for(int j = 0; j < d; j++) {
            cin >> a;
            chk[a] = 1;
        }
    }
    for(int i = 1; i <= n; i++) {
        if(chk[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    A = map(int, input().strip().split())
    return N, A

def solve(N, A):
    ranks = [0 for i in range(9)]
    for a in A:
        if a >= 3200:
            ranks[-1] += 1
        else:
            r = a // 400
            ranks[r] += 1
    n_colors = sum([r > 0 for r in ranks[:-1]])
    n_colors_max = n_colors + ranks[-1]
    n_colors_min = max(n_colors, 1)
    return " ".join(map(str, [n_colors_min, n_colors_max]))

if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

const int maxn = 405;

typedef long long LL;
const LL mod = 1e9 + 7;

LL qpow(LL a, LL n){
    LL res = 1;
    while(n > 0){
        if(n & 1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
LL pre[maxn][maxn];

void init(){
    memset(pre, 0, sizeof(pre));
    for(int x = 1; x <= 400;x++){
        for(int p = 0;p <= 400;p++){
            pre[x][p] = qpow(x, p);
            pre[x][p] = (pre[x][p] + pre[x - 1][p]) % mod;
        }
    }
}

LL cal(LL c, LL a, LL b){
    return (pre[b][c] - pre[a - 1][c] + mod) % mod;
}

int A[maxn], B[maxn];
int N, C;
LL dp[maxn][maxn];

int main(){
    init();
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    cin >> N >> C;
    for(int i = 1;i <= N;i++){
        cin >> A[i];
    }
    for(int i = 1;i <= N;i++){
        cin >> B[i];
    }
    for(int i = 1;i <= N;i++){
        for(int j = 0;j <= C;j++){
            for(int k = 0;k <= j;k++){
                dp[i][j] = (dp[i][j] + dp[i - 1][k] * cal(j - k, A[i], B[i])) % mod;
                //cout << i << " " << j << " " << dp[i][j] << endl;
            }
        }
    }
    cout << dp[N][C] << endl;
    return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<assert.h>
#include<stdlib.h>
#include<stack>
using namespace std;
/*********************Contest Template***********************/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<int,int> Cord;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);
struct S{
    int a,b; S(){}S(int _a,int _b){
        a=_a;
        b=_b;
    }
    const bool operator<(const S &o) const{
        return a<o.a;
    }
};
priority_queue<int,vector<int>,greater<int>> mpq;
#define SPACE 0
#define NL 1
inline void showAll(vector<int> &v,int NL_or_space){ 
    //0 is space, 1 is NL
    for(int &here:v){
        printf("%d",here);
        printf("%c",(NL_or_space)?'\n':' ');
    }
}
/*********************Contest Template***********************/
// const int SIZE=



int main(){
    int a,b,t;  scanf("%d %d %d",&a,&b,&t);

    int ans=0;
    for(int i=1 ; i<=t ; i++){
        if(i%a==0) ans+=b;
    }
    printf("%d\n",ans);
	

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9+5;
int main()

{

long long N,W;
cin>>N>>W;
vector<int>w(N+1);
vector<int>v(N+1);

for(int i=1;i<=N;i++)
{
    cin>>w[i]>>v[i];
}



int max_value=1000*N;
vector<int>dp[max_value+1];
for(int i=0;i<=N;i++)
{
    dp[0].push_back(0);

}
for(int j=1;j<=max_value;j++)
{
    int flag=0;
    dp[j].push_back(inf);
    for(int i=1;i<=N;i++)
    {
        long long c1;
        if(j-v[i]>=0)
            c1=w[i]+dp[j-v[i]][i-1];
        else
            c1=w[i];
        long long c2=dp[j][i-1];
        if(min(c1,c2)>W)
            dp[j].push_back(inf);
        else
        {
            dp[j].push_back(min(c1,c2));
            flag=1;
        }
    }
    if(flag==0)
    {
        cout<<j-1<<endl;
        break;
    }
    else if(flag==1 && j==max_value)
    {
        cout<<max_value<<endl;
    }
}


return 0;
}


Measured memory_bytes: 54144
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll r, g, b, n;
    cin>>r>>g>>b>>n;
    ll ans = 0;
    for(ll i=0;i<=n;++i){
        for(ll j=0;j<=n;++j){
            ll flag = n-(r*i+g*j);
            if(flag%b == 0 and flag >=0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

int n, ans;
int magic_square[ 115 ][ 115 ];
int ar[ 2001 ] = {};

int main() {
	for ( int i = 0; i <= 1000; i++ ) {
		for ( int j = 0; j <= 1000; j++ ) {
			ar[ i + j ]++;
		}
	}
	while ( ~scanf( "%d", &n ) ) {
		ans = 0;
		for ( int i = max( n - 3000, 0 ); i <= 1000; i++ ) {
			if ( i > n ) {
				break;
			}
			for ( int j = max( 0, n - i - 2000 ); j <= 1000; j++ ) {
				if ( i + j > n ) {
					break;
				}
				ans += ar[ n - ( i + j ) ];
			}
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
main()
{
	int d,f,i;
	while(scanf("%d",&d)!=EOF){
		int M=0;
		for(i=1;i<600/d;i++){
			f=i*d*i*d;
			M+=f*d;
		}
		printf("%d\n",M);
	}
	return 0;
}

Measured memory_bytes: 596
def main():
    a=input()
    _max=0
    c=0
    for i in range(len(a)):
        if a[i]=='R':
            c+=1
        else:
            if _max<c:
                _max=c
                c=0
    if _max<c:
        _max=c
    print(_max)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9044
#include<iostream>
using namespace std;
int t[6],n,a,flg,cnt,tmp,p[6][6][6][6][6][6];
string moji;
void init(){
  if(a==6){
    p[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]=0;
  }else{
    for(int i=0;i<6;i++){
      t[a]=i;
      a++;
      init();
      a--;
    }
  }
}
int change(){
  if(moji=="Red"){
    return 0;
  }else if(moji=="Yellow"){
    return 1;
  }else if(moji=="Blue"){
    return 2;
  }else if(moji=="Magenta"){
    return 3;
  }else if(moji=="Green"){
    return 4;
  }else{
    return 5;
  }
}
void mov(int z){
  for(int j=0;j<4;j++){
    tmp=t[0]; t[0]=t[2]; t[2]=t[5]; t[5]=t[3]; t[3]=tmp;
    for(int k=0;k<3;k++){
      tmp=t[0]; t[0]=t[4]; t[4]=t[5]; t[5]=t[1]; t[1]=tmp;
      if(t[0]==z){
    //cout<<t[4]<<endl<<t[3]<<t[0]<<t[2]<<t[5]<<endl<<t[1]<<endl;
    return;
      }
    }
  }
}
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    flg=cnt=a=0;
    init();
 
    for(int i=0;i<n;i++){
      for(int j=0;j<6;j++){
	cin>>moji;
	t[j]=change();
      }
      if(p[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]==1){
	cnt++;
      }else{
	for(int j=0;j<6;j++){
	  mov(j);
	  for(int k=0;k<4;k++){
	    tmp=t[1];  t[1]=t[2];  t[2]=t[4];  t[4]=t[3];  t[3]=tmp;
	    p[t[0]][t[1]][t[2]][t[3]][t[4]][t[5]]=1;
	  }
	  
	}
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1392
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    K = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    ls=len(s)
    tot=pow(26,ls+K,mod)


    def extgcd1(a0,b0):#計算量log(b0),フェルマーの小定理より早い
            u,v,a,b=1,0,a0,b0
            while b:
                t=a//b; a-=t*b; a,b=b,a; u,v=v,u-t*v
            if a!=1: return -1#互いに素じゃない
            return u%b0
    
    N=ls+K
    fact=[0]*(N+1)#NはnCrの最大のn
    ifact=[0]*(N+1)
    fact[0],fact[1],ifact[0],ifact[1]=1,1,1,1
    for i in range(2,N+1):
        x=(fact[i-1]*i)%mod
        fact[i]=x
        ifact[i]=extgcd1(x,mod)
    pows=[1]*(N+1)
    for i in range(1,N+1):
        pows[i]=pows[i-1]*25%mod

    def comb(n,r): return (fact[n]*ifact[r]%mod)*ifact[n-r]%mod
    
    for i in range(0,ls):
        tot-=comb(ls+K,i)*pows[ls+K-i]
        tot%=mod
    print(tot)




if __name__ == "__main__":
    main()

Measured memory_bytes: 122628
#include <cstdio>

int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	int tmp = a % b;
	if (tmp == 0) return b;
	else return gcd(b, tmp);
}

int main() {
	int N;
	int* A = new int[100000];
	scanf("%d", &N)+1;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i])+1;
	}

	int* before = new int[100000];
	int gcdTmp = A[0];
	before[0] = gcdTmp;
	for (int i = 1; i < N; i++) {
		gcdTmp = gcd(gcdTmp, A[i]);
		before[i] = gcdTmp;
	}

	int* after = new int[100000];
	gcdTmp = A[N - 1];
	after[N - 1] = gcdTmp;
	for (int i = N - 2; i >= 0; i--) {
		gcdTmp = gcd(gcdTmp, A[i]);
		after[i] = gcdTmp;
	}
	
	int top = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) gcdTmp = after[i + 1];
		else if (i == N - 1) gcdTmp = before[i - 1];
		else gcdTmp = gcd(before[i - 1], after[i + 1]);
		if (gcdTmp > top) top = gcdTmp;
	}

	printf("%d", top);

	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int MAX_V = 10000;

vector<int> g[MAX_V]; //グラフ
vector<int> tp; //トポロジカルソートの結果

void bfs(int s, int indeg[MAX_V], bool used[MAX_V]){
	queue<int> q;

	q.push(s);
	used[s] = true;

	while(not q.empty()){
		int u = q.front(); q.pop();
		tp.emplace_back(u);
		rep(i,g[u].size()){
			int v = g[u][i];
			indeg[v]--;
			if(indeg[v] == 0 && not used[v]){
				used[v] = true;
				q.push(v);
			}
		}
	}
}

//グラフに閉路がある場合、0を返す
bool topologicalSort(int v){
	int indeg[MAX_V]; //入次数
	bool used[MAX_V];
	memset(indeg, 0, sizeof(indeg));
	memset(used, 0, sizeof(used));

	rep(i,v) rep(j,g[i].size()) indeg[ g[i][j] ]++;
	rep(i,v) if(indeg[i] == 0 && not used[i]) bfs(i, indeg, used);

	for(auto it:tp) cout << it + 1 << endl;

	if(tp.size() == v) return true;
	else return false;
}

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

	rep(i,m){
		if(i == 1) continue;
		g[i].emplace_back(1);
	}
	rep(i,n){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
	}

	topologicalSort(m);
	vector<int> ans(m);
	rep(i,m) ans[tp[i]] = i + 1;
	//rep(i,m){ cout << ans[i] << endl; }
}



Measured memory_bytes: 3452
import java.util.Scanner;

public class Main {
	static int N;
	static int[] A;
	static int min;

	public static void main(String[] args) {
		readInput();

		solve();
	}

	static void solve() {
		
		while(true) {
			int newMin = min;
			for(int i=0; i<N; i++) {
				int a = A[i] % min;
				
				if(a == 0) {
					a = min;
				}
				
				if(newMin > a) {
					newMin = a;
				}
				
				A[i] = a;
			}
			
			if(newMin == min) {
				break;
			}else {
				min = newMin;
			}
		}
		
		System.out.println(min);
	}
	

	static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			A = new int[N];
			
			min = Integer.MAX_VALUE;
			
			for(int i = 0; i<N; i++) {
				A[i] = sc.nextInt();
				if(min > A[i]) {
					min = A[i];
				}
			}
		}
	}
}


Measured memory_bytes: 50440
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

部分文字列　文字列の一致

sのi文字目までとtのj文字目まででやった場合の答えをxs[i][j]とする

s[i]とt[j]が一致する場合、
	xs[i][j] = xs[i - 1][j - 1] + 1
そうでない場合、
	xs[i][j] = max(xs[i - 1][j], xs[i][j - 1]))

ただし添字が負になる項は 0

求めるものはxs[n][m]である

上記を求めたあと、文字列は以下のようにして作る

string solve(int i, int j){
	if(s[i] == t[j]){
		if(i == 0 || j == 0) return "" ~ s[i];
		else return solve(i - 1, j - 1) ~ s[i];
	}
	else{
		if(i == 0 && j == 0) return "";
		if(i == 0) return solve(i, j - 1);
		if(j == 0) return solve(i - 1, j);
		if(xs[i - 1][j] > xs[i][j - 1]) return solve(i - 1, j);
		else return solve(i, j - 1);
	}
}



// メモ化再帰のほうがよかったかも

*/

void main(){
	string s = readln.chomp;
	string t = readln.chomp;
	
	long n = s.length;
	long m = t.length;
	
	int[][] xs;
	
	foreach(i; 0 .. n){
		xs ~= new int[](m);
		foreach(j; 0 .. m){
			debug writeln("i:", i, " j: ", j, " xs:", xs);
			if(s[i] == t[j]){
				if(i == 0 || j == 0) xs[i][j] = 1;
				else xs[i][j] = xs[i - 1][j - 1] + 1;
			}
			else{
				if(i == 0 && j == 0) xs[i][j] = 0;
				else if(i == 0) xs[i][j] = xs[i][j - 1];
				else if(j == 0) xs[i][j] = xs[i - 1][j];
				else xs[i][j] = max(xs[i - 1][j], xs[i][j - 1]);
			}
		}
	}
	
	string solve(long i, long j){
		if(s[i] == t[j]){
			if(i == 0 || j == 0) return "" ~ s[i];
			else return solve(i - 1, j - 1) ~ s[i];
		}
		else{
			if(i == 0 && j == 0) return "";
			if(i == 0) return solve(i, j - 1);
			if(j == 0) return solve(i - 1, j);
			if(xs[i - 1][j] > xs[i][j - 1]) return solve(i - 1, j);
			else return solve(i, j - 1);
		}
	}
	solve(n - 1, m - 1).writeln;
}


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

using namespace std;

int find_blocks(vector<int> &vec,vector<int>::iterator start, int *blocks)
{
    static int counter = 0;
    vector<int>::iterator find_point;
    counter++;
    find_point = find(start,vec.end(),counter);
    if (find_point == vec.end())
    {
        if (counter == 1 && vec[0] != 1)
        {
            *blocks = -1;
            return 0;
        }
        else if (counter == 1 && vec[0] == 1)
        {
            return 0;
        }
        else
        {
            *blocks += find_point - start - 1;
            return 0;
        }
    }
    else
    {
        if(counter == 1)
        {
            *blocks += find_point - start;
        }
        else
        {
            *blocks += find_point - start - 1;
        }
        find_blocks(vec,find_point,blocks);
    }
}

int main()
{
    int inputs[200000];
    vector<int> a;
    int n,ans = 0;
    cin >> n;
    int i, j;
    for (i = 0; i < n; i++)
    {
        cin >> inputs[i];
        a.emplace_back(inputs[i]);
    }
    find_blocks(a,a.begin(),&ans);
    cout << ans;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void eratstheness(lint n, bool* res, lint* a){
    res[0] = res[1] = false;
    lint i = 2;
    while(i*i <= n){
        for (lint j = 2 * i; j < n+1; j += i){
            if (!(res[j])) continue;

            if (j % i == 0){
                res[j] = false;
                a[j] = i; 
            }
        }
        i++;
    }
}

int main(){
    int n; cin >> n;
    bool check[n+1]; rep(i, n+1) check[i] = true;
    lint prime_list[n+1]; prime_list[1] = 1;
    eratstheness(n, check, prime_list);

    lint ans[n+1];
    ans[1] = 1;
    lint a = 1;

    lint p, r, x;
    for (lint i = 2; i < n+1; i++){
        if (check[i]){
            ans[i] = 2;
            a += i * ans[i];
            continue;
        }
        p = prime_list[i];
        r = i/p;
        if (r%p == 0){
            x = r/p;
            while (x % p == 0){
                x /= p;
            }
            ans[i] = ans[r] + ans[x];
        }
        else{
            ans[i] = ans[r] * 2;
        }
        a += i * ans[i];
    }
    cout << a << endl;
}


Measured memory_bytes: 169556