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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  vector<ll>results;
  rep(i, n){
    if(i==0){results.insert(results.begin(), a[i]);continue;}
    auto it = lower_bound(results.begin(), results.end(), a[i]);
    if( it==results.end() ){
      if(results.size()>0 && a[i]>results[results.size()-1])*prev(it)=a[i];
//      else results.insert(results.begin(), a[i]);
    }else{
      if(it==results.begin()){ results.insert(results.begin(), a[i]);
      }else{
        it--;
        *it = a[i];
      }
    }
  }
  cout<<results.size()<<endl;

  return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<utility>

using namespace std;

int main(){

 int dat[3];
 int dum;
 for(int i=0;i<3;i++) cin>>dat[i];
 for(int i=0;i<2;i++){
	for(int j=i+1;j<3;j++){
		if(dat[i]>dat[j]){
			swap(dat[i],dat[j]);
		}
	}
 }
 cout<<dat[0]<<" "<<dat[1]<<" "<<dat[2]<<endl;
 return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<cstring>
#define  si(a)       scanf("%d",&a);
#define  sl(a)       scanf("%lld",&a);
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b);
#define  queues      priority_queue
#define mod 998244353
#define mem(a)  memset(a,0,sizeof(a))
#include<vector>
typedef long long ll;
const int INF=0x3f3f3f3f;
//priority_queue<int,vector<int >,greater<int > >q;
// nth_element()
#define PI acos(-1)
using namespace std;
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main(){
int t;
cin>>t;
int sum=0;
int s[100003];
 for(int i=0;i<t;i++)
  cin>>s[i],sum+=s[i];
  sort(s,s+t);
  sum-=s[t-1];
  if(sum>s[t-1])cout<<"Yes\n";
  else cout<<"No\n";
}
/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<list>
#include<iterator>
#include<cmath>
using namespace std;

long long a[211111];
long long b[211111];
long long c = 0;

long long p1 = 0;
long long p2 = 0;

list<long long>old;

list<long long>ans;

int main()
{
	long long n;
	scanf("%lld", &n);

	for (long long i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
	}

	sort(a, a + n);
	
	for (long long i = 0; i < n; i++)
	{
		old.push_back(a[i]);
	}

	//放入最小
	ans.push_back(old.front());
	old.pop_front();
	n--;

	bool turn = true;//turn 大  ，否则 小
	while (n >= 2)
	{
		if (turn)
		{
			turn = false;
			ans.push_front(old.back());
			old.pop_back();
			n--;

			ans.push_back(old.back());
			old.pop_back();
			n--;
		}

		else
		{
			turn = true;
			ans.push_front(old.front());
			old.pop_front();
			n--;

			ans.push_back(old.front());
			old.pop_front();
			n--;
		}

	}

	if (n == 1)
	{
		ans.push_front(old.front());
	}

	for (auto it = ans.begin(); it != ans.end(); it++)
	{
		b[c++] = (*it);
	}

	for (long long i = 0; i < c - 1; i++)
	{
		long long k = b[i] - b[i + 1];

		if (k > 0)
			p1 += k;
		else
			p1 -= k;
	}


	while (!ans.empty())
		ans.pop_back();

	while (!old.empty())
		old.pop_back();


	n = c;
	c = 0;

	for (long long i = 0; i < n; i++)
	{
		old.push_back(a[i]);
	}

	//放入最大
	ans.push_back(old.back());
	old.pop_back();
	n--;

	turn = true;//turn 小  ，否则 大
	while (n >= 2)
	{
		if (turn)
		{
			turn = false;
			ans.push_front(old.front());
			old.pop_front();
			n--;

			ans.push_back(old.front());
			old.pop_front();
			n--;
		}

		else
		{
			turn = true;
			ans.push_front(old.back());
			old.pop_back();
			n--;

			ans.push_back(old.back());
			old.pop_back();
			n--;
		}

	}

	if (n == 1)
	{
		ans.push_front(old.front());
	}

	for (auto it = ans.begin(); it != ans.end(); it++)
	{
		b[c++] = (*it);
	}

	for (long long i = 0; i < c - 1; i++)
	{
		long long k = b[i] - b[i + 1];

		if (k > 0)
			p2 += k;
		else
			p2 -= k;
	}


	printf("%lld\n", max(p1, p2));

	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
	
   cin>>a>>b>>c;
  cout<<a*b/2<<endl;
	
}


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

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

    int a[n];
    int days = 0;
    for(int i=0; i<m; i++){
        cin >> a[i];
        days += a[i];
    }

    cout << (n >= days ? n-days : -1) <<  endl;
}

    


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
//template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    double sum = 0;
    for (auto &a : A) { 
        cin >> a;
        sum += a;
    }
    sum = (double)sum/N;
    double d = 10000;
    int ans = -1;
    for (int i = 0; i < N; i++) {
        double m = (double)sum-A[i];
        if (m<0)m*=-1;
        if (chmin(d, m)) ans = i;
    }
    cout << ans << endl;
    return 0;
}

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


#define int long long 

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string str; cin >> str;
	if(str == "RRR") {
		cout << 3 << endl;
	} else if(str == "SSS") {
		cout << 0 << endl;
	} else if(str == "RRS" || str == "SRR") {
		cout << 2 << endl;
	} else {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 3644
/*
“Yesterday is history, tomorrow is a mystery, today is a gift of God,
which is why we call it the present.” ― Bill Keane
*/
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGEsj
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
constexpr int MAX=3e5;
inline lli add(lli a, lli b, int mod){
	lli x=a+b;
	if(x>=mod)
		x-=mod;
	return x; 
}
inline lli mul(lli a, lli b, int mod){
	return ((a%mod)*(b%mod))%mod;	
}
inline lli sub(lli a, lli b, int mod){
	lli x=a-b;
	if(x<0)
		x+=mod;
	return x;
}
// lli powr(int a, unsigned int b, int m){
// 	a%=m;
// 	if(b==0) return 1LL;
// 	else if(b&1) return mul(a, powr(a*a, (b-1)/2, m), m);
// 	else return powr(a*a, b/2, m);
// }
lli powr(lli a, lli b, lli mod) {
	lli ans = 1;
	while(b) {
		if(b&1ll) ans*=a, ans%=mod;
		a*=a; a%=mod;
		b>>=1;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int bitcnt=0;
	for(char c: s) if(c=='1') bitcnt++;
	lli u, v;
	u=v=0;
	for(int i=n-1; i>=0; --i){
		if(s[i]=='1'){
			u=add(u, powr(2,n-i-1,bitcnt+1), bitcnt+1);
			u=u%(bitcnt+1);
			if(bitcnt-1==0) continue;
			v=add(v, powr(2,n-i-1,bitcnt-1), bitcnt-1);
			v=v%(bitcnt-1);
		}	
	}
	
	int dp[MAX]={0};
	dp[1]=1;
	dp[2]=1;
	for(int i=3; i<MAX; ++i){
		dp[i]=1+dp[i%__builtin_popcount(i)];
	}
	lli res;
	for(int i=0; i<n; ++i){
		if(s[i]=='1'){
			if(bitcnt-1==0){
				cout<<0<<endl;
				continue;
			}
			res=sub(v,powr(2,n-i-1,bitcnt-1),bitcnt-1);
			cout<<1+dp[res%(bitcnt-1)]<<endl;
		}
		else{
			res=add(u,powr(2,n-i-1,bitcnt+1),bitcnt+1);	
			cout<<1+dp[res%(bitcnt+1)]<<endl;
		}
	}
	return 0;
}


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

int main() {

    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    int pass = 0;
    int abr = 0;
    char s[n];
    scanf("%s", s);
    for(int i = 0; i < n; i++) {
    	if(s[i] == 'c') {
    		printf("%s\n", "No");
    	}else if(s[i] == 'a') {
    		if(pass < a + b) {
    			printf("%s\n", "Yes");
    			pass++;
    		}else {
    			printf("%s\n", "No");
    		}
    	}else if(s[i] == 'b') {
    		if(pass < a + b && abr < b) {
    			printf("%s\n", "Yes");
    			pass++;
    		}else {
    			printf("%s\n", "No");
    		}
    		abr++;
    	} 
    }	
}

Measured memory_bytes: 768
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;
const int INF=1<<30;

struct edge{int to,cost;};
typedef pair<int,int> P;

int V;
vector<edge> G[100];
int d[11][100];
priority_queue<P, vector<P>, greater<P> > que;

void dijkstra(int s,int a){
	
	
	for(int i=0;i<V;i++)
		d[a][i]=INF;
	que.push(P(0,s));
	d[a][s]=0;
	
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[a][v]<p.first)	continue;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			int Min = (a==0 ? d[a][v]+e.cost : min(d[a][v]+e.cost,d[a-1][v]+e.cost/2));
			if(d[a][e.to]>Min){
				d[a][e.to]=Min;
				que.push(P(d[a][e.to],e.to));
			}
		}
	}
}

int main(){
	
	int c,m,s,end;
	edge E;
	while(cin>>c>>V>>m>>s>>end,!(c==0&&V==0&&m==0&&s==0&&end==0)){
		for(int i=0;i<m;i++){
		int a,b,f;
		cin>>a>>b>>f;
		a--;
		b--;
		E.to=b;
		E.cost=f;
		G[a].push_back(E);
		E.to=a;
		G[b].push_back(E);
		}
	
	s--;
    end--;
	for(int i=0;i<=c;i++) dijkstra(s,i);
	
	cout<<d[c][end]<<endl;
	

		for(int i=0;i<100;i++)
		G[i].clear();
	}
	
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std ;
int main(){
	int n , h ;
	cin >> n >> h ;
	int s=0 ;
	for(int i=0 ; i<h ; i++){
	    int a ;
	    cin >> a ;
	    s+=a ;
	}
	if(s>=n) cout << "Yes" ;
	else cout << "No" ;
}

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

const int DIM = 1e5 + 5;

int arr[DIM];

int main(void) {
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    for (int i = 1; i <= n; ++i)
        cin >> arr[i];
    
    sort(arr + 1, arr + n + 1);
    
    int s = 0;
    for (int i = n; i > n - k; --i)
        s += arr[i];
    
    cout << s;
    return 0;
}


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

int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout << ((j<=a)^(i<=b));
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int p,q,a,n;

int search(int P,int Q,int N,int T){
  if(P*q==p*Q) return 1;
  if(P*q>p*Q) return 0;
  if(N==n) return 0;
  int ret=0;
  for(int i=T;Q*i<=a;i++){
    ret+=search(P*i+Q,Q*i,N+1,i);
  }
  return ret;
}


int main(){
  while(1){
    cin>>p>>q>>a>>n;
    int ans;
    if(p==0 && q==0 && a==0 && n==0) break;
    ans=search(0,1,0,1);
    cout<<ans<<endl;
  }

  return 0;
}




Measured memory_bytes: 2984
using System;

namespace codefestival_qual_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int pareNum = 0;
            for(int i = 0; i < N; i++){
                if(a[a[i]-1] == i+1){
                    pareNum++;
                }
            }
            Console.WriteLine(pareNum/2);
        }
    }
}

Measured memory_bytes: 18912
S = input().split()
N = int(S[0])
A = int(S[1])
B = int(S[2])
AB = A + B
DIV = int(N / AB)
MOD = N % AB
X = 0
if MOD <= A:
  X = MOD
else:
  X = A
print(A * DIV + X)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N; cin >> N;
  
  vector <int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i]; A[i]--;
  }

  int ans = 0;
  for (int i = 0; i < N; i++){
    if (A[A[i]] == i){
      ans++;
    }
  }
  cout << ans / 2 << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

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

// edit

void solve() {
    
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    if(N % 2 == 1){
        sort(all(A));
        sort(all(B));
        
        ll ans = B[N / 2] - A[N / 2] + 1;
        cout << ans << endl;

    }else{
        sort(all(A));
        sort(all(B));
        
        ll ans = (B[N / 2 - 1] + B[N/2]) - (A[N / 2 - 1] + A[N / 2]) + 1;
        cout << ans << endl;
        
    }

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 5992
#include<stdio.h>
int main()
{
    


int i,n,x=0;
scanf("%d",&n);

for(i=1;i<=9;i++)
{
    if(n%i==0 && n/i<=9)
    {
        printf("Yes\n");
        x=1;
        break;
    }
    
}


if(x==0)
    printf("No\n");

    
    
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];

  int mi = v[0];
  int cnt = 0;

  rep(i, n) {
    if (v[i] <= mi) {
      cnt++;
      mi = min(mi, v[i]);
    }
  }

  cout << cnt;
  return 0;
}


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

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

Measured memory_bytes: 3556
# include "iostream"
# include "cstdio"
# include "cstring" 

using namespace std;
 
const int maxm=100+10; 

bool  
    f[maxm],   //f[i]表示切割在j位置时1~j是否存在i字符 
    q[maxm];   //q[i]表示切割在j位置时j+1~n是否存在i字符 

int main(){
    int n, //字符串长度 
        now,  //当前不同字符数 
        ans;  //已知最大不同字符数(初始值为0) 
    register int i,j;
    char s[maxm]; 
    scanf("%d",&n);    //读入字符串的长度 
    scanf("%s",s);     //读入的字符串 
    for(i=0;i<n;i++){  //枚举切割点 
        f[s[i]-'a']=true;     
        //当前i位置的字符在f中标记为存在 
        memset(q,false,sizeof(q));    //初始化q数组 
        for(j=i+1;j<n;j++){   
            //当前j位置的字符在q中标记为存在 
            q[s[j]-'a']=true;  
        }
        now=0;    //初始化now 
        for(j=0;j<26;j++){
            if(f[j] && q[j]){    
                //如果两串中拥有相同字符那么记入到now中 
                now++; 
            } 
        } 
        ans=max(ans,now); 
        //若当前不同字符数大于已知不同字符则更新答案 
    }
    printf("%d",ans);  //打印答案 
    return 0; 
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else{if(a>b){
		printf("a > b\n");
	}else{if(a==b){
		printf("a == b\n");
	}
	}
	}
	return 0;
}

Measured memory_bytes: 1008
def main():
    import sys
    from collections import deque
    from operator import itemgetter
    b=sys.stdin.buffer
    n,d,a=map(int,b.readline().split())
    d*=2
    m=map(int,b.read().split())
    q=deque()
    popleft,append=q.popleft,q.append
    s=b=0
    for x,h in sorted(zip(m,m),key=itemgetter(0)):
        while q and q[0][0]<x:b-=popleft()[1]
        if h>b:
            t=(b-h)//a
            s-=t
            t*=a
            b-=t
            append((x+d,-t))
    print(s)
main()

Measured memory_bytes: 55752
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for i in range(M)]
lsub =[]
rsub = []

for i in range(M):
  lsub.append(LR[i][0])
  rsub.append(LR[i][1])

L = max(lsub)
R = min(rsub)

ans = min(R, N) - L + 1

if ans >= 1:
  print(ans)
  
else:
  print(0)

Measured memory_bytes: 29096
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


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


Measured memory_bytes: 256
n,k =  gets.chomp.split.map(&:to_i)

ans = 0
arr = [*0..n]
ruiseki = [0]

(n+1).times do |i|
  next if i == 0
  ruiseki << ruiseki[i-1] + arr[i]
end

k.upto(n) do |i|
  min_sum = ruiseki[i-1]
  max_sum = ruiseki[n] - ruiseki[n-i]

  ans += max_sum - min_sum + 1
end

p ans % (10**9 + 7) + 1

Measured memory_bytes: 19216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll rwpw(ll a, ll p = MOD-2){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

int main(void){
	ll n,a,b,ans,tmp=1ll,i;
	cin >> n >> a >> b;
	ans = rwpw(2ll,n);
	add_mod(ans,MOD-1);
	for(i=1ll; i<=b; ++i){
		mul_mod(tmp,(n-i+1));
		mul_mod(tmp,rwpw(i));
		if(i==a || i==b){
			add_mod(ans,MOD-tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=100010;
int n,m;
int p[N];
int h[N],tot;
struct Edge{
	int v,next;
}e[N*2];
void addEdge(int u,int v){
	e[++tot]=(Edge){v,h[u]}; h[u]=tot;
	e[++tot]=(Edge){u,h[v]}; h[v]=tot;
}
void readData(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]);
	int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		addEdge(u,v);
	}
}
bool vis[N];
int lis[N],cnt;
void extract(int u){
	vis[u]=true;
	lis[++cnt]=u;
	for(int i=h[u],v;i;i=e[i].next)
		if(!vis[v=e[i].v])
			extract(v);
}
int calc(){
	static bool exist[N];
	for(int i=1;i<=cnt;i++){
		int u=lis[i];
		exist[u]=true;
	}
	int res=0;
	for(int i=1;i<=cnt;i++){
		int u=lis[i];
		res+=exist[p[u]];
	}
	for(int i=1;i<=cnt;i++){
		int u=lis[i];
		exist[u]=false;
	}
	return res;
}
void solve(){
	int ans=0;
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			cnt=0;
			extract(i);
			ans+=calc();
		}
	printf("%d\n",ans);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 4096
#include<cstdio>

int main() {
    int a,b;
    std::scanf("%d %d",&a,&b);
        if(a < b) {
        std::printf("a < b");
    }
    else if(a > b ) {
        std::printf("a > b");
    }
    else if(a == b){
        std::printf("a == b");
    }
    std::printf("\n");
    return 0;
    }


Measured memory_bytes: 2680
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,command,x,l,r;
    multiset<int> mySet;
    multiset<int>::iterator begin;
    multiset<int>::iterator end;
    cin >> n;
    
    for(int i = 0;i < n;++i){
        cin >> command;
        if(command == 0){
            cin >> x;
            mySet.insert(x);
            cout << mySet.size() << endl;
        }else if(command == 1){
            cin >> x;
            cout << mySet.count(x) << endl;
        }
        else if(command == 2){
            cin >> x;
            mySet.erase(x);
        }
        else{
            cin >> l >> r;
            begin = mySet.lower_bound(l);
            end = mySet.upper_bound(r);
            
            for(;begin != end;++begin){
                cout << *begin << endl;
            }
        }
    }
}



Measured memory_bytes: 12360
S = input()
T = input()
stot = dict()
ttos = dict()
for s, t in zip(S, T):
    stot.setdefault(s, set())
    stot[s].add(t)
    ttos.setdefault(t, set())
    ttos[t].add(s)

ans = 'Yes'
for k, l in stot.items():
    if len(l) > 1:
        ans = 'No'
        break

for k, l in ttos.items():
    if len(l) > 1:
        ans = 'No'
        break
print(ans)


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

using namespace std;
int po2(int a)
{
    return a*a;
}
int po3(int a)
{
    return po2(a)*a;
}
int main()
{
    int n;
    scanf("%d",&n);
    int ans=n+po2(n)+po3(n);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 表の行数r、列数cの数値を取得
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();

		// 表のサイズ+1の2次元配列をつくる
		int[][] sheet = new int[r + 1][c + 1];

		// 表中の数の入力準備
		int n;
		// 合計値をsumとする
		int sum = 0;

		for (int row = 0; row < r + 1; row++) {
			for (int column = 0; column < c + 1; column++) {

				// 最終行でないときの処理
				if (!(row == r)) {
					// 最終列のときsumを2次元配列に入れる
					if (column == c) {
						sheet[row][column] = sum;
						sum = 0;
					}

					if (column < c) {
						// 表中の数の入力
						n = sc.nextInt();
						// 2次元配列に入力値nを入れる
						sheet[row][column] = n;
						// 合計値sumに入力値nを足す
						sum = sum + n;
					}
				}

				// 最終行のときの処理
				if (row == r) {
					for (column = 0; column < c + 1; column++) {
						for (row = 0; row < r + 1; row++) {
							sum = sum + sheet[row][column];
							if (row == r) {
								sheet[row][column] = sum;
								sum = 0;
							}
						}
					}
				}
			}
		}

		// 表を出力する
		for (int row = 0; row < r + 1; row++) {
			for (int column = 0; column < c + 1; column++) {
				System.out.print(sheet[row][column]);
				if (!(column == c)) {
					System.out.print(" ");
				}
				if (column == c) {
					System.out.println("");
				}
			}
		}
	}

}



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

int main() {
  double n, a = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    double p;
    string s;
    cin >> p >> s;
    if(s == "BTC")
      p *= 380000;
    a += p;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if(A+B+C>=22)
  {
    cout << "bust" << endl;
  }
  else
  {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
// 1 2 3 4 5 6 7 
// 13 12
int main(){
    long long n;
    cin>>n;
    cout<<n*(n-(long long)1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

def main():
    a = list(input())
    a.sort()
    a = ''.join(a)
    b = list(input())
    b.sort(reverse=True)
    b = ''.join(b)
    ans = [a, b]
    ans .sort()
    # print(a, b)
    if ans[0] == b:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()


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

#define int long long

// ?????????????????????
struct dijkstra {
    using p = pair<int, int>;

    struct edge {
        int to;
        int cost;
        edge(int to, int cost)
            : to(to), cost(cost) { }
    };

    vector<edge> G[100001];
    int d[100001];

    dijkstra(int V) {
        fill(d, d+V, 1e+9);
    }

    void add_edge(int s, int t, int d) {
        G[s].push_back(edge(t, d));
    }

    void run(int s) {
        d[s] = 0;
        priority_queue<p, vector<p>, greater<p>> que;
        que.push(p(0, s));
        while(!que.empty()) {
            p pi = que.top(); que.pop();
            int v = pi.second;
            if(d[v] < pi.first) continue;
            for(int i=0; i<G[v].size(); ++i) {
                edge e = G[v][i];
                if(d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(p(d[e.to], e.to));
                }
            }
        }
    }
};

signed main() {
    int V, E, r;
    cin >> V >> E >> r;
    dijkstra dij(V);
    for(int i=0; i<E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        dij.add_edge(s, t, d);
    }

    dij.run(r);
    for(int i=0; i<V; ++i) {
        if(dij.d[i]==1e+9) cout << "INF" << endl;
        else cout << dij.d[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 19408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll INF = (ll)1e17;
const int N = 5050;
ll dp[N];
int n;
int a[N];
ll A, B;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%lld%lld", &n, &B, &A);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	if (A < B) {
		reverse(a + 1, a + n + 1);
		for (int i = 1; i <= n; i++)
			a[i] = n + 1 - a[i];
		swap(A, B);
	}
	a[0] = 0;
	a[n + 1] = n + 1;
	for (int i = 0; i <= n + 1; i++)
		dp[i] = INF;
	dp[0] = 0;
	for (int l = 0; l <= n; l++) {
		ll w = 0;
		for (int r = l + 1; r <= n + 1; r++) {
			if (a[r] < a[l]) {
				w += A;
			} else {
				dp[r] = min(dp[r], dp[l] + w);
				w += B;
			}
		}
	}
	printf("%lld\n", dp[n + 1]);

	return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

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

int main()
{
    ll n,max=0,sum=0;
    cin >> n;
    vll l(n);
    rep(i,n){
        cin >> l[i];
        if(max <= l[i])max = l[i];
        sum += l[i];
    }
    if(sum - max > max)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main(){
	var h, w, b int
	fmt.Scan(&h, &w)
	A := make([][]int, h)
	for i:=0; i<h; i++{
		A[i] = make([]int, w)
	}
	x := make([]int, w)
	for i:=0; i<h; i++{
		for j:=0; j<w; j++{
			fmt.Scan(&A[i][j])
		}
	}
	for i:=0; i<w; i++{
		fmt.Scan(&x[i])
	}

	for i:=0; i<h; i++{
		b = 0
		for j:=0; j<w; j++{
			b += A[i][j] * x[j]
		}
		fmt.Println(b)
	}
}


Measured memory_bytes: 1800
S = [int(_) for _ in input()]
length = len(S)
temp = [S[0]]
for x in S[1:]:
    if(len(temp) == 0):
        temp.append(x)
    elif( temp[-1] == x):
        temp.append(x)
    else:
        temp.pop(-1)
print(length-len(temp))
        

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int a[200005];
map<int, ll> mp;
void solve() {
    cin >> n;
    rep(i, n) {
        cin >> a[i];
        ++mp[a[i]];
    }

    ll sum = 0;
    for (auto& m : mp) {
        sum += m.second * (m.second - 1) / 2;
    }

    for (auto& m : mp) {
        m.second = sum - m.second * (m.second - 1) / 2 + (m.second - 1) * (m.second - 2) / 2;
    }

    rep(i, n) cout << mp[a[i]] << endl;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 10368
import sys
sys.setrecursionlimit(10**6)
MOD = 10**9+7

def perm(num, col):
	global ans
	for i in range(num):
		ans *= col-i
		ans %= MOD
	return

n, k = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)
par = [-1 for _ in range(n)]
def dfs1(x, p):
	for v in adj[x]:
		if v == p:
			continue
		par[v] = x
		dfs1(v, x)
	return
dfs1(0, -1)

ans = k
perm(len(adj[0]), k-1)

def dfs2(x):
	if len(adj[x]) == 1:
		return
	else:
		perm(len(adj[x])-1, k-2)
		for v in adj[x]:
			if v == par[x]:
				continue
			else:
				dfs2(v)
		return

for v in adj[0]:
	dfs2(v)
print(ans)

Measured memory_bytes: 88300
import sys
input = sys.stdin.readline
from collections import deque

nn = 200200
mod = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
inv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod
for i in range(1, nn)[::-1]:
    inv[i] = fainv[i] * fa[i-1]

C = lambda a, b: fa[a] * fainv[b] % mod * fainv[a-b] % mod if 0 <= b <= a else 0

N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

BU = [1] * N
TD = [1] * N
SI = [1] * N
for i in R[::-1]:
    a = 1
    s = 1
    for j in X[i]:
        a = a * BU[j] % mod
        s += SI[j]
    SI[i] = s
    BU[i] = inv[s] * a % mod

for i in R:
    c = len(X[i])
    AL = [1] * (c + 1)
    AR = [1] * (c + 1)
    for k, j in enumerate(X[i]):
        AL[k+1] = AL[k] * BU[j] % mod
    for k, j in enumerate(X[i][::-1]):
        AR[c-k-1] = AR[c-k] * BU[j] % mod
    for k, j in enumerate(X[i]):
        TD[j] = TD[i] * AL[k] % mod * AR[k+1] % mod * inv[N - SI[j]] % mod

for i in range(N):
    print(BU[i] * fa[SI[i]] % mod * TD[i] % mod * fa[N - SI[i]] % mod * C(N-1, SI[i] - 1) % mod)

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

struct Card{ char Suit; int Value; };

void BubbleSort(struct Card A[], int N){

    Card bf;
    bool flag = true;

    while ( flag ){
        flag = false;
        for ( int i = N - 1; i >= 1; i-- ){
            if ( A[i].Value < A[i-1].Value ){
                bf     = A[i];
                A[i]   = A[i-1];
                A[i-1] = bf;
                flag = true;
            }
        }
    }
}

void SelectionSort(struct Card A[], int N){
    Card bf;
    int minj;

    for ( int i = 0; i < N; i++ ){
        minj = i;
        for ( int j = i; j < N; j++ ){
            if ( A[j].Value < A[minj].Value ) minj = j;
        }
        if ( minj != i ){
            bf = A[i];
            A[i] = A[minj];
            A[minj] = bf;
        }
    }
}

bool isStable( struct Card A[], struct Card B[], int N ){
    for ( int i = 0; i < N; i++ ){
        if ( A[i].Suit != B[i].Suit ) return false;
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    Card A[N],B[N];
    for ( int i = 0; i < N; i++ ){ 
        cin >> A[i].Suit >> A[i].Value;
    }
    for ( int i = 0; i < N; i++ ) B[i] = A[i];
    BubbleSort( A, N );
    for ( int i = 0; i < N - 1; i++ ){
        cout << A[i].Suit << A[i].Value << " ";
    }
    cout << A[N-1].Suit << A[N-1].Value << endl;
    cout << "Stable" << endl;
    SelectionSort( B, N );
    for ( int i = 0; i < N - 1; i++ ){
        cout << B[i].Suit << B[i].Value << " ";
    }
    cout << B[N-1].Suit << B[N-1].Value << endl;
    if ( isStable(A,B,N) ) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#define MN 100
#define eps 1e-10
int n,cnt,x[MN+5],y[MN+5];
const double pai=acos(-1);
double tk,k[MN+5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	if(n==2){
		puts("0.5");
		puts("0.5");
		exit(0);
	}
	for(int i=1;i<=n;i++){
		cnt=0;
		for(int j=1;j<=n;j++){
			if(i==j)continue;
			k[++cnt]=atan2(x[j]-x[i],y[j]-y[i]);
		}
		std::sort(k+1,k+1+cnt);
		bool ptd=false;
		tk=k[1]-k[cnt]+2*pai;
		if(tk>=pai-eps){
			printf("%.10lf\n",(tk-pai)/(2*pai));
			continue;
		}
		for(int j=1;j<=cnt-1;j++){
			tk=k[j+1]-k[j];
			if(tk>=pai-eps){
				printf("%.10lf\n",(tk-pai)/(2*pai));
				ptd=true;
				break;
			}
		}
		if(!ptd)printf("%.10lf\n",0.);
	}
}

Measured memory_bytes: 384
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
for i in range(n):
  q = 10**9
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)

Measured memory_bytes: 3064
n = int(input())
s = input()

def Z(S):
    A = [0]*len(S)
    i = 1; j = 0
    A[0] = len(S)
    while i < len(S):
        while i+j < len(S) and S[j] == S[i+j]:
            j += 1
        A[i] = j
        if not j:
            i += 1
            continue
        k = 1
        while len(S)-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

ans = 0

for i in range(n):
    a = Z(s[i:])
    b = [a[j] if j - a[j] >= 0 else 0 for j in range(len(s[i:]))]
    ans = max(ans,max(b))

print(ans)


'''
    if len(a) > 1:
        ind = a.index(max(a[1:]))
        if a[ind-1] > 0:
            ans = max(ans,a[ind-1] // 2)
        elif a[ind] - ind - 1 < 0:
            continue
        else:
            ans = max(ans,a[ind])
'''

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

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;

	vector<long long> a(n);
	long long dp[n];
	fill(dp,dp+n,INT_MAX);
	dp[0]=0;

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

	//do stuff

	for(int i=1;i<n;i++)
	{
		for(int j =1;j<=k;j++)
		{
			if(i-j>=0)
			{
				dp[i] = min(dp[i],dp[i-j]+abs(a[i] - a[i-j]));
			}
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
//There was and will always be only one Chester
//RIP legend
#include<bits/stdc++.h>
#define Nilesh ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
  Nilesh;
  int f[26]={0};
  string a;
  cin>>a;
  int l=a.length();
  for(int i=0;i<l;i++)
  {
      f[a[i]-'a']++;
  }
  int answer;
  int flag=0;
  for(int i=0;i<26;i++)
  {
      if(f[i]==0)
      {
          answer=i;
          flag=1;
          break;
      }
  }
  if(flag==1)
  cout<<(char)(97+answer);
  else
    cout<<"None";

}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		int a,b,c;
		Scanner scan = new Scanner(System.in);
	     a = Integer.parseInt(scan.next());
	     b = Integer.parseInt(scan.next());
	     c = Integer.parseInt(scan.next());
	    if((a<b)&&(b<c)){
		System.out.println("Yes");
		}else{
	    System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 26072
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

    ll N ;
    cin >> N ;
    vector<ll> monster(N);
    rep(i, N ) cin >> monster[i];

    ll ans = monster[0];
    rep(i, N) ans = gcd(ans, monster[i]);

    cout << ans << endl;

	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#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>;

int main()
{
    string s;
    cin >> s;
    if (s.find("7") != string::npos)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;

const int MAX_N = 500;
const int MAX_M = 100000;

ll par[MAX_N];
ll urank[MAX_N];
ll usize[MAX_N];
ll num;

void init(int n) {
  num = n;
  rep(i,n) {
    par[i] = i;
    urank[i] = 0;
    usize[i] = 1;
  }
}

ll find(ll x) {
  if(par[x] == x) {
    return x;
  }
  return par[x] = find(par[x]);
}

ll get_usize(ll x) {
  return usize[find(x)];
}

void unite(ll x,ll y) {
  x = find(x);
  y = find(y);
  if(x == y) return;

  ll s = usize[x] + usize[y];

  num--;
  if(urank[x] < urank[y]) {
    par[x] = y;
    usize[y] = s;
  } else {
    par[y] = x;
    usize[x] = s;
    if(urank[x] == urank[y]) urank[x]++;
  }
}

bool same(ll x,ll y) {
  return find(x) == find(y);
}

ll num_set() {
  return num;
}

struct edge {ll u,v,cost;};

bool comp(const edge &a,const edge &b) {
  return a.cost < b.cost;
}

ll N,M;

edge d[MAX_M];
bool notuse[MAX_M];
bool isNAB[MAX_M];


ll kruskal1 () {
  init(N);
  sort(d,d+M,comp);

  ll ret = 0;

  rep(i,M) {
    if(!same(d[i].u,d[i].v)) {
      ret += d[i].cost;
      isNAB[i] = true;
      unite(d[i].u,d[i].v);
    }
  }

  return ret;
}

ll kruskal2() {
  init(N);

  ll ret = 0;
  ll cou = 0;

  rep(i,M) {
    if(!same(d[i].u,d[i].v) && !notuse[i]) {
      ret += d[i].cost;
      unite(d[i].u,d[i].v);
      cou++;
    }
  }

  if(cou < N - 1) {
    return 1e9;
  }
  return ret;
}

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

  rep(i,M) {
    cin >> d[i].u >> d[i].v >> d[i].cost;
    d[i].u--;d[i].v--;
  }


  ll min_ = kruskal1();

  rep(i,M) {
    if(!isNAB[i]) {
      continue;
    }

    notuse[i] = true;
    ll min2_ = kruskal2();
    notuse[i] = false;

    if(min_ == min2_) {
      isNAB[i] = false;
    }
  }

  ll ans_a = 0,ans_b = 0;
  rep(i,M) {
    if(isNAB[i]) {
      ans_a++;
      ans_b += d[i].cost;
    }
  }

  cout << ans_a << " " << ans_b << endl;

  return 0;
}



Measured memory_bytes: 4348
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(X: int, Y: int):

    if abs(X-Y) <= 1:
        print("Brown")
    else:
        print("Alice")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n;

int main(){
	cin >> n;
	cout << n/2 - !(n%2) << endl;
	
	return 0;
}

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

int main()
{
  vector<int64_t> x(2), y(2);
  
  rep(i, 2) {
    cin >> x.at(i);
  }
  rep (i, 2) {
    cin >> y.at(i);
  }
  
  int64_t max, product;
  rep(i, 2) {
    rep(j, 2) {
      product = x.at(i) * y.at(j);
      if (i == 0 && j == 0) {
        max = product;
      } else if (product > max) {
        max = product;
      }
    }
  }
  
  cout << max << endl;
}

Measured memory_bytes: 3624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DColoringEdgesOnTree {
public:

    vector<P> graph[100005];
    vector<int> ans;
    vector<int> color;
    int k;

    void dfs(int p) {
      int c = 1;
      for(auto e: graph[p]) {
        if (c == color[p]) {
          c++;
        }

        ans[e.second] = c;
        color[e.first] = c;
        chmax(k, c);
        c++;

        dfs(e.first);
      }
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      k = 0;
      ans.resize(n-1);
      color.resize(n);
      rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].emplace_back(b, i);
      }

      dfs(0);

      cout << k << endl;
      for(auto e: ans) {
        cout << e << '\n';
      }

    }
};

signed main() {
  DColoringEdgesOnTree solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 6784