akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    vector<ll> s;
    ll n;
    cin>>n;
    rep(i,n){
        ll a;
        cin>>a;
        s.push_back(a);
    }

    sort(s.begin(),s.end());

    ll smax = s[s.size()-1];
    ll mid1 = (smax)/2;

    ll samin = smax;
    ll p = 0;



    rep(i,n-1) {
        ll k=s[i];

        if(mid1<s[i]){
            k = smax-s[i];
        }


       // cout<<s[i]<<" "<<k<<endl;
        if(samin>=abs(mid1-k)){
            samin = abs(mid1-k);
            p=i;
        }
    }


    cout<<smax<<" "<<s[p]<<endl;





    return 0;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, a, x[50] = {}, dp[51][51][2501] = {};

int main() {
  cin >> n >> a;
  rep(i, 0, n) cin >> x[i];
  dp[0][0][0] = 1;

  rep(i, 0, n) rep(j, 0, i + 1) rep(k, 0, 2501) {
    dp[i + 1][j][k] += dp[i][j][k];
    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
  }

  ll ans = 0;

  rep(i, 1, n + 1) {
    ans += dp[n][i][i * a];
  }

  cout << ans << endl;
}


Measured memory_bytes: 49152
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;;testcase++){
    int3(a, b, c);
    int2(d, p);

    int res = a * p;
    if(p <= c)res = min(res, b);
    else res = min(res, (p - c) * d + b);

    pri(res);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1208
import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]

t = [0] * N
for i in range(N):
    t[i] = i - L[i] + 1
    
c = 0
for i in range(N - 1):
    if t[i] == 0 and t[i + 1] == 0:
        t[i] = -1
        t[i + 1] = 1
        c += 1

index = 0
while index < N:
    if index + 1 < N and t[index] == 0 and t[index + 1] == 0:
        t[index] = -1
        t[index + 1] = 1
        c += 1
    elif index + 1 < N and t[index] == 0 and t[index + 1] < 0:
        c += 1
        t[index] = t[index + 1] - 1
        t[index + 1] = 1
    elif index + 1 < N and t[index + 1] == 0 and (t[index] < -1 or t[index] > -1):
        c += 1
        t[index + 1] = t[index] + 1
        t[index] = -1
    index += 1

print(c)

Measured memory_bytes: 13876
n = int(input())

list1 = list(map(int,input().split()))
S1 = list1
S2 = []
cache = 0
for i in range(n):
    if sum(S2) - sum(S1) >= 0:
        break
    cache = sum(S2)-sum(S1)
    S2.append(S1.pop(-1))

print(min(abs(cache),abs(sum(S2) - sum(S1))))

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a; cin >> a;
	if(a == 7 || a == 5 || a == 3) cout << "YES" << endl;
	else cout << "NO" << endl;	

	return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int P[N];
  
  int i, j;
  for(i=0; i<N; i++)
    cin >> P[i];

  int count = 1;
  int min = P[0];
  for(i=1; i<N; i++){
    if(min >= P[i]){
      count ++;
      min = P[i];
    }
  }

  cout << count << endl;
    
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size()-1;i++)
		if (s[i]==s[i+1])
		{
			cout<<i+1<<" "<<i+2;
			return 0;
		}
	for(int i=0;i<s.size()-2;i++)
		if (s[i]==s[i+2])
		{
			cout<<i+1<<" "<<i+3;
			return 0;	
		}
	cout<<-1<<" "<<-1;
	return 0;	
}

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

int main(){
    int k;
    cin >> k;
    int ans = 0;
    for(int i=1; i<=k; i++){
        for(int j=i+1; j<=k; j++){
            if((i+j)%2 == 1) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <string>
#include <iostream>
using namespace std;
typedef string::const_iterator State;

int number(State& it) {
	int result = 0;
	while (isdigit(*it)) {
		result *= 10;
		result += (*it) - '0';
		++it;
	}
	return result;
}

int expression(State&);

int factor(State& it) {
	if (*it == '(') {
		++it;
		int result = expression(it);
		++it;
		return result;
	}
	else return number(it);
}

int term(State& it) {
	int result = factor(it);
	for (;;) {
		if (*it == '*') {
			++it;
			result *= factor(it);
		}
		else if (*it == '/') {
			++it;
			result /= factor(it);
		}
		else break;
	}
	return result;
}

int expression(State& it) {
	int result = term(it);
	for (;;) {
		if (*it == '+') {
			++it;
			result += term(it);
		}
		else if (*it == '-') {
			++it;
			result -= term(it);
		}
		else break;
	}
	return result;
}

int main () {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string line;
		cin >> line;
		State it = line.begin();
		cout << expression(it) << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  string s;
  cin >> s;
  if (s == "Sunny")
    cout << "Cloudy" << endl;
  else if (s == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

input()

for s in sys.stdin:
  d = map(float,s.split())
  xa,ya,ra,xb,yb,rb = d[0],d[1],d[2],d[3],d[4],d[5]
  if ((xa-xb)**2+(ya-yb)**2)**0.5 > ra + rb:
    print 0
  elif ((xa-xb)**2+(ya-yb)**2)**0.5 + rb < ra :
    print 2
  elif ((xa-xb)**2+(ya-yb)**2)**0.5 + ra < rb :
    print -2
  else:
    print 1

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const ll INF = 1e18L + 5;

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

    vi value(n), weight(n);

    int suma = 0;

    for(int i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
        suma += value[i];
    }

    vector <ll> dp(suma + 1, INF);

    dp[0] = 0;

    //dp[i] je za odredjenu vrednost najmanja tezina

    for(int i = 0; i < n; i++)
    {
        for(int j = suma; j >= 0; j--)
        {
            if(j - value[i] >= 0)
            {
                dp[j] = min(dp[j], (ll)dp[j - value[i]] + weight[i]);
            }
        }
    }

//    for(int i = 0; i < dp.size(); i++)
//    {
//        cout << i << " : " << dp[i] << '\n';
//    }

    ll maksimalnoResenje = 0;

    for(int i = 0; i <= suma; i++)
    {
        if(dp[i] <= w)
        {
            maksimalnoResenje = max(maksimalnoResenje, (ll)i);
        }
    }

    cout << maksimalnoResenje << '\n';

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int ans = 0;
	int cnt;
	for (int i = 1; i < N+1; i += 2)
	{
		cnt = 0;
		for (int j = 1; j < i+1; j++)
		{
			if (i % j == 0)
			{
				cnt++;
			}
		}
		if (cnt == 8)
		{
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

struct card{
    char mark;
    int num;
};

int main(){

    int n;
    scanf("%d\n",&n);

    struct card A[n];//元入力
    struct card B[n];//バブルソート
    struct card C[n];//選択ソート
    struct card cp;

    char air;
    int flag=1;
    
    //初期入力
    for(int i=0;i<n;i++){
        scanf("%c%d%c",&A[i].mark,&A[i].num,&air);
        B[i]=A[i];
        C[i]=A[i];
    }

    //バブルソート
    while(flag){
        flag=0;
        for(int i=0;i<n-1;i++){
            if(B[i].num>B[i+1].num){
                cp=B[i];
                B[i]=B[i+1];
                B[i+1]=cp;
                flag=1;
            }
        }
    }

    //選択ソート
    int min;
    for(int i=0;i<n-1;i++){
        min=i;
        for(int f=i+1;f<n;f++){
            if(C[min].num>C[f].num){
                min=f;
            }
        }
        cp=C[min];
        C[min]=C[i];
        C[i]=cp;
    }

    //安定か否か
    int stable=1;
    for(int i=0;i<n;i++){
        if(B[i].num!=C[i].num||B[i].mark!=C[i].mark){
            stable=0;
        }
    }

    printf("%c%d",B[0].mark,B[0].num);
    for(int i=1;i<n;i++){
        printf(" %c%d",B[i].mark,B[i].num);
    }
    printf("\n");
    printf("Stable\n");
    
    printf("%c%d",C[0].mark,C[0].num);
    for(int i=1;i<n;i++){
        printf(" %c%d",C[i].mark,C[i].num);
    }
    printf("\n");
    
    if(stable==1){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
    
}


Measured memory_bytes: 2096
read a b c
five=0
seven=0
for i in $a $b $c
do
  if [ "$i" -eq 5 ]; then
    five=`expr $five + 1`
  fi
  if [ "$i" -eq 7 ]; then
    seven=`expr $seven + 1`
  fi
done
if [ "$five" -eq 2 ]; then
  if [ "$seven" -eq 1 ]; then
    echo "YES"
  else
    echo "NO"
  fi
else
  echo "NO"
fi

Measured memory_bytes: 540
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MAX_DIGIT_NUM 10
typedef long long int lli;

lli get_num_digits(lli x){
    if(x == 0){
        return 1;
    }

    lli res = 0;
    while (x > 0){
        x /= 10;
        res++;
    }
    return res;
}

bool is_753_num(lli x){
    lli num_3 = 0, num_5 = 0, num_7 = 0;
    while(x > 0){
        if(x % 10 == 3){
            num_3++;
        }else if(x % 10 == 5){
            num_5++;
        }else if(x % 10 == 7){
            num_7++;
        }else{
            return false;
        }
        
        x /= 10;
    }
    
    if(num_3 == 0){
        return false;
    }
    
    if(num_5 == 0){
        return false;
    }
    
    if(num_7 == 0){
        return false;
    }
    
    return true;
}

void display_vec(lli* itr_vec, lli n){
    cout << "vector:[";
    for(lli i = 0; i < n; ++i){
        cout << " " << *(itr_vec + i);
    }
    cout << " ]" << endl;
}

int main(){
    lli n;
    cin >> n;
    vector<lli> vec_753(1, 0);
    // vec_753.push_back(2);
    // vec_753.push_back(3);
    // vec_753.push_back(5);
    // vec_753.push_back(7);
    lli ans = 0;
    for(lli i = 0; get_num_digits(vec_753[i]) < MAX_DIGIT_NUM; ++i){
        if(vec_753[i] > n){
            break;
        }

        // cout << "i = " << i << endl;
        vec_753.push_back(10 * vec_753[i] + 3);
        vec_753.push_back(10 * vec_753[i] + 5);
        vec_753.push_back(10 * vec_753[i] + 7);
        // cout << "size = " << vec_753.size() << endl;

        ans += (is_753_num(vec_753[i]))? 1 : 0;
    }
    // display_vec(vec_753.data(), (lli)vec_753.size());
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, X;
  ci(N, X);
  ve<int> m(N);
  int c = 0, a = 0;
  rep(i, N){
    ci(m.at(i));
    c += m.at(i);
    a++;
  }
  sort all(m);
  wh(c <= X){
    c += m.at(0);
    a ++; 
  }
  co(a - 1);
}


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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int a[4] = {25, 10, 5, 1};
    for(int i = 0; i < 4; i++){
        ans += n/a[i];
        n %= a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <vector>	

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long long> vl;

typedef pair<int,int> pi;
typedef pair<double,double> pd;

#define pb push_back
#define mp make_pair

#define endl "\n"
typedef long long int ll;
typedef unsigned int uint;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

int INF = 1e9+1;

int main(){
	fastio();
	unsigned long long int n,a,b;
	cin>>n>>a>>b;
	if (a==0){
		cout<<0<<endl;
		return 0;
	}
	unsigned long long int  x = n/(a+b);
	unsigned long long int  y = (n - x*(a+b)) > a ? a : (n - x*(a+b))%a;
	cout<<x*a+y<<endl; 
	return 0;
}


Measured memory_bytes: 256
def chk(n):
    if 0<n<=12: return 1
    else: 0

s=input()
a,b=int(s[0:2]),int(s[2:4])

if chk(a) and chk(b): print("AMBIGUOUS")

elif chk(a) and not chk(b): print("MMYY")

if not chk(a) and chk(b) : print("YYMM")

if not chk(a) and not chk(b): print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a;
  cin>>a;
  bool ok=false;
  for(char i='a';i<='z';i++){
    if(a==i){
      ok=true;
    }
  }
  if(ok){
    cout<<'a'<<endl;
  }else{
    cout<<'A'<<endl;
  }
  return 0;
}

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

int main()
{
    cin.tie(0);
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    vector<vector<int>> bd(H, vector<int>(W));

    int total = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            bd[i][j] = 1000;

            if ((i + 1) % h == 0 && (j + 1) % w == 0) {
                bd[i][j] = -(1000 * (h * w - 1) + 1);
            }

            total += bd[i][j];
        }
    }

    if (total > 0) {
        cout << "Yes" << endl;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (j > 0)
                    cout << " ";
                cout << bd[i][j];
            }
            cout << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

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

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

  ll ans=0, tl=-2*t, interim=0;
  rep(i, n) {
    ll ti;
    cin >> ti;

    if(tl + t > ti) { // 被っている時
      interim += (ti - tl);
    } else { // 被ってない時
      ans += interim;
      interim = t;
    }
    tl = ti;
  }
  ans += interim;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

int main(){
    ll N;
    cin >> N;
    //末尾がAのもの、先頭がBのものを集める、
    //どちらにも該当するやつは、べつで保存する

    ll a = 0;
    ll b = 0;
    ll ab = 0;
    ll res = 0;
    string s;
    REP(i,N)
    {
        cin >> s;
        for(int i = 1; i < s.size(); ++i)
        {
            if(s[i-1] == 'A' && s[i] =='B')++res;
        }

        if(s[0] == 'B' && s[s.size() - 1] == 'A')
        {
            ++ab;
        }
        else if(s[0] == 'B')++b;
        else if(s[s.size()-1] == 'A')++a;
    }

    //XXA 1
    //BXX 2
    //BXXA 2

    //XXABXXABXXABXX

    //BXXA は 3個で  A BXXABXXABXXA
    // (3-1)個

    res += ab;

    if(a > b)
    {
        res += b;
    }
    else
    {
        res += a;
    }

    if(a == 0 && b == 0 && ab > 0)
    {
        --res;
    }

    cout << res << endl;

    return 0;    
}


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

int main(){
  int N,M;
  const int INF=1e9;
  cin>>N>>M;
  std::vector<int> a(M),b(M),c(M),v(M+1,1);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
  }
  typedef pair<int,int> P;
  std::vector<P> que(N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++)que[j]=P(INF,M);
    que[i]=P(0,M);
    for(int j=0;j<M;j++){
      for(int k=0;k<M;k++){
        if(que[a[k]].first>que[b[k]].first+c[k])que[a[k]]=P(que[b[k]].first+c[k],k);
        if(que[b[k]].first>que[a[k]].first+c[k])que[b[k]]=P(que[a[k]].first+c[k],k);
      }
    }
    for(int j=0;j<N;j++)v[que[j].second]=0;
    for(int j=0;j<M;j++){
      if(que[a[j]].first==que[b[j]].first+c[j])v[j]=0;
      if(que[b[j]].first==que[a[j]].first+c[j])v[j]=0;
    }
  }
  int ans=0;
  for(int i=0;i<M;i++)if(v[i])ans++;
  cout<<ans<<endl;
}


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

int main(){
    ll N; cin >> N;
    string ans = "";
    while(N){
        N--;
        int c = N%26;
        ans += ('a'+c);
        N /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

n = int(input())
s = input()

dp = [[0]*(n+1) for _ in range(n+1)]
res = 0
for i in range(n-1,-1,-1):
    for j in range(n-1,i,-1):
        if s[i]==s[j]:
            dp[i][j] = dp[i+1][j+1]+1
        res = max(res, min(dp[i][j], j-i))

print(res)


Measured memory_bytes: 229896
using System;

public class AtCoderA
{
    static void Main()
    {
        int a;
        int p;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = int.Parse(words[0]);
            p = int.Parse(words[1]);
        }

        Console.WriteLine((a * 3 + p) / 2);
    }
}

Measured memory_bytes: 11092
use std::io::Read;

fn main() {
    let stdin = std::io::stdin();

    let mut v_r: Vec<u8> = Vec::new();
    let mut v_l: Vec<u8> = Vec::new();

    let mut needs_space = false;
    let mut taking = b'R';
    for byte in stdin.bytes() {
        if let Ok(c) = byte {
            if taking == b'R' && c == b'R' {
                v_r.push(c);
            } else if taking == b'L' && c == b'L' {
                v_l.push(c);
            } else if taking == b'R' && c == b'L' {
                v_l.push(c);
                taking = c;
            } else if taking == b'L' { // c == b'R' or c == b'\n'
                if needs_space {
                    print!(" ");
                }
                for _ in 0..v_r.len()-1 {
                    print!("0 ");
                }
                let r = (v_r.len() + 1) / 2 + v_l.len() / 2;
                print!("{} ", r);
                let l = v_r.len() / 2 + (v_l.len() + 1) / 2;
                print!("{}", l);
                for _ in 1..v_l.len() {
                    print!(" 0");
                }
                
                needs_space = true;
                v_l.clear();
                v_r.clear();
                if c != b'R' {
                    break;
                }
                v_r.push(c);
                taking = b'R';
            }
        }
    }
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long ll;
const int N = 1e6+9, M = 1e2+9, OO = 0x3f3f3f3f,MOD = 1e9 + 7;
ll arr[N];
int main()
{
   int n;
   scanf("%d",&n);
   for(int i=0;i<n;++i) scanf("%lld",arr+i);
   sort(arr,arr+n);
   ll a=arr[n-1],r=lower_bound(arr,arr+n-1,a/2)-arr;
   ll mid=a/2;
   if(abs(mid-arr[r-1])<abs(mid-arr[r]) || arr[r]==a) r--;
   r=arr[r];
   printf("%lld %lld\n",a,r);

  #ifdef _LOCAL_DEFINE  
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}



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

int main(){
  int64_t N,M=0;
  int sum=0;
  cin>>N;
  int64_t n=N;
  while(!(n/10==0)){
    sum++;
    n /=10;
  }
  int c=pow(2, sum);
  for(int tmp=0;tmp<c;tmp++){
    bitset<9> A(tmp);
    int64_t s=N;
    int t=1;
    for(int i=0;i<sum;i++){
      if(A.test(i)){
        int64_t a=pow(10, t);
        M +=s%a;
        s /=a;
        t =1;
      }
      else t++;
    }
    M +=s;
  }
  cout<<M<<endl;
}


Measured memory_bytes: 3920
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	int L, A, B, C, D; cin >> L >> A >> B >> C >> D;
	int a = (A - 1) / C+1;
	int b = (B -1) / D + 1;
	cout << L - max(a, b) << endl;
	return 0;
}

Measured memory_bytes: 3048
N = int(input())
A = list(map(int, input().split()))
S = [0]
ans = 0
for i in range(len(A)):
	S.append(S[i] + A[i])
S.sort()
count = 1
for i in range(1, len(S)):
	if S[i-1] == S[i]:
		count += 1
	else:
		ans += (count * (count - 1)) / 2
		count = 1
ans += (count * (count - 1)) / 2
print(int(ans))

Measured memory_bytes: 25976
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll mod = (ll)1e9 + 7;
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<int,int>mp;
set<int> s;
int vis[111];
int main()
{
    fast;
     int a,b;
     cin>>a>>b;
     a*=3;
     int c=0;
     c+=(a/2)+((a%2)+b)/2;
     cout<<c<<endl;
}




Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))



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

int main(){

    string a;
    cin >> a;

    if(a[0]!='A'){
        cout << "WA" << endl;
        return 0;
    }else{
        int s=0;
        for(int i=1;i<a.size();i++){
            if(a[i]=='C'){
                if(i>=2&&i<a.size()-1){
                    s++;
                }else{
                    cout << "WA" << endl;
                    return 0;
                }
            }else{
                if(a[i]-'a'<0||a[i]-'a'>25){
                    cout << "WA" << endl;
                    return 0;
                }
            }
        }
        if(s!=1){
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << 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;
using ll = long long;

int main(){

    int K,N;
    cin >> K >> N;
    int A[N],B[N],ans;
    
    rep(i,N) cin >> A[i];
    sort(A,A+N);
    rep(i,N-1) B[i] = A[i+1] - A[i];
    B[N-1] = K - A[N-1] + A[0];
    sort(B,B+N);
    ans = K - B[N-1];
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();

        Set<Long> set = new HashSet<>();

        for (long i = 1; i <= (long) Math.sqrt(M) + 2; i++) {
            if (M % i == 0) {
                set.add(i);
                set.add(M / i);
            }
        }

        long ret = Long.MIN_VALUE;

        for (long val : set) {
            if (val * N <= M) ret = Math.max(ret, val);
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 23636
s = input()
x, y = map(int, input().split())
d = [len(i) for i in s.split('T')]
 
s1 = d[2::2]
s2 = d[1::2]
 
now_x = [0]
now_y = [0]

x -= d[0]

for i in s1:
    nx = set()
    for j in now_x:
        nx.add(j-i)
        nx.add(j+i)
    now_x = nx

for i in s2:
    ny = set()
    for j in now_y:
        ny.add(j-i)
        ny.add(j+i)
    now_y = ny

if x in now_x and y in now_y:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()


int main() {
	int n;
	cin >> n;
	
	rep(i, 0, 30){
		rep(j, 0, 20){
			if (4 * i + j * 7 == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

}


Measured memory_bytes: 256
from collections import deque


reverse = False

string = deque(input().rstrip())
operate_times = int(input().rstrip())

for i in range(operate_times):
    row = input().rstrip()
    if row[0]=='1':
        if reverse:
            reverse = False
        else:
            reverse = True
    
    if row[0]=='2':
        row = row.split()
        head_or_tail = int(row[1])
        add_string = row[2]

        if reverse:
            if head_or_tail==1:
                string.append(add_string)
            else:
                string.appendleft(add_string)
        
        else:
            if head_or_tail==2:
                string.append(add_string)
            else:
                string.appendleft(add_string)


answer_string = ''
if reverse:
    for _ in range(len(string)):
        right = string.pop()
        answer_string+=right
    print(answer_string)
else:
    print(''.join(string))

Measured memory_bytes: 8436
#include<bits/stdc++.h>
#define MAX 2000010
#define inf 2147483647
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n,n_,L;
int st[MAX*2];

void init(){
  n_ = 1;
  while(n_<n)n_*=2;
  FOR(i,0,2*n_-1)st[i]=inf;
}

void update(int a,int b){
  a+=n_-1;
  st[a] = b;
  while(a>0){
    a = (a-1)/2;
    st[a] = min(st[a*2+1],st[a*2+2]);
  }
}

int find(int a,int b,int c,int l,int r){
  if(r<=a || b<=l)return inf;
  if(a<=l && r<=b)return st[c];
  
  int L = find(a,b,c*2+1,l,(l+r)/2);
  int R = find(a,b,c*2+2,(l+r)/2,r);
  return min(L,R);
}

void solve(){
  FOR(i,0,n-L+1){
    cout<<find(i,i+L,0,0,n_);
    if(i!=n-L)cout<<" ";
  }
  cout<<endl;
}

int main()
{
  cin>>n>>L;
  init();
  FOR(i,0,n){
    int a;
    cin>>a;
    update(i,a);
  }
  solve();
  return 0;
}



Measured memory_bytes: 11316
#include <cmath>
#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

long long maxmin(long long x, long long y, long long z){
  if(x >= y && x >= z){
    if(y > z){
      return x-z;
    }
    else{
      return x-y;
    }
  }
  else if(y >= x && y >= z){
    if(x > z){
      return y-z;
    }
    else{
      return y-x;
    }
  }
  else{
    if(x > y){
      return z-y;
    }
    else{
      return z-x;
    }
  }
}

int main(){
  long long i,j;
  long long h,w;
  cin >> h >> w;
  if(h%3 == 0 || w%3 == 0){
    cout << 0 << endl;
    return 0;
  }
  long long ans = LLONG_MAX;
  long long h2 = h/2;
  long long w2 = w/2;
  long long a1,a2,a3;
  for(i = 1;i < h;i++){
    a1 = i*w;
    a2 = (h-i)*(w/2);
    a3 = (h-i)*(w-w/2);
    if(ans > maxmin(a1,a2,a3)) ans = maxmin(a1,a2,a3);
    a2 = (h-i)/2*w;
    a3 = (h-i-(h-i)/2)*w;
    if(ans > maxmin(a1,a2,a3)) ans = maxmin(a1,a2,a3);
  }
  swap(h,w);
  for(i = 1;i < h;i++){
    a1 = i*w;
    a2 = (h-i)*(w/2);
    a3 = (h-i)*(w-w/2);
    if(ans > maxmin(a1,a2,a3)) ans = maxmin(a1,a2,a3);
    a2 = (h-i)/2*w;
    a3 = (h-i-(h-i)/2)*w;
    if(ans > maxmin(a1,a2,a3)) ans = maxmin(a1,a2,a3);
  }


  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main() {
	string s = "0";
	cin >> s;
	/*vector<int> h((int)n);
	for (int i = 0; i < n; ++i) cin >> h[i];*/
	string str_k = "keyence";
	string ans = "YES";

	if (s.substr(0, 7) == str_k || s.substr(s.length() - 8, 7) == str_k)
	{
		cout << "YES" << endl;
		return 0;
	}

	int max_k = 1;

	int i = 0;
	if (s.substr(0, 1) == "k")
	{
		int k = 1;
		while (1)
		{
			if (s.substr(k, 1) == str_k.substr(k, 1))
			{
				++k;
			}
			else
			{
				max_k = k;
				int nokori = 7 - max_k;

				if (s.substr(s.length() - nokori, nokori) == str_k.substr(max_k, nokori))
				{
					cout << "YES" << endl;
					return 0;
				}
				else
				{
					cout << "NO" << endl;
					return 0;
				}
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  cout << 6-a-b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]) out("Yes");
    else if(s[1]==s[2]&& s[1]==s[3]) out("Yes");
    else out("No");

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N;
  scanf("%d",&N);
  if (N > 1 && N % 2 == 0)
  {
     printf("0.5");
  }
  else if (N > 1 && N % 2 != 0)
  {
    printf("%f",(float)(N/2+1)/N);
  }
  else
  {
    printf("1");
  }
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main {

    // Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        solve(N);
    }

    static void solve(long N){
        int odd=0, sum=0;
        for (int i=1; i<=N; i++) {
            if (i%2 == 1) odd++;
            sum++;
        }
        System.out.println((double)odd/(double)sum);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> Pair;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll INFL = 1e18;


int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    rep(i,n-1){
        if(s[i]==s[i+1]) score++;
    }
    int ans = min(score+2*k,n-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=1e5+10,inf=1e9+10;
int n,a[M];
vector<int> b;
bool check(int x)
{
    int cnt=0;
    for(int i=0;i<n && cnt<2;i++)
        if(a[i]%x!=0)
            cnt++;
    return cnt<2;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int k=0;k<2;k++)
    {
        b.push_back(a[k]);
        int n=(int)sqrt(a[k]+.5);
        for(int i=2;i<=n;i++)
            if(a[k]%i==0)
            {
                b.push_back(i);
                if(a[k]/i!=i) b.push_back(a[k]/i);
            }
    }
    sort(b.begin(),b.end());
    int ans=1;
    for(auto p: b)
        if(check(p))
            ans=p;
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 640
n = int(input())
p = list(map(int,input().split()))
#print(n)
#print(p)
ans = 0
for i in range(1,n-1):
  if p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]     :
#    print(p[i-1],p[i],p[i+1])
    ans+=1
    
    
print(ans)    

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

int main() {
	string s;
	cin >> s;
	string ans = "AC";
	if (s[0] != 'A') {

		cout << "WA" << endl;
		return 0;
	}
	int count = 0;
	int index;
	for (int i = 2; i < s.length() - 1; i++) {
		if (s[i] == 'C') {
			count++;
			index = i;
		}
	}
	if (count != 1) {
		cout << "WA" << endl;
		return 0;
	}
	count = 0;
	for (int i = 0; i < s.length(); i++) {
		if (i == 0 || i == index) {
			continue;
		}
		if (s[i] >= 'a'&&'z' >= s[i]) {
			count++;
		}
	}
	if (count != s.length() - 2) {
		cout << "WA" << endl;
		return 0;
	}
	cout << "AC" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  string s;
  while(getline(cin,s)){
    s+=' ';
    stack<double>st;
    double p=0;
    int t=1;
    r(i,s.size()){
      if(s[i]==' '&&isdigit(s[i-1])){
        if(p!=0){
          st.push(t*p),p=0,t=1;
        }
      }
      else if(s[i]=='*'){
        double x1=st.top();st.pop();
        double x2=st.top();st.pop();
        st.push(x2*x1);
      }
      else if(s[i]=='+'){
        double x1=st.top();st.pop();
        double x2=st.top();st.pop();
        st.push(x2+x1);
      }
      else if(s[i]=='/'){
        double x1=st.top();st.pop();
        double x2=st.top();st.pop();
        st.push(x2/x1);
      }
      else if(s[i]=='-'){
        if(isdigit(s[i+1]))t=-1;
        else{
          double x1=st.top();st.pop();
          double x2=st.top();st.pop();
          st.push(x2-x1);
        }
      }
      else if(isdigit(s[i])){
        p*=10,p+=s[i]-'0';
      } 
    }
    printf("%.6f\n",st.top());
  }
}

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

int func(int n){
  if(n%2==0) return n/2;
  else return n*3 + 1;
}

int main(){
  const int MAX = 1000000;
  int a[MAX];
  cin >> a[0];
  
  map<int,int> mp_count;
  mp_count[a[0]]++;
  for(int i=1;i<MAX;i++){
    a[i] = func(a[i-1]);
    if(mp_count[a[i]]>0){
      cout << i+1 << endl;
      break;
    }else{
      mp_count[a[i]]++;
    }
  }
}

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

public class Main {

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

		String keyBoard = sc.next();
		int inputSize = keyBoard.length();
		boolean beautifulFlag = true;

		List<String> wordList = new ArrayList<String>();

		for (int i = 0; i < inputSize; i++) {
			wordList.add(keyBoard.substring(i, i+1));

		}

		Collections.sort(wordList);

		for (int i = 0; i < wordList.size(); i++) {
			String word = wordList.get(0);

			int wordCount = wordList.lastIndexOf(word) + 1;

			if (wordCount % 2 != 0) {
				System.out.println("No");
				beautifulFlag = false;
				break;
			}

			for (int j = 0; j < wordCount; j++) {
				wordList.remove(0);
			}
		}

		if (beautifulFlag) {
			System.out.println("Yes");

		}

		sc.close();
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#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 OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    double h, a;
    cin >> h >> a;
    OP(ceil(h / a));
    return 0;
}

Measured memory_bytes: 256
/*#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 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;




int main() {
string S,t="";
cin>>S;
int count=0;
bool fin=false;
rep(i,S.size()){
  int j=1;
  while(t==S.substr(i,j)){
    if(j<S.size()-1)j++;
    else {
      fin=true;
      break;
    }
  }
  t=S.substr(i,j);
  i+=j-1;
  if(!fin)count++;
  
  
}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 ll dp[3001][3001];
 
int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

ll n,m,i,j;
string s,t,ans;
cin>>s>>t;
n=s.length();
m=t.length();

f(i,0,n)dp[i][0]=0;
f(i,0,m)dp[0][i]=0;


for(i=1;i<=n;i++){

  for(j=1;j<=m;j++){

      if(s[i-1]==t[j-1])
      {
          dp[i][j]=dp[i-1][j-1]+1;
          
      }
      else{
          dp[i][j]=max(dp[i][j-1],dp[i-1][j]);

        
      }
  }


} 

i=n;j=m;
while(i>0&&j>0){

    if(s[i-1]==t[j-1]){ans+=s[i-1];

i--;j--;}

      
    
    else if(dp[i-1][j]>=dp[i][j-1])i-=1;
    else j-=1;

}
reverse(ans.begin(),ans.end());
cout<<ans;



 
   return 0;
 }

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a+b<10){
        cout << a + b << endl;
    }else{
        cout << "error" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    int H,W,M;
    cin >> H >> W >> M;
    vi A(H,0),B(W,0);
    ve<pii> C;
    rep(i,M){
        int h,w;
        cin >> h >> w;
        h--,w--;
        C.push_back({h,w});
        A[h]++;
    }
    
    int a = 0;
    int aa = -1;
    rep(i,H) if(chmax(a,A[i])) aa = i;
    rep(i,M) if(C[i].fi != aa) B[C[i].se]++;
    int b = 0;
    rep(i,W) if(chmax(b,B[i])) aa = i;
    
    int ans = a+b;
    
    
    rep(i,H) A[i] = 0;
    rep(i,W) B[i] = 0;
    rep(i,M) B[C[i].se]++;
    a = 0;
    aa = -1;
    
    rep(i,W) if(chmax(a,B[i])) aa = i;
    rep(i,M) if(C[i].se != aa) A[C[i].fi]++;
    b = 0;
    rep(i,H) if(chmax(b,A[i])) aa = i;
    
    chmax(ans,a+b);
    
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 9772