akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int p[n];
  vector<int> point(3, 0);
  int i;
  for (i = 0; i < n; i++) {
    cin >> p[i];
    if (p[i] <= a) {
      point[0]++;
    } else if (p[i] <= b) {
      point[1]++;
    } else {
      point[2]++;
    }
  }
  sort(point.begin(), point.end());
  cout << point[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){

  int d,t,s;
  cin>>d>>t>>s;
  if(s*t>=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3620
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Lsn (x<<1)
#define Rsn (x<<1|1)
#define Mid (L+R>>1)

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=1000000;
const int M=5000000;

struct node{
	int val,id;
	bool operator < (const node &B) const {return val<B.val;}
} A[N];

struct Edge{
	int y,nxt;
} E[M];
int x[N],y[N],las[N],__las[N],Id[N],dfn[N],low[N],stk[N],scc[N],val[N],pos[N];
int n,l,r,res,cnt,__cnt,num,tot,sccnum;
int Ql,Qr,Qx,Qv;

void Add_Edge(int x,int y){
	E[cnt]=(Edge){y,las[x]};las[x]=cnt++;
}
void Build(int x,int L,int R){
	Id[x]=++num;
	if (L==R){
		int y=A[L].id;
		if (y>n){
			Add_Edge(Id[x],y-n);
		} else{
			Add_Edge(Id[x],y+n);
		}
		return;
	}
	Build(Lsn,L,Mid);
	Build(Rsn,Mid+1,R);
	Add_Edge(Id[x],Id[Lsn]);
	Add_Edge(Id[x],Id[Rsn]);
}
void Query(int x,int L,int R){
	if (Ql<=L&&R<=Qr){
		Add_Edge(Qv,Id[x]);
		return;
	}
	if (Ql<=Mid) Query(Lsn,L,Mid);
	if (Qr>Mid) Query(Rsn,Mid+1,R);
}
void Work(int i,int l,int r){
	l=lower_bound(val+1,val+2*n+1,l)-val;
	r=upper_bound(val+1,val+2*n+1,r)-val-1;
	Ql=l,Qr=pos[i]-1,Qv=i;
	if (Ql<=Qr) Query(1,1,2*n);
	Ql=pos[i]+1,Qr=r,Qv=i;
	if (Ql<=Qr) Query(1,1,2*n);
}
void dfs(int x){
	dfn[x]=low[x]=++tot;
	stk[++*stk]=x;
	for (int i=las[x],y;~i;i=E[i].nxt)
		if (!dfn[y=E[i].y]){
			dfs(y);
			low[x]=min(low[x],low[y]);
		} else{
			if (!scc[y]) low[x]=min(low[x],dfn[y]);
		}
	if (low[x]==dfn[x]){
		int u;sccnum++;
		do{
			u=stk[(*stk)--];
			scc[u]=sccnum;
		} while (u!=x);
	}
}
bool check(int d){
	memcpy(las,__las,sizeof(__las));
	cnt=__cnt;
	For(i,1,n+1){
		Work(i,x[i]-d,x[i]+d);
		Work(i+n,y[i]-d,y[i]+d);
	}
	memset(dfn,0,sizeof(dfn));
	memset(scc,0,sizeof(scc));
	tot=0;sccnum=0;
	For(i,1,num+1){
		if (!dfn[i]) dfs(i);
	}
	For(i,1,n+1){
		if (scc[i]==scc[i+n]) return 0;
	}
	return 1;
}

int main(){
	memset(las,-1,sizeof(las));
	n=IN();
	For(i,1,n+1){
		x[i]=IN(),y[i]=IN();
		A[i]=(node){x[i],i};
		A[i+n]=(node){y[i],i+n};
	}
	sort(A+1,A+2*n+1);
	For(i,1,2*n+1){
		val[i]=A[i].val;
		pos[A[i].id]=i;
	}
	num=2*n;
	Build(1,1,2*n);
	memcpy(__las,las,sizeof(las));
	__cnt=cnt;
	l=-1,r=int(1e9);
	while (l<=r){
		int mid=(l+r>>1);
		if (check(mid)) res=mid,l=mid+1;else r=mid-1;
	}
	printf("%d\n",res+1);
}

Measured memory_bytes: 43392
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int N, M, S;
    const int m(100000);
    //dp[i][j] := iこの数字で総和j
    while(1){
        std::cin >> N >> M >> S;
        if(!N) break; 
        std::vector<std::vector<int>> dp(N*N+1 ,std::vector<int>(S+1));
        dp[0][0] = 1;
        for(int i(1), i_len(N*N); i <= i_len; ++i){
            for(int j(0); j <= S; ++j){
                if(i <= j) dp[i][j] += dp[i][j-i] + dp[i-1][j-i];
                if(j-M-1 >= 0) dp[i][j] -= dp[i-1][j-M-1];
                dp[i][j] %= m;
                if(dp[i][j] < 0) dp[i][j] += m;
            }
        }
        std::cout << dp[N*N][S] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3324
s = list(input())
cnt, new_cnt = 0, 0
for x in s:
    if x == "A" or x == "C" or x == "G" or x == "T":
        new_cnt += 1
        if cnt < new_cnt:
            cnt = new_cnt
    else:
        new_cnt = 0

print(cnt)


Measured memory_bytes: 61576
my $s = <>;chomp $s;
my @dat = split(/ /,$s);

if($dat[0] == $dat[1]){
    if($dat[1] == $dat[2]){
       print "No";   
    }else{
       print "Yes";
    }
}else{
    if($dat[1] == $dat[2] || $dat[0] == $dat[2]){
      print "Yes";
    }else{
      print "No";    
    }
} 


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

using namespace std;

int main(void) {
    int N;
    string S;
    int64_t ans,cnt;
    cin >> N >> S;
    
    map<char,int64_t> mp;
    for(int i=0;i<S.size();i++) {
        mp[S[i]]++;
    }
    
    if(mp.size() < 3){ 
        cout << "0\n";
        return 0;
    }
    ans = 1;
    for(auto m:mp) {
        ans *= m.second;
    }
    
    // 全部求めて引く？？？
    cnt = 0;
    for(int i=0;i<(N-2);i++) {
        for(int j=i+1;j<(N-1);j++) {
            if((j+j-i) >= N) break;
            if((S[i] != S[j]) && (S[i] != S[j+j-i]) && (S[j] != S[j+j-i])) cnt++;
        }
    }

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


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


ll L[51];
ll P[51];

ll keisan(ll A, ll B) {
	if (A == 0) return 1;
	if (L[A] == B) return P[A];

	ll kotae = 0;
	B--;

	if (B >= L[A - 1]) {
		kotae += P[A - 1];
		B -= L[A - 1];
	}
	else if (B > 0){
		kotae += keisan(A - 1, B);
		B = 0;
	}

	if (B > 0) {
		kotae++;
		B--;
	}

	if (B >= L[A - 1]) {
		kotae += P[A - 1];
		B -= L[A - 1];
	}
	else if (B > 0) {
		kotae += keisan(A - 1, B);
		B = 0;
	}

	return kotae;
}



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


	ll N, X;
	cin >> N >> X;

	L[0] = 1;
	rep1(i, 50) {
		L[i] = 2 * L[i - 1] + 3;
	}
	P[0] = 1;
	rep1(i, 50) {
		P[i] = 2 * P[i - 1] + 1;
	}


	co(keisan(N, X));

	Would you please return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
$t = explode(' ', trim(fgets(STDIN)));
$s = array_sum($t);
fscanf(STDIN, "%d", $m);
while ($m--) {
	fscanf(STDIN, "%d %d", $p, $x);
	echo $s + $x - $t[$p-1], "\n";
}

Measured memory_bytes: 3576
#include<stdio.h>
	
int main(void){
	int x,y,z;
	int i;
	
	while(scanf("%d %d",&x ,&y) != EOF){
		z=x+y;
		for(i=0; z!=0; i++){
			z = z/10;
		}
		printf("%d\n",i);
	}

	return 0;
}

Measured memory_bytes: 600
program abc130e
  implicit none
  integer(8),parameter :: md = 10**9+7
  integer :: n, m, i, j
  integer,dimension(:),allocatable :: s, t
  integer(8),dimension(:,:),allocatable :: dp
  read *, n, m
  allocate(s(n),t(m),dp(0:m,0:n))
  read *, s, t
  dp = 1
  do i = 1,n
     do j = 1,m
        if (s(i)==t(j)) then
           dp(j,i) = mod(dp(j-1,i)+dp(j,i-1),md)
        else
           dp(j,i) = mod(md+dp(j-1,i)+dp(j,i-1)-dp(j-1,i-1),md)
        end if
     end do
  end do
  print *, dp(m,n)
end program abc130e


Measured memory_bytes: 31488
#include <cstdio>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define EPS 1e-6
typedef complex<double> P;

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

double dist(const P& a, const P& b)
{
	return sqrt((a.real()-b.real())*(a.real()-b.real())+(a.imag()-b.imag())*(a.imag()-b.imag()));
}

bool isIntoC(const P& p, const C& c)
{
	return dist(p, c.p) < c.r+EPS;
}

bool isIntoC(const L& l, const C& c)
{
	return dist(l[0], c.p) < c.r+EPS && dist(l[1], c.p) < c.r+EPS;
}

int CrossPtNum(const C& c, const L& l)
{
	P LV=l[0]-l[1];
	double A=(LV.real()*LV.real())+(LV.imag()*LV.imag());
	double B=(LV.real()*l[0].real())-(LV.real()*c.p.real())+(LV.imag()*l[0].imag())-(LV.imag()*c.p.imag());
	double C=(l[0].real()-c.p.real())*(l[0].real()-c.p.real())+(l[0].imag()-c.p.imag())*(l[0].imag()-c.p.imag())-(c.r*c.r);

	if(fabs(B*B-A*C) < EPS) return 1;
	if(B*B-A*C  > 0) return 2;
	
	return 0;
}

bool intersectSC(const L& l, const C& c)
{
	if(isIntoC(l, c)) return false;
	
	double vc=dot(l[1]-l[0], c.p-l[0]);
	if(vc<0)
	{
		double dif=c.r-dist(l[0], c.p);
		return dif+EPS > 0;
	}
	
	double vv=dot(l[1]-l[0], l[1]-l[0]);
	
	if(vc > vv)
	{
		double d=dist(l[1], c.p);
		double dif=c.r*c.r-d*d;
		
		return dif+EPS > 0;
	}
	
	double cc=dot(c.p-l[0], c.p-l[0]);
	double dif=c.r*c.r-(cc-(vc/vv)*vc);
	
	return dif+EPS > 0;
}

int main()
{
	int x,y,r;
	while(scanf("%d%d", &x, &y), (x||y))
	{
		vector<P> tri;
		for(int i=0; i<3; i++)
		{
			tri.push_back(P(x,y));
			if(i==2) break;
			scanf("%d%d", &x, &y);
		}
	
		scanf("%d%d%d", &x,&y,&r);
		C c(P(x,y), r);
		
		bool g=true;
		for(int i=0; i<3; i++)
		{
			if(!isIntoC(tri[i], c))
			{
				g=false;
				break;
			}
		}
		
		if(g) 
		{
			puts("b");
			continue;
		}
		int cr[3];
		cr[0]=cross(tri[0]-tri[1], tri[0]-c.p);
		cr[1]=cross(tri[1]-tri[2], tri[1]-c.p);
		cr[2]=cross(tri[2]-tri[0], tri[2]-c.p);
		
		if(cr[0]<EPS&&cr[1]<EPS&&cr[2]<EPS||cr[0]+EPS>0&&cr[1]+EPS>0&&cr[2]+EPS>0)
		{
			g=true;
			for(int i=0; i<3; i++)
			{
				if(CrossPtNum(c, L(tri[i], tri[(i+1)%3])) == 2) g=false;
			}
			if(g) 
			{
				puts("a");
				continue;
			}
			
		}
		
		for(int i=0; i<tri.size(); i++)
		for(int j=i+1; j<tri.size(); j++)
		{
			if(intersectSC(L(tri[i], tri[j]), c))	g=true;
		}
		if(g)
		{
			puts("c");
			continue;
			
		}
		
		puts("d");
	}
}

Measured memory_bytes: 0
sa = []
cnt = 0
for i in range(3):
    x,y,z = map(int,input().split())
    sa.append([x-y,y-z,z-x])
for i in range(3):
    if sa[0][i] == sa[1][i] == sa[2][i]:
        cnt += 1
if cnt==3:
    print('Yes')
else:
    print('No')

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

int main (){
	int a, b, i, ans;
	ans = 0;
	cin >> a >> b;

	for (i = 0; i < 2; i++){
		if (a >= b){
			ans += a;
			a--;
		}
		else {
			ans += b;
			b--;
		}
	}
	cout << ans << endl;

	return 0;
}


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

int t[100000];
int main(){
	int n;scanf("%d",&n);
	int Max=0;
	rep(i,n){
		scanf("%d",&t[i]);
		Max=max(Max,t[i]);
	}
	vector<int>v;
	for(int i=1;i*i<=Max;i++){
		if(Max%i==0){
			v.push_back(i);
			v.push_back(Max/i);
		}
	}
	sort(v.begin(),v.end());
	int cnt=0;
	rep(i,n){
		cnt+=*lower_bound(v.begin(),v.end(),t[i])-t[i];
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int n,m,q,a[60],b[60],c[60],d[60],A[20],ma;
void dfs(int dep)
{
	if(dep==n+1)
	{
		int sum=0;
		for(int i=1;i<=q;i++)
		{
			if(A[b[i]]-A[a[i]]==c[i])
				sum+=d[i];
		}
		ma=max(ma,sum);
		return;
	}
	for(int i=A[dep-1];i<=m;i++)
	{
		A[dep]=i;
		dfs(dep+1);
	}
}
int main()
{
	A[0]=1;
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1);
	cout<<ma;
}


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

int main(){
int N,K;
  cin>>N>>K;
  vector<int>l(N+1);
  for(int i=0; i<N+1; i++){
   cin>>l[i];
  }
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans=0;
  for(int i=0; i<K; i++){
   ans+=l[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[i] - 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 25704
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string a;
  cin >> a;
  if(a.length()==2) cout << a << endl;
  else cout << a[2] << a[1] << a[0] << endl;
  return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int val[100000],n,sum=0,check=0,pu=0;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> val[i];
	sort(&val[0],&val[n]);
	for(int i=0;i<n;i++){
		if(val[i] != check){
			sum += pu;
			check = val[i];
			pu = 1;
		}else{
			pu ^= 1;
		}
	}
	cout << sum + pu << endl;

}

Measured memory_bytes: 640
open Batteries

let solve (a, b) line =
  Scanf.sscanf line "%d %d" (fun x y ->
  let ratio = max ((a-1) / x+1) ((b-1) / y+1) in
  (x*ratio, y*ratio))

let () =
  IO.lines_of stdin
  |> Enum.skip 1
  |> Enum.fold solve (1, 1)
  |> fun (x, y) -> Int.print stdout (x + y)


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

int main() {
int n;
  cin >> n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i);
  }
  sort(x.begin(), x.end());
  int max=x.at(n-1);
  vector<int> sum(max);
  for(int i=0;i<max;i++){
    for(int j=0;j<n;j++){
      sum.at(i)+=pow((i+1-x.at(j)),2);
    }
  }
   sort(sum.begin(), sum.end());
  cout << sum.at(0) << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

scores = []

if S[0] == '0':
    scores.append(0)

cur = 'w'
for i in range(len(S)):
    if cur == S[i]:
        scores[-1] += 1
    else:
        scores.append(1)
        cur = S[i]

if S[-1] == '0':
    scores.append(0)

import numpy as np
scoreCS = np.cumsum(np.array([0]+scores))

ans = -1
for l in range(0, len(scoreCS), 2):
    r = K*2 + 1 + l
    if r >= len(scoreCS):
        break
    ans = max(ans, scoreCS[r] - scoreCS[l])

if ans == -1:
    ans = scoreCS[-1]
print(ans)



Measured memory_bytes: 14828
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong k, a, b;

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

    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

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

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	string s;
	in(s);
	ll len, ans;
	len = s.length();
	ans = 0;

	for (ll i = 0; i < (1 << (len - 1)); i++) {
		string t = "";
		for (ll j = 0; j < len;j++) {
			t += s[j];
			if (i & (1 << j)) {
				ans += stoll(t);
				t = "";
			}
		}
		if (t != "") {
			ans += stoll(t);
		}
	}

	outn(ans);

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 2e5 + 10, K = 26, inf = 1e9, infll = 1e18;
const double pi = acos(-1);
int n, m, f[maxn], pos[maxn][K + 2];
string A;

void solve(){
	int i, j, k, l, r; cin >> A;
	n = A.length();
	f[n] = 1;
	for0(i, 0, K){
		pos[n][i] = n;
	}
	forw0(i, n, 0){
		for0(j, 0, K){
			pos[i][j] = pos[i + 1][j];
		}
		pos[i][A[i] - 'a'] = i;
		f[i] = n;
		for0(j, 0, K){
			f[i] = min(f[i], f[pos[i][j] + 1] + 1);
		}
	}
	int p = 0;
	for(i = f[0]; i; i--){
		for0(j, 0, K){
			if(f[pos[p][j] + 1] + 1 == i){
				cout << char(j + 'a');
				p = pos[p][j] + 1;
				break;
			}
		}	
	}
}

signed main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 49020
/*input
contest
son
*/
/**
    Author: Kristopher Paul
    Date Created: 18-08-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

vector<int> ind[26];

int bs(int val,int c){
    vector<int>::iterator i = lower_bound(ind[c].begin(),ind[c].end(),val);
    if(i == ind[c].end()){
        return -1;
    }
    return *i;
}

void solve(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    bool th[26] = {};
    int sn = s.length();
    FOR(i,0,sn){
        th[s[i]-'a'] = true;
    }
    int tn = t.length();
    FOR(i,0,tn){
        if(!th[t[i]-'a']){
            cout << "-1" << endl;
            return;
        }
    }
    FOR(i,0,sn){
        ind[s[i]-'a'].pb(i);
    }
    int p = 0;
    int ans = 0;
    FOR(i,0,tn){
        int pos = bs(p,t[i]-'a');
        if(pos == -1){
            ans += (sn-p);
            p = 0;
            pos = bs(p,t[i]-'a');
            ans += pos+1;
        }else{
            ans += (pos-p+1);
        }
        p = pos+1;
        p %= (sn);
    }
    cout << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,M,to[200005],nxt[200005],head[200005],cnt=1;
int f[200005],S[200005],L[200005],R[200005],p[200005],dp[200005];
inline void add(int u,int v) {
	to[cnt]=v;nxt[cnt]=head[u];head[u]=cnt++;
	to[cnt]=u;nxt[cnt]=head[v];head[v]=cnt++;
}
void dfs(int cur,int fa){
	int cnt=0;
	f[cur]++;
	for(int i=head[cur];i;i=nxt[i])
		if(to[i]!=fa){
			dfs(to[i],cur);
			f[cur]=f[cur]*f[to[i]]%M;
		}
	for(int i=head[cur];i;i=nxt[i])
		if(to[i]!=fa)
			p[++cnt]=to[i];
	f[cur]++;f[cur]%=M;
	L[0]=R[cnt+1]=1;
	for(int i=1;i<=cnt;i++)	L[i]=L[i-1]*f[p[i]]%M;
	for(int i=cnt;i>=1;i--)	R[i]=R[i+1]*f[p[i]]%M;
	for(int i=1;i<=cnt;i++)	S[p[i]]=L[i-1]*R[i+1]%M;
}
void dfs2(int cur,int fa){
	if(cur==1) dp[cur]=1;
	else	dp[cur]=(S[cur]*dp[fa]+1)%M;
	for(int i=head[cur];i;i=nxt[i])
		if(to[i]!=fa) dfs2(to[i],cur);
}
signed main(){
	cin>>n>>M;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		add(u,v);
	}
	dfs(1,1);
	dfs2(1,1);
	for(int i=1;i<=n;i++)	cout<<dp[i]*(f[i]+M-1)%M<<endl;
    return 0;
}

Measured memory_bytes: 16256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

typedef long long ll;

ll n;
ll a[55], b[55];
ll c[55][55];
bool vv[55][55];
bool v[55];
ll ans;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        vv[i][a[i]] = true;
    }
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &b[i]);
    }
    memset(c, -1, sizeof(c));
    for(ll i = 0; i < n; i++)
    {
        c[i][b[i]] = 0;
        for(ll j = 0; j <= 50; j++)
        {
            for(ll k = 1; k <= 50; k++)
            {
                ll t = j % k;
                if(c[i][t] == -1) continue;
                if(c[i][j] == -1) c[i][j] = c[i][t] + (1LL << k);
                else c[i][j] = min(c[i][j], c[i][t] + (1LL << k));
            }
        }
    }
    while(1)
    {
        ll mx = 0;
        for(ll j = 0; j < n; j++)
        {
            ll mn = 4e18;
            for(ll k = 0; k <= 50; k++)
            {
                if(vv[j][k] && c[j][k] > -1) mn = min(mn, c[j][k]);
            }
            if(mn > 3e18)
            {
                printf("-1\n");
                return 0;
            }
            mx = max(mx, mn);
        }
        ll t = 1;
        ll cnt = 0;
        while(t <= mx) t *= 2, cnt++;
        t /= 2, cnt--;
        ans += t;
        ll j;
        for(j = 0; j < n; j++)
        {
            if(!vv[j][b[j]]) break;
        }
        if(j == n) break;
        for(j = 0; j < n; j++)
        {
            for(ll k = 0; k <= 50; k++) if(vv[j][k]) vv[j][k % cnt] = true;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;

	ll A[100001] = {};
	ll B[100001] = {};

	ll nanshuu = 0;
	rep1(i, N) {
		cin >> A[i];
		A[i] += nanshuu;
		if (A[i - 1] > A[i]) {
			nanshuu += M;
			A[i] += M;
		}
	}

	rep1(i, N - 1) {
		B[A[i + 1] % M] += A[i + 1] - A[i];
	}

	ll X;
	ll saidai = -1e18;
	ll kari = 0;
	rep(i, M) {
		kari += A[N] / M - 1;
		if (i > A[1]) kari++;
		if (i <= A[N] % M) kari++;
		kari -= B[i];

		if (saidai < kari) {
			saidai = kari;
			X = i + 1;
		}
	}

	ll goukei = A[N] - A[1];

	if (X <= A[1]) X += M;
	rep1(i, N - 1) {
		if (A[i + 1] >= X && X - A[i] - 1 >= 0) {
			goukei -= X - A[i] - 1;
		}

		if (A[i + 1] >= X) X += M;
	}

	co(goukei);

	Would you please return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int n, w, cnt;
	int[] cnts;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt(); w = sc.nextInt();
		cnts = new int[2*n+10];
		cnt = 0;
		
		for(int i=1;i<=w;i++) {
			update(i, 1);
		}
		System.out.print(cnt + (n==w? "\n":" "));
		for(int i=1;i<n-w+1;i++) {
//			debug(i, cnts);
			update(i, -1);
			update(i+w, 1);
			System.out.print(cnt + (i==n-w? "\n": " "));
		}
	}
	
	void update(int x, int c) {
		cnts[1] += c==1? 2: -2;
		if(x!=1) cnts[x] += c==1? 2: -2;
		if( ( cnts[x] == 2 || cnts[x] == 3 ) && c == 1 ) cnt++;
		if( ( cnts[x] == 1 || cnts[x] == 0 ) && c == -1 ) cnt--;
		for(long j=2;j*j<=x;j++) if(x%j==0) {
			cnts[(int)j] += c;
			if( cnts[(int)j] == 2 && c == 1 ) cnt++;
			if( cnts[(int)j] == 1 && c == -1 ) cnt--;
			if( j != x/j ){
				cnts[(int)(x/j)] += c;
				if( cnts[(int)(x/j)] == 2 && c == 1 ) cnt++;
				if( cnts[(int)(x/j)] == 1 && c == -1 ) cnt--;
			}
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 44908
#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(int i=0;i<x;i++)
#define repn(i,x) for(int 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())
int w,h;
string f[65];
struct uf{
	int par[4005],ran[4005];
	void init(){ for(int i=0;i<4005;i++) par[i] = i,ran[i] = 0; }
	int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
	void unite(int x,int y){
		x = find(x); y = find(y); if(x==y) return;
		if(ran[x] < ran[y]) par[x] = y;
		else{
			par[y] = x;
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x,int y){ return find(x)==find(y); }
}kaede;
vector<int>edge[5005];
vector<int>zax[5005];
int mnx[5005],mxx[5005];
bool bad;
P dfs(int v,int u){
	P num = mp(0,0);
	for(int i=0;i<edge[v].size();i++){
		int to = edge[v][i];
		if(to == u) continue;
		P ret = dfs(to,v);
		num.fi += ret.fi;
		num.sc += ret.sc;
	}
	rep(i,zax[v].size()){
		num.fi += zax[v][i];
		num.sc += 1;
	}
	//num.fi / num.sc
	//mnx[v]-0.5 < num.fi/num.sc < mxx[v]+0.5?

	if(num.sc){
		ll L = (2LL*mnx[v]-1LL) * num.sc;
		ll M = 2LL*num.fi;
		ll R = (2LL*mxx[v]+1LL) * num.sc;
		
		if(L < M && M < R);
		else bad = 1;
	}
	return num;
}
int main(){
	while(1){
		cin>>h>>w;
		if(w == 0) return 0;
		rep(i,w) cin>>f[i];
		kaede.init();
		rep(i,w) rep(j,h){
			if(f[i][j] == '.') continue;
			if(i != w-1){
				if(f[i][j] == f[i+1][j]){
					kaede.unite(i*61+j,i*61+j+61);
				}
			}
			if(j != h-1){
				if(f[i][j] == f[i][j+1]){
					kaede.unite(i*61+j,i*61+j+1);
				}
			}
		}
		rep(i,5005){
		    edge[i].clear();zax[i].clear();
		}
		int root = -1;
		rep(i,w-1) rep(j,h){
			//f[i][j] & f[i+1][j]
			if(f[i][j] == '.' || f[i+1][j] == '.') continue;
			int a = i*61+j;
			int b = i*61+j+61;
			if(i+1 == w-1){
				root = kaede.find(b);
			}
			if(kaede.find(a) != kaede.find(b)){
				edge[kaede.find(b)].pb(kaede.find(a));
			}
		}
		rep(i,w) rep(j,h){
			if(f[i][j] == '.') continue;
			int a = i*61+j;
			zax[kaede.find(a)].pb(j);
		}
		rep(i,5005){
			SORT(edge[i]);
			ERASE(edge[i]);
			mnx[i] = INF;
			mxx[i] = -INF;
			
		}
		rep(i,w) rep(j,h){
			if(f[i][j] == '.') continue;
			int a = i*61+j;
			if(i == w-1){
				mnx[kaede.find(a)] = min(mnx[kaede.find(a)],j);
				mxx[kaede.find(a)] = max(mxx[kaede.find(a)],j);
			}
			else{
			    if(f[i][j] == '.' || f[i+1][j] == '.') continue;
				int b = i*61+j+61;
				if(kaede.find(a) != kaede.find(b)){
					mnx[kaede.find(a)] = min(mnx[kaede.find(a)],j);
					mxx[kaede.find(a)] = max(mxx[kaede.find(a)],j);
				}
			}
		}
		bad = 0;
		dfs(root,-1);
		puts(bad?"UNSTABLE":"STABLE");
	}
}


Measured memory_bytes: 3500
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a>b) {
			System.out.println("a > b");
		}else if(a<b) {
			System.out.println("a < b");
		}else {
			System.out.println("a == b");
		}

	}
}



Measured memory_bytes: 26240
N = int(input())
l = list(map(int, input().split()))
even = True
ans = 0
while even == True:
  for i, j in enumerate(l):
    if j%2==0:
      l[i] /= 2
    else:
      even = False
  if even == True:
    ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  cout << data.at(N - 1) - data.at(0) << endl;
  return 0;
}


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

int main(void){
    int D, p[10], c[10];
    long long G;
    cin >> D >> G;
    for (int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int min_prb = 1000;
    for (int i = 0; i < (1 << D); i++){
        long long scr = 0;
        int flg = 0;
        int idx;
        int prb = 0;
        for (int j = D-1; j >= 0; j--) {
            if (i & 1 << j) {
                scr += 100 * (j+1) * p[j] + c[j];
                prb += p[j];
            } else if (flg == 0) {
                flg = 1;
                idx = j;
            }
        }
        for (int k = 1; k <= p[idx] & scr < G; k++){
            scr += 100 * (idx+1);
            prb += 1;
        }
        if (scr >= G & prb < min_prb ){
            min_prb = prb;
        }
    }
    cout << min_prb << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> 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;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll T, X;
  cin >> T >> X;
  vector<ll> A;
  cout << setprecision(10) << (long double)T / X << endl;
  return 0;
}


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

#define cget getchar_unlocked
#define cput putchar_unlocked

inline int in() {
  int n = 0; short c;
  while ((c = getchar()) >= '0') n = n * 10 + c - '0';
  return n;
}

inline void out(int n) {
  short res[10], i = 0;
  do { res[i++] = n % 10, n /= 10; } while (n);
  while (i) putchar(res[--i] + '0');
}

class SCC {
private:
  const int N;
  vector<vector<int>> G, R;
  vector<int> ord, low;
  stack<int> st;
  void dfs(const int u, int &tm) {
    ord.at(u) = low.at(u) = tm++, st.push(u);
    for (int v : G.at(u)) {
      if (ord.at(v) < 0) {
        dfs(v, tm);
        low.at(u) = min(low.at(u), low.at(v));
      } else if (cmp.at(v) < 0) {
        low.at(u) = min(low.at(u), ord.at(v));
      }
    }
    if (ord.at(u) == low.at(u)) {
      R.push_back(vector<int>{});
      while (true) {
        const int v = st.top();
        st.pop();
        cmp.at(v) = cnt;
        R.back().push_back(v);
        if (v == u) break;
      }
      cnt++;
    }
  }

public:
  vector<vector<int>> graph;
  vector<int> cmp;
  int cnt;
  SCC(const int n) : N(n), G(n), ord(n, -1), low(n), cmp(n, -1), cnt(0) {}
  void add(const int from, const int to) { G.at(from).push_back(to); }
  vector<vector<int>> solve() {
    int tm = 0;
    for (int i = 0; i < N; i++) {
      if (ord.at(i) < 0) dfs(i, tm);
    }
    for (int i = 0; i < N; i++) cmp.at(i) = cnt - 1 - cmp.at(i);
    reverse(R.begin(), R.end());
    return R;
  }
  vector<vector<int>> build() {
    graph.resize(cnt);
    for (int i = 0; i < N; i++) {
      for (int j : G.at(i)) {
        if (cmp.at(i) != cmp.at(j)) {
          graph.at(cmp.at(i)).push_back(cmp.at(j));
        }
      }
    }
    return graph;
  }
};

signed main() {
  int N = in(), M = in();  
  SCC SC(N);
  for (int i = 0; i < M; i++) {
    int a = in(), b = in();
    SC.add(a, b);
  }

  auto G = SC.solve();
  out(G.size()), cput('\n');
  for (int i = 0, h = G.size(); i < h; i++) {
    out(G.at(i).size());
    for (int j = 0, w = G.at(i).size(); j < w; j++) {
      cput(' '), out(G.at(i).at(j));
    }
    cput('\n');
  }
}

Measured memory_bytes: 87184
#include    <iostream>
#include    <vector>

using namespace std;

void printVector(const vector<int> &A) {
    for(int i = 0; i < A.size(); i++) {
        cout << A[i];
        if(i+1 < A.size()) cout << ' ';
    }
    cout << endl;
}

int main() {
    int n, count = 0;
    auto swap = [](int &a, int &b) {
        int tmp = a;
        a = b;
        b = tmp;
    };

    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    
    for(int i = 0; i < n; i++) {
        int minj = i;
        for(int j = i; j < n; j++)
            if(A[j] < A[minj])  minj = j;
        if(A[i] != A[minj]) {
            swap(A[i], A[minj]);
            count++;
        }
    }
    printVector(A);
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    n=n%10;
    switch(n){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon"<<endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon"<<endl;
            break;
        case 3:
            cout<<"bon"<<endl;
            break;
    }
    return 0;
}


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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define sz(x) x.size()
#define INF LONG_LONG_MAX
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

/*LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}*/
/*LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}*/

int main()
{
    C c;
    cin>>c;
    C d = c + 1;
    cout<<d;
}


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

#define int long long
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define x first
#define y second

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

	int n;
	cin>>n;
	vector<char> ans;
	string s="abcdefghijklmnopqrstuvwxyz";
	while (n>=26){
		int x=n%26;
		if (x==0) x=26,n--;
		ans.pb(s[x-1]);
		n/=26;
	}
	if (n!=0) cout<<s[n-1];
	reverse(ans.begin(),ans.end());
	for (int i=0; i<ans.size(); i++)
		cout<<ans[i];
	cout<<endl;
	return 0;
}

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

const int Nmax=200010;

int main() {
	string a,b;
	cin >> a >> b;
	if(a > b) cout << '>' << endl;
	if(a == b) cout << '=' << endl;
	if(a < b) cout << '<' << endl;
	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int times[5] = {0,0,0,0,0};
    for(int i = 0; i < 5; i++){
        cin >> times[i];
    }

    int mintime = 124;
    int pastTime = 0;
    for(int i = 0; i < 5; i++){
        if(mintime > times[i] % 10 && times[i] % 10 != 0){
            mintime = times[i]%10;
        }
        pastTime += (times[i] / 10)*10;
        if(times[i] % 10 != 0){
            pastTime += 10;
        }
    }

    int result = 0;

    if(mintime == 124){
        result = pastTime;
    }else{
        result = pastTime + mintime-10;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
N,K = gets.split.map(&:to_i)
h = []
N.times{h << gets.to_i}
# puts h

h.sort!

# puts h
x = []
0.upto(N-K){|i| x << h[K-1+i] - h[i]}
x.sort!
# puts x
puts x.first

Measured memory_bytes: 4896
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

module ModOp = struct
  let prime = 1_000_000_007
  let (-) a b = (a + prime - b) mod prime
  let (+) a b = (a + b) mod prime
  let ( * ) a b = (a * b) mod prime

  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then pow (x*x) (n/2)
    else x * pow (x*x) (n/2)
end

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n,m,x) = scan "%d %d %d" Tuple3.make
let mat = scan_matrix n m ~sep:' ' 0 Int.of_string

let () =
  ListL.map (powerset (0++^n)) ~f:(fun ls ->
      let arr = Array.make m 0 in
      let w = ref 0 in
      ListL.iter ls ~f:(fun i ->
          w := !w + mat.(i).(0);
          ArrayL.iteri (Array.sub mat.(i) 1 m) ~f:(fun i v -> arr.(i) <- arr.(i) + v));
      if ArrayL.for_all arr ~f:((<=) x) then !w
      else Int.max_num)
  |> List.min
  |> (fun v -> if v = Int.max_num then -1 else v)
  |> Printf.printf "%d\n"


Measured memory_bytes: 7796
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


string N;

int g[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1 };
int memo[1001010][2];
int f(int i, int j) { // =[0,i]円+j円を支払う最小枚数
    if (i < 0) {
        if(j == 0) return 0;
        else return 1;
    }
    if (0 <= memo[i][j]) return memo[i][j];

    int res = LLINF;
    rep(d,10) {
        int n = N[i] - '0' + j;

        int sm = g[d];
        if (d < n) sm += f(i - 1, 1) + g[10 + d - n];
        else sm += f(i - 1, 0) + g[d - n];

        chmin(res, sm);
    }

    return memo[i][j] = res;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;


    cin >> N;
    ll n=N.size();
    rep(i, n+2) rep(j, 2) memo[i][j] = -1;
    cout << f(N.length() - 1, 0) << endl;

    // cin>>N;
    // ll n=N.size();
    // ll ans=LLINF;
    // ll dp[n+1][2];
    // rep(i,n+1){
    //     rep(j,2) dp[i][j]=-1;
    // }



    return 0;
}


Measured memory_bytes: 95132