akhauriyash/Code-Regression huggingface dataset:
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        long k = sc.NextLong();
        long mod = 0;
        for (int i = 1; i <= k; i++)
        {
            mod *= 10;
            mod += 7;
            mod %= k;
            if (mod == 0)
            {
                Console.WriteLine(i);
                return;
            }
        }

        Console.WriteLine("-1");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27540
#include <stdio.h>
#include <map>
#pragma warning(disable : 4996)
#pragma warning(disable : 4996)

#define N_MAX 200000

int N, K;
int P[N_MAX];
int main(void) {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; ++i) {
		scanf("%d", &P[i]);
	}
	double cs = 0;
	for (int i = 0; i < K; ++i) {
		cs += P[i];
	}
	int mi = 0;
	double max = cs;
	for (int i = K; i < N; ++i) {
		cs  = cs - P[i - K] + P[i];
		if (cs > max) {
			mi = i - K+1;
			max = cs;
		}
	}
	double mp = 0.0;
	for (int i = mi; i < mi + K; ++i) {
		mp += (P[i] + 1.0) / 2.0;
	}
	printf("%lf", mp);
	return 0;
}
 

Measured memory_bytes: 896
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s1 = ''.join(s)
t1 = ''.join(t)
ls = [s1,t1]
ls1 = sorted(ls)
if s1 == t1:
    print('No')
elif ls == ls1:
    print('Yes')
else:
    print('No')

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

int main() {
  ll N;
  cin >> N;
  vector<int> L;
  ll sub;
  for (ll i=0;i<N;i++) {
    cin >> sub;
    L.push_back(sub);
  }
  sort(L.begin(),L.end());
  ll ans=0;
  for (ll i=0;i<N-2;i++) {
    for (ll j=i+1;j<N-1;j++) {
      if (L[i]==L[j]) continue;
      for (ll k=j+1;k<N;k++) {
        if (L[i]==L[k] || L[j]==L[k]) continue;
        if ((L[i]+L[j])>L[k]) ans++;
      }
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
  
using namespace std;
 
#define endl "\n"
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPI;
 
const int INF=2e9;
const int MX=100005;
const int MOD=1000000007;

long long int power(long long int a,long long int b)
{
    a %= MOD;
    long long int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
bool isprime(int n)
{
    if(n==1)
    return 0;
    int i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}


//vector<int> sieve(100001);
// void SIEVE()
// {
//     int i,j;
//     for(i=0;i<=100000;i++)
//     sieve[i]=i;
//     for(i=2;i*i<=100000;i++)
//     {
//         if(sieve[i]!=i)
//         continue;
//         for(j=i*i;j<=100000;j=j+i)
//         {
//             if(sieve[j]==j)
//             sieve[j]=i;
//         }
//     }
// }


/*_______________________________________________*/





int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cout<<"ACL";
    
}


Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  string S; cin>>S;
  vector<ll> vec(N+1,0); rep(i,N) vec[i+1]=vec[i]+(S[i]=='('?1:-1);
  
  ll m=*min_element(vec.begin(),vec.end());
  
  if(m==0) {cout<<S; rep(i,vec[N]) cout<<')'; cout<<'\n';}
  else {rep(i,abs(m)) cout<<'('; cout<<S; rep(i,vec[N]-m) cout<<')'; cout<<'\n';}
  
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;

    cin >> n;
    int tempCost = 0;
    int minCost = 999999999;

    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());

    // 最小値から最大値までを範囲として計算する


    for (int i = a.at(0); i <= a.at(a.size() - 1); i++) {
        tempCost = 0;
        for (int j = 0; j < a.size(); j++) {
            tempCost  += (i - a.at(j)) * (i - a.at(j));
        }
     
        if (tempCost < minCost) {
            minCost = tempCost;
        } 
    }

    cout << minCost << endl;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		while ((n = sc.nextInt()) != 0) {
			int max = 0, min = 1000, sum = 0;
			for (int i = 0; i < n; i++) {
				int score = sc.nextInt();
				sum += score;
				if (max < score)
					max = score;
				if (min > score)
					min = score;
			}

			sum -= min;
			sum -= max;
			System.out.println(sum / (n - 2));
		}

	}
}

Measured memory_bytes: 29296
def partition(arr, left, right):
    x = arr[right]
    i = left - 1
    for j in range(left, right):
        if arr[j] <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[right] = arr[right], arr[i + 1]
    return i + 1

if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))

    pos = partition(A, 0, n - 1)

    for i in range(n):
        if i:
            print(' ', end='')
        if i == pos:
            print('[%d]'%(A[i]), end='')
        else:
            print(A[i], end='')

    print()



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

#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 9;
const int MAX_M = 31;

int n,m,p,a,b;
int t[MAX_N];
int d[MAX_M][MAX_M];
double dp[1<<8][MAX_M];

int main()
{
	while(1){
	scanf("%d%d%d%d%d",&n,&m,&p,&a,&b);
	if(n+m+p+a+b == 0){
		break;
	}
	rep(i,n){
		scanf("%d",&t[i]);
	}
	rep(i,m){
		rep(j,m){
			d[i][j] = INF;
		}
	}
	rep(i,1<<n){
		rep(j,m){
			dp[i][j] = INF;
		}
	}
	rep(i,p){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		d[x-1][y-1] = z;
		d[y-1][x-1] = z;
	}
	dp[0][a-1] = 0;
	for(int i=1;i<(1 << n);i++){
		rep(j,m){
			rep(k,n){
				if(i & (1 << k)){
					rep(l,m){
						dp[i][j] = min(dp[i][j],dp[i ^ (1 << k)][l] + (double)d[l][j] / t[k]);
					}
				}
			}
		}
	}
	double ans = INF;
	rep(i,1<<n){
		ans = min(ans,dp[i][b-1]);
	}
	if(ans > 1000){
		printf("Impossible\n");
	}else{
		printf("%.5lf\n",ans);
	}
	}
	return 0;
}

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

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

	vector<char> st(3);
	rep(i,3) st[i] = s[i];

	sort(st.begin(), st.end());
	rep(i,3) s[i] = st[i];
	if(s == "abc"){ cout << "Yes" << endl;
	}else cout << "No" << endl;


	return 0;

}




Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n,i,j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
  }
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  
  printf("%d\n",B[n]);
  
  return 0;
}



Measured memory_bytes: 9592
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])

Measured memory_bytes: 84940
#include<bits/stdc++.h>
#define MAX 10000
#define NIL -1
using namespace std;

struct Node
{
    int p,l,r;
};
Node T[MAX];
int n;

void preParse(int u)
{
    if(u==NIL)return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u)
{
    if(u==NIL)return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

void postParse(int u)
{
    if(u==NIL)return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main()
{
	int i,v,l,r,root;

	scanf("%d",&n);
	for(i=0;i<n;i++)
    {
        T[i].p=NIL;
    }

    for(i=0;i<n;i++)
    {
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL)T[l].p=v;
        if(r!=NIL)T[r].p=v;
    }

    for(i=0;i<n;i++)
    {
        if(T[i].p==NIL)root=i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

 	return 0;
}



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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}



int main()
{

ll a,b,c,k;
cin>>a>>b>>c>>k;
ll ans=0;
ans+=min(k,a);

k-=min(a,k);

if(k)
{
  k-=min(k,b);

}

if(k)
{
 // k-=min(c,k);
  ans-=k;
}
cout<<ans<<"\n";
  return 0;

}






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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int L,R;
  L=A + B;
  R=C + D;
  if (L==R){
    cout << "Balanced" << endl;
  }
  else if(L>R) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	n := readInt()
	a := make([]int, n)
	x := make([]int, n)
	ans := make([]int, 0, n)
	for i := range a {
		a[i] = readInt()
	}

	for i := n - 1; i >= 0; i-- {
		j := i + i + 1
		cnt := 0
		for j < n {
			cnt = (cnt + x[j]) % 2
			j += i + 1
		}
		if cnt != a[i] {
			x[i] = 1
			ans = append(ans, i+1)
		}
	}

	fmt.Println(len(ans))
	for i := range ans {
		fmt.Print(ans[len(ans)-1-i], " ")
	}
}


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

typedef long long ll;
const int lim = 5;
ll a, b;
int q;

ll imax(ll X){
    ll lo = 1, mi, hi = sqrt(X) + 2;
    while(lo < hi){
        mi = (lo + hi + 1) >> 1;
        if(mi * (mi - 1) < X) lo = mi;
        else hi = mi - 1;
    }
    return lo;
}
ll mysol(ll a, ll b){
        if(a == 1 && b == 1){
            return 0;
        }
        ll ansa = 0, ansb = 0;
        ll k = imax(a*b-1);
        if(a > 1){
            if(a < lim){
                set<ll> S;
                for(int j = 1; j < a; j++) if((a*b-1)/j > b) S.insert((a*b-1)/j);
                ansa += S.size();
                S.clear();
            }else{
                if(k >= (a*b-1)) ansa += (a*b-1) - b;
                else if(k <= b){
                    ansa += (a*b-1)/(b+1);
                }else{
                    ansa += k - b + max(0LL, (a*b-1)/k - 1);
                    //printf("ans1 : %lld\n",k + max(0LL, (a*b-1)/k - (a*b-1)/(a+1)));
                }
            }
        }
        if(b > 1){
            if(b < lim){
                set<ll> S;
                for(int j = 1; j < b; j++) if((a*b-1)/j > a) S.insert((a*b-1)/j);
                ansb += S.size();
                S.clear();
            }else{
                if(k >= (a*b-1)) ansb += (a*b-1) - a;
                else if(k < a){
                    ansb += (a*b-1)/(a+1);
                }else{
                    ansb += k - a + max(0LL, (a*b-1)/k - 1);
                    //printf("ans1 : %lld\n",k + max(0LL, (a*b-1)/k - (a*b-1)/(a+1)));
                }
            }
        }
        //printf("a = %lld, b = %lld, k = %lld\n",a,b,k);
        //printf("ansa = %lld, ansb = %lld\n",ansa,ansb);
        //return ansa + ansb + min(a-1-ansa,b-1-ansb);
        return ansa + ansb;
}

ll sol2(ll a, ll b){
    if(a > b) swap(a,b);
    if(b <= a + 1) return a + a - 2;
    ll lo = 0, mi, hi = 2e9;
    while(lo < hi){
        mi = (lo + hi + 1) >>1;
        if(mi * mi < a * b) lo = mi;
        else hi = mi - 1;
    }
    ll c = lo;
    return c*(c+1) < a*b ? c + c - 1 : c + c - 2;
}

mt19937 g(0x95949);
uniform_int_distribution<int> d(1,1e9);

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    for(cin >> q; q--; ){
        cin >> a >> b;
        //a = d(g); b = a + 1;
        //if(mysol(a,b) == sol2(a,b)) continue;
        //cout << "mysol = " << mysol(a,b) << '\n';
        cout << sol2(a,b) << '\n';
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {}
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 1000000007;
using mint = ModInt<MOD>;

//const int MOD = 1000000007;
const int MAX = 2000010;
long long inv[MAX], inv_fact[MAX], fact[MAX];
void init_comb() {
  inv[1] = 1;
  inv_fact[0] = inv_fact[1] = 1;
  fact[0] = fact[1] = 1;
  for (int i = 2; i < MAX; i++) {
    inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;
    fact[i] = fact[i - 1] * i % MOD;
  }
}
long long comb(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (inv_fact[k] * inv_fact[n - k] % MOD) % MOD;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init_comb();
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  mint ans;
  rep(i, k+1)
    ans += mint(25).pow(i)*mint(26).pow(k-i)*comb(n-1+i, i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 51116
package main

import (
	"fmt"
)

const (
	char = '#'
)

func main() {
	var h, w int
	for {
		fmt.Scanln(&h, &w)
		if h == 0 && w == 0 {
			break
		}
		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				fmt.Printf("%c", char)
			}
			fmt.Printf("\n")
		}
		fmt.Printf("\n")
	}
	return
}



Measured memory_bytes: 1104
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int x = max(A, C);
  int y = min(B, D);
  cout << max(y - x, 0) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    // 再帰的に解く (x, y を入れ替えておく)
    long long d = extGCD(b, a % b, y, x); 
    y -= a / b * x;
    return d;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

//約数列挙
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

ll a[100010];
ll s1[100010],s2[100010];


int main () {

    int n;cin>>n;

    rep(i,n) cin>>a[i];

    s1[0]=a[0];
    s2[0]=a[n-1];

    rep(i,n-1) {
        s1[i+1]=GCD(s1[i],a[i+1]);
        s2[i+1]=GCD(s2[i],a[n-2-i]);
    }

    ll ans=s1[n-2];

    rep(i,n-1) {
        ans=max(ans,GCD(s1[n-3-i],s2[i]));
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include <iostream>

int main(){
	int h, m, s;
	int time_s;
	std::cin >> time_s;
	s = time_s % 60;
	m = time_s / 60 % 60;
	h = time_s / 3600;
	std::cout << h << ':' << m << ':' << s << '\n';

	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int tmp1 = H1 * 60 + M1;
    int tmp2 = H2 * 60 + M2;
    cout << tmp2 - tmp1 - K << endl;
    return 0;
}


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


using namespace std;
#define max 10005
int main(){
    int h,n;
    cin >> h >> n;
    int a[n],sum=0;
    for(int i=0; i<n; i++){
       cin >> a[i];
       sum+=a[i];
    }
    if(sum>=h)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 4016
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

const static ui NMAX = 5000;
static ui N;
static string S;

struct Z_algorithm {
  vector<ul> Z;
  ul n;

  Z_algorithm(const string& str) {
    ul n = str.size();
    this->n = n;
    Z.resize(n, 0);
    ul c = 0;
    FORi(i, 1, n) {
      if (Z[i - c] + i < Z[c] + c) {
        Z[i] = Z[i - c];
      } else {
        ul j = 0;
        if (i < c + Z[c]) {
          j = c + Z[c] - i;
        }
        while (i + j < n && str[i + j] == str[j]) {
          j++;
        }
        Z[i] = j;
        c = i;
      }
    }
  }

  ul distnict_max(void) const {
    ul res = 0;
    FOR0(i, n) {
      ul k = Z[i];
      if (k > i) {
        k = i;
      }
      res = max(k, res);
    }
    return res;
  }
};

void solve(void) {
  ul res = 0;
  FOR0(i, N) {
    Z_algorithm z(S.substr(i));
    res = max(res, z.distnict_max());
  }
  cout << res << endl;
}

int main(void) {
  cin >> N;
  cin >> S;
  solve();
  return 0;
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))
cnt = 0
sum_ = 0
min_ = float('Inf')
for i in range(N):
    if a[i] < 0:
        cnt += 1
    min_ = min(min_, abs(a[i]))
    sum_ += abs(a[i])
if cnt % 2 == 0:
    print(sum_)
else:
    print(sum_ - 2 * min_)

Measured memory_bytes: 14208
def myAnswer(N:int,C:int,K:int,T:list)->int:
   T.sort()
   ans = 0
   counter = 1
   hantei = T.pop(0)
   for t in T:
      if(counter == C or (t - hantei) > K):
         ans += 1
         hantei = t
         counter = 1
      else:
         counter += 1
   ans += 1
   return ans

def modelAnswer():
   return
def main():
   N,C,K = map(int,input().split())
   T = [int(input()) for _ in range(N)]
   print(myAnswer(N,C,K,T))

if __name__ == '__main__':
   main()

Measured memory_bytes: 7484
#include <stdio.h>
#include <stdlib.h>

long long int chmin(long long int a, long long int b)
{
	if (a > b)
		return b;
	else
		return a;
}


int main(int argc, char const *argv[])
{
	long long int n;
	scanf("%lld", &n);
	long long int dp[100100]; 
	long long int h[100100]; 
	for (int i = 0; i < n; i++)
	{
		dp[i] = 1000000;
		scanf("%lld", h+i);
	}
	dp[0] = 0;
	dp[1] = llabs(h[1] - h[0]);
	for (int i = 2; i < n; ++i)
	{
		dp[i]=chmin(dp[i - 2] + llabs(h[i] - h[i - 2]), dp[i - 1] + llabs(h[i] - h[i - 1]));
	}
	printf("%lld", dp[n-1]);
	return 0;
}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = set()

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1)

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

using namespace std;

typedef long long int int64;

string aarr[200005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	map<string, int> cccc;
	int maxi = 0;
	for(int i = 1; i <= n; i++) {
		cin >> aarr[i];
		cccc[aarr[i]]++;
		maxi = max(maxi, cccc[aarr[i]]);
	}
	vector<string> anss;
	set<string> weree;
	for(int i = 1; i <= n; i++) {
		if(cccc[aarr[i]] == maxi && weree.count(aarr[i]) == 0) {
			anss.push_back(aarr[i]);
			weree.insert(aarr[i]);
		}
	}
	sort(anss.begin(), anss.end());
	for(string s : anss)
		cout << s << "\n";
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	int l, a, b, c, d;
	cin>>l>>a>>b>>c>>d;
	a=(a-1)/c+1;
	b=(b-1)/d+1;
	cout<<(l-(a>b?a:b))<<endl;
	return 0;
}

Measured memory_bytes: 1196
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a<=8&&b<=8)
			System.out.println("Yay!");
		else System.out.println(":(");
	}
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    cout << n/2 - (n%2 == 0 ? 1 : 0) << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main(){
	int k, n;
	std::cin >> k >> n;
	std::vector<int> a(n);
	std::vector<int> d(n);
	for(int i=0; i<n; i++){
		std::cin >> a[i];
	}
	for(int i=1; i<n; i++){
		d[i] = a[i] - a[i-1];
	}
	d[0] = (k-a[n-1]) + a[0];
	std::sort(d.begin(), d.end());

	std::cout << k-d[n-1] << std::endl;
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static bool Solve(string S)
        {
            return S != "AAA" && S != "BBB";
        }

        static void Main(string[] args)
        {
            string S = Read();
            Console.WriteLine(Solve(S) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
can = True

for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - prev_t
    dist = abs(x - prev_x) + abs(y - prev_y)
    if dt < dist or dist % 2 != dt % 2:
        can = False
    prev_t = t
    prev_x = x
    prev_y = y

if can:
    print("Yes")
else:
    print("No")


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int h, w;
	cin >> h >> w;
	if(h > w) swap(h, w);
	if(h == 1){
		cout << 1 << endl;
	}else{
		cout << (h * w + 1) / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>

using namespace std;

int main() {
	int i, j, k;
	int n;
	vector<long>a(3005,-1);
	long maxn = 1, minn = 9999999;
	long sum = 0, f;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a[i];
		minn = min(minn, a[i]);
		sum += a[i];
	}

	sum -= n;
	cout << sum << endl;
	getchar();
	getchar();
	return 0;

	sort(a.begin(), a.end(), greater<long>());

	

	//for (i = minn; i <= a[0] * 2 - 1; i++) {
	for (i = minn; i <= 99999; i++) {
		for (j = 0; j < n; j++) {
			sum += i % a[j];
		}
		//cout << sum << endl;
		//maxn = max(maxn, sum);
		if (maxn < sum) {
			maxn = sum;
			f = i;
		}
		sum = 0;
	}


	//cout << "maxn->" << maxn << " f->" << f << endl;








	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
let n, k, r, s, p, t = Scanf.scanf " %d %d %d %d %d %s" @@ fun a b c d e f -> a, b, c, d, e, f
let f = function 'r' -> p | 's' -> r | _ -> s
let ss = Array.init n (fun i -> f t.[i])
let _ = Array.(iteri (fun i s -> if i >= k && ss.(i - k) > 0 && t.[i] = t.[i - k] then ss.(i) <- 0) ss; fold_left (+) 0 ss) |> Printf.printf "%d\n"

Measured memory_bytes: 4480
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
#import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

#import math
from collections import deque, defaultdict, Counter


def main():
    """
    N = int(input())
    Nr = math.sqrt(N)
    Nr = int(Nr)+1
    count = 0
    for i in range(2, Nr):

        if N % i == 0:
            M = N
            while M % i != 0:
                M = M // i

            if M < i:
                break
            else:
                ans = M % i
                if ans == 1:
                    count += 1
        else:
            ans = N % i
            if ans == 1:
                count += 1
    print(count+2)

    """
    K = int(input())
    count = 0
    q = deque()
    for i in range(1, 10):
        q.append(i)
    while q:
        num = q.popleft()
        count += 1
        if count == K:
            ans = num
            break
        mod10 = num % 10
        if mod10 != 0:
            q.append(10*num + mod10 - 1)
        q.append(10*num + mod10)
        if mod10 != 9:
            q.append(10*num + mod10 + 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40560
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<bool> have(n,false);
  for(int i=0;i<k;i++){
    int d;cin>>d;
    vector<int> a(d);
    for(int j=0;j<d;j++){
      cin>>a[j];
      have[a[j]-1]=true;
    }
  }
  
  int ans=0;
  for(int i=0;i<n;i++){
    if(!have[i]){
      ans++;
    }
  }
  
  cout<<ans;
  
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ll x;
    cin >> x;
 
    ll n = 100;
    int ans = 0;
    while (n < x)
    {
        n += n / 100;
        ans++;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        string t = sc.Next();

        string answer = string.Join("", s.Reverse()) == t ? "YES" : "NO";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define MOD 1000000007
#define INF 2000000001

using namespace std;

typedef pair<int, int> pi;
int n, k;
char s[100001];
int main() {
	cin >> n >> k;
	rep(i, n) cin >> s[i];
	rep(i, n) {
		if (i != k - 1) cout << s[i];
		else cout << char(s[i] + ('a' - 'A'));
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++)
    cin >> A[i];
  int min = 1000000001;
  int max = -1;
  for (int i = 0; i < N; i++)
  {
    if (A[i] < min)
      min = A[i];
    if (max < A[i])
      max = A[i];
  }
  cout << max - min << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        in.close();
 
		for (int a = 1; a < 10; a++) {
			for (int b = 1; b < 10; b++) {
				if (a * b == n) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 23252
H,W,K = map(int,input().split())
A = []
for i in range(H):
    b = list(input())
    b.append("0")
    A.append(b)

ans = 10**6
for i in range(2**(H-1)):
    p = "0" + str(H-1)
    bin_list = list(format(i,p+"b"))
    sec = []
    for i in range(H-1):
        if bin_list[i] == "1":
            sec.append(i)
    sec.append(H-1)
    l = len(sec)

    W_start = 0
    k = 0
    while(True):
        H_start = 0
        pross = 10**4
        for i in range(l):
            H_end = sec[i] + 1
            j = W_start
            c = 0
            while(True):
                for t in range(H_start,H_end):
                    if A[t][j] == "1":
                        c += 1
                j += 1
                if c > K or j > W:
                    pross = min(pross,j-W_start)
                    break
            H_start = sec[i] + 1

        k += 1
        W_start += pross-1
        if W_start > W-1 or pross == 1:
            break
    if pross != 1:
        ans = min(ans,k+l-2)

print(ans)

Measured memory_bytes: 45916
import math
N = int(input())
ans = (1+N)*N/2
for i in range(1,N+1):
  for j in range(1,i):
    ans += math.gcd(i,j)*6
for i in range(1,N+1):
  for j in range(1,i):
    if i== j:
      break
    for k in range(1,j):
      if i == k or j == k:
        break
      else:
        ans += math.gcd(k,math.gcd(i,j))*6
print(int(ans))

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define forr(i, b, e)     for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds;

typedef long long       ll;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
#define tam 220000
typedef pair<ii,int> iii;
ll pot(ll b,ll e, ll mod)
{
    b%=mod;
    ll res=1;
    while(e>0)
    {
        if (e&1)res*=b,res%=mod;
        b*=b,b%=mod;
        e/=2;
    }
    return res;
}
struct  Hash
{
    int p=997,m[2],in[2];
    vector<int> h[2],inv[2];
    Hash(){}
    void init(string s)
    {
       m[0] = 998244353, m[1] = 1000000009;
        forr(i, 0, 2)
        {
            in[i] = pot(p, m[i]-2, m[i]);
            h[i].resize(s.size() + 1);
            inv[i].resize(s.size() + 1);
            ll acu = 1;
            h[i][0] = 0, inv[i][0] = 1;
            forr(j, 0, s.size())
            {
                h[i][j + 1] = (h[i][j] + acu * s[j]) % m[i];
                inv[i][j + 1] = (1ll * inv[i][j] * in[i]) % m[i];
                acu = (acu * p) % m[i];
            }
        }
    }
    ll get(int b, int e)
    {
        ll ha[2];
        forr(i, 0, 2)
            ha[i] = ((((h[i][e] - h[i][b]) * (ll)inv[i][b]) % m[i]) + m[i]) % m[i];
        return((ha[0] << 32) | ha[1]) ;
    }
};
unordered_map<ll,int > vposiz,vposder;
Hash h1;string txt;
bool f(int m)
{
    if (!m)return true;
    vposiz.clear();
    vposder.clear();
    ll valhas;
    int pos1,pos2;
    forr(i,0,txt.size())
    {
        if (i+m-1>=txt.size())break;
        valhas=h1.get(i,i+m);

        if (vposiz[valhas]==0)
            vposiz[valhas]=i+1;
        vposder[valhas]=i+1;
    }
    for(unordered_map<ll,int>::iterator ite=vposiz.begin();ite!=vposder.end();ite++)
    {
        valhas=ite->F;
        pos1=ite->S;
        pos2=vposder[valhas];
        if (pos2-pos1>=m)
            return 1;
    }
    return 0;
}
int main()
{
    //cout<<pot(2,3,(ll)1e9)<<" "<<pot(3,4,(ll)1e9)<<endl;
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    cin>>txt;
    int iz,der,mid;
    iz=0,der=txt.size();
    h1.init(txt);
    //cout<<f(5)<<endl;
    //return 0;
    while(iz+1<der)
    {
        mid=(iz+der)/2;
        if (f(mid)==1)
            iz=mid;
        else
            der=mid;
    }
    cout<<iz<<endl;
}
// PLUS ULTRA!


Measured memory_bytes: 768
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int c[][] = new int[a + 2][b + 2];

        for (int i = 0; i < a; i++) {
            String str = scanner.next();
            String[] s = str.split("", 0);
            for (int i1 = 0; i1 < b; i1++) {
                if (s[i1].equals("#")) {
                    c[i + 1][i1 + 1] = 1;
                } else {
                    c[i + 1][i1 + 1] = 0;
                }
            }
        }

        int result[][] = new int[a][b];
        for (int i = 0; i < a; i++) {
            for (int i1 = 0; i1 < b; i1++) {
                if (c[i + 1][i1 + 1] == 1) {
                    System.out.print("#");
                } else {
                    result[i][i1] += c[i][i1];
                    result[i][i1] += c[i][i1 + 1];
                    result[i][i1] += c[i][i1 + 2];
                    result[i][i1] += c[i + 1][i1];
                    result[i][i1] += c[i + 1][i1 + 1];
                    result[i][i1] += c[i + 1][i1 + 2];
                    result[i][i1] += c[i + 2][i1];
                    result[i][i1] += c[i + 2][i1 + 1];
                    result[i][i1] += c[i + 2][i1 + 2];
                    System.out.print(result[i][i1]);
                }
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 22356
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

int isprimex[114514];

bool isprime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;
	if (n == 3)return true;
	bool flag = true;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)flag = false;
	}
	return flag;
}

int calculate() {
	isprimex[0] = 0;
	isprimex[1] = 0;
	isprimex[2] = 0;
	for (int i = 3; i <= 100001; i++) {
		if (i % 2 == 0)isprimex[i] = isprimex[i - 1];
		else if (isprime(i) && isprime((i + 1) / 2))isprimex[i] = isprimex[i - 1] + 1;
		else isprimex[i] = isprimex[i - 1];
	}
	return 0;
}

int main() {

	calculate();

	int Q;
	cin >> Q;
	int l[114514];
	int r[114514];
	for (int i = 1; i <= Q; i++) {
		cin >> l[i] >> r[i];
	}

	for (int i = 1; i <= Q; i++) {
		cout << isprimex[r[i]] - isprimex[l[i] - 1] << endl;
	}
	cout << endl;

	return 0;
}

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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main(){
	int n, t;

	while(cin >> t >> n, !(t == 0 && n == 0)) {
		set<pii> wall;

		for(int i = 0; i < n; ++i) {
			int x, y;
			cin >> x >> y;

			wall.insert(pii(x, y));
		}

		map<pii, int> d;
		queue<pii> q;

		int sx, sy;
		cin >> sx >> sy;

		d[pii(sx, sy)] = 0;
		q.emplace(sx, sy);

		const int dx[] = {0, 1, 1, 0, -1, -1};
		const int dy[] = {-1, 0, 1, 1, 0, -1};

		while(!q.empty()) {
			auto p = q.front(); q.pop();

			if(d[p] == t) {
			  continue;
			}

			for(int k = 0; k < 6; ++k) {
			  int nx = p.first + dx[k];
			  int ny = p.second + dy[k];

			  pii np(nx, ny);
			  if(wall.count(np) || d.count(np)) {
				continue;
			  }

			  d[np] = d[p] + 1;
			  q.push(np);
			}
		}

		cout << d.size() << endl;
	}
}

Measured memory_bytes: 3348
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int a,b,c;
	cin >> a >> b >> c;

	if (a + b + c >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;


	return 0;
}

Measured memory_bytes: 256