akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}


int main(){
  string s;
  cin>>s;
  lint ans=0;
  if(s.size()%2==0){
      rep(i,s.size()/2){
          if(s[i]!=s[s.size()-1-i])ans++;
      }
  }else {
      rep(i,s.size()/2){
                    if(s[i]!=s[s.size()-1-i])ans++;
      }
  }
  cout<<ans;
}

Measured memory_bytes: 256
I=16843009;g[101][101],h[101][101];a,b,c;k;*d;x;main(n){for(scanf("%d%*d",&n);a++<n;)for(b=0;b++<n;)h[a][b]=g[a][b]=a-b?I:0;for(;~scanf("%d%d%d",&a,&b,&c);)h[a][b]=h[b][a]=g[a][b]=g[b][a]=c;for(;k++<n;)for(a=0;a++<n;)for(b=0;b++<n;c<*d?*d=c,g[a][b]-I?g[a][b]=I,x++:0:0)d=h[a]+b,c=h[a][k]+h[k][b];printf("%d",x/2);}

Measured memory_bytes: 256
def resolve():
    a, b = map(int, input().split())
    s = input()
    
    flag_len = False
    flag_bar = False
    flag_num = True
    if a+b+1 == len(s):
        flag_len = True
    if s.count("-") == 1 and s[a] == "-":
        flag_bar = True
    if flag_len and flag_bar:
        for i in range(len(s)):
            code = ord(s[i])
            if code < ord("0") or ord("9") < code:
                if code!= ord("-"):
                    flag_num == False
                    break
                
    if flag_len and flag_bar and flag_num:
        print("Yes")
    else:
        print("No")
resolve()

Measured memory_bytes: 9168
module Main where

import Control.Monad
import Control.Applicative
import Data.List

showingList :: [Int] -> String
showingList (x:[]) = show x
showingList (x:xs) = (show x) ++ " " ++ (showingList xs)

solve :: String -> Int
solve s
    | s == "SSS" = 0
    | s == "SSR" = 1
    | s == "SRS" = 1
    | s == "SRR" = 2
    | s == "RSS" = 1
    | s == "RSR" = 1
    | s == "RRS" = 2
    | otherwise = 3

main :: IO ()
main = do
    s <- getLine
    print $ solve s


Measured memory_bytes: 3764
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

const int N = 1e5 + 5;
vector<int> T(N);
void update(int x,int val) {
    for(; x <= N; x += x&-x) T[x] += val;
}
int sum(int x) {
    int res = 0;
    for(; x > 0; x -= x&-x) res += T[x];
    return res;
}
int query(int l, int r) {
    return sum(r)-sum(l-1);
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v(m);
    for(auto &i : v) cin >> i.ss >> i.ff;
    sort(all(v));

    for(auto i : v){
        auto l = i.ss;
        auto r = i.ff;
        if(query(l, r) == 0) update(r - 1, 1);
    }

    cout << query(1, n);
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 4488
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

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

const ll MOD = 1E9+7;

ll power(ll a, ll n)
{
    if (n == 0) return 1;
    if (n%2 == 0) return power(a, n/2)*power(a, n/2)%MOD;
    else return (power(a, n/2)*power(a, n/2)%MOD)*a%MOD;
}

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

    ll n; cin >> n;
    ll result = (power(10, n)-2*power(9, n)+power(8, n)+10*MOD)%MOD;
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3632
N = int(input())
csf = [list(map(int, input().split())) for _ in range(N-1)]
ans = []

for i in range(N):
    t = 0
    for j in range(i, N-1):
        C = csf[j][0]
        S = csf[j][1]
        F = csf[j][2]
        if S <= t:
            if t % F == 0:
                t += C
            else:
                t += F - t % F + C
        else:
            t = C + S
    ans.append(t)

print(*ans, sep='\n')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int maxn=1000;
ll n,stk[maxn],top;
struct point{
	ll x,y,id,on;
	bool operator< (point o)const{
		return x<o.x||x==o.x&&y<o.y;
	}
}p[maxn];
vector<int> vec;
double ans[maxn];
 
void work(int l,int mid,int r){
	double a=atan2(p[l].y-p[mid].y,p[l].x-p[mid].x),b=atan2(p[r].y-p[mid].y,p[r].x-p[mid].x);
	a-=b;
	a-=acos(-1);
	while(a<0)
		a+=acos(-1)*2;
	ans[p[mid].id]=a/acos(-1)/2;
}
 
int main(){
	cin>>n;
	if(n==2){
		puts("0.5");
		puts("0.5");
		return 0;
	}
	for(int i=1;i<=n;++i){
		cin>>p[i].x>>p[i].y;
		p[i].id=i;
	}
	sort(p+1,p+n+1);
	stk[1]=1;stk[2]=2;top=2;
	for(int i=3;i<=n;++i){
		while(top>=2&&
		(p[i].y-p[stk[top]].y)*(p[stk[top]].x-p[stk[top-1]].x)
		>(p[i].x-p[stk[top]].x)*(p[stk[top]].y-p[stk[top-1]].y))
			--top;
		stk[++top]=i;
	}
	for(int i=1;i<=top;++i)
		vec.push_back(stk[i]);
	stk[1]=n;stk[2]=n-1;top=2;
	for(int i=n-2;i;--i){
		while(top>=2&&
		(p[i].y-p[stk[top]].y)*(p[stk[top]].x-p[stk[top-1]].x)
		>(p[i].x-p[stk[top]].x)*(p[stk[top]].y-p[stk[top-1]].y))
			--top;
		stk[++top]=i;
	}
	for(int i=2;i<top;++i)
		vec.push_back(stk[i]);
	work(vec[vec.size()-1],vec[0],vec[1]);
	for(int i=1;i+1<vec.size();++i)
		work(vec[i-1],vec[i],vec[i+1]);
	work(vec[vec.size()-2],vec[vec.size()-1],vec[0]);
	for(int i=1;i<=n;++i)
		printf("%.5f\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N;cin>>N;
  vector<int> vec(N);
  REP(i,0,N)cin>>vec[i];
  int max_m=abs(vec[0]-0)+abs(0-vec[N-1]);
  REP(i,0,N-1){
    max_m+=abs(vec[i+1]-vec[i]);
  }
  //print(max_m)

  vector<int> ans(N,max_m);
  ans[0]-=abs(vec[0]-0)+abs(vec[1]-vec[0])-abs(vec[1]-0);
  REP(i,1,N-1){
    ans[i]-=abs(vec[i]-vec[i-1])+abs(vec[i+1]-vec[i])-abs(vec[i+1]-vec[i-1]);
  }
  ans[N-1]-=abs(vec[N-1]-vec[N-2])+abs(0-vec[N-1])-abs(0-vec[N-2]);
  REP(i,0,N){
    print((ans[i]))
  }

}


Measured memory_bytes: 2048
#include <cstdio>
int arr[100005], ans[100005];
int main()
{
	// freopen("AGC012-C.in", "r", stdin);
	long long n;
	scanf("%lld", &n);
	n++;
	int cnt = 0, len = 0;
	while (n != 1)
	{
		cnt += n & 1;
		arr[len++] = n & 1;
		n >>= 1;
	}
	int l = cnt - 1, r = cnt, cur = 0;
	for (int i = len - 1; i >= 0; i--)
	{
		ans[r++] = cur++;
		if (arr[i])
			ans[l--] = cur++;
	}
	printf("%d\n", r << 1);
	for (int i = 0; i < r << 1; i++)
		printf("%d%c", (i < r ? ans[i] : i - r) + 1, " \n"[i + 1 == r << 1]);
	return 0;
}


Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
ab = ab[::-1]
uf = UnionFind(n+1)
ans = [n*(n-1)//2]
for i in range(m-1):
  t = ans[-1]
  a,b = ab[i]
  if uf.same(a,b):
    ans.append(t)
  else:
    ans.append(t-uf.size(a)*uf.size(b))
  uf.union(a,b)
ans = ans[::-1]
print(*ans,sep="\n")

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod(ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit(ll b, ll i) { return b & (1 << i); }
inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
// struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int n;
    cin >> n;
    
    vi l(n);
    rep(i,n) cin >> l[i];
    
    sort(ALL(l));
    int ans = 0;
    
    rep(i,n)reps(j,i+1,n-1)reps(k,j+1,n-1){
        if(l[i] != l[j] && l[k] != l[j] && l[i] != l[k]){
            ans += (l[i] + l[j]) > l[k];
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3600
N = int(input())
abc = []
for i in range(N):
    data = list(map(int, input().split()))
    abc.append(data)

dp = [[0 for i in range(3)] for j in range(N)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(N-1):
    for j in range(3):
        if j == 0:
            dp[i+1][1] = max(dp[i][0] + abc[i+1][1], dp[i+1][1])
            dp[i+1][2] = max(dp[i][0] + abc[i+1][2], dp[i+1][2])
        if j == 1:
            dp[i+1][0] = max(dp[i][1] + abc[i+1][0], dp[i+1][0])
            dp[i+1][2] = max(dp[i][1] + abc[i+1][2], dp[i+1][2])
        if j == 2:
            dp[i+1][1] = max(dp[i][2] + abc[i+1][1], dp[i+1][1])
            dp[i+1][0] = max(dp[i][2] + abc[i+1][0], dp[i+1][0])

print(max(dp[N-1]))

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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

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

int cost[101][101];
int n, k;

signed main() {

	while( cin >> n >> k, n ) {
		fill( cost[0], cost[101], INF );
		REP( i, 101 ) {
			cost[i][i] = 0;
		}

		REP( i, k ) {
			int t, from, to;
			cin >> t;
			if( t ) {
				int fare;
				cin >> from >> to >> fare;
				from--; to--;
				
				REP( i, n ) {
					REP( j, n ) {
						chmin( cost[i][j], min( cost[i][from] + cost[to][j] + fare, cost[i][to] + cost[from][j] + fare ) );
					}
				}
			
				
			} else {

				cin >> from >> to;
				from--; to--;
				if( cost[from][to] != INF ) cout << cost[from][to] << endl;
				else						cout << -1 << endl;
			}
		}
	}
}


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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007

typedef long long ll;
int main() {
  ll n;
  string s;
  cin >> n;
  cin >> s;
  ll count = 0;
  for(ll i = 1; i < n; i++) {
    if(s[i] == s[i-1]) continue;
    else count++;
  }
  count++;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int s,w;
  cin>>s>>w;
  if(w>=s)
    cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)

class Point {
public:
    double x,y;
    Point(double x,double y):x(x),y(y){}
    Point():x(0),y(0){}

    Point operator + (Point p) {return Point(x + p.x,y + p.y);}
    Point operator - (Point p ){return Point(x - p.x,y - p.y);}
    Point operator * (Point p ){return Point(x * p.x,y * p.y);}
    Point operator / (Point p ){return Point(x / p.x,y / p.y);}

    double abs(){return sqrt(norm());}
    double norm(){return x * x + y * y;}

    bool operator < (const Point & p) const {
      return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
      return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b){
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a,Vector b){
  return a.x * b.y - a.y * b.x;
}

int main(){
  ll n;
  cin >> n;
  vector<Vector> p(4);
  double d1,d2;
  rep(i,n){
    rep(j,4){
      cin >> d1 >> d2;
      p[j] = Vector(d1,d2);
    }
    ll ans = 0;
    if(0 == cross(p[0] - p[1],p[2] - p[3])){
      ans = 2;
    }else if(0 == dot(p[0] - p[1],p[2] - p[3])){
      ans = 1;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3232
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules ! vec_md { ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) } ; ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] } ; ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] } ; }

#[allow(unused_macros)]
macro_rules! chmax {
    ( $ x : expr , $ y : expr ) => {
        if $x < $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        mut blocks: [(usize, usize, u64); n]
    }

    let mut dp = vec_md![0u64;n+1;20_001];
    blocks.sort_by(|&a, &b| (a.0 + a.1).cmp(&(b.0 + b.1)));
    for i in 0..n {
        let (w,s,v) = blocks[i];
        for j in 0..dp[0].len() {
            if j+w < dp[0].len() && j <= s {
                chmax!(dp[i+1][j+w], dp[i][j] + v);
            }
            chmax!(dp[i+1][j], dp[i][j]);
        }
    }
    let mut ret = 0;
    for i in 0..dp[0].len() {
        ret = std::cmp::max(ret, dp[n][i]);
    }
    println!("{}", ret);
}

Measured memory_bytes: 174332
C=input()
A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(len(A)-1):
    if C==A[i]:
        print(A[i+1])
        exit(0)







Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  l[i].append(i)
l.sort(key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l[i][2]]=BIT.sum(l[i][1]+1)-BIT.sum(l[i][0])

for i in range(q):
  print(ans[i])

Measured memory_bytes: 232524
#include <bits/stdc++.h>
#define MAXN 1000010
#define ll long long

using namespace std;

int n, m;
int t, k;
int a[MAXN], b[MAXN],c[MAXN];
int f;
int d, x, y, p, u, v;
string s;

int main() {
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 1; i <= n - 1; i++) {
		cin >> c[i];
	}
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i + 1] == a[i] + 1) {
			sum += b[a[i]] + c[a[i]];
		}
		else {
			sum += b[a[i]];
		}
	}
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 4480
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ans := 0
	var a int
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		if a%2 == 0 {
			for a%2 == 0 {
				a = a / 2
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1152
n, s = int(input()), input()
dp = [0] * (n + 1)
ans = 0
for i in range(n):
    for j in range(n - 1, i, -1):
        if s[i] == s[j]:
            dp[j + 1] = min(dp[j] + 1, j - i)
        else:
          dp[j + 1] = 0
    ans = max(max(dp), ans)
print(ans)

Measured memory_bytes: 73864
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
       	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = 0;
      	String s = br.readLine();
     	String t = br.readLine();
      	for(int i=0; i<3; i++) {
          	if(s.charAt(i) == t.charAt(i)) {
              	count++;
			}
		}
		System.out.println(count);
        
	}
}


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

int main(){
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int people = 0;
  X -= Z;
  while(X > 0){
    X -= (Y + Z);
    if (X >= 0){
      people += 1;  
    }
    
  }

  cout << people << endl;
}

Measured memory_bytes: 3552
A, B, C, K = gets.chomp.split(" ").map(&:to_i)

k = K

k -= A

if k < 0 then
  puts K
  return
end

if k == 0 then
  puts A
  return
end

k -= B

if k < 0 then
  puts K
  return
end

if k == 0 then
  puts A
  return
end

puts A - k

Measured memory_bytes: 14312
(* O(n^2) *)
let n = Scanf.scanf " %d" @@ (+) 0
let bs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let search_backi a f =
  let i = ref @@ Array.length a - 1 in
  let found = ref false in
  while not !found && !i >= 0 do if f !i a.(!i) then found := true; decr i done;
  !i + if !found then 1 else 0
let remove a i =
  let a' = Array.make (Array.length a - 1) a.(0) in
  Array.iteri (fun j x -> if j < i then a'.(j) <- x else if j > i then a'.(j - 1) <- x) a;
  a'
let rec f acc a n =
  if n = 0 then acc
  else
    let i = search_backi a (fun i x -> i + 1 = x) in
    if i = -1 then (print_endline "-1"; exit 0)
    else f (a.(i) :: acc) (remove a i) @@ n - 1
let ans = f [] bs n
let _ = ans |> List.iter @@ Printf.printf "%d\n"

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c,k,ans=0;
  cin>>n>>c>>k;
  vector<int>v(n);
  for(int i=0;i<n;++i)cin>>v[i];
  sort(v.begin(),v.end());
  for(auto it=v.cbegin();it!=v.cend();++ans){
    const int x=*it+k;
    for(int i=0;*it<=x&&i<c&&it!=v.cend();++i,++it);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
bool ans() {
    string S;
    cin >> S;
    int cnt = 0;
    for (char c : S) if (c == 'o') cnt++;
    return cnt + 15 - S.size() >= 8;
}
int main() {    
    cout << (ans() ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            Map<String, Integer> score = new HashMap<>();
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                score.put(s, score.getOrDefault(s, 0) + 1);
            }
            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                String s = in.next();
                score.put(s, score.getOrDefault(s, 0) - 1);
            }
            int ans = 0;
            for (int v : score.values()) ans = (v > ans) ? v : ans;
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
#define mod 100003
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define piiii pair<int,piii>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
#define no {cout<<"NO"<<endl;return;}
#define yes {cout<<"YES"<<endl;return;}

void solve(){
    int n,k;
    cin>>n>>k;
    long double maxx=0,sum=0;
    long double p[n+1];
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=1;i<=k;i++){
        sum+=0.5*(p[i]+1);
    }
    maxx=max(maxx,sum);
    for(int j=k+1;j<=n;j++){
        //cout<<i<<" "<<j<<endl;
        sum-=0.5*(p[j-k]+1);
        sum+=0.5*(p[j]+1);
        maxx=max(maxx,sum);
    }
    cout<<setprecision(12)<<maxx;




    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    ll a, b;
    cin >> k;
    cin >> a >> b;
    ll c = a / k;
    ll d = b / k;
    if(d > c || (a % k == 0) || (b % k == 0))
    {
        cout << "OK\n";
    }
    else
    {
        cout << "NG\n";
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

vector<ll> prime;

ll N, P;
ll memo = pow(10, 12);
bool flag = 1;

void primeenumeration(ll n) {
  FOR(i, 2, n+1) {
    if (pow(i, N) > P && flag) {
      memo = i;
      flag = 0;
    }
    if (i > 1001000) {
      break;
    }
    bool flag = true;
    FOR(j, 2, i) {
      if (j*j > i) break;
      if (i%j == 0) {
        flag = false;
        break;
      }
    }
    if (flag) prime.push_back(i);
  }
}

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

  cin >> N >> P;
  if (N == 1) {
    cout << P << endl;
    return 0;
  }

  primeenumeration(P+10);
  //for (auto&& i : prime) {
  //  cerr << i << endl;
  //}
  //cerr << endl;
  cerr << memo << endl;
  cerr << prime.size() << endl;
  cerr << *(prime.end()-1) << endl;

  ll ans = 1;
  ll tmp = P;
  ll cnt = 0;
  ll i = 0;
  for (; tmp >= prime[i];) {
    if (tmp%prime[i] == 0) {
      tmp /= prime[i];
      cnt++;
    } else {
//      cerr << i << endl;
  //    cerr << i << " " << prime[i] << " " << cnt << " " << endl;
  //    cerr << pow(prime[i], (cnt / N)) << endl;
      ans *= pow(prime[i], (cnt / N));
      i++;
      cnt = 0;
      if (memo == i) break;
    }
  }
  ans *= pow(prime[i], (cnt / N));

  cout << ans << endl;
}


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

ll sum[100001];
int main() {
	ll n;
	while (scanf("%lld", &n), n) {
		ll cnt = 0;
		rep(i, n) {
			sum[i] = cnt;
			int a; scanf("%d", &a);
			cnt += a;
		}
		sum[n] = cnt;
		ll Max = LLONG_MIN;
		rep(i, n) {
			for (int j = i + 1; j <= n; j++) {
				Max = max(Max, sum[j] - sum[i]);
			}
		}
		cout << Max << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <stdio.h>
#include <math.h>

int main(){
	int N, D, count = 0;

	scanf("%d %d", &N, &D);
	long x, y;

	for(int i=0; i<N; i++){
		scanf("%ld %ld", &x, &y);
		if(sqrt(pow(x,2)+pow(y, 2)) <= D)
			count++;
	}
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 2152
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
readString = map BS.unpack . BS.words

getIntList = readIntList <$> BS.getLine
getNString n = map readString <$> replicateM n BS.getLine

simulate (ps : pss) table_ac table_wa ac wa = do
  let f = fst ps
  let s = snd ps
  p <- VUM.read table_ac f
  if p == 0
    then do
      if s == "AC"
        then do
          wa' <- VUM.read table_wa f
          let wa'' = wa + wa'
          VUM.write table_ac f 1
          let ac' = ac + 1
          if pss == [] then return (ac', wa'') else simulate pss table_ac table_wa ac' wa''
        else do
          wa' <- VUM.read table_wa f
          VUM.write table_wa f (wa' + 1)
          if pss == [] then return (ac, wa) else simulate pss table_ac table_wa ac wa
    else do
      if pss == [] then return (ac, wa) else simulate pss table_ac table_wa ac wa

main = do
  [n, m] <- getIntList
  pss <- getNString m
  if m == 0
    then putStrLn "0 0"
    else do
      let pss' = map (\ps -> ((read (head ps) :: Int), last ps)) pss
      table_ac <- VUM.replicate (n + 1) 0 :: IO (VUM.IOVector Int)
      table_wa <- VUM.replicate (n + 1) 0 :: IO (VUM.IOVector Int)
      (ac, wa) <- simulate pss' table_ac table_wa 0 0
      putStrLn $ (show ac) ++ " " ++ (show wa)


Measured memory_bytes: 30988
n, d = gets.split.map(&:to_i)
puts n.times.map{|i| gets.split.map(&:to_i)}.combination(2).map{|a, b|
    Math.sqrt(a.zip(b).map{|a_it, b_it| (a_it - b_it) ** 2 }.inject(:+))
}.count{|val|
    val == val.to_i
}



Measured memory_bytes: 1788
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
s
'''

def solve(n,k):
	return min(n%k,abs(n%k - k))
	

N,K = list(map(int, stdin.readline().rstrip().split()))
ans = solve(N,K)
print(ans)


Measured memory_bytes: 39408
D = {}
D["a"] = input()
D["b"] = input()
D["c"] = input()

def turn(t):
  if len(D[t]) == 0:
    return t
  else:
    tmpStr = D[t][0]
    D[t] = D[t][1:]
    return turn(tmpStr)
print(turn("a").capitalize())

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 100010
#define maxm 200010
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m;
int head[maxn],nxt[maxm*2],to[maxm*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
ll A,B,C;
int fa[maxn],vis[maxn],flag;
int dis[maxn];
int find(int x)
{
    if(fa[x]==x)  return x;
    int tmp=fa[x],f=find(fa[x]);
    dis[x]^=dis[tmp];
    return fa[x]=f;
}
void work(int x,int y)
{
    int u=find(x),v=find(y);
    if(u==v)
    {
        if(dis[x]==dis[y])  flag=1;
        return;
    }
    dis[u]=(dis[x]^dis[y]^1);
    fa[u]=v;
}
int cnt;
void dfs(int x)
{
    cnt++;vis[x]=1;
    for(int i=head[x];i;i=nxt[i])
    {
        work(x,to[i]);
        if(vis[to[i]])  continue;
        dfs(to[i]);
    }
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=m;i++)
    {
        int q=read(),w=read();
        add(q,w);
        add(w,q);
    }
    for(int i=1;i<=n;i++)  fa[i]=i;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt=0;
            flag=0;
            dfs(i);
            if(cnt==1)      C++;
            else if(!flag)  A++;
            else            B++;
        }
    }
    ll ans=0;
    ans+=C*n+C*(n-C);
    ans+=B*B;
    ans+=A*A*2;
    ans+=A*B*2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
signed main(){
  long long ans,n,rec;
  cin>>n;
  ans=n-1;
	for(long long putch=2;putch*putch<=n;putch++){
      	if(n%putch==0){
	rec=putch+(n/putch)-2;
    if(rec<ans)
      ans=rec;
    }
    }
  cout<<ans<<endl;
  
  return(0);
}

Measured memory_bytes: 256
import collections
s = input()
n = len(s)
count_dict = collections.Counter(s)
p = len(count_dict)
critical = [0]*p
def manupulation(str,string,k):
        ans = ['1']*(k-1)
        for i in range(k-1):
            if string[i] == str or string[i+1] == str:
                ans[i] = str
        return "".join(ans)

def hantei(str,string,k):
    l = 1
    for i in range(k):
        if string[i] != str:
            l = 0
            break
    return l

i=0
for k1 in count_dict:
    kaisuu = 0
    k0 = k1
    string1 = s
    while hantei(k0,string1,n-kaisuu) == 0:
        string1 = manupulation(k0,string1,n-kaisuu)
        kaisuu +=1
    critical[i] = kaisuu
    i += 1
print(min(critical))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main() {
	// your code goes here
	ll h,w;
	cin>>h>>w;
	char a[h][w];
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			cin>>a[i][j];
		}
	}
	
	ll dp[h+1][w+1];
	dp[1][1]=1;
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			if(i==1&&j==1)
				continue;
			if(a[i-1][j-1]=='#')
				dp[i][j]=0;
			else
			{
				if(j>1&&i>1)
				{
					dp[i][j]=(dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
				}
				else if(i==1)
				{
					dp[i][j]=dp[i][j-1];
				}
				else if(j==1)
				{
					dp[i][j]=dp[i-1][j];
				}
			}
		}
	}
	cout<<dp[h][w];
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>

using namespace std;
int main()
{
	int a, b, c, m1, m2, m3, tmp;
	cin >> a >> b >> c;
	if (a <= b) {
		m1 = b;
		m2 = a;
		
	}
	else {
		m1 = a;
		m2 = b;

	}

	if (m2 < c) {
		m3 = m2;
		m2 = c;
		if (m2 > m1) {
			tmp = m1;
			m1 = m2;
			m2 = tmp;
		}
	}
	else {
		m3 = c;
	}
	tmp = 10 * m1 + m2 + m3;
	cout << tmp;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MOD=1000000007;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  rep(i,n-2) {
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
  } 
  cout << ans << endl;
}


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

int main(){
    int a, b, c, d=0;
    cin >> a >> b >> c;
    for( int x = a; x <= b; x++ ){
        if( c % x == 0 ){
            d++;
        }
    }
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 3100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Tuple{
    String name;
    int time;
    Tuple(String name, int time){
        this.name = name;
        this.time = time;
    }
}

class myQueue{
    int size = 100000;
    Tuple[] data;
    int head;
    int tail;

    myQueue(){
        data = new Tuple[size];
        head = 0;
        tail = 0;
    }

    void enqueue(String n, int t){
        if(isFull()){
            System.err.println("queue is full");
            return;
        }
        data[tail] = new Tuple(n,t);
        tail = (tail + 1) % size;
    }

    Tuple dequeue(){
        if(isEmpty()){
            System.err.println("queue is empty");
            return null;
        }
        Tuple answer = data[head];
        head = (head + 1) % size;
        return answer;
    }
    
    boolean isFull(){
        return head == (tail + 1) % size;
    }

    boolean isEmpty(){
        return head == tail;
    }
}
class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] input = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int q = Integer.parseInt(input[1]);
        
        myQueue mq = new myQueue();
        for(int i = 0; i < n; i++){
            String[] line = br.readLine().split(" ");
            mq.enqueue(line[0], Integer.parseInt(line[1]));
        }

        int now = 0;
        while(!mq.isEmpty()){
            Tuple process = mq.dequeue();
            if(process.time <= q){
                now += process.time;
                System.out.println(process.name + " " + now);
            }else{
                now += q;
                mq.enqueue(process.name, process.time - q);
            }
        }
    }
}


Measured memory_bytes: 69300
X, N = map(int,input().split())
if N != 0:
  ps = sorted(list(map(int,input().split())))
  # print(ps)
  min_num = 1000
  min_abs = 1000
  p_index = 0
  for i in range(0,102):
    if i == ps[p_index]:
      p_index += 1
      p_index %= N
    elif abs(i-X)<min_abs:
      min_num = i
      min_abs = abs(i-X)
  print(min_num)
else:
  print(X)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define int long long 

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

    int m=t.length();
    while(s.length()<m)
    {
        s+=s;
    }
    int n=s.length();
    s+=s;

    string S=t+'@'+s;
    int N=S.length();
    vector<int>z(N);
    int L=-1, R=-1; 
    for(int i=1; i<N; ++i)
    {
        if(i>R)
        {
            int j=i;
            while(j<N && S[j-i]==S[j])
            {
                j++;
                z[i]++;
            }
            L=i, R=j-1;
        }
        else 
        {
            if(z[i-L]<R-i+1)
            {
                z[i]=z[i-L];
                continue;
            }
            z[i]=R-i+1;
            int j=R+1;
            while(j<N && S[j-i]==S[j])
            {
                j++;
                z[i]++;

            }
            L=i, R=j-1;
        }
        // cout<<z[i]<<' ';
    }

    vector<bool>v(n);
    vector<int>cnt(n);
    int ans=0;
    for(int j=0; j<n; ++j)
    {
        if(v[j]) continue;
        int i=j;
        cnt[j]=0;
        // cout<<j<<": ";
        while(z[i+m+1]==m && !v[i])
        {
            // cout << i << ' ';
            v[i]=1;
            i=(i+m)%n;
            cnt[j]++;
        }
        // cout<<endl;
        if(i==j && z[i+m+1]==m)
        {
            cout<<-1;
            exit(0);
        }
        cnt[j]+=cnt[i];
        ans=max(ans, cnt[j]);
    }
    cout<<ans;
}

Measured memory_bytes: 32968
MOD = 10 ** 9 + 7


def main(s):
    reminder = [[(j - k) * 9 % 13 for j in range(10)] for k in range(13)]
    dp = [1] + [0] * 12
    for char in s:
        if char == "?":
            dp = [sum(dp[j] for j in k) % MOD for k in reminder]
        else:
            dp = [dp[(int(char) - k) * 9 % 13] for k in range(13)]

    return dp[5]


S = input()
print(main(S))

Measured memory_bytes: 3188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;


#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	string s;
	cin >> s;
	int cnt = 0;
	int cnt2 = 0;
	if (s[0] == 'A') {
		FOR(i, 2, s.length() - 2) {
			if (s[i] == 'C') {
				cnt++;
			}
		}
	}

	REP(i, s.length()) {
		if (s[i] >= 'a' && s[i] <= 'z') {
			cnt2++;
		}
	}

	if (cnt == 1 && cnt2 == s.length() - 2) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main() {
    ll N; cin >> N;
    ll a = 1, b = 1, c;
    for (; a <= 3500; a++) {
        for (b = a; b <= 3500; b++) {
            if (4 * a * b - N * (a + b) > 0) {
                if (a * b * N % (4 * a * b - N * (a + b)) == 0) {
                    c = a * b * N / (4 * a * b - N * (a + b));
                    goto loopend;
                }
            }
        }
    }
    loopend:
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+100;
int a[maxn],sum;
void solve(){
	int n,m;scdd(n,m);
	rep1(i,n){
		scd(a[i]);
		sum+=a[i];
	}
	int ans=0;
	rep1(i,n)
		if(a[i]>=(sum+m*4-1)/(m*4))ans++;
	if(ans>=m)
		printf("Yes");
	else printf("No");
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct city {
    struct city *zero;
    struct city *one;
} city_t;
int main(){
    city_t a, w, x, y, z, b;
    a.zero = &x;   a.one = &y;
    w.zero = &b;   w.one = &y;
    x.zero = NULL; x.one = &z;
    y.zero = &x;   y.one = NULL;
    z.zero = &w;   z.one = &b;
    b.zero = &y;   b.one = &x;
    while (1){
        char *ptr = NULL;
        size_t len = 0;
        ssize_t read;
        city_t *cur = &a;
        int i;
        read = getline(&ptr, &len, stdin);
        if (ptr[0] == '#')
            return 0;
        for (i=0;i<read; i++){
            if (ptr[i] == '0')
                cur = cur->zero;
            else if (ptr[i] == '1')
                cur = cur->one;
            if (cur == NULL)
                break;
        }
        if (cur == NULL)
            puts("No");
        else {
            if (cur == &b)
                puts("Yes");
            else
                puts("No");
        }
    }
}

Measured memory_bytes: 532
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int calc_num(string S,char c1,char c2){
    int N=S.size();
    int _N;
    int ans=0;
    if(N%2==0){
        _N=N;
    }
    else{
        _N=N-1;
    }
    for(int i=0;i<_N;i+=2){
        if(S[i]!=c1){
            ans++;
        }
        if(S[i+1]!=c2){
            ans++;
        }
    }
    if(N!=_N && S[N-1]!=c1){
        ans++;
    }
    return ans;

}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> S;
    N = S.size();
    int ans = calc_num(S,'0','1');
    ans = min(calc_num(S,'1','0'),ans);
    cout << ans << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cctype>
using namespace std;
const int N=5e5+5;
struct data
{
	double t;
	long long v;
}q[N],p;
int l=1,r=0;
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) w|=ch=='-',ch=getchar();
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
int main()
{
	int n=read();
	long long L=read(),L0=L;
	double now=0;
	while(n--)
	{
		p.t=read(),p.v=read();
		while(p.v>L)
			if(q[l].v+L<=p.v)
			{
				now-=q[l].v*q[l].t;
				L+=q[l++].v;
			}else
			{
				long long x=p.v-L;
				now-=x*q[l].t;
				L+=x;
				q[l].v-=x;
			}
		L-=p.v;
		now+=p.v*p.t;
		q[++r]=p;
		while(l<r && q[r-1].t>=q[r].t)
		{
			q[r-1].t=(q[r-1].t*q[r-1].v+q[r].t*q[r].v)/(q[r-1].v*1.0+q[r].v);
			q[r-1].v+=q[r].v;
			r--;
		}
		printf("%.7lf\n",now*1.0/(L0-L));
	}
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N;
  cin >> N;

  bool ok = false;
  for (int i = 1; i <= 9; ++i) {
    ok |= N % i == 0 && N / i <= 9;
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256