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

ll N, ans=0;

void yakusuu1(ll num) {
    for(int i=2;i*i<=num;i++) {
        if(num%i==0) {
            if(i==num/i) ans++;
            else ans += 2;
        }
    }
    if(num!=1) ans++;
    //cout << "OK1" << endl;
}

void yakusuu2(ll num) {
    for(int i=2;i*i<=num;i++) {
        int num1 = num;
        int flag=0;
        while(num1%i==0) {
            num1 /= i;
            flag=1;
            //cout << i << " : " << num1 << endl;
        }
        if(flag==1&&num1%i==1) ans++;
    }
    if(num!=1) ans++;
    //cout << "OK2" << endl;
}

signed main(){
    cin >> N;
    yakusuu1(N-1);
    yakusuu2(N);
    //cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
// #define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 2000000000000000000 //1e16
 
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,r,l,s,u,v,w,j,pos,sum=0,flag=0,count=0;
    string S,T; 
    int d;
    cin>>d>>t>>s;
    if(s*t>=d)
    {
        cout<<"Yes";
    }
    else cout<<"No";
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3648
import scala.io.StdIn

object Main extends App {

  private val w = StdIn.readLine()
  val wsize = w.length
  var text = ""
  var cnt = 0
  
  do {
    cnt += text.toLowerCase.split(' ').count(p => p == w)
    text = StdIn.readLine()
  } while(text != "END_OF_TEXT")
  
  println(cnt)
  
}


Measured memory_bytes: 43876
#include<iostream>
#include<vector>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
#include<cstdint>

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) const { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) const { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) const { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};

int64_t const MOD = 1e9+7;
typedef mod_int<MOD> mint;

// fact
template<typename INT>
struct factorial {
  std::vector<INT> fact, ifact;
  void init(int64_t N) {
    fact.resize(N+1); ifact.resize(N+1);
    fact[0] = fact[1] = INT(1);
    for(int i = 2; i <= N; ++i) fact[i] = fact[i-1]*i;
    ifact[N] = fact[N].inv();
    for(int i = N-1; i >= 0; --i) ifact[i] = ifact[i+1]*(i+1);
  }
  INT perm(int64_t n, int64_t k) { // nPk
    if(k > n || k < 0) return INT(0);
    return fact[n]*ifact[n-k];
  }
  INT comb(int64_t n, int64_t k) { // nCk
    if(k > n || k < 0) return INT(0);
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  if(M==1) fin(0);
  factorial<mint> F;
  F.init(M);
  mint ans;
  for(int i = 0; i <= N; ++i) {
    mint p = F.perm(M-i, N-i);
    ans += mint(-1).pow(i)*F.comb(N,i)*F.perm(M,i)*p*p;
  }
  fin(ans.v_);
  return 0;
}


Measured memory_bytes: 11468
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int gcd(int x,int y){
	while(y){
		int t=x%y;
		x=y;
		y=t;
	}
	return x;
}
int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m)==2){
		int x=gcd(n,m);
		printf("%d %d\n",x,n/x*m);
	}
}

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

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

	int pos = 0, zero = 0, neg = 0;

	vector<ll> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] > 0) pos++;
		else if (a[i] == 0) zero++;
		else neg++;
		a[i] = abs(a[i]);
	}
	
	sort(a.begin(), a.end());

	if (neg % 2 == 1 && zero == 0) a[0] = -a[0];

	cout << accumulate(a.begin(), a.end(), 0LL) << endl;

	return 0;
}

Measured memory_bytes: 1024
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;
const ll INF = 1LL<<50;

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;
}

int main(){

string S;
cin>>S;
bool dream=false,erase=false;
int p=0;
while(p<S.size()){
    if(dream){
        if((p<S.size()-4)&&(S.substr(p,5)=="erase")){
            p+=5;
            dream=false;
            erase=true;
        }
        else if((p<S.size()-1)&&(S.substr(p,2)=="er")){
            p+=2;
            dream=false;

        }
        else if((p<S.size()-4)&&(S.substr(p,5)=="dream")){
            p+=5;
            dream=true;
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }

    }
    else if(erase){
        if(S[p]=='r'){
            erase=false;
            p++;
        }
        else if((p<S.size()-4)&&(S.substr(p,5)=="erase")){
            p+=5;
            erase=true;

        }
        else if((p<S.size()-4)&&(S.substr(p,5)=="dream")){
            p+=5;
            erase=false;
            dream=true;
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    else{
        if((p<S.size()-4)&&(S.substr(p,5)=="erase")){
            p+=5;
            erase=true;
        }
        else if((p<S.size()-4)&&(S.substr(p,5)=="dream")){
            p+=5;
            dream=true;
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }

    }
}
cout<<"YES"<<endl;
return 0;
}

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

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 ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  lb N,M,D;
  cin>>N>>M>>D;
  lb ans = (N-D)*(M-1)*2/N/N;
  if(D==0) ans /= 2;
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

Measured memory_bytes: 3748
n, m = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(m)] 

start, end = e[0][0], e[0][1]
for i in e: 
  if start < i[0]:
    start = i[0]
  if end > i[1]:
    end = i[1]
  if start > end:
    break

if start > end:
  print(0)
else:
  print(end-start+1)

Measured memory_bytes: 21156
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define nl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define dcit cin.sync_with_stdio(0);cin.tie(0)
#define frp(x, y) freopen(x, "r", stdin);freopen(y, "w", stdout);
#define endl '\n'
typedef pair<int, int> pii;
typedef long long ll;

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)

template<typename T> void scani(T& x){x = 0; register bool _ = 0;register T c = gc;while((c<48||c>57)&&c!=45) c=gc;_=c== 45;c=_ ?gc:c;while (c<48||c>57)c=gc;for (;c<48||c>57;c=gc);for (;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printi(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
string nextstring() { string r; register char c=gc;while(c==32||c==10) c = gc;while(!(c==32||c==10)) { r += c;c = gc; }return r; }
char nextgetchar(){ register char c = gc; while(c==32 || c==10) c = gc; return c;}

void prints(string k){ for (int i = 0; i < k.length(); i++)pc(k[i]); }
void scani() {}

template<typename First, typename ... Ints>
void scani(First &arg, Ints&... rest) { scani(arg);scani(rest...); }

const int MAXN = 200002;
ll N, C, h[MAXN], dp[MAXN];
deque<int> q;

double slope(int k, int j){
    if(h[j] == h[k]) return 0x3f3f3f3f;
    return (dp[j]-dp[k] + h[j]*h[j] - h[k]*h[k])/(2.0*(h[j]-h[k]));
}
int main(){
    memset(dp, 0x3f, sizeof dp);  dp[1] = 0;
    scani(N, C);
    for (int i = 1; i <= N; i++)scani(h[i]);
    q.push_back(1);
    for (int i = 2; i <= N; i++) {
        while(q.size() > 1 && slope(q[0], q[1]) <= h[i])
            q.pop_front();

        dp[i] = (h[i] - h[q[0]])*(h[i] - h[q[0]]) + C + dp[q[0]];

        while(q.size()>1 && slope(q[q.size()-2], q[q.size()-1]) >= slope(q[q.size()-1], i))
            q.pop_back();

        q.push_back(i);
//        for (int j = last; j < i; j++) {
//            ll temp = (h[i]-h[j])*(h[i]-h[j]) + C + dp[j];
//            if(temp < dp[i]){
//                last = j;
//                dp[i] = temp;
//            }
//        }
    }
    printi(dp[N]);
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
int main(){
  int n,c,u,k,v,G[100][100],used[100]={},d[100]={},min=0;
  
  cin>>n;
  for(int i=1;i<n;i++)
    d[i]=INF;

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      G[i][j]=-1;
  
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      cin>>c;
      G[u][v]=c;
    }
  }

  while(min!=INF){
    min=INF;
    int idx;
    for(int i=0;i<n;i++)
      if(used[i]!=1 && d[i]<min){
	min=d[i];
        idx=i;
      }
    for(int i=0;i<n;i++)
      if(G[idx][i]!=-1 && used[i]!=1 && d[idx]+G[idx][i]<d[i])d[i]=d[idx]+G[idx][i];
    used[idx]=1;
  }
  
  for(int i=0;i<n;i++)
    cout<<i<<' '<<d[i]<<endl;

  return 0;
}



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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int a = 0, c = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != 'A' && s[i] < 97)
		{
			if (s[i] != 'C')
			{
				cout << "WA";
				return 0;
			}
		}
		if (i == 0 && s[i] == 'A')
		{
			a++;
		}
		else if (i > 1 && i < s.length() - 1 && s[i] == 'C')
		{
			c++;
		}
	}
	if (a == 1 && c == 1)
		cout << "AC";
	else
		cout << "WA";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int x[100][100];
	int y[100] = {0};
	int a[100];
	int n,m;
	int i,j;

	scanf(" %d %d",&n,&m);
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%d",&x[i][j]);
		}
	}
	for(i = 0;i < m;i++){
		scanf(" %d",&a[i]);
	}
	
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			y[i]+=x[i][j]*a[j];
		}
	}
	for(i = 0;i < n;i++){
		printf("%d\n",y[i]);
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m,i,ans,j;
    while(cin>>n)
    {
        ans=1;

        for(i=1; i<=n; i++)
        {
            ans=ans*2;
            if(ans>n)
            {

                ans=ans/2;
                break;

            }
        }
        cout<<ans<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,d,x;
  cin>>n;
  cin>>d>>x;
  vector<int> a(n);
  int ans=x;
  REP(i,n){
    cin>>a[i];
    ans += (d-1)/a[i]+1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
 
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
 
a = []
b = []
for ai, bi in ab:
    a.append(ai)
    b.append(bi)
 
dp = [[0 for _ in range(t)] for _ in range(n+1)]
 
for i in range(n):
    for j in range(t):
        if j + a[i] <= t-1:
            if dp[i+1][j + a[i]] < dp[i][j] + b[i]:
                dp[i+1][j + a[i]] = dp[i][j] + b[i]
        if dp[i+1][j] < dp[i][j]:
            dp[i+1][j] = dp[i][j]
 
ans = 0
 
for i in range(n):
    ans = max(ans, dp[i][t-1] + b[i])
 
print(ans)


Measured memory_bytes: 124376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, x, m, sum = 0, d = 100010;
  cin >> n >> x;
  rep(i,n)
  {
    cin >> m;
    sum += m;
    d = min(d, m);
  }
  cout << n + (x - sum) / d;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pb                  push_back
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    string s,t;cin>>s>>t;
    fo0(i,s.length()){
        if(s[i]!=t[i])
            cnt++;
    }
    cout<<cnt;

}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<fixed<<setprecision(3)<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 3912
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def sqrt(n: int):
    lb = 0
    rb = n + 1
    while lb + 1 < rb:
        m = (lb + rb) // 2
        if m * m > n:
            rb = m
        else:
            lb = m
    return lb


def solve(Q: int, A: "List[int]", B: "List[int]"):
    for Ai, Bi in zip(A, B):
        a = sqrt(Ai * Bi)
        b = a + 1 if a * (a + 1) <= Ai * Bi else a

        def f(a: int, b: int):
            m = a + b - 2
            if a * b == Ai * Bi:
                m -= b - a + 1
                if {a, b} == {Ai, Bi}:
                    m += 1
            return m

        print(max(f(a, b), f(a, b - 1)))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    A = [int()] * (Q)  # type: "List[int]"
    B = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(Q, A, B)


if __name__ == '__main__':
    main()


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

int main() {
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  int Z=0;
  if(2*C>=A+B){
    Z=A*X+B*Y;
  }
  else if(X>Y&&A<2*C){
    Z=C*Y*2+(X-Y)*A;
  }
  else if(X<Y&&B<2*C){
    Z=C*X*2+(Y-X)*B;
  }
  else{
    Z=C*2*max(X,Y);
  }
  cout<<Z<<endl;
}

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

long long MOD = 998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    vector<vector<long long>> dp(c + 10, vector<long long>(d + 10));
    dp[a][b] = 1;
    for (int i = a; i <= c; i++){
        for (int j = b; j <= d; j++){
            dp[i][j] += dp[i - 1][j] * j;
            dp[i][j] %= MOD;
            dp[i][j] += dp[i][j - 1] * i;
            dp[i][j] %= MOD;
            dp[i][j] -= (((dp[i - 1][j - 1] * (i - 1)) % MOD) * (j - 1)) % MOD;
            dp[i][j] %= MOD;
            
            while (dp[i][j] < 0)
                dp[i][j] += MOD;
        }
    }


    cout << dp[c][d] << '\n';

    return 0;
}


Measured memory_bytes: 74036
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 101;
		for(int i=0; i<26; i++){
			char target = (char)(i+'a');
			int max=0;
			int cur=0;
			for(int j=0; j<s.length(); ++j){
				if(s.charAt(j)==target) cur = 0;
				else{
					cur++;
					max = Math.max(max, cur);
				}
			}
			ans = Math.min(ans,max);
		}
		
		System.out.println(ans);
		return;
	}
}

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

int main(){
  string str;
  cin >> str;
  for(int i = 0; str[i] != '\0'; i++ ){
    if(str[i]=='B'){
      if(i!=0){
        str.erase(str.begin()+(i-1),str.begin()+(i+1));
        i-=2;
      }else{
        str.erase(str.begin());
        i-=1;
      }
    }
  }
  cout << str << endl;
  return 0;
}
      

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			if (s.equals("AC")) {
				AC++;
			} else if (s.equals("WA")) {
				WA++;
			} else if (s.equals("TLE")) {
				TLE++;
			} else {
				RE++;
			}
		}
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);
	}
}

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

int main() {
    long long n, k, d; cin >> n >> k >> d;  if (n < 0) n = 0-n; long long div = n / d;
    if (div >= k) {cout << abs(n - (d*k)) << endl; return 0;}
    long long remain = k - div; long long newnum = n - (div*d);
    if (remain % 2 == 0) {cout << abs(newnum) << endl;}
    else {cout << abs(newnum - d) << endl;} 
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	int n,m; cin >> n >> m;
	vector<pair<int,int> > v;
	priority_queue<int> q;
	for(int i=0;i<n;i++){
		int a,b; cin >> a >> b;
		v.push_back(make_pair(a,-b));
	}
	ll ans=0;
	sort(v.begin(),v.end());
	int now=m-1;
	for(int i=0;now>=0;i++){
		bool in=false;
		while(i<n&&now+v[i].first<=m){
			q.push(-1*v[i].second);
			i++;
			in=true;
		}
		i--;
		if(q.empty()){
			//cout << "emp" << now << endl;
		}
		else{
		 //cout <<now << "now "<< q.top() << endl;
		 ans+=q.top();
		 q.pop();
		}
		now--;
		if(now<0)break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1908
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>


using namespace std;


using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int D;

    D=B / A;

    if(D<=0){

        cout<<0<<endl;

        return 0;
    }

    int ans;

    ans= min(C,D);

    cout<<ans<<endl;




}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    int N; cin >> N;
    vector<int> a(N);
    int s=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        s += a[i]-1;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[]args){
        Scanner cin=new Scanner(System.in);
        String first = cin.nextLine();
        String second = cin.nextLine();

        for(int i =1;i<=first.length()+second.length();i++){
        	if(i%2==1){
        		System.out.print(String.valueOf(first.charAt((i-1)/2)));
        	}
        	else{
        		System.out.print(String.valueOf(second.charAt((i/2)-1)));
        	}
        }
    }
}


Measured memory_bytes: 23764
import java.util.*;

import javax.swing.plaf.basic.BasicSliderUI.ScrollListener;

public class Main {
    static public void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String temp = sc.next();
        long n = Long.parseLong(temp);
        temp = sc.next();
        long k = Long.parseLong(temp);

        long temp2 = n % k;
        if (temp2 > k / 2) {
            temp2 = k - temp2;
        }
        System.out.println(temp2);
    }
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left\n";
	}
	else if (a + b == c + d) {
		cout << "Balanced\n";
	}
	else {
		cout << "Right\n";
	}
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  mint dp[n + 1][4] = {};
  dp[0][0] = 1;
  rep(i, n) {
    if(s[i] == 'A' || s[i] == '?') dp[i + 1][1] += dp[i][0];
    if(s[i] == 'B' || s[i] == '?') dp[i + 1][2] += dp[i][1];
    if(s[i] == 'C' || s[i] == '?') dp[i + 1][3] += dp[i][2];
    if(s[i] == '?')
      rep(j, 4) dp[i + 1][j] += dp[i][j] * 3;
    else
      rep(j, 4) dp[i + 1][j] += dp[i][j];
  }
  cout << dp[n][3] << endl;
}

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

using namespace std;

int WordsDegree[26];
bool Route[26][26], UsedHead[26], UsedTail[26];


bool judgeSide() {
	for (int i = 0; i < 26;++i) {
		if (WordsDegree[i] != 0) {
			return false;
		}
	}
	return true;
}

bool judgeCircle() {
	for (int k = 0; k < 26; ++k) {
		for (int i = 0; i < 26; ++i) {
			for (int j = 0; j < 26; ++j) {
				if (Route[i][k] && Route[k][j]) {
					Route[i][j] = true;
				}
			}
		}
	}

	for (int i = 0; i < 26; ++i) {
		if (!UsedHead[i]) {
			continue;
		}
		for (int j = 0; j < 26; ++j) {
			if (!UsedTail[j]) {
				continue;
			}
			if (!Route[i][j]) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	int n,head,tail;
	string str;

	while (cin >> n, n) {
		memset(WordsDegree, 0, sizeof(WordsDegree));
		memset(Route, false, sizeof(Route));
		memset(UsedHead, false, sizeof(UsedHead));
		memset(UsedTail, false, sizeof(UsedTail));
		for (int i = 0; i < n; ++i) {
			cin >> str;
			//cout << "head:" << str.front() << "   tail:" << str.back() << endl;
			//head = str.front() - 'a';
			//tail = str.back() - 'a';
			head = str[0] - 'a';
			tail = str[str.size() - 1] - 'a';
			++WordsDegree[head];
			--WordsDegree[tail];
			Route[head][tail] = true;
			UsedHead[head] = true;
			UsedTail[tail] = true;
		}
		if (judgeSide() && judgeCircle()) {
			cout << "OK" << endl;
		}
		else {
			cout << "NG" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<vector<int>> shop = vector<vector<int>>(100, vector<int>(10, 0));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 10; ++j)
        {
            cin >> shop[i][j];
        }
    }
    vector<vector<int>> gain = vector<vector<int>>(100, vector<int>(11, 0));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 11; ++j)
        {
            cin >> gain[i][j];
        }
    }
    vector<int> map = vector<int>(1024, 0);
    
    for (int i = 0; i < 1024; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            int count = 0;
            for (int k = 0; k < 10; ++k)
            {
                int num = ((i >> k) & 1);
                if (num & shop[j][k])
                {
                    count++;
                }
            }
            map[i] += gain[j][count];
        }
    }
    int ret = -2147483648;
    for (int i = 1; i < 1024; ++i)
    {
        ret = max(ret, map[i]);
    }
    cout << ret << endl;

    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
ll n;
ll cnt=0;
vector<vector<ll>> a(8);//辺(添え字は始点、値は終点)
vector<ll>t(8);//訪問したかどうか
void dfs(ll k){
  t[k]=1;
  ll buf=0;
  for(ll i=0;i<a[k].size();i++){
    if(t[a[k][i]]==0){
      //cout<<k spa a[k][i]<<endl;
      dfs(a[k][i]); 
      buf++;
    }
  }
  if(buf==0){
    bool judge=true;
    for(ll i=0;i<n;i++){
      if(t[i]==0)judge=false;
    }
    if(judge)cnt++;
  }
  t[k]=0;
}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = false;
  ll m;cin>>n>>m;
  ll p,q;
  for(i=0;i<m;i++){
    cin>>p>>q;
    a[p-1].push_back(q-1);
    a[q-1].push_back(p-1);
  }
  dfs(0);
  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 256
a=list(input())
b=list(input())
a.sort()
b.sort(reverse=True)

i=0
while a[i] == b[i] and i<min(len(a),len(b))-1:
    i+=1


if a[i]<b[i] or (a[i]==b[i] and len(a)<len(b)):
    print('Yes')
else:
    print('No') 









Measured memory_bytes: 3060
N = int(input())
A = [0] + list(map(int,input().split())) + [0]

All = 0

for i in range(N+1):
    All += abs(A[i]-A[i+1])

for i in range(1,N+1):
        print(All- abs(A[i-1]-A[i]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1]))

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

int main() {
    int N, count, end_flag;
    
    cin >> N;

    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    }
    
    count = -1;
    end_flag = 0;
    while (end_flag == 0)
    {
        count += 1;
        for (int i = 0; i < N; i++){

        if (vec[i]%2 != 0){
            end_flag = 1;
            break;
        }   

        vec[i] = vec[i]/2;
        }
    }   

    cout << count << endl;
}

Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
p = list(map(int,input().split()))
price = [x*(-1) for x in p]
heapq.heapify(price)
while m != 0:
    max_price = heapq.heappop(price)*(-1)
    heapq.heappush(price,(max_price//2)*(-1))
    m -= 1
print(sum(price)*(-1))

Measured memory_bytes: 19944
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
R,C,K=map(int, sys.stdin.readline().split())

value=defaultdict(lambda: 0)
value=[ [0 for _ in range(C+1)] for __ in range(R+1) ]
for _ in range(K):
    r,c,v=map(int, sys.stdin.readline().split())
    value[r][c]=v

dp0=[0]*(C+1)
dp1=[0]*(C+1)
dp2=[0]*(C+1)
dp3=[0]*(C+1)

for r in range(1,R+1):
    for c in range(1,C+1):
        #今のマスにアイテムがある場合
        if 0<value[r][c]:
            dp3[c]=max( dp3[c-1], dp2[c-1]+value[r][c] )
            dp2[c]=max( dp2[c-1], dp1[c-1]+value[r][c] )
            dp1[c]=max( dp1[c-1], dp0[c-1]+value[r][c], dp0[c]+value[r][c] )
            dp0[c]=max( dp0[c-1], dp0[c] )
        #今のマスにアイテムがない場合
        else:
            #dp0[c]=max( dp0[c-1], dp0[c] )
            #dp1[c]=max( dp1[c-1], dp1[c] )
            #dp2[c]=max( dp2[c-1], dp2[c] )
            #dp3[c]=max( dp3[c-1], dp3[c] )
            dp0[c]=dp0[c]
            dp1[c]=dp1[c-1]
            dp2[c]=dp2[c-1]
            dp3[c]=dp3[c-1]

    #上の行にアイテムをコピー
    for c in range(1,C+1):
        dp0[c]=max( dp0[c], dp1[c], dp2[c], dp3[c] )
    dp1=[0]*(C+1)
    dp2=[0]*(C+1)
    dp3=[0]*(C+1)

print dp0[C]


Measured memory_bytes: 148156
//#define _USE_MATH_DEFINES
#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, l;
    cin >> n >> l;

    int best = l;

    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        int cur = l + i - 1;
        sum += cur;
        if (abs(cur) < abs(best))
            best = cur;
    }
    cout << sum - best << endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    bool is_zero = false;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            is_zero = true;
            break;
        }
    }

    if (is_zero) {
        cout << 0 << "\n";
        return;
    }

    bool ok = true;
    ll ans = 1;
    for (ll i = 0; i < N; i++) {
        if (A[i] >= L_INF / ans) {
            ok = false;
            break;
        }

        ans *= A[i];

        if (ans > 1000000000000000000) {
            ok = false;
            break;
        }
    }

    if (ok) {
        cout << ans << "\n";
    }
    else {
        cout << -1 << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int mod = 1000000007;

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<bool> brk(n+2, 0);
  for(int i = 0; i < m; i++){
    int tmp;
    cin >> tmp;
    brk.at(tmp) = 1;
  }
  
  vector<long long> dp(n + 2, 0);
  dp.at(0) = 1;
  
  for(int i = 0; i < n; i++){
    if (brk.at(i)) dp.at(i) = 0;
    dp.at(i + 1) = (dp.at(i + 1) + dp.at(i)) % mod;
    dp.at(i + 2) = (dp.at(i + 2) + dp.at(i)) % mod;
  }
  
  cout <<  dp.at(n) % mod << endl;
  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,n;
ll getans(ll a,ll b,ll x)
{
    return a*x/b-a*(x/b);
}
int main()
{
    cin>>a>>b>>n;
    if(n<b) printf("%lld\n",getans(a,b,n));
    else printf("%lld\n",getans(a,b,b-1));
}


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

ll tc, bil, r;


int main(){
	scanf("%lld", &tc);
	map<string, int> m;
	ll jaw = 0;
	for(int k = 1; k<= tc; k++){
		string s;
		cin >> s;
		if(m[s] == 0){
			jaw++;
			m[s]++;
		}
	}
	printf("%lld\n",jaw);
}

Measured memory_bytes: 19272
package main

import (
	"fmt"
)

func main() {
	var a, w int
	var h, m, s int
	fmt.Scanf("%d", &a)
	w = a
	s = w % 60
	w = w / 60
	m = w % 60
	h = w / 60

	fmt.Printf("%d:%d:%d\n", h, m, s)
}



Measured memory_bytes: 1136
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        n: usize, // 1 <= N
        m: usize, // M <= 12
        x: i32, // 10 ^ 5
        c: [[i32; m + 1]; n],
    }
    let mut min_cost = i32::max_value(); // 適当に大きな数字

    // 2進数で各本の有無についてループを回す
    // ex. 0 0 0: 買わない 買わない 買わない
    //     0 0 1: 買わない 買わない 買う
    //     0 1 0: 買わない 買う 買わない
    for s in 0..1 << n {
        let mut cost = 0;
        let mut und = vec![0; m]; // 理解度

        // 各本について買ったか買ってないかをループで見る
        for i in 0..n {
            if s >> i & 1 == 1 {
                // ibit目が立っているならi番目のコストを追加
                cost += c[i][0];
                for j in 0..m {
                    und[j] += c[i][j + 1];
                }
                // xを下回る理解度が存在するならば
                if und.iter().filter(|ga| ga < &&x).count() == 0 {
                    // 現在の金額と比較して低いほうに更新
                    min_cost = min(min_cost, cost);
                }
            }
        }
    }
    if min_cost != i32::max_value() {
        println!("{}", min_cost);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2144
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    if S.count("RRR"):
        print(3)
    elif S.count("RR"):
        print(2)
    elif S.count("R"):
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8984
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,k,ans=0;
  cin >> n >> k;

  if(n>=1){
    ans++;
  }

  int i=1,h=k;
  while(n>=h){
    ans++;
    i++;
    h = pow(k,i);
  }


  pri(ans);

}

Measured memory_bytes: 256
splitOn :: Eq a => a -> [a] -> [[a]]
splitOn _ [] = []
splitOn t xs =
    case break (==t) xs of
        (a,[])  -> [a]
        (a,[_]) -> a:[[]]
        (a,_:b) -> a : splitOn t b

solve :: [Int] -> Int
solve = sum . map f . splitOn 0
  where
    f [] = 0
    f h = let m = minimum h
           in m + solve (map (+(-m)) h)

main :: IO ()
main = do
    n <- readLn :: IO Int
    h <- map read . words <$> getLine :: IO [Int]
    print $ solve h


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



int main(){

	int a,max=0,min=10000;
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a;
		if(max<a)
			max=a;
		if(min>a)
			min=a;
	}
	a= max-min;
	if(a<0)
		a=a*-1;
	cout <<a;
	return 0;



}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int ans;

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        read ans;
        for ( int i = 1; i < n; i++ ) {
            int a;
            read a;
            ans = gcd(a, ans);
        }
        echo ans fin;


        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
import numpy as np

N = int(input())
a = input().split()
a = [int(aa) for aa in a]

s = 0
for k in range(N):
    if a[k] % 2 == 0:
        j = 0
        while True:
            j += 1
            a[k] = a[k]/2
            if a[k] % 2 != 0:
                break
        s += j
print(s)

Measured memory_bytes: 22308
#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	S = input()
	if S[2] == S[3] and S[4] == S[5]:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    vector<tuple<string, int, int>> v;
    for(int i = 1; i <= N; i++) {
        string s;
        int t;
        cin >> s >> t;
        t *= -1;
        v.push_back(tie(s, t, i));
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < N; i++) {
        cout << get<2>(v[i]) << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


int a[4];

int main(){
	for(int i = 0; i < 4; i++){
		cin >> a[i];
	}
	
	cout << min(a[0],a[1]) + min(a[2],a[3]) << endl;
	
	return 0;
}

Measured memory_bytes: 256
# your code goes here
words = gets().split(" ")
hash = {}
long_word = ""

words.each do |word|
	if long_word.length < word.length
		long_word = word
	end

	if hash.key?(word)
		hash[word] = hash[word] + 1
	else
		hash[word] = 1
	end
end

count = 0
count_word = ""
hash.each do |k, v|
	if count < v
		count = v
		count_word = k
	end
end

puts count_word + " " + long_word

Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n;
typedef long long ll;
ll ans=0;
int main()
{
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        ans+=(n-1)/i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int h,m,s;
bool input(){
cin>>h>>m>>s;
if(h==-1)return false;
return true;
}
char ans[2][100];
void solve(){
const int time = 60 * 120;
int tmp = 60 * 60 * h + 60 * m + s;
int now = time - tmp;
tmp = now;
int a_s = tmp % 60;
tmp /= 60;
int a_m = tmp % 60;
tmp /= 60;
int a_h = tmp;
sprintf(ans[0],"%02d:%02d:%02d",a_h,a_m,a_s);
tmp = now * 3;
a_s = tmp % 60;
tmp /= 60;
a_m = tmp % 60;
tmp /= 60;
a_h = tmp;
sprintf(ans[1],"%02d:%02d:%02d",a_h,a_m,a_s);
}
int main(){
while(input()){
solve();
cout<<ans[0]<<endl<<ans[1]<<endl;
}
}

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

int func(int A){
  int count=0;
  for(int i=1;i<100;i++){
    for(int j=i;j<100;j++){
      for(int k=j;k<100;k++){
        int B=i*i+j*j+k*k+i*j+j*k+k*i;
        if(A==B){
          if(i!=j && j!=k && k!=i){
            count+=6;
          }
          else if(i==j && j==k){
            count+=1;
          }
          else{
            count+=3;
          }
        }
      }
    }
  }
  return count;
}
    
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cout << func(i+1) << endl;
  }
}
  

Measured memory_bytes: 3564
R,C,K = map(int, input().split())

d = [[0 for _ in range(C+1)] for _ in range(R+1)]

#dp[行の中でピックした回数][行][列]　この順じゃないとTLEする
dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)]

for i in range(K):
    r, c, v = map(int, input().split())
    d[r-1][c-1] = v
for i in range(R):
    for j in range(C):
        # kが大きい方からやらないとダメ。01ナップサックと同じ考え方。書き換えられた値を見ないように。
        for k in range(2, -1, -1):
            # 拾う遷移。d[i][j]を取るかどうかという判定
            dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + d[i][j])
        for k in range(4):
            dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
            dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])
ans = 0

for k in range(4):
    ans = max(ans, dp[k][R-1][C-1])
print(ans)    

Measured memory_bytes: 469212
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  bool flag = false;
  int counter0 = 0;
  vector<int> v(n+1,0);
  for(int i = 0; i < n; i++){
    if(s[i]=='.') v[0]++;
  }
  for(int i = 1; i < n+1; i++){
    if(s[i-1]=='.') v[i]=v[i-1]-1;
    else if(s[i-1]=='#') v[i]=v[i-1]+1;
  }
 
  sort(v.begin(),v.end());
  cout<<v[0]<<endl;
  return 0;
}


Measured memory_bytes: 1412
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLUE 2

void dfs(void);
void visit(int);

int time,d[N],f[N],G[N][N],color[N],n;

int main(){
  int i,j,u,k,v;
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      G[i][j]=0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }
  dfs();
  return 0;
}

void visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++time;
  for(v = 0;v < n;v++){
    if(G[u][v]==0)continue;
    if(color[v] == WHITE){
      visit(v);
    }
  }
  color[u] = BLUE;
  f[u] = ++time;
}

void dfs(){
  int u;
  for(u = 0;u < n;u++){
    color[u] = WHITE;
  }
  time=0;

  for(u = 0;u < n;u++){
    if(color[u]==WHITE){
      visit(u);
    }
  }
  for(u = 0;u < n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

Measured memory_bytes: 636