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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> fsf = {A, B, C};
  sort(fsf.begin(),fsf.end());
  vector<int> ans = {5,5,7};
  if (ans == fsf)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n,x,i,ans=0,d=0;
    cin>>n>>x;
    int l[n];
    for(i=0;i<n;i++)cin>>l[i];
    while(x>=d){
        d=d+l[ans];
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int y=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
	int m=(s[5]-'0')*10+(s[6]-'0');
	int d=(s[8]-'0')*10+(s[9]-'0');
	int flag=0;
	if(y>2019){
		flag=1;
	}
	if(y>=2019&&m>4){
		flag=1;
	}
	if(y>=2019&&m>=4&&d>30){
		flag=1;
	}
	if(flag==1){
		printf("TBD");
	}else{
		printf("Heisei");
	}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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

		while(stdIn.hasNext()){
			int year = stdIn.nextInt();
			int month = stdIn.nextInt();
			int day = stdIn.nextInt();

			if(year<=1867){
				System.out.println("pre-meiji");
			}
			else if(1869<=year&&year<=1911){
				System.out.println("meiji "+(year-1867)+" "+month+" "+day);
			}
			else if(1913<=year&&year<=1925){
				System.out.println("taisho "+(year-1911)+" "+month+" "+day);
			}
			else if(1927<=year&&year<=1988){
				System.out.println("showa "+(year-1925)+" "+month+" "+day);
			}
			else if(1990<=year){
				System.out.println("heisei "+(year-1988)+" "+month+" "+day);
			}

			else if(year==1868){
				if(month>9){
					System.out.println("meiji 1 "+month+" "+day);
				}
				else if(month==9){
					if(day>=8){
						System.out.println("meiji 1 "+month+" "+day);
					}
					else{
						System.out.println("pre-meiji");
					}
				}
				else{
					System.out.println("pre-meiji");
				}
			}
			else if(year==1912){
				if(month>7){
					System.out.println("taisho 1 "+month+" "+day);
				}
				else if(month==7){
					if(day>=30){
						System.out.println("taisho 1 "+month+" "+day);
					}
					else{
						System.out.println("meiji "+(year-1867)+" "+month+" "+day);
					}
				}
				else{
					System.out.println("meiji "+(year-1867)+" "+month+" "+day);
				}
			}
			else if(year==1926){
				if(month>12){
					System.out.println("showa 1 "+month+" "+day);
				}
				else if(month==12){
					if(day>=25){
						System.out.println("showa 1 "+month+" "+day);
					}
					else{
						System.out.println("taisho "+(year-1911)+" "+month+" "+day);
					}
				}
				else{
					System.out.println("taisho "+(year-1911)+" "+month+" "+day);
				}
			}
			else if(year==1989){
				if(month>1){
					System.out.println("heisei 1 "+month+" "+day);
				}
				else if(month==1){
					if(day>=8){
						System.out.println("heisei 1 "+month+" "+day);
					}
					else{
						System.out.println("showa "+(year-1925)+" "+month+" "+day);
					}
				}
				else{
					System.out.println("showa "+(year-1925)+" "+month+" "+day);
				}
			}
		}
	}
}
			

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    /**
     * set = {-1, place of max(Ai), n} として、
     * valがでかい方から順に決めていく
     * Ai が最大から2つ目になるときは、
     * Aiよりでかい要素を"一つのみ"含むとき
     *
     */

    i32 n, p; cin >> n;
    vi place(n+1);
    rep (i,n) {
        cin >> p;
        place[p] = i;
    }

    multiset<i32> used_p_places;
    used_p_places.insert(-1);
    used_p_places.insert(-1);
    used_p_places.insert(n);
    used_p_places.insert(n);

    i64 sum = 0;
    for (i32 val = n; val >= 1; --val) {
        i32 plc = place[val];
        auto iter = used_p_places.lower_bound(plc);
        i32 R = *++iter;
        i32 r = *--iter;
        i32 l = *--iter;
        i32 L = *--iter;

        sum += val * (R-r) * (plc-l);
        sum += val * (r-plc) * (l-L);

        used_p_places.insert(plc);
    }
    cout << sum << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=300005;
//i_am_noob
int n,sum[maxn],sum2[maxn],ans=0;
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> str;
    sum[0]=0;
    rep(n) sum[i+1]=sum[i]+(str[i]=='E');
    sum2[0]=0;
    rep(n) sum2[i+1]=sum2[i]+(str[n-1-i]=='W');
    rep(n) ans=max(ans,sum[i]+sum2[n-1-i]);
    print1(n-1-ans);
	return 0;
}


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

using namespace std;

bool cmp(pair<string, pair<int, int>> &a, pair<string, pair<int, int>> &b){
    if (a.first == b.first)
        return a.second.first > b.second.first;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i].first >> v[i].second.first;
        v[i].second.second = i + 1;
    }
    sort(v.begin(), v.end(), cmp);
    for (auto elem : v){
        cout << elem.second.second << endl;
    }
    return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s.at(k-1) += 0x20;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    d,x = LI()
    a = [I() for _ in range(n)]
    r = [0] * (d+1)
    r[0] = x
    for c in a:
        for i in range(1,d+1,c):
            r[i] += 1


    return sum(r)


print(main())




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

int main() {
  double A,B;
  cin>>A>>B;
  bool f=true;
  double C,D;
  for(int i=1; i<1250; i++){
    C=i*0.08;
    D=i*0.1;
    if(A<=C && C<A+1 && B<=D && D<B+1){
      cout<<i<<endl;
      f=false;
      break;
    }
  }
  if(f) cout<<-1<<endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  vector<int> r(n+1);
  r.at(0)=0;
  for(int i=1;i<n+1;i++){
    r.at(i)+=r.at(i-1)+p.at(i-1);
  }
  vector<int> s(n-k+1);
  for(int i=0;i<n-k+1;i++){
    s.at(i)=r.at(i+k)-r.at(i);
  }
  sort(s.begin(),s.end());
  double ans=(s.at(n-k)+k)/2.0;
  cout << fixed << setprecision(9) << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main() {
	rishabh();
    int n;
    cin>>n;
    string str;
    cin>>str;
    ll ans=0;
    set<char> prev;
    for(int i=1;i<n;i++){
        prev.insert(str[i-1]);
        set<char> next;
        for(int j=i;j<n;j++){
            next.insert(str[j]);
        }
        ll temp=0;
        for(auto x: prev){
            if(next.count(x))temp++;
        }
        ans=max(ans,temp);
    }
    cout<<ans;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] a = new int[N];
            int[] b = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
            }
            int[] c = new int[M];
            int[] d = new int[M];
            for (int i = 0; i < M; i++) {
                c[i] = in.nextInt();
                d[i] = in.nextInt();
            }

            for (int n = 0; n < N; n++) {
                int minDistance = (int) 1e9;
                int minM = -1;
                for (int m = 0; m < M; m++) {
                    int distance = Math.abs(a[n] - c[m]) + Math.abs(b[n] - d[m]);
                    if (distance < minDistance) {
                        minDistance = distance;
                        minM = m;
                    }
                }
                System.out.println(minM + 1);
            }
        }
    }
}


Measured memory_bytes: 27228
t = [16,8,17,7,8,21,13,5,1,25,12,14,12,6,4,24,6,9,18,3,22,19,3,24,7,7,2,23,11,6,14,17,4,21,24,23,6,14,6,15,26,22,19,18,20,11,10,16,18,5,16,7,7,24,18,16,14,18,22,25,19,20,13,23,3,25,19,25,25,3,17,16,5,22,9,11,5,6,6,13,26,14,9,13,11,11,1,19,22,23,19,18,5,14,26,11,25,3,24,6,24,20,12,19,7,25,16,19,6,1,4,16,15,15,5,6,24,26,2,3,15,5,10,21,22,16,22,1,2,15,25,7,16,15,5,25,12,6,16,2,14,16,12,10,22,18,22,9,16,25,1,13,25,5,8,23,17,14,17,18,17,16,13,24,21,10,10,12,15,15,22,1,15,23,21,24,23,8,13,19,14,3,2,24,3,15,11,19,6,26,11,22,1,20,24,4,11,14,12,25,10,25,8,6,9,24,10,19,23,14,11,11,21,6,14,21,24,24,26,18,26,2,13,14,13,7,17,15,15,11,5,20,12,25,8,14,11,15,1,21,7,26,17,18,3,4,4,9,21,20,5,9,15,10,23,1,25,25,26,16,22,19,3,13,16,19,1,10,12,6,22,7,21,2,6,1,1,15,22,12,26,25,12,14,20,18,11,4,3,16,23,19,18,20,5,19,10,23,8,4,9,26,3,15,2,26,3,14,6,23,12,17,9,10,20,22,4,23,22,24,8,18,3,2,12,4,22,7,25,12,23,7,2,21,19,2,13,2,15,18,24,20,12,8,3,19,13,16,24,15,8,7,13,7,14,11,5,21,6,4,24,15,20,15,7]
for i in range(365):
    print(t[i])

Measured memory_bytes: 9284
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	int a, b;
	cin >> a >> b;

	cout << (a + b) % 24 << endl;

	return 0;
}

Measured memory_bytes: 256
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let p = 1. /. float n
let log2 n = log n /. log 2.
let ans = ref 0.
let _ =
  for i = 1 to n do
    let j = max 0. @@ ceil @@ log2 @@ float k /. float i in
    ans := !ans +. p *. 0.5 ** j done;
  Printf.printf "%.12f\n" !ans

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


 
int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,k;
    cin>>n>>k;
    
    int cur=k;
    
    int ct=1;
    while(cur<n){
        ct++;
        cur+=k-1;
    }
    cout<<ct;
    
    
    
    return 0;
    
    
    
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int k, i, sum, ans, tmp;

	while( scanf("%d", &k ) != EOF ) {
		if( k == 0 ) break;
		sum = 0;
		for( i = 0; i < k * ( k - 1 ) / 2; i++ ) {
			scanf( "%d", &tmp );
			sum += tmp;
		}
		ans = sum / ( k - 1 );
		printf( "%d\n", ans );
	}
	return 0;
}

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

int main() {
  int n, m;
  int fr, to;
  cin >> n >> m ;

  vector<int> cities(n);
  for(int i = 0; i < m; i++) {
    cin >> fr >> to;
    cities.at(fr-1)++;
    cities.at(to-1)++;
  }
  for(int i = 0; i < n; i++) {
    cout << cities.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		while (n-- > 0) {
			String order = in.next();
			StringBuilder m = new StringBuilder(in.next());
			int ln = m.length();
			for (int i=order.length()-1; i>=0; i--) {
				switch (order.charAt(i)) {
					case 'J':
						m.insert(0, m.charAt(ln-1));
						m.deleteCharAt(ln);
						break;
					case 'C':
						m.append(m.charAt(0));
						m.deleteCharAt(0);
						break;
					case 'E':
						if (ln%2 == 0) {
							m.append(m.substring(0, ln/2));
							m.delete(0, ln/2);
						} else {
							m.append(m.charAt(ln/2));
							m.append(m.substring(0, ln/2));
							m.delete(0, (ln+1)/2);
						}
						break;
					case 'A':
						m.reverse();
						break;
					case 'P':
						for (int j=0; j<ln; j++) {
							if ('1' <= m.charAt(j) && m.charAt(j) <= '9') {
								m.setCharAt(j, (char)(m.charAt(j)-1));
							} else if (m.charAt(j) == '0') {
								m.setCharAt(j, '9');
							}
						}
						break;
					case 'M':
						for (int j=0; j<ln; j++) {
							if ('0' <= m.charAt(j) && m.charAt(j) <= '8') {
								m.setCharAt(j, (char)(m.charAt(j)+1));
							} else if (m.charAt(j) == '9') {
								m.setCharAt(j, '0');
							}
						}
						break;
				}
				// out.println(m);
			}

			out.println(m);
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

typedef long long ll;

string s;
int k;
ll res;

int main()
{
    cin >> s;
    cin >> k;
    int i = 1;
    while (i < s.length())
        if (s[i] == s[i - 1]) { res++; i += 2; }
        else i++;
    if (k == 1 || i != s.length() || s[0] != s[int(s.length()) - 1]) {
        res *= k;
        cout << res << endl;
        return 0;
    }
    i = 0;
    ll add = 1; i += 2;
    while (i < s.length())
        if (s[i] == s[i - 1]) { add++; i += 2; }
        else i++;
    if (i == s.length()) {
        res = res + add * ll(k - 1);
        cout << res << endl;
        return 0;
    }
    res = res * ll((k + 1) / 2) + add * ll(k / 2);
    cout << res << endl;
    return 0;
}


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

int main() {
  int sss;
  int s1;
  int s2;
  int s3;
  
  cin >> sss;
  
  s3 = sss % 2;
  s2 = (sss / 10) % 2; 
  s1 = (sss / 100) % 2;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll INF = 1LL << 50;

struct range{
    ll l, r, len;

    range(ll _l, ll _r){
        l = _l;
        r = _r;
        len = max(0LL, r - l + 1);
    }
};

bool cmp(const range &a, const range &b){
    return a.l < b.l;
}

range unite(range a, range b){
    return range(max(a.l, b.l), min(a.r, b.r));
}

int main(){
    int N;
    cin >> N;
    vector<range> p(N, range(-INF, INF));
    for(int i = 0; i < N; i++){
        ll l, r;
        cin >> l >> r;
        p[i] = range(l, r);
    }

    sort(p.begin(), p.end(), cmp);

    vector<range> sumf(N + 1, range(-INF, INF));
    vector<range> sumb(N + 1, range(-INF, INF));

    for(int i = 0; i < N; i++){
        sumf[i + 1] = unite(sumf[i], p[i]);
    }
    for(int i = N; i > 0; i--){
        sumb[i - 1] = unite(sumb[i], p[i - 1]);
    }

    ll mx = 0;
    ll mx_ind = -1;
    for(int i = 0; i < N; i++){
        if(mx < p[i].len){
            mx = p[i].len;
            mx_ind = i;
        }
    }

    range tmp = range(-INF, INF);
    for(int i = 0; i < N; i++){
        if(i != mx_ind){
            tmp = unite(tmp, p[i]);
        }
    }

    ll ans = mx + tmp.len;
    for(int i = 1; i < N; i++){
        //cout << ans << endl;
        ans = max(ans, sumf[i].len + sumb[i].len);
    }

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

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INT_MAX 0x7FFFFFFF
#define LL_MAX 0x7FFFFFFFFFFFFFFF
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
using namespace std;
typedef long long int LL;

int main(){
  int N, W;
  cin >> N >> W;
  LL mw[101][100001];
  REP(i, 100001) {
    mw[0][i] = INT_MAX / 2;
  }
  mw[0][0] = 0;
  for(int i=1; i<=N; ++i) {
    int w, v;
    cin >> w >> v;
    REP(j, 100001) {
      if(j-v>=0)
        mw[i][j] = MIN(mw[i-1][j], mw[i-1][j-v]+w);
      else
        mw[i][j] = mw[i-1][j];
    }
  }
  int ret = 0;
  REP(i, 100001) {
    if(mw[N][i] <= W) ret = i;
  }
  cout << ret << endl;
}

Measured memory_bytes: 79104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args)throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Reader in = new Reader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Reader in, PrintWriter out) throws Exception {
            String haiku = in.readLine();
            int count5 = 0, count7 = 0;
            for (int i = 0; i < haiku.length(); ++i) {
                char ch = haiku.charAt(i);
                if (ch == '5') {
                    count5++;
                } else if (ch == '7') {
                    count7++;
                }
            }
            if (count5 == 2 && count7 == 1) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public Reader(InputStream in) {
            din = new DataInputStream(in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[1000005]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    break;
                }
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) {
                buffer[0] = -1;
            }
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }
}



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

//input
int N, Q;
string s;
char t[200020];
char d[200020];

bool isOK(int idx, int dst) {
    for (int i = 0; i < Q; ++i) {
        if (s[idx] == t[i]) {
            if (d[i] == 'R') ++idx;
            else --idx;
        }
        if (idx == dst) return true;
        else if (idx == -1 || idx == N) return false; 
    }
    return false;
}

int bisection(int dst) {
    int ng = N + (-1) - dst;
    int ok = dst;

    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (isOK(mid, dst)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> N >> Q;
    cin >> s;
    for (int i = 0; i < Q; ++i) cin >> t[i] >> d[i];

    int r = bisection(-1);
    int l = bisection(N);

    if (l <= r) cout << 0 << endl;
    else cout << N - (N - l) - (r + 1) << endl;

}

Measured memory_bytes: 900
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            int ans = 1;
            char current = S[0];

            for(int i = 1; i<N; i++)
            {
                if(current != S[i])
                {
                    ans++;
                    current = S[i];
                }
            }

            Console.WriteLine(ans);
            //Console.ReadLine();

        }
    }
}


Measured memory_bytes: 11232
#include <stdio.h>

int             main(void)
{
        int             n;
        scanf("%d", &n);
        int             l[n];
        int             r[n];
        for (int i = 0; i < n; i++)
                scanf("%d %d", &l[i], &r[i]);
        if (!(1 <= n && n <= 1000))
                return (1);
        for (int i = 0; i < n; i++)
                if (!(1 <= l[i] && l[i] <= r[i] && r[i] <= 100000))
                        return (1);
        int             nb = 0;
        for (int i = 0; i < n; i++)
        {
                nb += r[i] - l[i] + 1;
        }
        printf("%d\n", nb);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,b,n,ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b;
        ans+=(b-a+1);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

        vector<char> S;
        vector<char> T;
        for (int i = 0; i < s.length(); ++i) {
                S.push_back(s[i]);
        }
        for (int i = 0; i < t.length(); ++i) {
                T.push_back(t[i]);
        }
        sort(S.begin(), S.end());
        sort(T.begin(), T.end(), greater<char>());
#if 0
        for (int i = 0; i < S.size(); ++i) {
                cout << S[i];
        }
        cout << endl;
        for (int i = 0; i < T.size(); ++i) {
                cout << T[i];
        }
        cout << endl;
#endif
        int len = (S.size() > T.size()) ? T.size() : S.size();
        for (int i = 0; i < len; ++i) {
                char ss = S[i];
                char tt = T[i];
                if (ss == tt) continue;
                if (ss > tt) {
                        cout << "No" << endl;
                        exit(0);
                }
                if (tt > ss) {
                        cout << "Yes" << endl;
                        exit(0);
                }
        }

        if (T.size() > S.size()) {
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }


}


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

int main() {
  string s;
  cin >> s;
  cout << s[0];
  int c = 0;
  for(int i = 1; i < s.size() - 1; i++) {
    c++;
  }
  cout << c << s[s.size()-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int N, X, Y; cin >> N >> X >> Y;
    int cnt[N];
    rep(i,N) cnt[i] = 0;
    
    for (int i = 1; i <= N - 1; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            int num = min(abs(i - j), abs(i - X) + 1 + abs(Y - j));
            cnt[num]++;
        }
    }
    
    for (int i = 1; i < N; ++i) out(cnt[i]);

    
    return 0;
}






Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <cmath>
#include <queue> 
#define P pair<int ,int >
#define pb push_back
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define db double
#define int LL
using namespace std;
const int N   = 1e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define rep(i,x,y) for (int i=x;i<=y;++i)
#define rrep(i,x,y) for (int i=x;i<y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
int n,a[N],sum,ans;
signed main()
{
	read(n);
	rep(i,1,n) read(a[i]);//sum+=a[i]<<1;
	sort(a+1,a+1+n);
	if (n&1)
	{
		sum=0;
		rep(i,1,n/2+1) sum-=a[i]<<1;
		rep(i,n/2+2,n) 
		  sum+=a[i]<<1;
		
		sum+=a[n/2] +a[n/2+1];
		ans=sum;
		
		sum=0;
		rep(i,1,n/2) sum-=a[i]<<1;
		rep(i,n/2+1,n) sum+=a[i]<<1;
		sum-=a[n/2+1]+a[n/2+2];
		ans=max(ans,sum);
		printf("%lld",ans);
		return 0;
	}
	rep(i,1,n/2) sum-=a[i]<<1;
	rep(i,n/2+1,n) sum+=a[i]<<1;
	sum-=a[n/2+1];
	sum+=a[n/2];
	printf("%lld",sum);
	return 0;
}


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

const int N=100005;
const int MOD=1e9+7;
int n,m,dp[1005][1005];
char str[1005];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str);
		for(int j=1;j<=m;j++)
		{
			if(i==1&&j==1)
			{
				dp[i][j]=1;
				continue;
			}
			if(str[j-1]=='#') dp[i][j]=0;
			else dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=MOD;
		}
	}
	printf("%d\n",dp[n][m]);
}

Measured memory_bytes: 4224
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
const char sp =' ';
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

            string s;
    cin >> s;
    if(s[s.size()-1]=='s')cout <<s+"es";
        else cout << s+"s";

	return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int total = 0,num = sc.nextInt();
		for(int i = 0; i < num; i++) {
			total += i+1;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 24144
N = int(input())
enum = []

def dfs(n):
    if int(n) > N:  return
    if "3" in n and "5" in n and "7" in n:  enum.append(n)
    dfs(n + "3")
    dfs(n + "5")
    dfs(n + "7")
    
dfs("3")
dfs("5")
dfs("7")
print(len(enum))

Measured memory_bytes: 75908
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 30){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}



void solve(){
  ll N, M;
  cin >> N >> M;
  if(N == M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


Measured memory_bytes: 764
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);
        long count = 2;
        if(N - M > 1 || M - N > 1){
            count = 0;
        }
        else if(N == M){
            count = 2;
        }
        else{
            count = 1;
        }
        for(int i=1;i<=N;i++){
            count *= i;
            count %= Define.mod;
        }
        for(int i=1;i<=M;i++){
            count *= i;
            count %= Define.mod;
        }
        sb.Append(count+"\n");
    }
}
public static class Define{
    public const long mod = 1000000007;
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a << endl;
}

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

constexpr int inf = 1e9;

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    vector<int> dp(n, inf);
    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if(i - 2 >= 0) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp.back() << endl;
}


Measured memory_bytes: 1024
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    F = [int(i) for i in input().split()]
    A.sort()
    F.sort(reverse=True)

    def is_ok(mid):
        # midは目標成績
        need = 0
        for i in range(N):
            if mid < A[i]*F[i]:
                b = (F[i]*A[i] - mid)
                need += (b + F[i] - 1)//F[i]
        if need <= K:
            return True
        else:
            return False

    def binary_search_meguru():
        ng = -1
        ok = 10**18 + 1
        while abs(ok - ng) > 1:
            mid = ng + (ok - ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(binary_search_meguru())


if __name__ == '__main__':
    main()


Measured memory_bytes: 119500
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
using namespace std;

int main(void){
	int i;
	string s;
	cin>>s;
//	while(s.length()>=5){
//		int place=s.find("erasereraser");
//		if(place!=-1)s=s.replace(place,12,"");
//		else{
//			place=s.find("dreamereraser");
//			if(place!=-1)s=s.replace(place,13,"");
//			else{
//				place=s.find("dreamererase");
//				if(place!=-1)s=s.replace(place,12,"");
//				else{
//					place=s.find("dreameraser");
//					if(place!=-1)s=s.replace(place,11,"");
//					else{
//						place=s.find("dreamerase");
//						if(place!=-1)s=s.replace(place,10,"");
//						else{
//							place=s.find("erase");
//							int dplace=s.find("dream");
//							if(place!=-1)s=s.replace(place,5,"");
//							if(dplace!=-1)s=s.replace(dplace,5,"");
//							if(place==-1&&dplace==-1)break;
//						}
//					}
//				}
//			}
//		}
//	}
	bool ch=true;
	while(ch){
		int place=s.find("eraser");
		if(place!=-1)s=s.replace(place,6,"");
		else ch=false;
	}
	ch=true;
	while(ch){
		int place=s.find("erase");
		if(place!=-1)s=s.replace(place,5,"");
		else ch=false;
	}
	ch=true;
	while(ch){
		int place=s.find("dreamer");
		if(place!=-1)s=s.replace(place,7,"");
		else ch=false;
	}
	ch=true;
	while(ch){
		int place=s.find("dream");
		if(place!=-1)s=s.replace(place,5,"");
		else ch=false;
	}
	if(s.length()==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int X;
    cin >> X;
    int now = 0;
    int i = 0;
    while (X > now)
    {
        i++;
        now += i;
    }
    cout << i << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        if(Y%2==0 && Y>=2*X && Y<=4*X) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
	}

}


Measured memory_bytes: 35808
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>

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

using namespace std;

class Edge{
public:
    int to;
    int cost;
    Edge(int to,int cost):to(to),cost(cost){}
};

class Node{
public:
    int distance;
    int num;
    int ticket;
    Node(){}
    Node(int distance, int num,int ticket):distance(distance),num(num),ticket(ticket){}
    bool operator<(const Node &b)const{
        return distance > b.distance;
    }
};

vector<Edge> edge[101];
bool flg[101][11];

int c,n,m,s,d;

int solve(){

    priority_queue<Node> Q;
    Q.push(Node(0,s,0));
    int ans = 1000000;
    while(!Q.empty()){
        Node node = Q.top();Q.pop();
        if(flg[node.num][node.ticket]){
            continue;
        }
        flg[node.num][node.ticket] = true;
        //printf("num->%d cost->%d ticket->%d\n",node.num,node.distance,node.ticket);
        if(node.num == d){
            ans = min(ans,node.distance);
        }

        rep(i,edge[node.num].size()){
            Edge e = edge[node.num][i];
            int cost = node.distance + e.cost;
            Q.push(Node(cost,e.to,node.ticket));
            if(node.ticket < c){
                int cost = node.distance + e.cost/2;
                Q.push(Node(cost,e.to,node.ticket+1));
            }
        }
    }
    return ans;
}



void init(){
    rep(i,101){
        edge[i].clear();
        rep(k,11){
            flg[i][k] = 0;
        }
    }
}

int main(){

    while(cin >> c >> n >> m >> s >> d,!m==0){
        init();
        rep(i,m){
            int a,b,c;
            cin >> a >> b >> c;
            edge[a].push_back(Edge(b,c));
            edge[b].push_back(Edge(a,c));
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1340
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int n,m=-1;
	int i,j,k;
	int a[3]={0};
	int s=0;
	string sa;
	string sb="JOI";
	cin>>sa;
	for(i=0;i<sa.size();i++){
		if(m!=-1 && sa[i]==sb[m]){
			a[m]++;
		}else if(m==2){
			m=-1;
			if(a[0]>=a[1] && a[1]<=a[2] && s<a[1])s=a[1];
			memset(a,0,sizeof(a));
			if(sa[i]=='J')m=0,a[0]++;
		}else if(sa[i]==sb[m+1]){
			m++;
			a[m]++;
		}else if(sa[i]=='J'){
			m=0;
			memset(a,0,sizeof(a));
			a[0]++;
		}else{
			m=-1;
			memset(a,0,sizeof(a));
		}
	}
	
	if(m==2 && a[0]>=a[1] && a[1]<=a[2] && s<a[1])s=a[1];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3956
N, Y = map(int, input().split(" "))

x = -1
y = -1
z = -1
for i in range(N+1):
    for j in range(N+1):
        if i * 10000 + j * 5000 + (N-i-j)*1000 == Y and N-i-j >= 0:
            x = i
            y = j
            z = N-i-j
print(x,y,z)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] c = S.toCharArray();
        int N = c.length;

        boolean flag = true;
        for (int i=0;i<N/2;i++) {
            if (c[i]!=c[N-1-i]) flag = false;
        }

        for (int i=0;i<(N-1)/2/2;i++) {
            if (c[i]!=c[(N-1)/2-1-i]) flag = false;
        }
        for (int i=0;i<(N-3)/2/2;i++) {
            if (c[(N+3)/2-1+i]!=c[N-1-i]) flag = false;
        }
        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int c[52][52];

bool dfs(int x,int y){
  if(c[x][y]==0) return false;
  c[x][y]=0;
  for(int i=-1;i<=1;i++){
    for(int j=-1;j<=1;j++){
      if((i|j)!=0&&c[x+i][y+j]!=0)
	dfs(x+i,y+j);
    }
  }
  return true;
}

int main(){ _;
  int w,h;
  while(cin>>w>>h,!(w==0&&h==0)){
    int count=0;
    REP(j,h+2)REP(i,w+2) c[i][j]=0;
    REP(j,h)REP(i,w) cin>>c[i+1][j+1];
    REP(j,h)REP(i,w)
      if(dfs(i+1,j+1))
	count++;
    cout<<count<<endl;
  }
}

Measured memory_bytes: 1384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n); i++)
#define sz(x) int(x.size())
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;

    b = 2*b;

    if(a<=b){cout << 0 << endl;return 0;}

    cout << a-b << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	int T;
	int a,b,x[1000005];
	double y[1000005];
	cin>>T>>a>>b;
	for(int i = 0 ; i < T ; i ++){
		cin>>x[i];
		y[i]=fabs(b-(a-x[i]*0.006));
	}
	double min = y[0];int d=1;
	for(int i = 0 ; i < T - 1 ; i ++){
		if(min > y[i+1]) {
			min = y[i+1];
			d=i+2;
		}
	}
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 2304
def gcd(x, y)
	if y == 0 then
		return x
	end
	return gcd(y, x % y);
end
while true do
	n = gets.to_i
	if n == 0 then
		break
	end
	a = Array.new(n);
	b = Array.new(n);
	for i in 0 .. n-1 do
		a[i], b[i] = gets.split.map(&:to_i)
		r = gcd(a[i], b[i]); a[i] /= r; b[i] /= r;
	end
	s = 1;
	for i in 0 .. n-1 do
		s = s / gcd(s, b[i]) * b[i]
	end
	for i in 0 .. n-1 do
		a[i] *= s / b[i];
	end
	s = 1
	for i in 0 .. n-1 do
		s = s / gcd(s, a[i]) * a[i]
	end
	for i in 0 .. n-1 do
		p s / a[i]
	end
end

Measured memory_bytes: 8980
using System;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        string a = arr[0], b = arr[1];
        Console.WriteLine(
            int.Parse(a) < int.Parse(b) ?
            new string(a[0], int.Parse(b)) : new string(b[0], int.Parse(a)));
    }
}

Measured memory_bytes: 11220
def D():
    N = int(input())
    tmplist = [0 for i in range(N + 1)]
    for i in range(1, N + 1):
        key = i
        for j in range(2, key + 1):
            while i % j == 0:
                tmplist[j] += 1
                i /= j
    ans = 0
    anslist = []
    for p in range(N + 1):
        if tmplist[p] + 1 >= 75:
            anslist.append(pow(p, 74))
        for q in range(N + 1):
            if p != q and tmplist[p] + 1 >= 25 and tmplist[q] + 1 >= 3:
                anslist.append(pow(p, 24) * pow(q, 2))
            if p != q and tmplist[p] + 1 >= 15 and tmplist[q] + 1 >= 5:
                anslist.append(pow(p, 14) * pow(q, 4))
            for r in range(N + 1):
                if p != q and q != r and r != p and tmplist[p] + 1 >= 5 and tmplist[q] + 1 >= 5 and tmplist[r] + 1 >= 3:
                    anslist.append(pow(p, 4) * pow(q, 4) * pow(r, 2))
    anslist.sort()
    ans = 1
    for i in range(1, len(anslist)):
        if anslist[i] != anslist[i - 1]:
            ans += 1
    if len(anslist) == 0:
        ans = 0
    print(ans)

D()

Measured memory_bytes: 3064
object Main {
  def main(args: Array[String]): Unit = {
    io.Source.stdin.getLines foreach (n => println(pi(n.toInt)))
  }
  val primes: IndexedSeq[Int] = prime_sieve(30000)
  val pi_cache: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
  val phi_cache: collection.mutable.Map[(Int, Int), Int] = collection.mutable.Map.empty

  def prime_sieve(x: Int): IndexedSeq[Int] = {
    val n = x - x % 6 + 6
    val correction = if (x % 6 > 1) 1 else 2
    val sieve = Array.fill(n/3)(true)
    for (i <- 1 to (Math.sqrt(n) / 3).toInt if sieve(i)) {
      val k = (3 * i + 1) | 1
      for (j <- (k * k) / 3 until sieve.length by 2*k) sieve(j) = false
      for (j <- (k*(k-2*(i&1)+4))/3 until sieve.length by 2*k) sieve(j) = false
    }
    2 +: 3 +: (for (i <- 1 until n / 3 - correction if sieve(i)) yield (3*i+1)|1)
  }
  def bisect(n: Int): Int = {
    def loop(left: Int, right: Int): Int = {
      val mid = (left + right) / 2
      if (primes(mid) <= n && n < primes(mid+1)) mid+1
      else if (n < primes(mid)) loop(left, mid)
      else loop(mid+1, right)
    }
    if (n < primes.head) 0
    else if (n >= primes.last) primes.length
    else loop(0, primes.length)
  }
  def pi(x: Int): Int =
    pi_cache.getOrElseUpdate(x,
      if (x <= primes.last) bisect(x)
      else {
        val a = pi(Math.sqrt(Math.sqrt(x)).toInt)
        val b = pi(Math.sqrt(x).toInt)
        val c = pi(Math.cbrt(x).toInt)
        var result = phi(x, a) + ((b + a - 2) * (b - a + 1)) / 2
        for (i <- a + 1 to b) {
          val w = x / primes(i - 1)
          val b_i = pi(Math.sqrt(w).toInt)
          result -= pi(w)
          if (i <= c)
            for (j <- i to b_i)
              result = result - pi(w / primes(j - 1)) + j - 1
        }
        result
      }
    )
  def phi(x: Int, a:Int): Int =
    phi_cache.getOrElseUpdate(
      (x,a),
      {
        if (a == 1) (x + 1) / 2
        else phi(x, a - 1) - phi(x / primes(a - 1), a - 1)
      }
    )
}

Measured memory_bytes: 45196