akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int max = Math.max(Math.max(A, B), C);
    int sub = max * 3 - (A + B + C);
    if (sub % 2 == 0) {
      System.out.println(sub / 2);
    } else {
      System.out.println((sub + 3) / 2);
    }
  }
}

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

int main() {
  int N,p=1,c=0;
  cin>>N;
  vector<int> s(N);
  
  for(int i;i<N;i++){
    cin>>s.at(i);
  }  
  
  while(true){
    p=s.at(p-1);
    c++;
    if(p==2)break;
    else if(c>N){
      c=-1;
      break;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3768
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

INF = float('inf')
graph = [[INF for i in range(N)] for j in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    graph[A-1][B-1] = C
    graph[B-1][A-1] = C

for i in range(N):
    graph[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
            graph[j][i] = min(graph[j][i], graph[j][k] + graph[k][i])

ans = 10**9
for p in permutations(r, len(r)):
    dist = 0
    flag = 0
    for i in range(len(r) - 1):
        if graph[p[i]-1][p[i+1]-1] == INF:
            flag = 1
            continue
        dist += graph[p[i]-1][p[i+1]-1]
    if flag == 0:
        ans = min(ans, dist)

print(ans)

Measured memory_bytes: 88920
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	n,k = MI()
	a=(10**100) % mo
	dp = [0]*(n+1)
	ans = 0
	for kk in range(k,n+2):
		tmp = (n  - kk + 1)
		ans += (tmp+1) + tmp * (kk-1)
		ans %= mo
	print(ans % mo)

if __name__ == '__main__':
	main()

Measured memory_bytes: 10560
def solve(exp)
  $error = false
  w, i = Molecule(exp, 0)
  w = "UNKNOWN" if $error
  w
end

def Molecule(exp, i)
  sum = 0
  while (i < exp.size) && (exp[i] != ")") do
    case exp[i]
    when /[A-Z]/
      w, i = Atom(exp, i)
      n = 1
      n, i = Number(exp, i) if exp[i] =~ /[0-9]/
      w *= n
    when "("
      i += 1
      w, i = Molecule(exp, i)
      i += 1
      n, i = Number(exp, i)
      w *= n
    end
    sum += w
  end
  [sum, i]
end

def Atom(exp, i)
  name = exp[i]
  i += 1
  if exp[i] =~ /[a-z]/
    name += exp[i]
    i += 1
  end
  unless $atom.key?(name)
    $error = true
    return [-1000, i]
  end
  [$atom[name], i]
end

def Number(exp, i)
  n = 0
  while(exp[i] =~ /[0-9]/)
    n *= 10
    n += exp[i].to_i
    i += 1
  end
  [n, i]
end

$atom = {}
while true do
  line = gets.chomp
  break if line == "END_OF_FIRST_PART"
  name, weight = line.split
  $atom.store(name, weight.to_i)
end
while true do
  line = gets.chomp
  break if line == "0"
  puts solve(line)
end

Measured memory_bytes: 6116
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #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 REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------
int n;
string s;

ll powll(ll base,ll power){
    ll ans = 1;
    while (power){
        if (power&1) ans = (base*ans)%mod;
        base = (base*base)%mod;
        power >>= 1;
    }
    return ans;
}

int ch[30];
signed main(){
    int ans = 0;
    cin >> n;
    cin >> s;
    REP(i,n){
        ch[s[i]-'a']++;
        int v = 1;
        REP(j,('z'-'a'+1)){
            if (j == s[i]-'a') continue;
            v *= (ch[j]+1);
            v %= mod;
        }
        ans += v;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
using namespace std;
bool p(int n) {
    if (n == 2)return true;
    if (n % 2 == 0)return false;
    for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
    return true;
}
int main(){
    int n; while (cin >> n){
        if (n < 3)cout << "0\n";
        else {
            int sum = 0;
            for (int i = 2; i < n; i++)
                if (p(i) && p(n - i + 1))sum++;
            cout << sum << endl;
        }
    }
}

Measured memory_bytes: 2980
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> x(n),l(n);
  vector<pair<int,int>> p(n);
  for(int i=0;i<n;i++){
    cin >> x[i] >> l[i];
    p[i]=make_pair(x[i]+l[i],x[i]-l[i]);
  }
  sort(p.begin(),p.end());
  int ans=0;
  int r;
  for(int i=0;i<n;i++){
    if(!i){
      r=p[i].first;
      ans++;
    }
    else{
      if(p[i].second>=r){
        ans++;
        r=p[i].first;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  sort(vec.begin(), vec.end());
  
  int ans=1;
  
  for(int i=1; i<N; i++){
    if(vec[i-1]<vec[i]){
      ans++;
    }
  }
  
  cout << ans <<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


/*======================================================================*/
void solve(){
    map<string , int> m;
    int n;
    cin >> n;
    rep(i, 0, n){
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  int n, k;
  cin >> n >> k;

  int coin_count[100010] = {};
  REP(i, n + 1) {
    int tmp = i;
    while (tmp < k) {
      tmp *= 2;
      coin_count[i]++;
    }
  }

  vector<ld> probability(n + 1);
  REP(i, n + 1) {
    probability[i] = 1 / pow(2, (ld)coin_count[i]);
  }

  auto average = accumulate(all(probability), (ld)0.0) / n;

  cout << setprecision(15) << average << endl;

  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int cnt = 0;
    for (int i = 0; i * r <= n; ++i) {
        for (int j = 0; i * r + j * g <= n; ++j) {
            int k = n - i * r - j * g;
            if (k % b == 0) cnt++;
        }
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 3636
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

class Solver {
public:
	int n;
	string S, T;

	bool same2(int i) {
		rep(j, n) {
			int j2 = (i + j) % n;
			if (S[j] != T[j2]) return false;
		}
		return true;
	}

	bool same() {
		rep(i, n) {
			if (same2(i)) return true;
		}
		return false;
	}

	void solve() {
		cin >> S >> T;
		n = S.size();
		cout << (same() ? "Yes" : "No") << endl;
	}

};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;

// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;

// #define cin mycin
// #define cout mycout
// #define endl '\n'

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int K;
    scanf("%d", &K);
    int curr = 7;
    curr %= K;
    int cnt = 1;
    int i;
    for(i=0; i<10000000; i++) {
        if (curr == 0)
            break;

        curr = curr * 10 + 7;
        curr %= K;
        cnt++;
    }
    if (i == 10000000) {
        printf("-1\n");
    }
    else {
        printf("%d\n", cnt);
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1728
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=200001;
int n;
int a[MAXN],b[MAXN],A[MAXN],B[MAXN],ans=0;
inline bool CMP(int x,int y){
	return x<y;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n;++i) cin>>b[i];
	for(int w=0;w<=28;++w){
		for(int i=1;i<=n;++i){
			A[i]=a[i]&((1<<(w+1))-1);
			B[i]=b[i]&((1<<(w+1))-1);
		}
		sort(B+1,B+n+1,CMP);
		for(int i=1;i<=n;++i){
			int l1=lower_bound(B+1,B+n+1,(1<<w)-A[i])-B;
			int r1=lower_bound(B+1,B+n+1,(1<<(w+1))-A[i])-B-1;
			int l2=lower_bound(B+1,B+n+1,3*(1<<w)-A[i])-B;
			int r2=lower_bound(B+1,B+n+1,(1<<(w+2))-A[i])-B-1;
			if((r1-l1+r2-l2+2)&1) ans^=(1<<w);
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll n,q;
string s;

int main(){
	cin >> n >> q >> s;
	vector<ll> sum(n,0);
	rep(i,n-1){
		if(s[i] == 'A' && s[i+1] == 'C')sum[i+1] = 1;
	}
	rep(i,n-1)sum[i+1] += sum[i];
	rep(i,q){
		ll l,r;
		cin >> l >> r;
		l--; r--;
		cout << sum[r] - sum[l] << endl;
	}
}

Measured memory_bytes: 1792
def main():
    N, M = map(int, input().split())
    X, Y = max(N, M), min(N, M)
    if X == 1:
        print(1)
    elif Y == 1:
        print(X-2)
    else:
        print((X-2)*(Y-2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll /*A[2000000],*/ cnt = 0;
int A[210000];
int L[110001];
int R[110001];
 
int merge(int l, int m, int r){
    int n1 = m - l, n2 = r - m, i, j;
    //ll L[n1 + 1], R[n2 + 1];
    for(i = 0;i < n1;i++)L[i] = A[i + l];
    for(i = 0;i < n2;i++)R[i] = A[i + m];
    i = j = 0;
    for(int k = 0;k < r - l;k++){
        if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
        else A[k + l] = R[j++], cnt += n1 - i;
    }
}

int mergeSort(int l, int r){
    if(l + 1 < r){
        int m = (l + r) / 2;
        mergeSort(l, m);
        mergeSort(m, r);
        merge(l, m, r);
    }
}
 
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n;i++)scanf("%d", &A[i]);
	mergeSort(0, n);
	printf("%lld\n", cnt);
     
    return 0;
}

Measured memory_bytes: 4800
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n; vector<string> s;
int main() {
	while (cin >> n, n) {
		s.resize(n);
		for (int i = 0; i < n; i++) cin >> s[i];
		vector<int> flag(n, 0); // bit / i -> j
		vector<vector<int> > cost(n, vector<int>(n)); // i -> j
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (s[i].find(s[j]) != string::npos) {
					flag[i] |= 1 << j;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k <= s[i].size(); k++) {
					string ret = s[i].substr(0, k) + s[j];
					if (ret.substr(0, s[i].size()) == s[i]) {
						cost[i][j] = ret.size() - s[i].size();
						break;
					}
				}
			}
		}
		vector<vector<int> > dp(1 << n, vector<int>(n, 999999999));
		dp[0][0] = 0;
		for (int i = 1; i < 1 << n; i++) {
			for (int j = 0; j < n; j++) {
				if (!(i & (1 << j))) continue;
				int p = i - (1 << j);
				for (int k = 0; k < n; k++) {
					if(p != 0) dp[i][j] = min(dp[i][j], dp[p][k] + cost[k][j]);
					else dp[i][j] = min(dp[i][j], dp[p][k] + (int)s[j].size());
				}
			}
		}
		int ret = 999999999;
		for (int i = 1; i < 1 << n; i++) {
			int bit = i;
			for (int j = 0; j < n; j++) {
				if (i & (1 << j)) bit |= flag[j];
			}
			if (bit == (1 << n) - 1) {
				for (int j = 0; j < n; j++) ret = min(ret, dp[i][j]);
			}
		}
		cout << ret << endl;
	}
	return 0;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;

    for (int i = 1; i <= N; ++i) {
        int sum = 0;
        int n = i;
        while (n /10 != 0) {
            sum += n % 10;
            n /= 10;
        }
        sum += n;
        if (sum >= A && sum <= B) {
            total += i;
        }
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
S = gets.split("").map(&:to_s)
counts = []
count = 0
S.each do |s|
    if s == 'A' || s == 'C' || s == 'G' || s == 'T'
        count += 1
    else
        counts << count
        count = 0
    end
end
print counts.max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,x,y,sum=0;
    cin>>n>>k>>x>>y;
    if(n>k)
    {
        sum+=(x*k);
        sum+=((n-k)*y);
    }
    else
    {
        sum+=(n*x);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3600
import queue
n, m = map(int, input().split())
a = [0 for i in range(m)]
b = [0 for i in range(m)]
dic = {}
for i in range(1, n+1):
    dic[i] = []
for i in range(m):
    a[i], b[i] = map(int, input().split())
    dic[a[i]].append(b[i])
    dic[b[i]].append(a[i])
res = 0
INF = 100010
l = [0 for i in range(n+1)]
l[1] = 1
michi = [INF for i in range(n+1)] 
michi[1] = 0
p = [1]
shi = 1
while True:
    tmp = []
    for i in p:
        for j in dic[i]:
            if l[j] == 0:
                l[j] = 1
                tmp.append(j)
    if not tmp:
        break
    for i in tmp:
        michi[i] = shi
    p = tmp
    shi = p[0]
flag = True
for i in range(2, n+1):
    if michi[i] == INF:
        flag = False
if flag:
    print("Yes")
    for i in range(2, n+1):
        print(michi[i])
else:
    print("No")

Measured memory_bytes: 114324
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int nindex =0;
    int nextelemnet= 0;

    REP(i,n) {
        if(a[nindex]<=a[i]) {
            nindex = i;
        }
    }

    REP(i,n) {
        if(nextelemnet < a[i] && i != nindex) {
            nextelemnet = a[i];
        }
    }


    REP(i,n) {
        if(i != nindex) {
            cout << a[nindex]<< endl;
        }else {
            cout << nextelemnet << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
int n,a[500005];
int cnt;
int L[250005],R[250005];
void merge(int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++)L[i]=a[left+i];
	for(int i=0;i<n2;i++)R[i]=a[mid+i];
	L[n1]=R[n2]=1e9;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<R[j])a[k]=L[i++];
		else a[k]=R[j++];
	}
}
void ef(int left,int right){
	int mid;
	if(left+1<right){
		mid=(left+right)/2;
		ef(left,mid);
		ef(mid,right);
		merge(left,mid,right);
	}
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	ef(0,n);
	for(int i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 7056
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Hemant Malviya
 
//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define lld long long int 
#define vint vector<int>
#define vlld vector<long long int>
#define vst vector<string>
#define ps push_back
#define pii pair<int,int>
#define mk make_pair
#define le length
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define sv()                  int t; scanf("%d",&t); while(t--)
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
int main()
{
   string  n;
   cin>>n;
   int i;
   for( i =0;i<3;i++){
       if(n[i] == '7'){
          // cout<<"Yes";
           break;
       }
   }
   if( i == 3){
       cout<<"No";
   }else {
       cout<<"Yes";
   }
 return 0;   
}

Measured memory_bytes: 3596
def chmin(a, b):
  if a > b:
    return b
  else:
    return a

def main():
  dp = [1e12]*100100
  hs = [0]*100100
  
  N = int(input())
  hs[:N] = map(int, input().split())
  
  dp[0] = 0
  for i in range(N):
    dp[i+1] = chmin(dp[i+1], dp[i]+abs(hs[i+1]-hs[i]))
    dp[i+2] = chmin(dp[i+2], dp[i]+abs(hs[i+2]-hs[i]))
  print(dp[N-1])
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 15592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class TaskAA {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			long n = in.nextInt();
			long a = in.nextInt();
			long b = in.nextInt();
			long min = (n - 1) * a + b;
			long max = (n - 1) * b + a;
			out.println(Math.max(0, max - min + 1));
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

string s;
int main()
{
   
    cin>>s;
    if(s[0]==s[2])
        cout<<"Yes";
    else
        cout<<"No";
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> L(n);
    REP(i, 0, n) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());
    ll ans = n * (n - 1) * (n - 2) / 6;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = i - 1; j >= 0; j--) {
            auto it = upper_bound(L.begin(), L.begin() + j, L[i] - L[j]) - L.begin();
            dump(it);
            ans -= it;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    string s[101];
    set<string> str;
    int n; cin >> n;
    int ans = 0;
    for(int i = 0; i<n ;i++){
        cin >> s[i];
        if(str.count(s[i])==1){
            ans += 1;
        }
        str.insert(s[i]);
    }
    for(int i = 1; i < n; i++){
        if(s[i-1].back() != s[i][0]){
            ans+= 1;
        }
    }
    if(ans==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	printf("%d\n",p[a/2]-p[a/2-1]);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int fun(int a, int b, int N){
    int sum = 0;
    for(int i = 0; a * i <= N; i++){
        if((N - a*i) % b == 0){
            sum += 1;
        }
    }

    return sum;
}

int main(void){
    int sum = 0;
    int R, G, B, N;
    scanf("%d %d %d %d", &R, &G, &B, &N);

    for(int i = 0; i * R <= N; i++){
        int f = fun(G, B, N - i * R);
        sum += f;
    }

    printf("%d\n", sum);
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

const int len = 2e5+5;
int arr[len];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    for (int i = 0; i < n; i++)
        if (arr[i] > i){
            printf("-1\n");
            return 0;
        }

    ll ans = 0;
    int cur = 0;
    for (int i = n-1; i >= 0; i--){
        if (arr[i] < cur){
            ans = -1;
            break;
        }
        else if (arr[i] > cur)
            ans += arr[i];

        cur = max(0, arr[i]-1);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	ll n, k;
	cin >> n >> k;
	vecll a(n);
	rep(i, n) cin >> a[i];
	ll tmp_point = a[0];
	for (ll i = 1; i < k; i++)
		tmp_point += a[i];
	for (ll i = k; i < n; i++)
	{
		ll tmp = tmp_point;
		tmp_point -= a[i - k];
		tmp_point += a[i];
		if (tmp < tmp_point)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4796
/*
 	安部NANA先輩大好き

 */
#include<bits/stdc++.h>

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e9 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
vector<pii> vii;

bool used[2000006],use[2000006];
int x[2000006];
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n[3],m=0;
    stack<int> que;
    rep(i,0,3){
        cin >> n[i] ;
        rep(j,0,i){
            if(j!=i){
                if(n[j]!=n[i])m++;
            }
        }
    }
    if(n[0]==n[1]&&n[1]==n[2]&&n[0]==n[2])m=1;
    cout << m << endl;
    return 0;
}


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

using namespace std;

void dfs(int node, vector<int> adj[], int dp[], bool v[]) {
    v[node] = true;
    for (int i=0; i<adj[node].size(); i++) {
        if (!v[adj[node][i]])
            dfs(adj[node][i], adj, dp, v);
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]);
    }
}

int main() {
    int n, m;
    cin>>n>>m;
    vector<int> adj[n+1];
    for (int i=0; i<m; i++) {
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
    }
    int dp[n+1] = {0};
    bool v[n+1] = {false};

    for (int i=1; i<=n; i++) {
        if (!v[i])
            dfs(i, adj, dp, v);
    }
    int ans = 0;
    for (int i=1; i<=n; i++) {
        ans = max(ans, dp[i]);
    }

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

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
// #define int ll

using namespace std;
using Graph = vector<vector<int> >;


template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmin(T&a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int dp[100100];

int memodp(int v, Graph &G) {
  if (dp[v] != -1) {
    return dp[v];
  } else {
    int dis = 0;
    for (auto nv : G[v]) {
      chmax(dis, memodp(nv, G) + 1);
    }

    return dp[v] = dis;
  }
}

signed main() {
  int N, M;
  cin >> N >> M;

  // initialization
  for (int i = 0; i < N; i++) {
    dp[i] = -1;
  }

  Graph G(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
  }

  int max = 0;
  for (int i = 0; i < N; i++) {
    chmax(max, memodp(i, G));
  }

  cout << max << endl;
}


Measured memory_bytes: 8192
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Author: z0marlin
Title: D.cpp
Time: 16-08-2019T23:35:09+0530 
I suck at CP T_T
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
#include <bits/stdc++.h>
#if DEBUG
#define dprintf(...) printf(__VA_ARGS__)
#else
#define dprintf(...)
#endif
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define FORE(a, v) for(auto a:v)
#define MAX(a, b) ((a>b)?a:b)
#define MIN(a, b) ((a<b)?a:b)
#define MP(i, j) make_pair(i, j)
#define PB(a) push_back(a)
#define PPB(a) pop_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii_t;
typedef pair<ll,ll> pll_t;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;

const int MAX_SZ=1e6+2;
const int MOD=1e9+7;
int t = 1, n, m, q, ql, qr;
char ch;
vi_t inp, res;
int solve(){
    res.resize(n);
    int d1 = inp[n-1]-inp[0];
    int d2 = 0;
    for(int i=1,t=1; i<n-1; i++,t=-t){
        d2+=t*inp[i];
    }
    res[n-1]=(d1+d2)/2;
    for(int i=n-2; i>=0; i--){
        res[i] = inp[i]-res[i+1];
    }
    FORE(e, res){
        printf("%d ", 2*e);
    }
    printf("\n");
    return 0;
}

int main(){
    // scanf("%d", &t);
    while(t--){
        scanf("%d", &n);
        inp.resize(n);
        FOR(i,0,n){
            scanf("%d", &inp[i]);
        }   
        solve();
    }
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  long long x = b - 1;
  if (n < b - 1) x = n;
  long long ans = (a*x/b) - a*(x/b);
  cout << ans << endl;
  return 0;
}

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

#define ll long long
#define ii pair<int,int>
#define INF 1e9 + 7
#define vi vector<int>
#define add emplace_back


int main(){ios_base::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    for(int i=0; i<n; ++i) cin >> a[i];
    
    vi dp(n, INF);
    dp[0] = 0;
    for(int i=1; i<n; ++i){
        for(int j=max(0,i-k); j<i; ++j){
            dp[i] = min(dp[i], dp[j] + abs(a[i]-a[j]));
        }
    }
    
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


int main(){
    int A,B,C;
    cin>>A>>B>>C;
    cout<<C<<" "<<A<<" "<<B<<endl;
    return 0;
}

Measured memory_bytes: 256
def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else 10**9
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)


N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
print(dfs(0,0,0,0))

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

int main()
{
  int n,k,a[50],sum=0,c=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=n-1;i>=0;i--){
 if(c<=k){
        sum+=a[i];
        c++;
 }
  else break;

  }
  cout<<sum;
    return 0;

}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s;
    while(cin >> s) {
        int JOI = 0, IOI = 0;
        int N = s.size();
        rep(i, N-2) {
            if(s.substr(i, 3) == "JOI") JOI++;
            if(s.substr(i, 3) == "IOI") IOI++;
        }
        cout << JOI << '\n';
        cout << IOI << '\n';
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX_V=2e5;

vector<int> RD[MAX_V+1];
vector<int> TR[MAX_V+1];
int a[MAX_V+1],b[MAX_V+1];

void dfsrd(int v,int c){
	a[v]=c;
	rep(i,RD[v].size()){
		if(a[RD[v][i]]==0)dfsrd(RD[v][i],c);
	}
}
void dfstr(int v,int c){
	b[v]=c;
	rep(i,TR[v].size()){
		if(b[TR[v][i]]==0)dfstr(TR[v][i],c);
	}
}

int main(){
	int N,K,L;
	cin>>N>>K>>L;
	rep(i,K){
		int p,q;
		cin>>p>>q;
		RD[p].push_back(q);
		RD[q].push_back(p);
	}
	rep(i,L){
		int p,q;
		cin>>p>>q;
		TR[p].push_back(q);
		TR[q].push_back(p);
	}
	int crd=1,ctr=1;
	rep1(i,N){
		if(a[i]==0){
			dfsrd(i,crd);
			crd++;
		}
	}
	rep1(i,N){
		if(b[i]==0){
			dfstr(i,ctr);
			ctr++;
		}
	}
	lli x[MAX_V],y[MAX_V];
	rep(i,N)x[i]=y[i]=(lli)(a[i+1]-1)*N+b[i+1]-1;
	sort(y,y+N);
	rep(i,N){
		cout<<upper_bound(y,y+N,x[i])-lower_bound(y,y+N,x[i])<<" ";
	}
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  if(a>=b){
    while(k--){
      b*=2;
      if(a<b)break;
    }
  } 
  if(b>=c){
    while(k--){
      c*=2;
      if(c>b)break;
    }
  }  
  
  if(c>b&&b>a)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long K){
	ll a[32] = {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};
	cout << a[K-1] << endl;
}

int main(){	
	long long K;
	scanf("%lld",&K);
	solve(K);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll mod_div(ll a,ll b){
  ll tmp=MOD-2,c=b,ret=1;
  while(tmp>0){
    if(tmp&1){
      ret*=c;ret%=MOD;
    }
    c*=c;c%=MOD;tmp>>=1;
  }
  return a*ret%MOD;
}
 
#define MAX_K 2000100
vector<ll> kaijo(MAX_K);
ll combination(ll n, ll r){
  if(n<r||n<0||r<0)
    return 0;
  if(kaijo[0]!=1){
    kaijo[0]=1;
    for(ll i=1;i<MAX_K;i++)kaijo[i]=(kaijo[i-1]*i)%MOD;
  }
  ll ret=kaijo[n];
  long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
  return mod_div(ret,tmp);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n+1);
  ll num = 0;
  vi cnt(n+1);
  for(auto &a:A){cin>>a;cnt[a]++;if(cnt[a] == 2)num = a;}
  cout<<n<<endl;
  ll l=-1,r=-1;
  for(int i=0;i<n+1;i++){
    if(A[i] == num){
      if(l == -1)l = i;
      else if(r == -1)r = i;
    }
  }
  for(ll i=2;i<=n+1;i++){
    /*    if(i == 2){
      if(n == 1)cout<<1<<endl;
      else
	cout<<(n*(n+1)/2-dist)%MOD<<endl;
      continue;
      }else{*/
      cout<<(combination(n+1,i)-combination(l+n-r,i-1)+MOD)%MOD<<endl;
      //}
  }
  return 0;
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n;
long long curr(1000), cnt, x, y;
int main() {
    DAU
    cin >> n >> x;
    for (int i = 2; i <= n; ++i) {
        cin >> y;
        if (y > x)
            cnt += curr / x, curr %= x;
        if (y < x)
            curr += cnt * x, cnt = 0;
        x = y;
    }
    curr += cnt * x;
    cout << curr;
    PLEC
}


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

int main (){
    string s;
    char a;
    cin >> s;
    int ma=s.size(),tep=ma;
    a=s.at(0);
    for (int i=1;i<tep;i++){
        if(s.at(i)!=a){
            if(ma>max(i,tep-i)){
                ma=max(i,tep-i);
            }
        }
        a=s.at(i);
    }
    cout << ma << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long ;
using ld=long double;
 
int main(){
    int a,b;
    cin>>a>>b;
    int s=a-1,t=b-1;
    int ans=(t+s-1)/s;
    
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin>>N>>K;
  int p=0;
  for(int i=0;i<N;i++)
  {
    if(i==0)
    {
      p+=K;
    } 
    else
    {
      p*=(K-1);
    }
  }
  cout<<p<<endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int jew;
    scanf("%d", &jew);

    int val[jew], cost[jew];
    int prof[jew];
    for(int i = 0; i < jew; i++)
    {
        scanf("%d", &val[i]);
    }
    for(int i = 0; i < jew; i++)
    {
        scanf("%d", &cost[i]);
    }
    for(int i = 0; i < jew; i++)
    {
        prof[i] = 0;
        prof[i] = val[i] - cost[i];
    }

    int result = 0;
    for(int i = 0; i < jew; i++)
    {
        if(prof[i] > 0)
            result += prof[i];
    }

    printf("%d", result);

    return 0;
}

Measured memory_bytes: 128
object Main {
  def main(args: Array[String]): Unit = {
    val abc = io.StdIn.readLine().split(" ").map(_.toInt)
    val answer =
      if (abc zip abc.tail forall { case (l, r) => l < r }) {
        "Yes"
      } else {
        "No"
      }
    println(answer)
  }
}

Measured memory_bytes: 43808
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10, M = 1010;

int h[N];
vector<int> e[N];

void solve() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> h[i];
	for(int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		e[a].push_back(h[b]);
		e[b].push_back(h[a]);
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(e[i].size() == 0) cnt++;
		else {
			sort(e[i].begin(), e[i].end());
			int id = e[i].size() - 1;
			if(e[i][id] < h[i]) cnt++;
		}
	}
	cout << cnt << endl;
}

int main() {
	IOS;
	//FRE
	int t;
	solve();
	return 0;
}


Measured memory_bytes: 9180