akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 998244353;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const int MAX = 100010;
ll cnt[MAX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll d(n);
    rep(i, n){
        cin >> d[i];
        cnt[d[i]]++;
    }
    if(d[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    repr(i, 1, n){
        if(d[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ma = *max_element(ALL(d));
    repr(i, 1, ma+1){
        if(cnt[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    dump(ma);
    rep(i, ma){
        ans *= powmod(cnt[i], cnt[i+1]);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long h,sum=0;
    int n;
    cin>>h>>n;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        sum=sum+temp;
    }
    if(h<=sum)
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long; using uint = unsigned int; using uInt = unsigned long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; ++i)
#define gnr(i,l,r) for(int i=r; i>=l; --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define priend(a) {cout<<(a)<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;

template<class T>
T euler_phi(T n) {
  T ret = n;
  for(T i = 2; i * i <= n; ++i) {
    if(!(n % i)) {
      ret -= ret / i;
      while(!(n % i)) n /= i;
    }
  }
  if(n > 1) ret -= ret / n;
  return ret;
}

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

  cin>>n; pri1(euler_phi(n));
}


Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;

int main()
{
	int N,K,A;
	map<int,int> m;
	int ans=0;
	
	cin >> N >> K;
	for(int i=0;i<N;i++)
	{
		cin >> A;
		m[A]++;
	}
	
	vector<int> v;
	for(pair<int,int> i:m)
		v.push_back(i.second);
	sort(v.begin(),v.end());
	
	for(int size=v.size(),i=0;size>K;size--,i++)
		ans+=v[i];
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10748
import sys
from collections import deque

def main():

    input = sys.stdin.readline

    H,W = map(int,input().split())
    Ch,Cw = map(int,input().split())
    Dh,Dw = map(int,input().split())

    S=[list(map(str,list(input()[:-1]))) for i in range(H)]

    dh = (1, 0, -1, 0)
    dw = (0, 1, 0, -1)
    warph = (2, 2, 2, 2 ,2,1,1,1,1,0,0,-1,-1,-1,-1,-2,-2,-2,-2,-2)
    warpw = (-2, -1, 0, 1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2)

    d = deque()

    d.append((Ch-1,Cw-1))

    S[Ch-1][Cw-1] = 0

    while len(d) > 0:
        Ph,Pw = d.popleft()

        # if (Ph == Dh-1) & (Pw == Dw-1):
        #     goal = True
        #     break

        for i in range(4):
            nh = Ph + dh[i]
            nw = Pw + dw[i]
            if (nh < 0) | (nh >= H) | (nw < 0) | (nw >= W):
                continue
            if S[nh][nw] == "#":
                continue
            if S[nh][nw] == ".":
                S[nh][nw] = S[Ph][Pw]
                d.appendleft((nh,nw))
            elif S[nh][nw] > S[Ph][Pw]:
                S[nh][nw] = min(S[nh][nw],S[Ph][Pw])
                d.appendleft((nh,nw))





        for i in range(20):
            nh = Ph + warph[i]
            nw = Pw + warpw[i]
            if (nh < 0) | (nh >= H) | (nw < 0) | (nw >= W):
                continue
            if S[nh][nw] == "#":
                continue
            if S[nh][nw] == ".":
                S[nh][nw] = S[Ph][Pw] + 1
                d.append((nh,nw))
            elif S[nh][nw] > S[Ph][Pw] + 1:
                S[nh][nw] = min(S[nh][nw],S[Ph][Pw]+1)
                d.append((nh,nw))

    if S[Dh-1][Dw-1] == ".":
        print("-1")
    else:
        print(S[Dh-1][Dw-1])
         

if __name__ == "__main__":
    main()

Measured memory_bytes: 158636
using System;

namespace abc166
{
    class Program
    {
        static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            var a = new long[6207];
            for (var i = 0; i < a.Length; ++i)
            {
                a[i] = (long)Math.Pow(i, 5);
            }
            for (var i = 0; i < a.Length; ++i)
            {
                for (var j = 0; j < a.Length; ++j)
                {
                    if (a[i] - a[j] == n)
                    {
                        Console.WriteLine(i + " " + j);
                        return;
                    }
                    else if (a[i] + a[j] == n)
                    {
                        Console.WriteLine(j + " " + (- i));
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 27956
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<vector<int>>go;
vector<int>zyu;
void dfs(int ter,int per){
	zyu.pub(ter);
	for(auto it:go[ter]){
		if(it==per){continue;}
		dfs(it,ter);
	}
}
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int i,n;cin>>n;
	//2つの頂点の最小値 の合計を最大化
	//500であることに注意する?
	//1000って言われたら一生解けません。
	go.res(n);
	for(i=1;i<n;i++){
		int a,b;cin>>a>>b;a--;b--;
		go[a].pub(b);
		go[b].pub(a);
	}
	dfs(0,-1);
	vector<int>c(n);
	for(i=0;i<n;i++){cin>>c[i];}
	SO(c);REV(c);
	llint wa=0;
	vector<int>ans(n);
	for(i=0;i<n;i++){ans[zyu[i]]=c[i];wa+=c[i];}
	wa-=c[0];
	cout<<wa<<endl;
	for(i=0;i<n;i++){cout<<ans[i]<<" ";}cout<<endl;
	return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    string S;
    cin >> S;

    // 処理
    // 出力
    cout << (S <= "2019/04/30" ? "Heisei" : "TBD") << endl;

    return 0;
}


Measured memory_bytes: 256
/* 後は提出するだけ */
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007LL
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    int n;
    cin >> n;
    vector<double> t(n+2, 0), v(n+2, 0);
    rep(n){
        cin >> t[i+1];
        t[i+1] += t[i];
    }
    t[n+1] = t[n];
    rep(n) cin >> v[i];

    double ans = 0.0;
    double vv = 0.0, prev_vv;
    for(double tt=0.5;tt<=t.back();tt+=0.5){
        prev_vv = vv;
        vv += 0.5;
        rep(n+2){
            if(tt <= t[i]){
                vv = min(vv,  v[i] + (t[i]-tt));
            }else if(tt <= t[i+1]){
                vv = min(vv, v[i]);
            }else{
                vv = min(vv, v[i] + (tt-t[i]));
            }
        }
        if(prev_vv <= vv){
            ans += prev_vv * 0.5 + (vv-prev_vv) * 0.25;
        }else{
            ans += vv * 0.5 + (prev_vv-vv) * 0.25;
        }
    }
    printf("%.4lf", ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));


		Array.Sort(e,(x,y)=>x[0]-y[0]);

		int[] diff = new int[a[0]-a[1]+1];
		for(int i=a[1]-1; i<a[0];i++) diff[i-a[1]+1] = e[i][0]-e[i-a[1]+1][0];

		Array.Sort(diff);

		string ans = diff[0].ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


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

//昇順
int acs(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int min = (n<k) ? n : k;
  int v[n], ab[min+1][min+1], have[min+1][min+1][min];
  for (int i=0; i<n; i++) scanf("%d", v+i);
  ab[0][0] = 0;
  for (int i=1; i<min+1; i++) {
    ab[i][0] = ab[i-1][0] + v[i-1];
    for (int j=0; j<i; j++) {
      have[i][0][j] = v[j];
    }
  }
  for (int i=0; i<min+1; i++) {
    for (int j=1; j<min+1-i; j++) {
      ab[i][j] = ab[i][j-1] + v[n-j];
      for (int k=0; k<i; k++) have[i][j][k] = v[k];
      for (int k=0; k<j; k++) have[i][j][i+k] = v[n-k-1];
    }
  }
  for (int i=0; i<min+1; i++) {
    for (int j=0; j<min+1-i; j++) {
      if (i+j == k) continue;
      int c=0;
      qsort(have[i][j], i+j, sizeof(int), acs);
      while(c<k - (i+j) && have[i][j][c]<0 && c<i+j) {
        ab[i][j] += -have[i][j][c];
        c++;
      }
    }
  }
  int ans=0;
  for (int i=0; i<min+1; i++) {
    for (int j=0; j<min+1-i; j++) {
      ans = (ab[i][j]>ans) ? ab[i][j] : ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);

  int A,B;
  int C,D;
  int E,F;
  cin >> A >> B >> C >> D >> E >> F;

  double max_val = -1;

  int ans_water;
  int ans_salt;
  
  int water;
  int salt ;
  for(int i = 0; i <= 30; i++){
    for(int j = 0; j <= 30; j++){
      water = 0;
      salt = 0;
      water = 100 * A  * i + 100 * B * j;
      if(i + j == 0) continue;

      if(water > F) continue;
      for(int k = 0; k <= (F-water)/C; k++){
        for(int l = 0; l <= (F-water)/D; l++){
          salt = k * C + l * D;

          if(water + salt > F){
            continue;
          }

          double val = (double)salt/(double)water;

          if(val > (double)E / 100){
            continue;
          }
          if(val > max_val){
            max_val = val;
            ans_water = water;
            ans_salt = salt;
          }
        }
      }
    }
  }
  cout << ans_water + ans_salt << " " << ans_salt << endl;
}


Measured memory_bytes: 256
def solve(A,N):
    A.append(0)
    money,kabu = 1000,0
    ans = money
    pt = 0
    while pt < N:
        if A[pt] < A[pt+1]:
            ans = max(ans,money)
            kabu += (money // A[pt])
            money %= A[pt]
            pt += 1
            while pt < N:
                if A[pt] > A[pt+1]:
                    money += (A[pt] * kabu)
                    kabu = 0
                    ans = money
                    pt += 1
                    break
                else:
                    pt += 1
        else:
            pt += 1

    return ans

def main():
    N = int(input())
    A = list(map(int,input().split()))

    print(solve(A,N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 8988
def calc_area(x,y)
   area=x*y
end

def calc_length(x,y)
   length=x+x+y+y
end

x,y=gets.split
a=x.to_i
b=y.to_i
if a.between?(1,100)==false then
   puts"Please input [1<= a,b <=100]"
   exit
end

if b.between?(1,100)==false then
   puts"Please input [1<= a,b <=100]"
   exit
end

area=calc_area(a,b)
length=calc_length(a,b)

printf("%d %d\n",area,length)


Measured memory_bytes: 6872
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

happiness=0
prev=-2
for i in range(N):
    now=A[i]-1
    happiness+=B[now]
    if prev==now-1:
        happiness+=C[now-1]
    prev=now
    
print(happiness)


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
int a,b,n,m,i,j,k,y;
int c,d[100];
for(i=0;i<100;i++){
d[i]=0;
}
scanf("%d",&n);
scanf("%d %d",&a,&b);
scanf("%d",&c);
for(i=0;i<n;i++){
scanf("%d",&d[i]);
}
for(j=0;j<n;j++){
for(k=0;k<n-1;k++){
if(d[k]<d[k+1]){
m=d[k+1];
d[k+1]=d[k];
d[k]=m;
}
}
}

for(i=0;i<n;i++){
if(c/(a+i*b)<d[i]/b){
c+=d[i];
}
else{
y=c/(a+i*b);
printf("%d\n",y);
break;
}
}
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,X;
  bool Y=false;
  cin>>A>>B;
  for(X=0;X<B*20;X++){
    if(X*8/100==A && X/10==B){
      cout<<X<<endl;
      Y=true;
      break;
    }
  }
  if(Y==false){
    cout<<-1<<endl;
  }
}


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

int main(){
    int N,s=0,i;
    cin >> N;
    vector<int> v(N);
    for(i=0;i<N;i++){cin >> v.at(i);
    }
    
    sort (v.begin(),v.end());
    if (N%2 == 0){
        for(i=N-1; 0<i;i-=2){
        s += (v.at(i)-v.at(i-1));
        }
    }
    if (N%2 == 1){
        for(i=N-1; 1<i;i-=2){
        s += (v.at(i)-v.at(i-1));
        }
        s += v.at(0);
        }
        cout << s << endl;
        
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
calc = 0
ans = 0

for i in range(N):
    A = list(map(int,input().split()))
    calc = 0
    for j in range(M):
        calc += A[j] * B[j]

    if calc + C > 0:
        ans += 1

print(ans)


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

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

using namespace std;

int main(){
	int w,h,n; cin>>w>>h>>n;
	int B[100][100]={};
	rep(_,n){
		int x,y,a; cin>>x>>y>>a;
		if     (a==1) rep(i,h) rep(j,x) B[i][j]=1;
		else if(a==2) rep(i,h) for(int j=x;j<w;j++) B[i][j]=1;
		else if(a==3) rep(j,w) rep(i,y) B[i][j]=1;
		else          rep(j,w) for(int i=y;i<h;i++) B[i][j]=1;
	}

	int ans=0;
	rep(i,h) rep(j,w) ans+=1-B[i][j];
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Pairs{
	private int x;
	private int y;

	//コンストラクタ
	public Pairs(int xx, int yy) {
		x = xx;
		y = yy;
	}

	//ゲットとセット--------------------------
	public int getX() { return x;}
	public int getY() { return y;}
}

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			Pairs[] array = new Pairs[n];  //二次元配列にする：n個{x,y,小数}
			for (int i=0; i<n; i++) {
				int xx = sc.nextInt();
				int yy = sc.nextInt();
				array[i] = new Pairs(xx,yy);
			}
			Arrays.sort(array,new Comparator<Pairs>() {
				@Override
				public int compare(Pairs p0, Pairs p1) {
					if (p0.getX() > p1.getX()) return 1;
					else if (p0.getX() < p1.getX()) return -1;
					else {  //xがおなじ
						if (p0.getY() > p1.getY()) return 1;
						else return -1;
					}

				}
			});
			for (int i=0; i<n; i++) {
				System.out.println(array[i].getX() + " " + array[i].getY());
			}
		}
	}
}



Measured memory_bytes: 114944
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf8");

const range = (n: number) => Array.from(Array(n), (_, i) => i);

const N = BigInt(input);

const getNo = (n: bigint): string => {
  const alphabets: string[] = Array.from(Array(26), (_, i) => String.fromCharCode("a".charCodeAt(0) + i));

  const getNo = (n: bigint, l: bigint): string => {
    const m = 26n ** l;
    if (n <= m) {
      return range(Number(l)).reduce(
        ({ num, str }, _) => ({
          num: num / 26n,
          str: alphabets[Number(num % 26n)] + str,
        }),
        { num: n - 1n, str: "" }
      ).str;
    } else {
      return getNo(n - m, l + 1n);
    }
  };

  return getNo(n, 1n);
};

console.log(getNo(N));


Measured memory_bytes: 29636
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

LL dp[ 51 ][ 51 ][ 3000 ];

int main()
{
	int N, A;
	cin >> N >> A;
	int x[ N ];
	REP( i, N ) cin >> x[ i ];
	dp[ 0 ][ 0 ][ 0 ] = 1;
	REP( i, N ) REP( j, N ) REP( k, 3000 )
	{
		dp[ i + 1 ][ j ][ k ] += dp[ i ][ j ][ k ];

		if( k - x[ i ] >= 0 )
		{
			dp[ i + 1 ][ j + 1 ][ k ] += dp[ i ][ j ][ k - x[ i ] ];
		}
	}
	LL ans = 0;
	REP( j, N + 1 ) REP( k, 3000 )
	{
		if( j == 0 ) continue;
		if( ( k % j == 0 ) && ( k / j == A ) )
		{
			ans += dp[ N ][ j ][ k ];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 60032
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

const int N = 310;
const int M = 1e5 + 10;
const int INF = 0x3f3f3f3f;

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

int a[N][N];
int vis[N], num[N];
int n, m, mid;

int main ()
{
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++)
	for(int j = 0; j < m; j++)
		scanf("%d", &a[i][j]);
	
	memset(vis, 0, sizeof(vis));
	mid = n;
		
	for(int cnt = 0; cnt < m; ){
		for(int i = 1; i <= m; i++)
			num[i] = 0;
		int mx = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++)
				if(!vis[a[i][j]]){
					num[a[i][j]]++;
					mx = max(mx, num[a[i][j]]);
					break;
				}
		}
		
		mid = min(mx, mid);
		for(int i = 1; i <= m; i++)
			if(num[i] == mx){
				vis[i] = 1;
				cnt++;
			}
	}
	
	printf("%d\n", mid);
	
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int x,y;
  cin>>x>>y;
 int z=(y-(2*x))/2;
  if(x<y && z>=0 && z<=x &&(y-(2*x))%2==0)
  {cout<<"Yes";}
  else
  { cout<<"No";}
return 0;
}

Measured memory_bytes: 3636
# include <iostream>
# include <set>
# include <string.h>
using namespace std;
const int N=56;
set <int> a[N];
int b[N];
int n,m,s,t,f;
void work (int x)
{
	set <int>:: iterator i;
	t++;
	if (t==n+1)
	{
		f=1;
		return ;
	}
	b[x]=1;
	for (i=a[x].begin ();i!=a[x].end ();i++)
	if (b[*i]==0)
	{
		work (*i);
		if (f==1)
		return ;
	}
}
int main (void)
{
	set <int>:: iterator p;
	int i,j,k,q;
	cin>>n>>m;
	for (i=1;i<=m;i++)
	{
		cin>>j>>k;
		a[j].insert (k);
		a[k].insert (j);
	}
	for (i=1;i<=n;i++)
	{
		p=a[i].begin ();
		while (p!=a[i].end ())
		{
			q=*p;
			if (q>i)
			{
				f=0;
				t=1;
				a[i].erase (q);
				a[q].erase (i);
				memset (b,0,sizeof (b));
				work (1);
				if (t<=n)
				s++;
				a[i].insert (q);
				a[q].insert (i);
			}
			p=a[i].upper_bound (q);
		}
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
t,a = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)

av_arr = []
n.times do |i|
  av_arr << (t - arr[i] * 0.006)
end

dis_arr = []
av_arr.each do |v|
  dis_arr << (a - v).abs
end

p dis_arr.index(dis_arr.min) + 1


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    char b; cin >> b;
    if (b == 'A') puts("T");
    if (b == 'C') puts("G");
    if (b == 'G') puts("C");
    if (b == 'T') puts("A");
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5+5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	char a;cin>>a;cout<<(a<97?"A":"a")<<endl;
}


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

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0; i<N; ++i){
    cin >> m[i];
  }
  sort(m.begin(),m.end());
  
  int Sum=0;
  int ext=0;
  int count=N-1;
  for(int i=0; i<N; ++i){
    Sum+=m[i];
  }
  ext = X-Sum; 
  int i = 0;
  while(true){
    if((ext-m[0]*i)<0){
      break;
    }
    count++;
    i++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.math.BigInteger;
 
public class Main implements Runnable {
	
	static int mod = 1000000007;
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
    	PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[] x = sc.nextlongArray(n);
        long[] y = sc.nextlongArray(m);
        
        out.println(sumRect(x,y));
        
        out.flush();
    }

	long sumRect(long[] x, long[] y){
		final int mod = 1000000007;
		
		long xsum = 0;
		for(int k=0;k<x.length;k++){
			xsum += k*x[k];
			xsum -= (x.length-k-1)*x[k];
		}
		
		long ysum = 0;
		for(int k=0;k<y.length;k++){
			ysum += k*y[k];
			ysum -= (y.length-k-1)*y[k];
		}
		
		xsum = (xsum%mod + mod)%mod;
		ysum = (ysum%mod + mod)%mod;
		
		return xsum*ysum %mod;
	}

}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextintArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public long[] nextlongArray(int n){
		long[] a = new long[n];
		for(int i=0;i<n;i++){
			a[i] = nextLong();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 26708
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pairsort1(const P& element1, const P& element2)
{//first昇順
	return element1.F < element2.F;
}
bool pairsort2(const P& element1, const P& element2)
{//first降順
	return element1.F > element2.F;
}
bool pairsort3(const P& element1, const P& element2)
{//second昇順
	return element1.S < element2.S;
}
bool pairsort4(const P& element1, const P& element2)
{//second降順
	return element1.S > element2.S;
}

int main() {
	int N;
	cin >> N;
	vector <pair<int, int>>ab(N), cd(N);
	vector<vector<bool>>map(N*2, vector<bool>(N*2,false));
	rep(i, N) {
		cin >> ab[i].F >> ab[i].S;
		map[ab[i].F][ab[i].S]=true;
	}
	rep(i, N) {
		cin >> cd[i].F >> cd[i].S;
	}
	sort(all(cd), pairsort1);
	sort(all(ab),pairsort1);
	vector<pair<int,int>>pair(N);
	int atmp = 0 , btmp = 0;
	int count = 0;
	rep(i, N) {
		int j = 0;
		int atmp = 0;
		int btmp = -1;
		bool flag = false;
		while (ab[j].F < cd[i].F){
			if (ab[j].S<cd[i].S&&
				ab[j].S >btmp&&
				map[ab[j].F][ab[j].S] ==true) {
				atmp = ab[j].F;
				btmp = ab[j].S;
				flag = true;
			}
			j++;
			if (j == N) {
				break;
			}
		}
		if (flag) {
			count++;
			map[atmp][btmp] = false;
		}
	}
	cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
 
std::string str;
 
int ans=0;
 
 
int main() {
 
    std::cin>>str;
 
    for(int i=0;i<str.size()-2;++i){
        int x = std::stoi(str.substr(i,3));
        if(abs(ans-753)>abs(x-753))
            ans=x;
    }
 
    std::cout<<abs(ans-753)<<std::endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int N, M;
bool G[8][8] = {};

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        G[a-1][b-1] = G[b-1][a-1] = true;
    }

    // 全順列を生成
    int linked_count = 0;
    int p[8] = {0, 1, 2, 3, 4, 5, 6, 7};
    do {
        bool is_linked = true;
        // N = 1のとき i は [0, 0]
        // N = 2のとき i は [0, 0]
        // N = 3のとき i は [0, 1]
        // iは始点となるノード番号-1
        for(int i = 0; i < N-1 && is_linked; ++i) {
            is_linked = G[p[i]][p[i+1]];
        }

        if(is_linked) ++linked_count;
    } while(next_permutation(p + 1, p + N)); // N = 3のとき [p+1, p+2] = [p+1, p+3)

    cout << linked_count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>e(500000), w(500000);

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (s[0] == 'E') {
		e[0] = 1;
	}
	if (s[n - 1] == 'W') {
		w[n - 1] = 1;
	}
	REP(i, 1, n) {
		if (s[i] == 'E') {
			e[i] = e[i - 1] + 1;
		}
		else {
			e[i] = e[i - 1];
		}
	} 
	REP(i, 1, n) {
		if (s[n - i] == 'W') {
			w[n - i] = w[n - i + 1] + 1;
		}
		else {
			w[n - i] = w[n - i + 1];
		}
	}
	int ans = 1000000;
	REP(i, 1, n - 1) {
		int hoge = n - 1 - e[i - 1] - w[i + 1];
		ans = min(ans, hoge);
	}
	ans = min(ans, n - 1 - w[1]);
	ans = min(ans, n - 1 - e[n - 2]);
	cout << ans << endl;
	return 0;
}

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

vector<ll> v;
int K;

void solve(ll num)
{
    if (num > 1e12) return;
    v.push_back(num);

    int d = num % 10;
    if (d > 0) solve(num * 10 + d - 1);
    solve(num * 10 + d);
    if (d < 9) solve(num * 10 + d + 1);
}

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

    v.clear();
    cin >> K;

    for (ll i = 1; i <= 9; ++i)
        solve(i);

    sort(v.begin(), v.end());
    cout << v[K - 1] << endl;
}


Measured memory_bytes: 18664
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  long long X;
  cin >> X;
  long long c = 100;
  int n;
  for (n = 0; c < X; ++n) {
    c += c / 100;
  }
  cout << n << "\n";
  return 0;
}


Measured memory_bytes: 3624
from collections import deque


def topological_sort_tree(tree: list, root) -> list:
    """根付き木をトポロジカルソートする"""
    n = len(tree)
    ans = [root]
    visited = [False] * n
    visited[root] = True
    q = deque([root])
    while q:
        par = q.popleft()
        for child in tree[par]:
            if visited[child]:
                continue
            visited[child] = True
            q.append(child)
            ans.append(child)
    return ans


n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]
MOD = 10 ** 9 + 7


tree = [[] for i in range(n)]
for a, b in info:
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)


inv2 = pow(2, MOD - 2, MOD)
ans = 0
tp_sorted = topological_sort_tree(tree, 0)[::-1]
dp = [0] * n
for v in tp_sorted:
    sum_ = 0
    w_p = []
    for nxt_v in tree[v]:
        sum_ += dp[nxt_v]
        if dp[nxt_v] != 0:
            w_p.append(pow(inv2, dp[nxt_v], MOD))
    dp[v] = sum_ + 1

    if len(tree[v]) == 1:
        continue
    if n - dp[v] != 0:
        w_p.append(pow(inv2, n - dp[v], MOD))

    res = 1
    all_w = 1
    for val in w_p:
        all_w *= val
        all_w %= MOD
    res -= all_w
    res %= MOD

    for val in w_p:
        b = 1 - val
        res -= all_w * pow(val, MOD - 2, MOD) * b
        res %= MOD
    ans += res * inv2
    ans %= MOD

print(ans % MOD)

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

typedef long long hash_type;

struct rolling_hash {
	int n;
	hash_type mod1, mod2, base1, base2;
	vector <hash_type> hash1, hash2, pow1, pow2;
	rolling_hash() { clear(); }
	rolling_hash(const rolling_hash &x) { *this = x; }
	rolling_hash(const string &s) { init(s); }
	inline void clear() {
		mod1 = 1e9 + 7;
		mod2 = 1e9 + 9;
		base1 = 1007;
		base2 = 1009;
		hash1.clear();
		hash2.clear();
		pow1.clear();
		pow2.clear();
	}
	inline void init(const string &s){
		clear();
		n = s.length();
		hash1.assign(n + 1, 0);
		hash2.assign(n + 1, 0);
		pow1.assign(n + 1, 1);
		pow2.assign(n + 1, 1);
		for (int i = 0; i < n; ++i) {
			hash1[i+1] = (hash1[i] * base1 + s[i]) % mod1;
			hash2[i+1] = (hash2[i] * base2 + s[i]) % mod2;
			pow1[i+1] = (pow1[i] * base1) % mod1;
			pow2[i+1] = (pow2[i] * base2) % mod2;
		}
	}
	// [l, r)
	inline pair <hash_type, hash_type> get_hash(int l, int r){
		hash_type h1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
		hash_type h2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
		return make_pair(h1, h2);
	}

	inline bool match(int l1, int r1, int l2, int r2){
		if (r1 > n || r2 > n) return false;
		return get_hash(l1, r1) == get_hash(l2, r2);
	}
	inline bool match(int l1, int l2, int k){
		return match(l1, l1 + k, l2, l2 + k);
	}
	inline int lcp(int l1, int l2){
		int ok = 0, ng = n;
		while (ng - ok > 1){
			int m = (ok + ng) / 2;
			if (match(l1, l2, m)) ok = m;
			else ng = m;
		}
		return ok;
	}
};

string s, t;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> s >> t;
	if (s == string((int)s.size(), s[0]) && t == string((int)t.size(), s[0]))
		return puts("-1") & 0;
	while ((int)s.size() < (int)t.size()) s += s;
	s += s;
	rolling_hash rs(s), rt(t);
	int n = (int)s.size() / 2, m = (int)t.size();
	vector <int> cnt(n, -1);
	for (int i = 0; i < n; ++i) {
		if (~cnt[i]) continue;
		int p = i, c = 0;
		vector <int> v;
		set <int> st;
		while (true) {
			if (rt.get_hash(0, m) != rs.get_hash(p, p + m)) break;
			v.push_back(p);
			st.insert(p);
			p = (p + m) % n;
			if (st.count(p)) {
				puts("-1");
				return 0;
			} 
			if (~cnt[p]) {
				c = cnt[p];
				break;
			}
		}
		if (v.empty()) cnt[i] = 0;
		else
			for (int j = 0; j < (int)v.size(); ++j)
				cnt[v[(int)v.size() - j - 1]] = c + j + 1; 
	}
	cout << *max_element(cnt.begin(), cnt.end()) << endl;
	return 0;
}

Measured memory_bytes: 97500
# -*- coding: utf-8 -*-
def main():
    s = int(input())
    # s = 10
    mod = 10**9+7

    dp = [0]*(s+1)
    dp[0] = 1
    for i in range(1, s+1):
        for j in range((i-3)+1):
            dp[i] += dp[j]
            dp[i] %= mod
    print(dp[s])
if __name__ == '__main__':
    main()

Measured memory_bytes: 8992
#include<stdio.h>
int main(){
  int x,y,r,number;

  scanf("%d%d",&x,&y);

  if(x<y){
    number = x;
    x = y;
    y = number;
  }

  r = x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }

  printf("%d\n",y);

  return 0;
}

Measured memory_bytes: 592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=0;i<2;i++){
    if(a>b){
      ans+=a;
      a--;
    }
    else{
      ans+=b;
      b--;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
// D - Xor Sum 4

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

const int MOD = 1000000007;

// A の全てのペアについてXORを求め、その総和を計算することになる
// 各ビットごとにXORの和を求め、(2のk乗) * （各ビットのXORの和）の総和を求める
// 各ビットのXORの和は 1と0の組み合わせの数となる

int main() {
	int N;
	cin >> N;

	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	ll sum = 0;
	// 2のk乗の桁ごとに和を計算
	for (int k = 0; k < 60; k++) {
		ll ones = 0;
		for (int i = 0; i < N; i++) {
			ones += (A[i] >> k) & 1;
		}
		ll xor_sum = (ones * (N - ones)) % MOD;

		//cout << xor_sum << " "; // **** debug ****

		ll bit_sum = xor_sum;
		for (int i = 0; i < k; i++) {
			bit_sum = (bit_sum * 2) % MOD;
		}

		sum = (sum + bit_sum) % MOD;
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <iostream>

using std::sort;
using std::cout;
using std::min;

const int MAXN=305;
int n,m;
int tmp[MAXN][MAXN];
long long ans;
long long G[MAXN][MAXN];

struct line{
	int u,v,w;
	line(int u=0,int v=0,int w=0):u(u),v(v),w(w){}
	friend bool operator< (const line &a,const line &b){
		return a.w<b.w;
	}
}ed[MAXN*MAXN];

inline bool jud(line &e){
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i==j) continue;
			G[i][j]=min(G[i][j],G[i][e.u]+e.w+G[e.v][j]);
			G[j][i]=G[i][j];
			G[i][j]=min(G[i][j],G[i][e.v]+e.w+G[e.u][j]);
			G[j][i]=G[i][j];
			if(G[i][j]<tmp[i][j]) return false;
		}
	}
	return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)
			scanf("%d",&tmp[i][j]);
	}
	for(int i=1;i<n;++i){
		for(int j=i+1;j<=n;++j)
			ed[++m]=line(i,j,tmp[i][j]);
	}
	sort(ed+1,ed+m+1);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)
			G[i][j]=1e12;
	}
	for(int i=1;i<=n;++i) G[i][i]=0;
	for(int i=1;i<=m;++i){
		if(G[ed[i].u][ed[i].v]==ed[i].w) continue;
		G[ed[i].u][ed[i].v]=ed[i].w;
		G[ed[i].v][ed[i].u]=ed[i].w;
		ans+=ed[i].w;
		if(!jud(ed[i])){
			ans=-1;
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <bits/stdc++.h>
#include <string>
typedef long long ll;
using namespace std;
int main(void){
    int n; cin >> n;
    string s; cin >> s;
    string t; cin >> t;
    for(int i=0;i<n;i++){
        cout << s[i] << t[i];
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

int32_t main(){
	boost;
	int n,r;
	cin>>n>>r;
	if(n>=10){
		cout<<r;
	}else{
		int res=r+(10-n)*100;
		cout<<res;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
#define INF 10000000000000000LL

ll ret;

void calc(ll H, ll W){
  for(ll w=1; w<W; w++){
    ll w1 = w, h1 = H;
    ll w2 = W-w, h2 = H;

    {
      ll w11 = w1/2, h11 = H;
      ll w12 = w1-w11, h12 = H;
      ret = min(ret, max(w11*h11, max(w12*h12, w2*h2)) - min(w11*h11, min(w12*h12, w2*h2)));
    }
    {
      ll w11 = w1, h11 = H/2;
      ll w12 = w1, h12 = H-h11;
      ret = min(ret, max(w11*h11, max(w12*h12, w2*h2)) - min(w11*h11, min(w12*h12, w2*h2)));
    }
    {
      ll w21 = w2/2, h21 = H;
      ll w22 = w2-w21, h22 = H;
      ret = min(ret, max(w21*h21, max(w22*h22, w1*h1)) - min(w21*h21, min(w22*h22, w1*h1)));
    }
    {
      ll w21 = w2, h21 = H/2;
      ll w22 = w2, h22 = H-h21;
      ret = min(ret, max(w21*h21, max(w22*h22, w1*h1)) - min(w21*h21, min(w22*h22, w1*h1)));
    }

  }
}
  
int main(){
  ll H, W;
  cin >> H >> W;

  ret = INF;
  calc(H, W);
  calc(W, H);

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




double a;

int main() {

	cin >> a;

	cout << a * PI * 2 << endl;

	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdlib>

int main(){
  char s[4];
  std::cin >> s;
  const int N = atoi(s);
  const int d_p = 7;
  const int c_p = 4;
  const int d_max = N / d_p;
  bool found = false;
  for(int i = d_max; 0 <= i; i--) {
    if ((N - i*d_p) % c_p == 0) {
      found = true;
      break;
    }
  }
  if(found)
    std::cout<<"Yes"<<std::endl;
  else
    std::cout<<"No"<<std::endl;
  return 0;
    
}

Measured memory_bytes: 256