akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	double w, h;double x, y; cin >> w >> h >> x >> y;
	cout << fixed<<setprecision(15)<<(w*h) / 2.0 << " ";
	if (w == x * 2 && h == y * 2)cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
# key not available ""
import math
n = int(input())
arr = [int(i) for i in input().split()]
dp = [0]*n
for i in range(1, n):
    if i == 1:
        dp[i] = dp[i-1]+(abs(arr[i]-arr[i-1]))
    else:
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]))
print(dp[-1])


Measured memory_bytes: 13716
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 998244353
ll n,m,arr[sz],brr[sz],k,l,crr[sz],t,i,j,hi,lo,mi;
int main()
{
 char c;
 scanf("%c",&c);
 if(c>='A' && c<='Z')
    printf("A\n");
 else
    printf("a\n");
}


Measured memory_bytes: 3756
#include <iostream>
using namespace std;
int ans[20];
int tot = 0;
int main()
{
	ios::sync_with_stdio(false);
	long long n;
	cin >> n;
	while (n)
	{
		int temp = n % 26;
		if (temp == 0)
		{
			temp = 26;
			n -= 26;
		}
		ans[tot++] = temp;
		n /= 26;
	}
	for (int i = tot - 1; i >= 0; i--)
	{
		int temp = 'a' + ans[i] - 1;
		putchar(temp);
	}
	cout << endl;
	return 0;
}

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second

const int MAXN = 505;

int ans[MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int h, hh, w, ww;
    cin >> h >> w >> hh >> ww;

    if (((h % hh) == 0) && ((w % ww) == 0))
    {
        cout << "No" << endl;
        return 0;
    }

    if (h % hh)
    {
        for (int j=1;j<=w;j++)
        {
            for (int i=1;i<=h;i++)
            {
                if (j % ww)
                {
                    ans[i][j] = 0;
                    continue;
                }

                if (i % hh)
                {
                    ans[i][j] = 100000;
                }
                else
                {
                    ans[i][j] = -((hh - 1) * 100000 + 1);
                }

            }
        }
    }
    else
    {
        for (int i=1;i<=h;i++)
        {
            for (int j=1;j<=w;j++)
            {
                if (i % hh)
                {
                    ans[i][j] = 0;
                    continue;
                }

                if (j % ww)
                {
                    ans[i][j] = 100000;
                }
                else
                {
                    ans[i][j] = -((ww - 1) * 100000 + 1);
                }
            }
        }
    }
    cout << "Yes" << endl;
    for (int i=1;i<=h;i++)
    {
        for (int j=1;j<=w;j++)
        {
            if (j > 1) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3072
using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] card = new int[3,3];
            for (int i = 0; i <= 2; i++)
            {
                string[] number = Console.ReadLine().Split(' ');
                for (int j = 0; j <= 2; j++)
                {
                    card[i,j] = int.Parse(number[j]);
                }
            }
            int N = int.Parse(Console.ReadLine());

            for(int i = 0; i <= N - 1; i++)
            {
                int b = int.Parse(Console.ReadLine());
                for(int j = 0; j <= 2; j++)
                {
                    for(int k = 0; k <= 2; k++)
                    {
                        if (card[j, k] == b)
                        {
                            card[j, k] = 0;
                        }
                    }
                }
            }

            int[] sum = new int[8];

            for(int i = 0; i <= 2; i++)
            {
                sum[i] = card[i, 0] + card[i, 1] + card[i, 2];
                sum[i + 3] = card[0, i] + card[1, i] + card[2, i];
            }

            sum[6] = card[0, 0] + card[1, 1] + card[2, 2];
            sum[7] = card[0, 2] + card[1, 1] + card[2, 0];

            bool check=false;

            for(int i = 0; i <= 7; i++)
            {
                if (sum[i] == 0)
                {
                    check = true;
                }
            }

            if (check) Console.WriteLine("Yes");
            else Console.WriteLine("No");

        }
    }
}


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

int main(void){

  int height;
  int width;

  do{
    cin >> height >> width;

    if ( height + width > 0){
      for ( int i = 0 ; i < height ; i++){
        for ( int j = 0 ; j < width ; j++){
          if((i + j) % 2 == 0){cout << '#';}
          else{cout << '.';}
        }
        cout << endl;
      }
      cout << endl;
    }
  }while(height + width > 0);

  return 0;
}

Measured memory_bytes: 3068
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto cnt = new long[][](2, 30);
    cnt[1][] = long.max;
    foreach (i; 0 .. N)
    {
        auto S = sread();
        cnt[i & 1][] = 0;
        foreach (c; S)
            cnt[i & 1][c - 'a']++;
        // writeln(cnt[i & 1]);
        foreach (j; 0 .. 30)
            cnt[i & 1][j] = cnt[(i + 1) & 1][j].min(cnt[i & 1][j]);
    }
    // writeln(cnt[(N + 1) & 1]);
    string ans;
    foreach (i; 0 .. 30)
    {
        ans ~= repeat(cast(char)('a' + i)).take(cnt[(N + 1) & 1][i]).array;
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long lint;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
 
int main(){
	// D: 問題の種類
	// G: 要求得点
	// p: 各問題の個数
	// c: コンプリート得点
    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }

    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
		// s: p全て解いた時の得点
		// num: 解いた個数
		//reset_max: 解いてない問題における最大得点問題
        int s = 0, num = 0, rest_max = -1;
        for(int i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
		//求められる得点以下ならば
        if(s < G){
			// s1: 
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;
#define endl '\n'
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>
#define debug(x) cerr << #x << " is " << x << endl;

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 1e3 + 5;
int pre[12][N];

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  // #ifndef ONLINE_JUDGE
	//   freopen("input.txt", "r", stdin);
	//   freopen("output.txt", "w", stdout);
  // #endif
  int n, m, k;
  cin >> n >> m >> k;
  int ans = INF;

  for(int i = 1; i <= n; i++){
    int cur = 0;
    for(int j = 1; j <= m; j++){
      char c; cin >> c;
      cur += (c == '1');
      pre[i][j] = pre[i-1][j] + cur;
    }
  }
  
  
  for(int i = 0; i < (1LL<<(n-1)); i++){
      int cnt = 0, last = 0;
      for(int c = 1; c <= m; c++){
        int pr = 0, need = 0;
        for(int bit = 0; bit <= (n-2); bit++){
          if((i&(1LL<<bit))){
              int num = pre[bit+1][c] - pre[bit+1][last] - pre[pr][c] + pre[pr][last];
              if(num > k){
                need = 1;
              }
              pr = bit+1;
          }
        }
        int num = pre[n][c] + pre[pr][last] - pre[pr][c] - pre[n][last];
        if(num > k){
          need = 1;
        }
        if(need){
          if(last == c-1){
            cnt = INF; break;
          }
          else{
            cnt++; last = c-1;
          }
        }
      }
      cnt += (__builtin_popcount(i));  
      ans = min(ans, cnt);  
  }
  cout << ans << '\n';
}



Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var W, H, N int
	fmt.Scan(&W, &H, &N)
	area := make([][]bool, W)
	for i := 0; i < W; i++ {
		area[i] = make([]bool, H)
	}
	for i := 0; i < N; i++ {
		var x, y, a int
		fmt.Scan(&x, &y, &a)
		switch a {
		case 1:
			for j := 0; j < x; j++ {
				for k := 0; k < H; k++ {
					area[j][k] = true
				}
			}
		case 2:
			for j := x; j < W; j++ {
				for k := 0; k < H; k++ {
					area[j][k] = true
				}
			}
		case 3:
			for j := 0; j < W; j++ {
				for k := 0; k < y; k++ {
					area[j][k] = true
				}
			}
		case 4:
			for j := 0; j < W; j++ {
				for k := y; k < H; k++ {
					area[j][k] = true
				}
			}
		}
	}
	cnt := 0
	for i := 0; i < W; i++ {
		for j := 0; j < H; j++ {
			if area[i][j] == false {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
import java.util.Scanner; 
import java.util.Arrays; 
import java.util.Collections; 
public class Main {
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
    int x=0;
    while(true){
    int a = sc.nextInt();
    int b = sc.nextInt();
    int[] list = {a,b};
          x=0;
      Arrays.sort(list);
        if(a==0&&b==0){
              break;
          }
      for(int i: list){
      System.out.print(i);
      if(x<1){
          System.out.print(" "); 
          x++;
      }   
      }
        System.out.println();
     }
    sc.close();
  }
}


Measured memory_bytes: 36440
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;

const int mod = 998244353 ;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  
  combination c(n+3);
  
  mint l=m;
  mint ans=0;
  
  rep(i,k+1){
    ans+=l*c(n-1,i)*((l-1).pow(n-1-i));
  }
  
  cout<<ans.x<<endl;
}

Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			String x=sc.nextLine();
			int ans=0;
			if(x.equals("0")) {
				break;
			}
			for(int i=0;i<x.length();i++) {
				ans+=Character.digit(x.charAt(i),10);
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 26644
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

s = input()

sa = sorted(s)
al="abcdefghijklmnopqrstuvwxyz"
cnt=0

for i in range(len(s)):
    if sa[i] == al[cnt]:
        cnt+=1
    if cnt == 26:
        print("None")
        exit()

print(al[cnt])

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

int main() {
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> t = vector<int>(N);
  for (int i = 0; i < N; i++) {
    cin >> t.at(i);
  }
  sort(t.begin(), t.end());

  int busCount = 0;
  int i = 0;
  while (i < N) {
    int firstT = t.at(i);
    int passengerCount = 0;
    while (i < N && passengerCount < C && t.at(i) <= firstT + K) {
      i++;
      passengerCount++;
    }
    busCount++;
  }
  cout << busCount << endl;
  return 0;
}

Measured memory_bytes: 640
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**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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,k = LI()
    dt = sorted([LI()[::-1] for _ in range(n)], reverse=True)

    u = set()
    s = 0
    o = []
    for d,t in dt[:k]:
        if t in u:
            o.append(d)
        else:
            u.add(t)
        s += d
    r = s + len(u) ** 2
    oi = len(o) - 1
    for d,t in dt[k:]:
        if oi < 0:
            break
        if t in u:
            continue
        s -= o[oi]
        oi -= 1
        s += d
        u.add(t)
        tr = s + len(u) ** 2
        if r < tr:
            r = tr

    return r



print(main())




Measured memory_bytes: 25516
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
K=[tuple(map(int,input().split())) for i in range(K)]
mod=998244353

DP=[0]*(4*10**5+100)
DP[1]=1
DP[2]=-1

for i in range(1,N+1):
    DP[i]+=DP[i-1]
    DP[i]%=mod
    
    for l,r in K:
        DP[i+l]+=DP[i]
        DP[i+l]%=mod
        DP[i+r+1]-=DP[i]
        DP[i+r+1]%=mod
        

    #print(DP[:10])

print(DP[N])
    


Measured memory_bytes: 24328
#include <bits/stdc++.h>
#include <iostream>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
 
int main(){
    int A,B,M,mina=1000001,minb=1000001,ans;
    cin>>A>>B>>M;
    
    vector<int> a(A),b(B),x(M),y(M),c(M);
    
    rep(i,A){
        cin>>a.at(i);
        mina=min(mina,a.at(i));
    }
    rep(i,B){
        cin>>b.at(i);
        minb=min(minb,b.at(i));
    }
    
    ans=mina+minb;
    
    rep(i,M){
        cin>>x.at(i)>>y.at(i)>>c.at(i);
        if(a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i)<ans)ans=a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i);
    }
    
    //cout<<mina<<" "<<minb<<endl;
    
    
    
    cout<<ans<<endl;
}
  


Measured memory_bytes: 2176
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for Z in range(X+1, Y+1):
  if max(x)<Z and min(y)>=Z:
    war = "No War"
    break
  else:
    war = "War"
print(war)


Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
 
using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;
 
int main() {
	string s,s1,s2;
	cin>>s;
	int b=s.size();
	for(int i=s.size()-2;i>=0;i-=2){
		b-=2;
		s1="";
		s2="";
		for(int j=0;j<b/2;++j){
			s1+=s[j];
			s2+=s[j+b/2];
		}
//		cout<<s1<<" "<<s2<<endl;
		if(s1==s2)break;
	}
	cout<<b<<endl;
	return 0;
}

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

int main(){
    int N,K;cin>>N>>K;
    int count=0;
    for(int i=0,j;i<N;i++){
        cin>>j;
        if(j>=K)count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N;
  int value;
  int min, max;
  int ans;
  int i;
  scanf("%d", &N);
  scanf("%d", &value);
  min = value;
  max = value;
  for(i=1; i<N; i++){
    scanf("%d", &value);
    if(value<min){
      min = value;
    }else if(value>max){
      max = value;
    }
  }

  ans = max - min;
  if(ans < 0){
    ans *= -1;
  }
  printf("%d\n", ans);

  return 0;

}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}
string s;
int n;

void solve(){
    cin>>s;
    n=s.size();
    int sit=0;
    int I,J,O;
    J=O=I=0;
    int res=0;
    for(int i=0;i<s.size();i++){
        if(sit==0){
            if(s[i]=='J'){
                J++;
                sit=1;
            }
            else{
                J=I=O=0;
                sit=0;
            }
        }
        else if(sit==1){
            if(s[i]=='J')J++;
            else if(s[i]=='O'){
                O++;
                sit=2;
            }
            else{
                J=I=O=0;
                sit=0;
                if(s[i]=='J')i--;
            }
        }
        else if(sit==2){
            if(s[i]=='O')O++;
            else if(s[i]=='I'){
                I++;
                sit=3;
            }
            else{
                if(s[i]=='J')i--;
                J=I=O=0;
                sit=0;
            }
        }
        else if(sit==3){
            if(s[i]=='I')I++;
            else{
                if(s[i]=='J')i--;
                J=I=O=0;
                sit=0;
            }
        }
        if(J>=O&&I>=O)res=max(res,O);
    }
    cout<<res<<endl;
}
int main(){

    solve();

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}

signed main(){
  int n; cin>>n;
	int m = 100005;
	int c[m]; CLR(c);
	rep(i,n){
		int a; cin>>a; c[a]++;
	}
	int s = 0;
	if(n==1) return cout<<1<<endl,0;
	// int ans = 0;
	rep(x,m-4){
		int tmp = 0;
		if(x) tmp+=c[x-1];
		tmp+=c[x]+c[x+1];
		if(s<=tmp){
			s = tmp;
		}
	}
	cout << s << endl;

  return 0;
}


Measured memory_bytes: 768
fn solve(n: usize) -> f64 {
    (n / 2 + n % 2) as f64 / n as f64
}

#[test]
fn test() {
    assert_eq!(solve(3), 2.0 / 3.0);
    assert_eq!(solve(5), 3.0 / 5.0);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    println!("{}", solve(n));
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define pb push_back
#define lp(j, n)  for(int j=0; j<(int)(n); ++j)
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
#define F first
#define S second
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef pair<int, int> pi;
typedef vector<pair<int,int> > vpii;
typedef map<int, int> mii;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
int cnt[N]={};
bool f;
int main()
{

   int n;
   cin>>n;
   vector<double> v(n);
   rep(i,n&&cin>>v[i]);
   n--;
  while(n--)
  {
     sort(all(v),greater<int>());
      double a= (v.back()+v[v.size()-2])/2;
      v.pop_back();
      v.pop_back();
      v.pb(a);
  }
    cout<<v[0];

go;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

const int MAX_N = 10100100;
int dp[MAX_N];
bool sieve[MAX_N];

int main()
{
  sieve[0] = sieve[1] = true;
  for (int i = 2; i * i <= MAX_N; i++){
    if (sieve[i]) continue;
    for (int j = i * i; j <= MAX_N; j += i){
      sieve[j] = true;
    }
  }

  int n, x, K = 1;
  while (n = in(), x = in(), n){
    int ans = -1;

    dp[0] = K;
    for (int i = 0; i < n; i++){
      int cost = in();
      for (int j = 0; j + cost <= x; j++){
        if (dp[j] == K){
          dp[j + cost] = K;
          if (!sieve[j + cost]) ans = max(ans, j + cost);
        }
      }
    }
    K++;
    if (ans < 0) puts("NA");
    else printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 15504
N = int(input())

A = input().split()
result = 1

A.sort()
fl = True

if int(A[0]) == 0:
    print(0)
else:
    for i in A:
        result *= int(i)
        if result > 10**18:
            fl = False   
            break                
    if fl:
        print(result)
    else:
        print(-1)



Measured memory_bytes: 19428
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	() => ( get().parse::<i64>().unwrap() ) }
	
    let n = get!();
    let a = get!();
    let b = get!();
    let mut ans = 0;
    for i in 1..n+1 {
    	let mut k = i;
        let mut t = 0;
        while k > 0 {
        	t += k % 10;
            k /= 10;
        }
        if a <= t && t <= b {
        	ans += i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n=int(input())
x=[]
y=[]
h=[]
cnt=0
for i in range(n):
    p,q,r=map(int,input().split())
    x.append(p)
    y.append(q)
    h.append(r)
    if r>0:
        cnt=i


def height(H,X,CX,Y,CY):
    tmp=max(H-abs(X-CX)-abs(Y-CY),0)
    return  tmp

for cx in range(101):
    for cy in range(101):
        H=h[cnt]+abs(x[cnt]-cx)+abs(y[cnt]-cy)
        flag = True
        for k in range(n):
            if h[k] != height(H,x[k],cx,y[k],cy):
                flag=False

        if flag:
            ans=[cx,cy,H]
            print(*ans)
            exit()


Measured memory_bytes: 3064
k = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

Measured memory_bytes: 2940
import unittest
from io import StringIO
import sys
import itertools
import math


def gcd(a, b, c):
    n = 1
    if a == b:
        if b != c:
            n = 3
    else:
        if b != c:
            n = 6
        else:
            n = 3
    return math.gcd(math.gcd(a, b), c) * n


def resolve():
    K = int(input())
    T = [i for i in range(1, K + 1)]
    Tr = itertools.combinations_with_replacement(T, 3)
    sumT = 0
    for a, b, c in Tr:
        sumT += gcd(a, b, c)
    print(sumT)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """200"""
        output = """10813692"""
        self.assertIO(input, output)

    def test_add(self):
        input = """195"""
        output = """9997134"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16352
#include<iostream>
#include<string>
using namespace std;
 
class Proc{
public:
  string nam;
  int tim;
  Proc(){
    nam = "";
    tim = 0;
  }
};
 
Proc Q[100001];
 
class Queue{
private:
  int fp;
  int rp;
public:
  Queue(){
    fp = 0;
    rp = 0;
  }
  int next(int p) const{
    return (p+1)%100001;
  }
  bool isFull() const{
    return (next(rp) == fp);
  }
  bool isEmpty() const{
    return (rp == fp);
  }
  void push(Proc d){
    if(isFull()){
      return;
    }
    Q[rp] = d;
    rp = next(rp);
  }
  Proc front(){
    if(isEmpty()){
      Proc er;
      er.tim = -1;
      return er;
    }
 
    return Q[fp];
  }
  void pop(){
    if(isEmpty()){
      return;
    }
    fp = next(fp);
  }
};
 
int main(){
  Queue que;
 
  int n,q;
  cin >> n >> q;
 
  for(int i=0;i<n;i++){
    Proc p;
    cin >> p.nam >> p.tim;
 
    que.push(p);
  }
 
  int total_tim = 0;
 
  while(!que.isEmpty()){
    Proc p = que.front();
    que.pop();
 
    if(p.tim <= q){
      total_tim += p.tim;
 
      cout << p.nam << ' ' << total_tim << endl;
    }else{
      total_tim += q;
      p.tim -=q;
 
      que.push(p);
    }
  }
 
  return 0;
}


Measured memory_bytes: 6892
import bisect

n = int(input())

L = list(map(int,input().split()))

A = sorted(L)

ans = 0

for i in range(n):
    for j in range(i+1,n):
        total = L[i] + L[j]
        ans += bisect.bisect_left(A,total) - (j+1)

print(ans)  


Measured memory_bytes: 44444
### constant

INF = 1 << 30
MAX_X = 25000

### subroutines

def check(a, b, x, y)
  xy = x + y
  abxy = a * x + b * y
  if $min_xy > xy
    $min_xy = xy
    $min_abxy = abxy
    $min_x = x
    $min_y = y
  elsif $min_xy == xy
    if $min_abxy > abxy
      $min_abxy = abxy
      $min_x = x
      $min_y = y
    end
  end
end

### main

loop do
  a, b, d = gets.split.map(&:to_i)
  break if (a | b | d) == 0
  #p [a, b, d]

  $min_xy = INF
  $min_axby = INF
  $min_x = $min_y = nil

  for x in (0..MAX_X)
    # ax+d = by
    r = a * x + d
    if r % b == 0
      y = r / b
      check(a, b, x, y)
    end

    # ax = by+d
    r = a * x - d
    if r >= 0 && r % b == 0
      y = r / b
      check(a, b, x, y)
    end

    # ax + by = d
    r = d - a * x
    if r >= 0 && r % b == 0
      y = r / b
      check(a, b, x, y)
    end
  end

  puts [$min_x, $min_y].join(' ')
end

Measured memory_bytes: 6124
#include <bits/stdc++.h>
using namespace std;
int n;
char s[15];
void dfs(int u,int now) {
    if (u==n) {
        puts(s);
        return;
    }
    for (int i=0;i<=now;++i) {
        s[u]=i+'a';
        dfs(u+1,max(now,i+1));
    }
}
int main()
{
    scanf("%d",&n);
    dfs(0,0);
    return 0;
}


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

int sosuu[] ={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541};

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d) {
        cout << "Yes" << endl;
    }else if(abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int i,n,k=0;
    cin >> n;
    if(n<=6){
        if(n==3){
            cout << 2 <<" " << 5 << " "<< 63 << endl;
            return 0;
        }
        if(n==4){
            cout << 2 <<" "<< 3 <<" "<< 4<< " " << 9 << endl;
            return 0;
        }
        if(n==5){
            cout << 2 << " "<< 3 << " "<< 4 << " " << 6 << " " << 9 << endl;
            return 0;
        }
        if(n==6){
            cout << 2 << " "<< 3 << " " << 4 << " "<< 6 << " "<< 9 << " "<< 12 << endl;
            return 0;
        }
    }
    if(n%8==0){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " ";
                k++;
            }
            if(k==n){
                break;
            }
        }
    }else if(n%8==1){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " " ;
                k++;
            }
            if(k==n/8*8){
                cout << i+6 << " " ;
                break;
            }
        }
    }else if(n%8==2){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " " ;
                k++;
            }
            if(k==n/8*8){
                cout << i+2 << " " << i+4 ;
                break;
            }
        }
    }else if(n%8==3){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " " ;
                k++;
            }
            if(k==n/8*8){
                cout << i+3 << " " << i+6 << " " << i+9 ;
                break;
            }
        
        }
    }else if(n%8==4){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " " ;
                k++;
            }
            if(k==n/8*8){
                cout << i+2 << " " << i+3 << " " << i+4 << " " << i+9 ;
                break;
            }
        }
    }else if(n%8==5){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " " ;
                k++;
            }
            if(k==n/8*8){
                cout << i+2 << " " << i+4 << " " << i+6 << " " << i+8 << " " << i+10;
                break;
            }
        }
    }else if(n%8==6){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " " ;
                k++;
            }
            if(k==n/8*8){
                 cout << i+2 << " " << i+4 << " " << i+6 << " " << i+8 << " " << i+10 << " " << i+12;
                 break;
            }
        }
    }
    else if(n%8==7){
        for(i=1;i<=30000;i++){
            if(i%2==0 || i%3==0){
                cout << i << " " ;
                k++;
            }
            if(k==n){
                break;
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 384
s = input()
k = int(input())
n = len(s)
res = []

for i in range(n):
    for j in range(i,n)[0:5]:
        s1 = s[i:j+1]
        if s1 not in res:
            for m in range(len(res)):
                if s1 < res[m]:
                    res.insert(m, s1)
                    break
            res.append(s1)
        res = res[0:k]
print(res[-1])



Measured memory_bytes: 3060
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

A,B  = nm()

s = A - 1
print(((B-1)+s -1)//s )


Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String[] args){
      
      Scanner sn = new Scanner(System.in);
      
      int a = sn.nextInt();
      int b = sn.nextInt();
      
      int c = (a*b)%2;
      
      if(c==0){
      	System.out.println("Even");
      }else{
      	System.out.println("Odd");
      }
        
    }
}

Measured memory_bytes: 21588
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
other = 0
for i in range(n // 2):
    other += a[(1 + 2 * i) % n]
ans = [total - 2 * other]
for i in range(n - 1):
    ans.append(a[i] * 2 - ans[-1])
for i in range(n):
    print(ans[i], end = " ")

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

int main() {
    int n,t;cin>>n>>t;
    int p,a;
    cin>>p;
    int ans=0;
    for (int i=1;i<n;i++) {
        cin>>a;
        ans+=min(a-p,t);
        p=a;
    }
    cout<<ans+t<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let (n, mut x) = {
        let s = scan_line();
        let mut ws = s.split_whitespace();
        let n: i64 = ws.next().unwrap().parse().unwrap();
        let x: i64 = ws.next().unwrap().parse().unwrap();
        (n, x)
    };
    let mut a: Vec<i64> = {
        let s = scan_line();
        let ws = s.split_whitespace();
        ws.map(|ai| ai.parse().unwrap()).collect()
    };
    if x == a.iter().sum() {
        print!("{}", n);
        return
    }
    a.sort();
    let mut cnt = 0;
    for ai in a {
        x -= ai;
        cnt += 1;
        if x < 0 {
            break;
        }
    }
    print!("{}", cnt - 1);
}

fn scan_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#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 shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n;
    ll k;
    cin >> n >> k;
    cout << pow(k-1,n-1)*k<<endl;

    return 0;
}

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


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
   int N,x,i;
   cin >> N >> x;
   int a[N];
   for(i=0;i<N;i++){
       cin >> a[i];
   }
   sort(a,a+N);
   int count=0;
   for(i=0;i<N;i++){
       if(x<a[i]){
           break;
       }else if(i==N-1){
           if(x==a[i]){
               count++;
           }
       }else{
           x=x-a[i];
           count++;
       }
   }
   cout << count << endl;
}


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

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

	int big{0}, small{1000'000'000+1};

	for (int i{}; i < n; ++i) {
		int x;
		std::cin >> x;
		big = std::max(big, x);
		small = std::min(small, x);
	}

	std::cout << big - small << "\n";
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let a: usize = read();
    let b: usize = read();

    let mut c = [0, 0, 0];
    for _ in 0..n {
        let p: usize = read();
        if p <= a {
            c[0] += 1;
        } else if p <= b {
            c[1] += 1;
        } else {
            c[2] += 1;
        }
    }
    println!("{}", c.iter().min().unwrap());
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, s, n) for (int i = s; i <= n; i++)
typedef long long ll;

class cl_queue {
private:
	/* Queue Array */
	int* queue;
	/* Head Position */
	int head;
	/* Tail Position */
	int tail;
	/* Queue Size */
	int queue_size;
	/* Name */
	string* name;
	/* Dequeued Name */
	string DQname;

public:
	/* Constructor */
	cl_queue(int size)
	{
		queue = new int[size + 1];
		name = new string[size + 1];
		head = 0;
		tail = 0;
		queue_size = size;
	}
	/* Destructor */
	~cl_queue()
	{
		delete[] queue;
	}
	/* Enqueue */
	void enqueue(int value, string given_name)
	{
		queue[tail] = value;
		name[tail] = given_name;
		if (tail == queue_size) tail = 0;
		else tail++;
	}
	/* Dequeue */
	int dequeue()
	{
		int dequeue_value = queue[head];
		DQname = name[head];
		if (head == queue_size) head = 0;
		else head++;
		return dequeue_value;
	}
	/* Dequeued name */
	string dequeued()
	{
		return DQname;
	}
};


int main()
{
	int n, q;
	string name;
	int tmp;

	int finished = 0;
	int time = 0;
	int deq_val;
	string deq_name;

	cin >> n >> q;

	cl_queue myQueue(n);

	rep(i, n) {
		cin >> name >> tmp;
		myQueue.enqueue(tmp, name);
	}

	while (finished < n) {
		deq_val = myQueue.dequeue();
		deq_name = myQueue.dequeued();

		if (deq_val > q) {
			deq_val -= q;
			time += q;
			myQueue.enqueue(deq_val, deq_name);
		}
		else {
			time += deq_val;
			finished++;
			cout << deq_name << " " << time << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 5760
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;


int main() {
	int n;
	cin >> n;
	int ans = 0;
	int b = 0;
	int a = 0;
	int ba = 0;
	string s;
	int len;
	for (int i = 0; i < n; i++) {
		cin >> s;
		len = s.size();
		if (s.at(0) == 'B' && s.at(len - 1) == 'A') ba += 1;
		else if (s.at(0) == 'B') b += 1;
		else if (s.at(len - 1) == 'A') a += 1;
		for (int j = 0; j < len - 1; j++)
			if (s.at(j) == 'A' && s.at(j+1) == 'B') ans += 1;
	}
	if (ba > 0) {
		ans += ba-1;
		if (a > 0) {
			ans += 1;
			a -= 1;
		}
		if (b > 0) {
			ans += 1;
			b -= 1;
		}
	}
	ans += min(a, b);
	cout<< ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    long long n; cin >> n;
    if(n & 1) cout << 0;
    else
    {
        long long ans = 0;
        while(n) n /= 5, ans += n / 2;
        cout << ans;
    }

    return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  vector<pair<string, int>> playlist;
  rep(i, n) {
    string s; std::cin >> s;
    int t; std::cin >> t;
    playlist.eb(s, t);
  }
  string x; std::cin >> x;
  int ans = 0;
  bool sleeped = true;
  rep(i, n) {
    if (playlist[i].fi == x) {
      sleeped = false;
      continue;
    }
    if (sleeped) continue;
    ans += playlist[i].se;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		if (N >= M) {
			System.out.println(0);
			return;
		}
		
		int[] map = new int[M];
		for (int i = 0; i < M; i++) {
			map[i] = sc.nextInt();
		}
		
		Arrays.sort(map);
		
		int sum = 0;
		LinkedList<X> list = new LinkedList<X>();
		for (int i = 0; i < M-1; i++) {
			X x = new X(i, map[i+1]-map[i]);
			list.add(x);
			sum += x.cost;
		}
		
		Collections.sort(list);
		for (int i = 0; i < N-1; i++) {
			X x = list.removeFirst();
			sum -= x.cost;
		}
		
		System.out.println(sum);
		
		
	}
	
	static class X implements Comparable<X>{
		int index;
		int cost;
		
		public X(int index, int cost) {
			this.index = index;
			this.cost = cost;
		}

		@Override
		public int compareTo(X o) {
			return o.cost - this.cost;
		}
	}
}

Measured memory_bytes: 49956
num = gets.to_i
list = gets.split
cnt = -1
bool = true
while bool
  list.each_with_index do |elem, i|
    if elem.to_i % 2 != 0
      bool = false 
      break
    else
      list[i] = elem.to_i/2
    end
  end
  cnt += 1
end
puts cnt

Measured memory_bytes: 14328