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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
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;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  bitset<4000001>x=1;
  rep(i,0,n)x=x|x<<a[i];
  ll sumbuf=0;
  rep(i,0,n)sumbuf+=a[i];
  rep(i,(sumbuf+1)/2,4000001){
    if(x[i]){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Integer[] ary = new Integer[n];
		for(int i = 0; i < n; i++){
			ary[i] = sc.nextInt();
		}
		Arrays.sort(ary, Collections.reverseOrder());
		int sum = Arrays.stream(ary).reduce(0, Integer::sum);
		String ans = (sum > 2 * ary[0]) ? "Yes" : "No";
		System.out.println(ans);
	}
}


Measured memory_bytes: 28756
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
  if (a < b)swap(a, b);
  if (a%b == 0)return b;
  else gcd(b, a%b);
  return 0;
}

ll lcm(ll a, ll b) {//最小公倍数
  if (a < b)swap(a, b);
  return (a / gcd(a, b))*b;
}

bool dpx[8000][16010] = { false };
bool dpy[8000][16010] = { false };

int main() {

  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;
  int cnt = 0;

  while (s[cnt] == 'F')cnt++;
  bool flag = true; // true ->X , false -> Y
  int cntx = 0, cnty = 0, sumx = cnt, sumy = 0;
  int temp = cnt;
  cnt = 0;

  flag ? dpx[0][8000 + temp] = true : dpx[0][8000] = true;
  dpy[0][8000] = true;

  for (int i = (temp == 0) ? 1 : temp + 1; i < s.length() + 1; i++) {
    if (s[i] == 'T' or i == s.length()) {
      if (flag) {
        sumy += cnt;
        cnty++;
        for (int j = 8000 - sumy; j <= 8000 + sumy; j++) {
          if (dpy[cnty - 1][j]) {
            dpy[cnty][j + cnt] = true;
            dpy[cnty][j - cnt] = true;
          }
        }
      }
      else {
        sumx += cnt;
        cntx++;
        for (int j = 8000 - sumx; j <= 8000 + sumx; j++) {
          if (dpx[cntx - 1][j]) {
            dpx[cntx][j + cnt] = true;
            dpx[cntx][j - cnt] = true;
          }
        }
      }
      flag = !flag;
      cnt = 0;
    }
    else cnt++;
  }

  dpx[cntx][x + 8000] and dpy[cnty][y + 8000] ? pr("Yes") : pr("No");

  // int t = 10;
  // for (int y = -t; y < t; y++) {
  //   for (int x = -t; x < t; x++) {
  //     cout << (dpx[cntx][x + 8000] and dpy[cnty][y + 8000] ? "1 " : "0 ");
  //   } cout << endl;
  // }
  //system("pause");
  return 0;
}


Measured memory_bytes: 125696
import sys
#input = sys.stdin.buffer.readline
from collections import Counter

def main():
    s = list(input())
    l = len(s)
    c = Counter(s)
    c = list(c.values())
    
    c.sort(reverse=True)

    for num in c:
        if num != -(-l//3):
            print("NO")
            exit()
        l -= 1

    print("YES")

if __name__ == "__main__":
    main()


Measured memory_bytes: 4340
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;
string a[4] = { "dream","dreamer","erase","eraser" };

int main() {
	long long N, C, K,t,i=0,ans=0,x=0,T1=0;
	long long T[100000];
	cin >> N >> C >> K;
	for (long long i = 0; i < N; i++)cin >> T[i];
	sort(T, T + N);
	while (1) {
		if (i == N - 1) {
			ans++;
			break;
		}
		else if (C == i + 1 - x || T[i +1] - T1> K) {
			ans++;
			x = i+1;
			T1 = T[i+1];
		}
		i++;
	}
	cout << ans << endl;
}

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

int main(){
  string s;
  int point_a=0,point_z=0;
  cin >> s;
  int l = s.size();
  
  for(int i=0; i<l; i++){
    if(s.at(i) == 'A'){
      point_a = i;
      break;
    }
  }
  
  for(int i=0; i<l; i++){
    if(s.at(i) == 'Z'){
      point_z = i;
    }
  }
  
  cout << point_z - point_a + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,L;
cin>>N>>L;
string a[N];
for(int i=0;i<N;i++){
    cin>>a[i];
}
sort(a,a+N);
for(int i=0;i<N;i++){
    cout<<a[i];
}
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');

                int[] A = Array.ConvertAll(input, int.Parse);
                int B = 0, C = 0;
                bool flg = true;

                for (int j = 0; j < 10; j++)
                {
                    if (A[j] > B) B = A[j];
                    else if (A[j] > C) C = A[j];
                    else
                    {
                        flg = false;
                        break;
                    }
                }
                sb.AppendLine(flg ? "YES" : "NO");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 8872
A, B, K = map(int, input().split())
if A > B:
    num = A
    A = B
    B = num
flag = 0
count = 0
el = []
for i in range(1,A+1):
    if A % i == 0 and B % i == 0:
        el.append(i)


print(el[-K])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

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

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 (a>b) { a=b; return 1; } return 0; }

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

	int h, w, m;
	cin >> h >> w >> m;

	vector<int> vh(m), vw(m);
	rep(i, m) cin >> vh[i] >> vw[i];

	map<int, int> mph;
	map<int, int> mpw;

	rep(i, m){
		if(mph.count(vh[i]) == 0) mph[vh[i]] = 0;
		mph[vh[i]]++;

		if(mpw.count(vw[i]) == 0) mpw[vw[i]] = 0;
		mpw[vw[i]]++;
	}

	int mxh = 0, mxw = 0;
	set<int> mih, miw;
	rep(i, m){
		if(mxh <= mph[vh[i]]){
			if(mxh < mph[vh[i]]) mih.clear();
			mxh = mph[vh[i]];
			mih.insert(vh[i]);
		}

		if(mxw <= mpw[vw[i]]){
			if(mxw < mpw[vw[i]]) miw.clear();
			mxw = mpw[vw[i]];
			miw.insert(vw[i]);
		}
	}
	set<pii> st;
	rep(i, m) st.insert({vh[i], vw[i]});

	if((ll)mih.size() * (ll)miw.size() > (ll)m){
		cout << mxh + mxw << endl;
	}else{
		for(int i : mih) for(int j : miw){
			if(st.count({i, j}) == 0){
				cout << mxh + mxw << endl;
				exit(0);
			}
		}
		cout << mxh + mxw - 1 << endl;
	}
}


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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for(int i=0; i<n; i++)cin >> a[i];
	int x = 0;
	vector<int> b(n, 0);
	vector<int> ans;
	for(int i=n-1; i >= 0; i--){
		int s = 0;
		for(int j = 2*i+1; j < n; j+=i+1)s ^= b[j];
		if(s != a[i]){
			b[i] = 1;
			ans.emplace_back(i+1);
		}
	}
	cout << ans.size() << "\n";
	for(auto x: ans)cout << x << "\n";
	return 0;
}

Measured memory_bytes: 3192
fun main(args: Array<String>) {
    val n = next().toInt()
    val ta = nextLongList()

    var f =0L

    var r = 0L

    for(i in 0 until n){
        if(i==0) {
            f = ta[i]
            continue
        }

        if(ta[i] < f){
            r += f - ta[i]
        }else{
            f = ta[i]
        }

        
    }
  println(r)


}
fun next() = readLine()!!
fun nextIntList() = next().split(" ").map{ it.toInt() }
fun nextDoubleList() = next().split(" ").map{ it.toDouble() }
fun nextLongList() = next().split(" ").map{ it.toLong() }

Measured memory_bytes: 64536
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
        long long int n,c=0;
        cin>>n;
        long long int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
        {
            if(i%2==0 && a[i]%2==1)
                c++;
        }
        cout<<c;
        
        
    }
    
    


Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
    int N,A,B,NA;
    scanf("%d%d%d",&N,&A,&B);
    
    NA =N*A;

    if(N<21 && A < 51 && B < 51){
        if(NA <= B){
            printf("%d\n",NA);
        }else{
            printf("%d\n",B);
        }
    }else{
        printf("指定範囲外の入力です\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

void smaller(int *x, int *y);

int main(void)
{
	int x, y;
	while(1){
		cin >> x >> y;
		
		if(x == 0 && y == 0)
		break;
		
		smaller(&x, &y);
		cout << x << ' ' << y << endl;
	}
	return 0;
}

void smaller(int *x, int *y){
	if(*x > *y){
		int type = *x;
		*x = *y;
		*y = type;
	}
}

Measured memory_bytes: 1164
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n) for(ll i=0;i<n;++i)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=a;--i)

int main(){
    ll now=0;
    ll k;
    cin >> k;
    for(ll i=0;i<k;i++){
        now = now*10 + 7;
        if(now%k == 0){
            cout << i+1 << endl;
            return 0;
        }
        now %= k;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const double eps = 0.0000001;
const int N=2200;
const int M=1e5+10;
const int mod=1e9+7;
void io(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
typedef pair<ll,ll> pii;
inline ll sgn(double x)
{
    return (x > eps) - (x < -eps);
}
int aa[2010];
ll p(ll a,ll b,ll mod)
{
    ll ans=0;
    for(;b;b>>=1)
    {
        if(b&1)
        {
            ans=ans+a%mod;
        }
        a=a*2%mod;
    }
    return ans%mod;
}
int main()
{
   int n;
   ll k;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
       cin>>aa[i];
   int sum=0;
   for(int i=1;i<=n;i++)
       for(int j=1;j<=n;j++)
           if(aa[i]>aa[j]) sum++;
   int summ=0;
   for(int i=1;i+1<=n;i++)
       for(int j=i+1;j<=n;j++)
       if(aa[j]<aa[i]) summ++;
    ll ans=(ll)p((ll)summ,k,mod);
    ans+=p(k*(k-1)/2,(ll)sum,mod)%mod;
    cout<<ans%mod<<endl;
}

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

typedef long long ll;
   
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    if(n<k)
    {
        cout<<min(n,abs(n-k));
    }
    else
    {
        cout<<min(n%k, abs((n%k)-k));
    }
    return 0;
}

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

ll sumxor(ll x) {
	if (x % 4 == 0) return x;
	else if (x % 4 == 1) return 1;
	else if (x % 4 == 2) return x ^ 1;
	else return 0;
}

int main(int argc, char const *argv[])
{
	ll a, b; cin >> a >> b;
	printf("%lld\n", sumxor(b) ^ sumxor(a - 1));

	return 0;
}

Measured memory_bytes: 256
<?php
$members = trim(fgets(STDIN));
list($days, $choco) = explode(' ', trim(fgets(STDIN)));

$ate = 0;
for ($i = $members; $i > 0; $i--) {
    $step = trim(fgets(STDIN));
    $j = 0;
    while (true) {
        if ($j * $step + 1 > $days) {
            break;
        }
        $ate++;
        $j++;
    }
}

$total = $ate + $choco;
echo($total."\n");

Measured memory_bytes: 3828
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b; return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b; return true;
    }
    return false;
}
template<int MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
constexpr ll MOD = 1e9 + 7;
using mint = Fp<MOD>;

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll K, N;
    cin >> K >> N;
    vector<ll> As(N);
    REP(n, N) cin >> As[n];

    ll mx = 0;
    REP(n, N - 1) chmax(mx, As[n + 1] - As[n]);

    ll dist = As[0] + (K - As[N - 1]);
    chmax(mx, dist);

    ll ans = K - mx;

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int pr(int num){
    if(num==2){
        //cout<<num;
        return true;
    }
    else if(num%2==0)return false;

    for(int i=3;i<=sqrt(num);i+=2){
        if(num%i==0){
            return false;
        }
    }
    //cout<<num;
    return true;
}



int main(){
    int x;
    
    cin>>x;
    int num=x;
    int ans;
    
    bool prime=false;

    while(!prime){
       pr(num);
       prime=pr(num);
       ans=num;
       ++num;
    }

    cout<<ans;
    return 0;
}


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

int main() {
  int K,S,r=0,i,j;
  cin >> K >> S;
  
  for(i=0; i<=K; i++)
    for(j=0; j<=K; j++)
      if(S-i-j>=0 && S-i-j<=K)
        r++;
  
  cout << r << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter

def main():
  input = sys.stdin.readline
  N = int(input())
  A = list(map(int, input().split()))
  B = []
  for i in range(N):
    B.append(A[i] - (i+1))
  B = sorted(B)
  b = B[(N-1)//2]
  ans = 0
  for a in B:
    ans += abs(a-b)
  
  print(ans)


if __name__ == '__main__':
  main()

Measured memory_bytes: 26004
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using ll = int64_t;

int main() {
  int n,k;
  cin>>n>>k;
  cout<<(n-k+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const int N = 1e5+100;
int dist[N];
bool visited[N];
vector<int> vertices[N];
int dfs(int u) {
	if(visited[u]) return dist[u];
	if(vertices[u].size()==0) return 0;
	visited[u] =1;
	for(auto it:vertices[u]) {
		if(!visited[it]) {
			dfs(it);
		}
		dist[u] = max(dist[u],dist[it]+1);
	}
	return dist[u];
}
int main() {
	int n,m;
	cin>>n>>m;
	int u,v;
	for(int i=0;i<m;i++) {
		cin>>u>>v;
		vertices[u].push_back(v);
	}
	int maxDist = INT_MIN;
	for(int i=1;i<=n;i++) {
		if(!visited[i]) {
			maxDist = max(maxDist, dfs(i));
		}
	}
	//for(int i=1;i<=n;i++) {
		//debug()<<imie(i) imie(dist[i]);
	//}
	//debug()<<imie(maxDist);
	cout<<maxDist;
}



Measured memory_bytes: 12132
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>K;
    typedef vector<mat> dim3;
    dim3 dp(60,mat(60,vec(3600,0)));
    dp[0][0][0] = 1;
    reps(i,1,N+1){
        rep(j,N+1){
            rep(k,K+1){
                ll &now = dp[i][j][k];
                if(k - 2*j >= 0) {
                    (now +=(j*2 + 1) * dp[i - 1][j][k - 2 * j]) %= MOD;
                    (now +=(j + 1) * (j + 1) * dp[i - 1][j+1][k - 2 * j]) %= MOD;
                    (now +=(j > 0) ? dp[i - 1][j - 1][k - 2 * j] : 0) %= MOD;
                }
            }
        }
    }
    cout<<dp[N][0][K]<<endl;
}


Measured memory_bytes: 103424
s, k = input(), int(input())

ans = []
a = ord('z') + 1
for i in s:
    if k == 0:
        ans.append(ord(i))
    elif a - ord(i) <= k and i != 'a':
        k -= a - ord(i)
        ans.append(ord('a'))
    else:
        ans.append(ord(i))
ans[-1] += k % 26
if ans[-1] >= a:
    ans[-1] -= 26
print(*map(chr, ans), sep='')


Measured memory_bytes: 11600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    rep (k, 1, 3) {
        rep (i, n - k) {
            if (s[i] == s[i + k]) {
                cout << i + 1 << " " << i + 1 + k << "\n";
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s==u) a--;
  else b--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    string s;
    cin >> s;
    vll d(s.size());
    ll p=0;
    rep(i,s.size()){
        if(s[i]=='B'){
            if(p!=0) p--;
        }else if(s[i]=='0'){
            d[p]=0;
            p++;
        }else{
            d[p]=1;
            p++;
        }
    }
    rep(i,p-1) cout << d[i];
    if(p!=0) cout << d[p-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            #define pi 3.14159265358979323846
            #define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli i,j,t,k,n,m,f,g,q;
                lli a,b,c;
                stack<lli> st;
                string s;
                cin>>s;
                rep(i,s.length()){
                    if(s[i]=='0'){
                        if(st.empty()){
                            st.push(0);
                            continue;
                        }
                        if(st.top()==1){
                            st.pop();
                        }
                        else{
                            st.push(0);
                        }
                    }
                    else{
                        if(st.empty()){
                                st.push(1);
                                continue;
                            }
                        if(st.top()==0){
                            st.pop();
                        }
                        else{
                            st.push(1);
                        }
                    }
                }
                cout<<s.length()-st.size()<<endl;
                return 0;

            }



Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int A, B;
    cin >> A >> B;
    if(A % 2 == 0){
        if(B % 2 == 0) cout << (A + B) /2 << endl;
        else cout << "IMPOSSIBLE" << endl;
    }else{
        if(B % 2 == 1) cout << (A + B) / 2 << endl;
        else cout <<  "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = []
for n in range(N):
    S.append(input())
c = Counter(S)
num = c.most_common()[0][1]
ans = []
for x in c:
    if c[x] == num:
        ans.append(x)
for x in sorted(ans):
    print(x)


Measured memory_bytes: 45032
#include <stdio.h>

int selectionSort(int A[],int N){
    int cnt=0;
    int i,j,minj;
    for(i=0; i<N; i++){
        minj = i;
        for(j=i; j<N; j++){
            if(A[j] < A[minj]) minj = j;
        }
        if(minj != i) cnt++;
        int tmp;
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
    }

    return cnt;
}

int main(){
    int N,i;
    int A[100];
    int ans;
    
    scanf("%d",&N);
    for(i=0; i<N; i++) scanf("%d",&A[i]);

    ans = selectionSort(A,N);

    for(i=0; i<N; i++){
        if(i != 0) printf(" ");
        printf("%d",A[i]);
    }

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

    return 0;
}



Measured memory_bytes: 2756
def ss(s):

    ans = 0
    ss = s
    flag = True

    while flag:
        ss = ss[:int(len(ss)-2)]
        if ss[:int(len(ss)/2)] == ss[(int(len(ss)/2)):]:
            ans += len(ss)
            flag = False

    return ans

def main():
    s = str(input())
    print(ss(s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b;
    cin >> a >> b;
    printf("%d %d\n", 100, 100);
    int b_cnt = 1;
    int w_cnt = 1;
    rep(i, 100) {
        rep(j, 100) {
            if ( j < 50 ) {
                if ( b_cnt < b && i % 2 == 1 && j % 2 == 0 ) {
                    ++b_cnt;
                    cout << "#";
                    continue;
                }
                cout << ".";
            } 
            else {
                if ( w_cnt < a && i % 2 == 1 && j % 2 == 1 ) {
                    ++w_cnt;
                    cout << ".";
                    continue;
                }
                cout << "#";
            }
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;
const int modulo = 1e9 + 7;
template<typename T>
inline T sum(const T& a, const T& b) { return T((a % modulo + b % modulo) % modulo); }
template<typename T>
inline T mul(const T& a, const T& b) { return T((1LL * (a % (1LL * modulo)) * (b % (1LL * modulo))) % (1LL * modulo)); }
string to_string(string a) { return "\"" + a + "\""; }
#ifdef __LOCAL_DEBUG
#define debug(args...) { string __out = #args; replace(__out.begin(), __out.end(), ',', ' '); stringstream __out_ss(__out);\
istream_iterator<string> __it(__out_ss); _debug(__it, args); }
void _debug(istream_iterator<string> it) { }
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T a, Args... args){ cerr << *it << " = " << to_string(a) << '\n'; _debug(++it, args...); }
#else
#define debug(...)
#endif

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int cnt[2] = {0}, n, ans = oo;
  string s;
  cin >> s;
  n = int(s.length());
  for (char k = '0'; k < '2'; ++k) {
    int tmp = 0;
    for (int i = 0; i < n; ++i)
      if (i % 2) {
        if (k != s[i]) tmp++;
      }
      else {
        if (((k - '0') ^ 1) + '0' != s[i]) tmp++;
      }
    ans = min(ans, tmp);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int s[100] = {};
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = min(a, b) + min(c, d);
	cout << ans << endl;
}



Measured memory_bytes: 256
import collections
h,w = map(int, input().split())
s=[input()for _ in range(h)]

r=[[1,0],[-1,0],[0,1],[0,-1]]
def bfs(i,j):
    global h,w,r
    f=[-1 for _ in range(h*w)]
    que = collections.deque([[i,j,0]])
    f[i*w+j] =0
    while que:
        i,j,k = que.popleft()
        for sr in r:
            ti = i + sr[0]
            tj = j + sr[1]
            if ti>=0 and tj>=0 and ti<h and tj<w:
                if s[ti][tj] == ".":
                    if f[ti*w+tj] == -1:
                        f[ti*w+tj] = k+1
                        que.append([ti,tj,k+1])
    return max(f)


res = 0
for i in range(h):
    for j in range(w):
        if s[i][j] ==".":
            tres = bfs(i,j)
            res = max(res,tres)
print(res)


Measured memory_bytes: 3316
import Control.Applicative
import Control.Monad

rect :: Int -> Int -> Char -> String
rect 0 _ _ = []
rect h w c = replicate w c ++ ['\n'] ++ rect (h - 1) w c

main = do 
  [h, w] <- map (\x -> read x :: Int) . words <$> getLine
  when (h /= 0 || w /= 0) $ putStr (rect h w '#') >> putChar '\n' >> main

Measured memory_bytes: 3944
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long h = a[0], w = a[1];

		if (h % 3 == 0 || w % 3 == 0) { Console.WriteLine(0); return; }
		var m = Math.Min(h > 3 ? w : long.MaxValue, w > 3 ? h : long.MaxValue);

		m = Math.Min(m, h % 2 == 0 ? DivideH0(h, w) : DivideH1(h, w));
		if (h != w) m = Math.Min(m, w % 2 == 0 ? DivideH0(w, h) : DivideH1(w, h));
		Console.WriteLine(m);
	}

	static long DivideH0(long h, long w)
	{
		var m = long.MaxValue;
		for (var v = (w + 1) / 2; v > 0; v--)
		{
			var d = Math.Abs(h * v - h / 2 * (w - v));
			if (d < m) m = d;
			else break;
		}
		return m;
	}

	static long DivideH1(long h, long w)
	{
		var h2 = h / 2;
		var m = long.MaxValue;
		for (long v = (w + 1) / 2, v2 = w - v; v > 0; v--, v2++)
		{
			var ss = new[] { h * v, h2 * v2, (h2 + 1) * v2 };
			Array.Sort(ss);
			var d = ss[2] - ss[0];
			if (d < m) m = d;
			else break;
		}
		return m;
	}
}


Measured memory_bytes: 13396
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();

		sc.close();

		if (A > K) {
			A -= K;
			K = 0;
		} else {
			K -= A;
			A = 0;
		}

		if (B > K) {
			B -= K;
			K = 0;
		} else {
			B = 0;
		}

		out.println(A + " " + B);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ld n,k;
    cin>>n>>k;
    ld ans=0;
    repi(i,1,n+1){
        ld dice=1.0/n,points=i;
        while(points<k){
            points*=2;
            dice/=2;
        }
        ans+=dice;
    }
    cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 3772
def main():
    N = int(input())
    H = list(map(int, input().split()))
    H[0] -= 1
    for i in range(1, N):
        if H[i-1] > H[i]:
            print("No")
            return
        if H[i-1] < H[i]:
            H[i] -= 1
    print("Yes")


if __name__ == "__main__":
    main()


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;cin>>n;
    vector<ll>a(n+1);
    rep(i,n)cin>>a[i+1];
    ll sum = 0;
    vector<ll> b(n+1);

    for(ll i = n;i>=1;i--)
    {
        ll sum1 = 0;
        for(ll j = 1;i*j < n+1;j++)
        {
            sum1+=b[i*j];
        }
       if(sum1%2 != a[i])
       {
           b[i]++;
       }
    }

    rep(i,n)sum+=b[i+1];

    cout<<sum<<endl;
    rep(i,n)
    {
        if(b[i+1]!=0)cout<<i+1<<" ";
    }
    cout<<endl;

    return 0;
}

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

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

int num_divisors(long long N){
    const auto &pf = prime_factorize(N);
    long long res = 1;
    for (auto p : pf) res *= p.second + 1;
    return res;
}

int main()
{
	long long n;
    long long ab;
    int cnt =0;
	cin >> n;

	for (int i=1; i<n; i++){
        ab = n-i;
        cnt += num_divisors(ab);
    }
    cout << cnt;

	return 0;
}

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

#ifdef LOCAL_DEBUG
    #include "/home/laxsuryavanshi/Desktop/cp/trace.hpp"
#else
    #define trace(...)
#endif // LOCAL_DEBUG

int32_t main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0); std::cout.tie(0);
    #ifdef LOCAL_INPUT
    freopen("in", "r", stdin);
    #endif
    int n; cin>>n;
    vector<int>v(n);
    for(int i=0; i<n; i++) {
        cin>>v[i];
    }
    auto ans=0ll;
    for (int i=0; i<n-2; i++) {
        for (int j=i+1; j<n-1; j++) {
            for (int k=j+1; k<n; k++) {
                if (v[i] != v[j] && v[j] != v[k] && v[k] != v[i] &&
                (v[i]+v[j]>v[k])&&(v[j]+v[k]>v[i])&&(v[i]+v[k]>v[j])) ans++;
                trace(i, j, k, v[i], v[j], v[k], ans);
            }
        }
    }
    cout<<ans;
}


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

#define I inline void 

using namespace std ; 

using ll = long long ; 
using ld = long double ; 

const int N = 2e6 + 7 ; 

// How interesting!

int n; 


int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in", "r" , stdin) ;
	string s ;
	cin >> s ;
	int x = 0 ;  
	for(auto u : s){
		x+= u - '0' ; 
	}
	x%= 9 ; 
	cout<< (x ? "No" : "Yes") ; 

	return 0 ; 
}

Measured memory_bytes: 3764
S = input()
T = input()

S = str(S)
T = str(T)
def register(S, T):
	
    if (1 <= len(S) <= 10 and len(T) == len(S) + 1) and (S[0: len(S)] == T[0: len(S)]):
      
        print("Yes")
    else:
        print("No")
         
register(S, T)
         

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int a = 0;
  int b = n;
  
  rep(i,0,8){
    a += n%10;
    n /= 10;
  }
  if(b%a == 0) printf("Yes\n");
  else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using iii = tuple<int, int, int>;
#define forn(i,n) for(int i=0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define fst first
#define snd second

vector<iii> E;

void dfs(multiset<int>& s, int v, int n, int cost) {
    if (v == n) {
        s.insert(cost);
        return;
    }
    for (iii e : E) {
        int a, b, w;
        tie(a, b, w) = e;
        if (a == v) {
            dfs(s, b, n, cost + w);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    int L;
    cin >> L;
    --L;
    int n = 1;
    while ((1 << n) <= L+1) ++n;
    //++n;
    for (int v = n-1; v >= 1; --v) E.pb(iii(v, v+1, 0));
    for (int v = n-1; v >= 1; --v) E.pb(iii(v, v+1, 1<<(n-1-v)));
    if ((L & (L+1)))
    for (int i = 0; (1<<i) <= L; ++i) {
        int bit = 1 << i;
        if (!(L & bit)) continue;
        int j = i-1;
        for (; j >= 0 && !((1<<j) & L); --j);
        if (j < 0) {
            E.pb(iii(1, n, L));
            continue;
        }
        int val = L & ~(bit - 1);
        E.pb(iii(1, n-j, val));
    }
    sort(all(E));

    assert(n <= 20);
    assert(E.size() <= 60);

    cout << n << ' ' << E.size() << '\n';
    for (iii e : E)
        cout << get<0>(e) << ' ' << get<1>(e) << ' ' << get<2>(e) << '\n';

    return 0;
    multiset<int> s;
    dfs(s, 1, n, 0);
    //for (int x : s) cout << "path: " << x << '\n';
    cout.flush();
    vector<int> v(s.begin(), s.end());
    assert((int)v.size() == L+1);
    for (int i = 0; i < L; i++) {
        assert(v[i] == i);
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char mozi[1000001];
	int mozisuu;
	int kazu;
	int currentkazu;
	int kosuu;
	int i;
	while(1) {
		scanf("%d",&kazu);
		if(kazu==0)break;
		scanf("%d",&mozisuu);
		scanf("%s",mozi);
		currentkazu=0;
		kosuu=0;
		for(i=2;i<mozisuu;i++) {
			if(mozi[i]=='I') {
				if(mozi[i-1]=='O' && mozi[i-2]=='I')currentkazu++;
				else currentkazu=0;
				if(currentkazu>=kazu)kosuu++;
			}
		}
		printf("%d\n",kosuu);
	}
	return 0;
}

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

int main() {
	string s,t;
	cin>>s>>t;
	int r[26]={};
	for(int i=0;i<26;i++)r[i]=-1;
	for(int i=0;i<s.size();i++){
		if(r[s[i]-'a']<0) r[s[i]-'a']=t[i]-'a';
		else {
			if(r[s[i]-'a']!=t[i]-'a'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	for(int i=0;i<26;i++)r[i]=-1;
	for(int i=0;i<t.size();i++){
		if(r[t[i]-'a']<0) r[t[i]-'a']=s[i]-'a';
		else {
			if(r[t[i]-'a']!=s[i]-'a'){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int n,r,g,b,ans;
int main()
{
	cin>>r>>g>>b>>n;
	for(int i=0;i<=3000;i++)
	{
		for(int j=0;j<=3000;j++)
		{
			int now=i*r+j*g;
			if(now>n)
			{
				break;
			}
			if((n-now)%b==0)
			{
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from string import ascii_lowercase
from functools import reduce
from operator import mul

# 入力
N = int(input())
S = input()

# 解は(各アルファベットの出現回数+1)の総積
ans = (
    reduce(
        mul,
        map(
            lambda c: S.count(c) + 1,
            ascii_lowercase
        )
    )
    - 1
) % (10**9 + 7)

# 出力
print(ans)


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  ll a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  ll sum = 0;
  ll total = 1LL * N * (N + 1) / 2;
  for (int i = 0; i < N; i++) sum += a[i];

  if (sum % total != 0) {
    cout << "NO" << endl;
  } else {
    ll cnt = sum / total;
    ll d[N]; // 階差数列
    d[0] = a[0] - a[N-1] - cnt;
    for (int i = 1; i < N; i++) d[i] = a[i] - a[i-1] - cnt;

    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (d[i] <= 0 && d[i] % N == 0) continue;
      
      flag = false;
    }

    cout << (flag ? "YES" : "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
//const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

int main(){
	int n;
	cin >> n;
	cout << n * n << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
      	int res = 0;
		Scanner sc = new Scanner(System.in);
		String input_line = sc.nextLine();
        int num = Integer.parseInt(input_line);
      
        if(num ==1){
          res = 1;
        }
        else if(num % 2 == 0){
          res = num / 2;
        }
        else{
          res = (int)num / 2 + 1;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define int long long
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
    FASTIO;
    int k;
    cin>>k;
    vector<int>v;
    int z=0;
    string str="";
    int cnt=1;
    int x=7;
    int ok=0;
    while(x%k)
    {
        x*=10;
        x+=7;
        x=x%k;
        cnt++;
        z++;
        if(z>k)
            break;
    }
    if(z<=k)
    {
        cout<<cnt;
    }
    else
        cout<<-1;
    return 0;
}


Measured memory_bytes: 3660
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

MOD = 1000000007

N = read()
S = input()
T = input()

ans = 1

i = 0
prev = 0

M1 = {0:3, 1:2, 2:1}
M2 = {0:6, 1:2, 2:3}
while i < N:
  if S[i] == T[i]:
    ans = ans * M1[prev] % MOD
    prev = 1
    i += 1
  else:
    ans = ans * M2[prev] % MOD
    prev = 2
    i += 2

print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>

#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using lint = long long;

int main(void)
{
	int N, M;
	cin >> N >> M;
	priority_queue<int, vector<int>, less<int>> A;
	rep(i, N){
		int temp;
		cin >> temp;
		A.push(temp);
	}

	rep(i, M){
		int top = A.top();
		top /= 2;
		A.pop();
		A.push(top);
	}

	lint ans = 0;
	while (!A.empty()){
		ans += A.top();
		A.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892