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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vvl a(n,vl(n));
	FOR(i,0,n) FOR(j,0,n) cin >> a[i][j];
	
	vvl b = a;

	bool ok = true;
	FOR(i,0,n) FOR(j,0,n) FOR(k,0,n) if (i != j && i != k && j != k) {
		if (a[i][j] + a[j][k] < a[i][k]) ok = false;
		if (a[i][j] + a[j][k] == a[i][k]) b[i][k] = oo;
	}
	
	if (!ok) {
		cout << -1 << endl;
		return 0;
	}

	ll res = 0;
	FOR(i,0,n) FOR(j,i+1,n) if (b[i][j] < oo) res += b[i][j];
	cout << res << endl;



}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

ll n = 0;
vll h(2000005, -1);

void insert(ll k) {
  h.at(++n) = k;
  ll i = n;
  while (i > 1 && h.at(i) > h.at(i / 2)) {
    swap(h.at(i), h.at(i/2));
    i /= 2;
  }
}

void maxHeapify(ll i) {
  ll l, r, largest;
  l = 2*i; r = 2*i+1;
  if (l <= n && h.at(l) > h.at(i)) largest = l;
  else largest = i;
  if (r <= n && h.at(r) > h.at(largest)) largest = r;

  if (largest != i) {
    swap(h.at(i), h.at(largest));
    maxHeapify(largest);
  }
}

ll extract() {
  ll tmp = h.at(1);
  h.at(1) = h.at(n--);
  maxHeapify(1);
  return tmp;
}

int main() {
  while (true) {
    string s; cin >> s;
    if (s == "end") break;
    else if (s == "insert") {
      ll k; cin >> k;
      insert(k);
    } else {
      ll e = extract();
      cout << e << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 18236
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  sort(a,a+N);
  reverse(a,a+N);

  int al = 0;
  int bo = 0;
  for(int i=0;i<N;i++){
    if(i%2==0) al += a[i];
    else bo += a[i];
  }

  cout << al - bo << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = []
u = []
for i in range(n):
    a, b = input().split()
    x += [float(a)]
    u += [str(b)]
ans = 0
for i in range(n):
    if u[i] == "JPY":
        ans += x[i]
    else:
        ans += x[i]*380000
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int n ,k, i, c, p;
int main() {
  scanf("%d%d\n", &n, &k); k = -2 * k;
  while(i++ < n)if((c = getchar_unlocked()) != p) k++, p = c;
  printf("%d", n - (k < 1 ? 1 : k));
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

void chmin(ll& a, ll b) { if (a > b) a = b; }
void chmax(ll& a, ll b) { if (a < b) a = b; }

signed main()
{
    ll N; cin >> N;
    vector<lpair> AB(N); rep(i, N) cin >> AB[i].second >> AB[i].first;

    sort(AB.begin(), AB.end());

    bool able = true;
    ll time = 0L;
    rep(i, N){
        time += AB[i].second; // 所要時間
        if (time > AB[i].first){ // 制限時刻
            able = false;
            break;
        }
    }

    if (able) puts("Yes");
    else puts("No");

    return 0;
}


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

int main()
{
  int n;
  cin>> n;
  vector<int> v(n);
  for (int i=0;i<n;i++){
    int a;
    cin>> a;
    v.at(i)=a;
  }
  
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  
  cout<< v.size() <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[111];
int main()
{
	int n,x,ans=0;
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		if(x>=a[i])
		{
			x-=a[i];
			ans++;
		}
	if(x>0&&ans==n)
		ans--;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define M2 100000007
#define F first
#define S second
#define PB push_back
#define INFL 1000000000000000000
#define INF 1000000000
string s;
bool v[500];
int main(void){
	cin>>s;
	int n=s.size();
	for(int i=n;i>=0;i--){
		char p;
		if(i==n)p='a'-1;
		else p=s[i];
		for(int j='a';j<='z';j++)v[j]=false;
		for(int j=0;j<i;j++)v[s[j]]=true;
		for(int j=p+1;j<='z';j++){
			if(v[j]==false){
				for(int k=0;k<i;k++)printf("%c",s[k]);
				printf("%c\n",j);
				return 0;
			}
		}
	}
	printf("-1\n");
}

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

int main(){
  long n,m,p[1001];
  while(cin>>n>>m,n||m){
    for(int i=1;i<=n;++i) cin>>p[i];
    p[0]=0;
    vector<long> s(0);
    for(int i=0;i<=n;++i){
      for(int j=0;j<=n;++j) s.push_back(p[i]+p[j]);
    }
    sort(s.begin(),s.end());
    long a=0;
    for(vector<long>::iterator it=s.begin();*it<m/2;++it){
      a=max(a,*it+*(upper_bound(s.begin(),s.end(),m-*it)-1));
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 17176
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,m,Max = -1,Min = 999;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> m;
        if(Max < m){Max = m;}
        if(m < Min){Min = m;}
    }
    cout << Max - Min << endl;
    return 0;
}

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

int main()
{
  int k;
  string s;
  cin>>k>>s;
  int n=s.size();
  if(n<=k)
    cout<<s<<endl;
  else
  {
    for(int i=0;i<k;i++)
      cout<<s.at(i);
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a == b) {
			System.out.println("a == b");
		} else if(a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a < b");
		}
	}
}

Measured memory_bytes: 26208
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	int N=in(),M=in();
	priority_queue<ll> Q;
	ll S=0;
	REP(i,N){
		ll V=in<ll>();
		S += V;
		Q.push(V);
	}
	REP(i,M){
		auto V=Q.top();
		Q.pop();
		S -= V;
		S += V/2LL;
		Q.push(V/2LL);
	}
	out(S);
	return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; ++i)
        cin >> l[i];
    sort(all(l));
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (l[i] != l[j] && l[j] != l[k] && l[k] < l[i] + l[j])
                    ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
int mx[100000],mi[100000];
bool k[100000]={};
bool used[100000]={};
vector<int> hen[100000];
void dfsx(int i){
  used[i]=true;
  for(int j=0;j<hen[i].size();j++){
    if(used[hen[i][j]])continue;
    
   if(!k[hen[i][j]]) mx[hen[i][j]]=min(mx[hen[i][j]],mx[i]+1);
    dfsx(hen[i][j]);
    if(!k[i])mx[i]=min(mx[hen[i][j]]+1,mx[i]);
  }
}
void dfsi(int i){
  used[i]=true;
  for(int j=0;j<hen[i].size();j++){
    if(used[hen[i][j]])continue;
     if(!k[hen[i][j]])  mi[hen[i][j]]=max(mi[hen[i][j]],mi[i]-1);
    dfsi(hen[i][j]);
   if(!k[i]) mi[i]=max(mi[hen[i][j]]-1,mi[i]);
  }
}
bool dfs(int i){
  if(mi[i]>mx[i])return false;
  used[i]=true;
  for(int j=0;j<hen[i].size();j++){
    if(used[hen[i][j]])continue;
    if(abs(mx[hen[i][j]]-mx[i])!=1)return false;
    if(!dfs(hen[i][j]))return false;
  }
  return true;
}
signed main() {
 int n;
 cin>>n;
 fill(mx,mx+n,MOD);fill(mi,mi+n,-1*MOD);
 int a,b;
 for(int i=0;i<n-1;i++){
   cin>>a>>b;
   
   hen[a-1].push_back(b-1);
   hen[b-1].push_back(a-1);

 }
 

 int K,v,p;
 cin>>K;
 for(int i=0;i<K;i++){
   cin>>v>>p;
   k[v-1]=true;
   mx[v-1]=p;
   mi[v-1]=p;
 }
 fill(used,used+n,false);
 dfsx(0);
fill(used,used+n,false);
  dfsx(0);
  fill(used,used+n,false);
 dfsi(0);
fill(used,used+n,false);
  dfsi(0);
  fill(used,used+n,false);
if(dfs(0)){
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++)cout<<mx[i]<<endl;
}else{
  cout<<"No";
 // for(int i=0;i<n;i++)cerr<<mx[i]<<endl;
}
return 0;
}


Measured memory_bytes: 12800
import java.util.*;
import java.io.*;
 
public class Main {
	public static long GCD(long a, long b) {
		if(b==0)return a;
		if(a==0)return b;
		return (a>b)?GCD(a%b, b):GCD(a, b%a);
	}
	public static long LCM(long a, long b) {
		return a*b/GCD(a, b);
	}
	public static long nCk(int n, int k) { //O(K)
		if (k > n) {
			return 0;		
		}
		long res = 1;
		for(int i = 1; i<=k; i++) {
			res = (n - k + i) * res/i;
		}
		return res;
	}
	public static long C(int a, int b, long[][] s) {
		int m = (int) 1e9 + 7;
		if (s[a][b] >= 0) {
			return s[a][b];
		} else if (a < b | a < 0 | b < 0) {
			s[a][b] = 0;
			return 0;
		} else if (a == b | b == 0) {
			s[a][b] = 1;
			return 1;
		} else {
			return s[a][b] = (C(a - 1, b, s) % m + C(a - 1, b - 1, s) % m) % m;
		}
 
	}
 
	public static void main(String[] args) throws Exception {
 
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String a=sc.next();
		StringBuilder s=new StringBuilder();
		for(int i=0;i<a.length();i++) {
			s.append('x');
		}
		System.out.println(s);
		pw.close();
		
		
	}
 
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
			
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
 
		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
	}
	static class pair implements Comparable<pair>  {
		int x;
		int y;
		public pair(int x,int y) {
			this.x=x;
			this.y=y;
		}
		public String toString(){
			return x+" "+y;
		}
		public int compareTo(pair other) {
			if(this.x==other.x) {
				return this.y-other.y;
			}
			else {
				return this.x-other.x;
			}
		}
	}
 
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;

int W, H, x, y, r;

signed main()
{
    cin >> W >> H >> x >> y >> r;
    if(0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

/*



*/



Measured memory_bytes: 3104
#include<stdio.h>
#include<string.h>
int main(void){
  int n,i,count=0;
  scanf("%d",&n);
  char a[n];
  scanf("%s",a);
  for(i=2;i<n;i++){
    if(a[i-2]=='A'&&a[i-1]=='B'&&a[i]=='C') count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
(function(input) {
    var p = input.split(' ').map(Number);
    var x = p.shift();
    var y = p.shift();
    console.log(greatestCommonDevisor(x, y));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function greatestCommonDevisor(x, y) {
    return Math.max.apply(null, commonDevisor(x, y));
}

function commonDevisor(x, y) {
    if (x > y) {
        x = x % y;
    } else if (x < y) {
        var tmp = y;
        y = x;
        x = tmp % x;
    }
    var a = [];
    for (var i = 1; i <= x; i++) {
        if (x % i === 0 && y % i === 0) {
            a.push(i);
        }
    }
    return a;
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, tmp1, tmp10, tmp100;
  cin >> N;
  tmp100 = N / 100;
  tmp10 = N - (100 * tmp100);
  tmp10 /= 10;
  tmp1 = N - (100 * tmp100) - (10 * tmp10);
  if (tmp100 == 7) {
    printf("Yes\n");
  } else if (tmp10 == 7) {
    printf("Yes\n");
  } else if (tmp1 == 7) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
	int i,j,count=0,m=0,len;
	char s[100],t[100],temp;
	scanf("%s %s",&s,&t);
	len = strlen(s);

	while(m<len){
		count=0;
		temp=s[0];
		for(i=0;i<=len-2;i++){
			s[i]=s[i+1];
		}
		s[len-1]=temp;
		for(j=0;j<=len-1;j++){
			if(s[j]==t[j])count++;
		}
		if(count==len)break;
		m++;
	}
	printf(count==len?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string s;
  cin >> s;
  
  sort(s.begin(), s.end());
  cout << (s == "abc" ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
#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
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#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>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
FO
void solve(){
    ull N;
    cin>>N;
    string ans="";
    string s="abcdefghijklmnopqrstuvwxyz";


    while(N){
        N--;
        ans=s[N%26]+ans;
        //cout<<ans<<endl;
        N/=26;
    }
    cout<<ans;
    return;
}
int main(){
    //IO FO
    //TEST
    solve();

    return(0);
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define int long long int

using namespace std;
typedef pair<int, int> PII;
typedef pair<PII, int> PPI;
typedef pair<int, PII> PIP;
typedef pair<PII, PII> PPP;
typedef vector<PII> VP;
typedef VP::iterator VPI;
typedef vector<int> VI;
const int INF = 3e18;
const double PI = acos(-1);
const int MOD = 1e9 + 7;

int n, x;
int a[2010];
int ans = INF;

int dp[2010][4010];

signed main()
{
  cin >> n >> x;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }

  for(int i = 1; i <= n; i++){
    dp[i][n + i] = a[i];
    for(int j = n + i - 1; j >= i; j--){
      dp[i][j] = min(dp[i][j + 1], a[j % n ? j % n : n]);
    }
  }

  for(int i = n; i >= 1; i--){
    int sum = 0;
    for(int j = 1; j <= n; j++){
      sum += dp[j][i + j];
    }
    ans = min(sum + x * (n - i), ans);
  }

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


Measured memory_bytes: 39552
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int cnt=0;
int A[MAX], L[MAX/2+2],R[MAX/2+2];

void merge(int A[], int left, int mid, int right){
 
  int i,j,k, sw=0;
  int n1 = mid - left;
  int n2 = right - mid;
  /* L[0...n1], R[0...n2] を生成 */
  for (i = 0; i<n1; i++)
    L[i] = A[left + i];
  for (i = 0; i < n2; i++)
    R[i] = A[mid + i];
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  for (k = left; k<right; k++){
    cnt++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else {
      A[k] = R[j];
      j = j + 1;
    }
  }
}

void mergeSort(int A[], int left, int right)
{
  if (left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}


void print(int A[], int N){
  int i;
  for ( i = 0; i < N; i++ ){
    if (i) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
}

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

  mergeSort(A,0,n);

  print(A,n);
  
  return 0;
}



Measured memory_bytes: 5672
#include <stdio.h>

int main(){
  
    int n;
    int i;
    int a[250000];

	scanf("%d", &n);
  
    int b[250000] = {};
  
    for(i=0; i<n-1; i++){
    	scanf("%d ", &a[i]);
    }
 	
    for(i=0; i<n-1; i++){
    	b[(a[i]-1)]++;
    }
     
    for(i=0; i<n; i++){
    	printf("%d\n", b[i]);
    }
  
    return 0;
}

Measured memory_bytes: 3460
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, i, j, k, a, b;
	cin >> n >> m;
	vector<bool> ca(n + 1, false), cb(n + 1, false);
	while (m--) {
		cin >> a >> b;
		if (a > b) swap(a, b);
		if (a == 1) ca[b] = true;
		if (b == n) cb[a] = true;
	}
	
	bool valid = false;
	for (i = 1; i <= n; i++) {
		if (ca[i] && cb[i]) {
			valid = true;
		}
	}
	if (valid) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";

	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);
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }
    int C = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int S = 0;
            for (int k = 0; k < D; k++) {
                S += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            int L = 0, H = 1e9;
            while (H - L > 1) {
                int M = (L + H) / 2;
                if (M * M <= S) {
                    L = M;
                } else {
                    H = M;
                }
            }
            if (L * L == S) {
                C++;
            }
        }
    }
    cout << C;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int nmax=2e6+5;
const int mod=1e9+7;
int fact[nmax+1],invfact[nmax+1];
int modpow(int x,int y){
  int ans=1;
  while(y){
   if(y&1)ans=(1LL*ans*x)%mod;
   x=(1LL*x*x)%mod;
   y>>=1;
  }
  return ans;
}
int nCr(int n,int r){
  if(r>n)return 0;
  return (1LL*( (1LL*fact[n]*invfact[r])%mod )*invfact[n-r])%mod;
}  
void preprocess(){
 fact[0]=1;
 for(int i=1;i<=nmax;i++){
   fact[i]=(1LL*i*fact[i-1])%mod;
 }
 invfact[nmax]=modpow(fact[nmax],mod-2);
 for(int i=nmax-1;i>=0;i--){
   invfact[i]=(1LL*(i+1)*invfact[i+1])%mod;
 }
}  
int main()
{
  int r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  preprocess();
  long long ans=0;
  for(int i=r1;i<=r2;i++){
    ans+=nCr(i+c2+1,i+1);
    ans-=nCr(i+c1,i+1);
    ans=(ans+mod)%mod;
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 16000
#include<stdio.h>
int main(){
int a,b,c,d;
while(1){
scanf("%d %d",&a,&b);
if(a==0&&b==0)
break;
for(c=0;c<a;c++){
for(d=0;d<b;d++){
	if(c%2==0){
		if(d%2==0)
printf("#");
else
printf(".");
	}
		if(c%2==1){
		if(d%2==0)
printf(".");
else
printf("#");
	}
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#define MOD	10000
#define INF 123456789

long long int N, K, A[112], B[112];
long long int pasta[112], dp[112][3][2], ans = 0;

int main(void) {
	scanf("%lld%lld", &N, &K);
	for (int i = 0; i < K; ++i) { scanf("%lld%lld", &A[i], &B[i]); }

	for (int i = 0; i < N; ++i) { for (int j = 0; j < 3; ++j) { for (int k = 0; k < 2; ++k) { dp[i][j][k] = INF; } } }
	for (int i = 0; i < K; ++i) { pasta[A[i] - 1] = B[i]; }
	if (pasta[0] == 0) {
		for (int j = 0; j < 3; ++j) {
			dp[0][j][0] = 1;
			dp[0][j][1] = 0;
		}
	}
	else {
		for (int j = 0; j < 3; ++j) { dp[0][j][0] = dp[0][j][1] = 0; }
		dp[0][pasta[0] - 1][0] = 1;
	}

	// DP
	for (int i = 1; i<N; i++) {
		if (pasta[i] == 0) {
			dp[i][0][0] = (dp[i - 1][1][0] + dp[i - 1][1][1] + dp[i - 1][2][0] + dp[i - 1][2][1]) % MOD;
			dp[i][1][0] = (dp[i - 1][0][0] + dp[i - 1][0][1] + dp[i - 1][2][0] + dp[i - 1][2][1]) % MOD;
			dp[i][2][0] = (dp[i - 1][1][0] + dp[i - 1][1][1] + dp[i - 1][0][0] + dp[i - 1][0][1]) % MOD;
			dp[i][0][1] = dp[i - 1][0][0] % MOD;
			dp[i][1][1] = dp[i - 1][1][0] % MOD;
			dp[i][2][1] = dp[i - 1][2][0] % MOD;
		}
		else {
			for (int j = 0; j<3; j++) {
				if (j == pasta[i] - 1) {
					dp[i][j][0] = (dp[i - 1][0][0] + dp[i - 1][0][1] + dp[i - 1][1][0] + dp[i - 1][1][1] + dp[i - 1][2][0] + dp[i - 1][2][1] - dp[i - 1][j][0] - dp[i - 1][j][1]) % MOD;
					dp[i][j][1] = dp[i - 1][j][0];
				}
				else {
					dp[i][j][0] = dp[i][j][1] = 0;
				}
			}
		}
	}

	for (int j = 0; j < 3; ++j) {
		for (int k = 0; k < 2; ++k) {
			ans += dp[N - 1][j][k];
		}
	}
	printf("%lld\n", ans % MOD);
	return 0;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const int N = 500100;
const int oo = 1e9;

string s;

int main() {
	cin >> s;
	for (int i = 0; i+8 < s.size(); ++i){
		printf("%c", s[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[50],b[50],c[50],n;
  a[50]=0;
  b[50]=0;
  c[50]=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    //cout << "a" << i << "=" << a[i] << endl;
  }
  for(int i=1;i<=n;i++){
    cin >> b[i];
    //cout << "b" << i << "=" << b[i] << endl;
  }
  for(int i=1;i<=n-1;i++){
    cin >> c[i];
    //cout << "c" << i << "=" << c[i] << endl;
  }
  int sum=0;
  for(int i=0;i<n;i++){
    //cout << b[a[i]] << endl;
    sum+=b[a[i]];
    if(a[i+1]-a[i]==1) sum+=c[a[i]];
    //cout << sum << endl;
  }
  cout << sum << endl;
  return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans = 0,T;
void dfs(long long x,bool a,bool b,bool c) //a,b,c´ú±í7,5,3³öÏÖµÄ±êÖ¾Î» 
{//dfsÃ¶¾ÙËùÓÐ´øÓÐ357µÄÊý×é£¬Ê±¼ä¸´ÔÓ¶È3^10 
	 if(x > T) return;
	 if(a&&b&&c) ans++;
	 x *= 10;
	 dfs(x+7,true,b,c);
	 dfs(x+5,a,true,c);
	 dfs(x+3,a,b,true);
}
int main() {
	cin>>T;
	dfs(0,0,0,0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
res = []
for p in range(x):
	for q in range(y):
		if (p+1)*(q+1) > k:
			break
		for r in range(z):
			if (p+1)*(q+1)*(r+1) > k:
				break
			res.append(A[p]+B[q]+C[r])
res.sort(reverse=True)
for i in res[:k]:
	print(i)

Measured memory_bytes: 8708
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/math/common_factor.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;
using namespace boost::numeric::ublas;

int main() {
	long long A, B;

	cin >> A >> B;

  long long r = (A + B);
  if (r % 2LL)
	cout << "IMPOSSIBLE" << endl;
  else
    	cout << r / 2LL << endl;


	return 0;
}


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

const int MAX = 100;
const int MAX_W = 100000;
typedef long long llong;

typedef struct _Baggage {
    int w;
    llong v;
} Baggage;

int N, W;
vector<Baggage> wv(MAX);
llong memo[MAX + 1][MAX_W + 1];

llong rec(int n, int s)
{
    llong ans = 0;
    if (memo[n][s] >= 0) {
        return memo[n][s];
    }
    
    if (n == N) {
        ans = 0;
    } else if (s < wv[n].w) {
        ans = rec(n + 1, s);
    } else {
        ans = max(rec(n + 1, s), rec(n + 1, s - wv[n].w) + wv[n].v);
    }
    
    memo[n][s] = ans;
    
    return ans;
}

void solve()
{
    memset(memo, -1, sizeof(memo));
    cout << rec(0, W) << endl;
}

int main(int argc, const char * argv[]) {
    cin >> N >> W;
    
    for (int i = 0; i < N; i++) {
        cin >> wv[i].w >> wv[i].v;
    }
    
    solve();
    
    return 0;
}


Measured memory_bytes: 79232
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    int N;
    std::cin >> N;
    std::vector<std::pair<int, std::pair<std::string, int>>> restaurant(N);
    for (int i = 0; i < N; ++i) {
        std::string S;
        int P;
        std::cin >> S >> P;
        restaurant[i] = std::make_pair(i, std::make_pair(S, P));
    }
    auto comp = [](const auto& a, const auto& b) {
        return (a.second.first == b.second.first) ? a.second.second > b.second.second:a.second.first < b.second.first;
    };
    std::sort(restaurant.begin(), restaurant.end(), comp);
    for (int i = 0; i < N; ++i) {
        std::cout << restaurant[i].first+1 << "\n";
    }

}

Measured memory_bytes: 256
#include <stdio.h>
#define N 250


int main(){
  int id[N];
  int i;
  int n;
 

  scanf("%d",&n);
  for(i=1; i <=n; i++){
    scanf("%d",&id[i]);
  }

  for(i=1; i <= n; i++){
    printf("node %d: key = %d, ",i,id[i]);
    if((i/2) >=1){
      printf("parent key = %d, ",id[i/2]);
    }
    if(2*i <=n){
	printf("left key = %d, ",id[2*i]);
      }
    if(2*i+1 <= n){
      printf("right key = %d, ",id[2*i+1]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <sstream>
#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 int
#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;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
 
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  bool a[16080];
  bool b[16080];
 
  a[0]= b[0] = true;
 
  
  string str;cin >> str;
  str+='T';
  vector<ll>s;
  ll x,y ; cin >> x >> y;
 
  vector<ll> xx, yy;
 
  ll co=0;
  rep(i,str.size()){
    if(str[i]!='T')co++;
    else {s.pb(co); co=0;}
  }
  
  if(s.size()==0){
    if((x==0)&&(y==0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  
 
  rep(i,s.size()){
    if(i%2==0) xx.pb(s[i]);
    else yy.pb(s[i]);
  }
  
  x -= xx[0];
  xx.erase(xx.begin()+0);
 
  xx.pb(abs(x)); yy.pb(abs(y));
  
  sort(rall(xx));  sort(rall(yy));
 
 
  ll sumx = 0; rep(i,xx.size()) sumx += xx[i];
  ll sumy = 0; rep(i,yy.size()) sumy += yy[i];
 
  x = 0;
  rep(i,xx.size()){
    for(ll j = x ; j >= 0; j-- )
      if(a[j]) 
	a[j+xx[i]] = true;
      
    
    x+= xx[i];
  }
 
  y = 0;
  rep(i,yy.size()){
    for(ll j  = y;  j >= 0; j--)
      if(b[j])
	b[j+yy[i]] = true;
    
    
    y+=yy[i];
  }
 
  if(((sumx%2)==0) && ((sumy%2)==0)){
    if(a[sumx/2] && b[sumy/2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
 
  cout << "No" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void) {
	char s[100000];
	scanf("%s", s);
	int i;
	for (i = 0; s[i] != '\0'; i++) ;
	int j;
	for (j = 0; j < i; j++) if (s[j] == 'a') break;
	if (j == i) {
		printf("a");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'b') break;
	if (j == i) {
		printf("b");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'c') break;
	if (j == i) {
		printf("c");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'd') break;
	if (j == i) {
		printf("d");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'e') break;
	if (j == i) {
		printf("e");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'f') break;
	if (j == i) {
		printf("f");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'g') break;
	if (j == i) {
		printf("g");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'h') break;
	if (j == i) {
		printf("h");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'i') break;
	if (j == i) {
		printf("i");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'j') break;
	if (j == i) {
		printf("j");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'k') break;
	if (j == i) {
		printf("k");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'l') break;
	if (j == i) {
		printf("l");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'm') break;
	if (j == i) {
		printf("m");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'n') break;
	if (j == i) {
		printf("n");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'o') break;
	if (j == i) {
		printf("o");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'p') break;
	if (j == i) {
		printf("p");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'q') break;
	if (j == i) {
		printf("q");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'r') break;
	if (j == i) {
		printf("r");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 's') break;
	if (j == i) {
		printf("s");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 't') break;
	if (j == i) {
		printf("t");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'u') break;
	if (j == i) {
		printf("u");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'v') break;
	if (j == i) {
		printf("v");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'w') break;
	if (j == i) {
		printf("w");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'x') break;
	if (j == i) {
		printf("x");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'y') break;
	if (j == i) {
		printf("y");
		return 0;
	}
	for (j = 0; j < i; j++) if (s[j] == 'z') break;
	if (j == i) {
		printf("z");
		return 0;
	}
	printf("None");
	return 0;
}

Measured memory_bytes: 256
I=lambda:[int(i)for i in input().split()];F=1<<65;r=range;n,m=I();X=set([0,F,-F]);Y=set(X);R=[((-F,F),F),((-F,F),-F)];H=[(F,(-F,F)),(-F,(-F,F))]
for i in r(n):a,b,c=I();R.append(((a,b),c));Y.add(c);X.add(a);X.add(b)
for i in r(m):a,b,c=I();H.append((a,(b,c)));X.add(a);Y.add(b);Y.add(c)
s=dict(enumerate(sorted(X)));K=len(s);t=dict(enumerate(sorted(Y)));L=len(t);h=dict((s[i],i)for i in s);w=dict((t[i],i)for i in t);V=[[0]*-~K for i in r(L+1)];U=[i[:]for i in V];v=[i[:]for i in V];q=[(h[0],w[0])];v[w[0]][h[0]]=1;z=0
for (a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(L+1):
 for j in r(K):
  U[i][j+1]+=U[i][j]
for d,(e,f) in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for j in r(K+1):
 for i in r(L):
  V[i+1][j]+=V[i][j]
while q:
 x,y=q.pop();z+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  k=0;c=x+e;d=y+f
  if(0<=c<K)*(0<=d<L)*v[d][c]==0:k=U[-~f//2+y][x]==0if f!=0else V[y][-~e//2+x]==0
  if k:q.append((c,d));v[d][c]=1
if z>F:z='INF'
print(z)

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

int main() {
    long long A, B, C, X, Y = 0;
    cin >> A >> B >> C >> X >> Y;
    long long s1 = 0, s2 = 0, s3 = 0, s4 = 0;
    if(X > Y) {
        s3 = 2 * Y * C + (X - Y) * A;
        s4 = 2 * X * C;
    } else {
        s3 = 2 * X * C + (Y - X) * B;
        s4 = 2 * Y * C;
    }
    s1 = A * X + B * Y;
    s2 = A * X + B * Y;
    long long min = s1;
    if(min > s2) min = s2;
    if(min > s3) min = s3;
    if(min > s4) min = s4;
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


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

using namespace std;


#define PI 3.14159265
#define int long long


bool is(string s){
	for(char c : s){
		if(c != 'A' and c != 'C' and c != 'G' and c != 'T'){
			return false;
		}
	}

	return true;
}



main(){


	string s; cin >> s;

	int n = s.size();


	int record = 0;
	for(int i = 0; i < n; i++){
		for(int j = i; j < n; j++){
			if(is(s.substr(i, j - i + 1))){
				record = max(record, j - i + 1);
			}
		}
	}


	cout << record << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
hl = list(map(int, input().split()))

hl[0] -= 1
for i in range(1,n):
    if hl[i-1] <= hl[i]-1:
        hl[i] -= 1

    if hl[i-1]>hl[i]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 63984
#include<bits/stdc++.h>
#include <ext/rope>
 
#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
 
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))
 
#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf
 
#define ll  long long
#define ull unsigned long long
 
#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;
 
int main()
{
     IOS
     ll a,f;
     long double b,m,g;
     cin>>a>>b;
     f = (a*b)+.001;
     
     cout<<f<<endl;
     return 0;
}

Measured memory_bytes: 3744
#include<stdio.h>

void print(int *a, int N)
{
	for (int i = 0; i < N; i++)
	{
		if (i)
			printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

void insertionSort(int *a, int N)
{
	int i, j, v;
	for (i = 1; i < N; i++)
	{
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v)
		{
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		print(a, N);
	}
}

int main()
{
	int N;
	int a[101];
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", &a[i]);
	print(a, N);
	insertionSort(a, N);
}


Measured memory_bytes: 2092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

const int MAXN = 100;
const int MAXV = 1e5;
const int INF = 0x3f3f3f3f;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

int dp[MAXV + 10];
int w[MAXN], val[MAXN], n, W;

inline void solve() {
	n = read<int>(); W = read<int>();
	for(int i = 1; i <= n; ++i)
		w[i] = read<int>(),
		val[i] = read<int>();
	
	memset(dp, 0x3f, sizeof dp);
	dp[0] = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = MAXV; j >= val[i]; --j)
			chkmin(dp[j], dp[j - val[i]] + w[i]);
	
	for(int i = MAXV; ; --i) 
		if(dp[i] <= W) { printf("%d\n", i); return ;}
}

int main() {

	solve();

	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    int n;
    cin>>n;
    n=n%1000;
    if(n==0)
    cout<<0<<endl;
    else 
    cout<<1000-n<<endl; 
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	string s, t;
	cin >> s >> t;
	
	int ans = 1000;
	for(int i=0 ; i<s.size()-t.size()+1 ; ++i){
		int cnt=0;
		for(int j=0 ; j<t.size() ; ++j){
			cnt += t[j] != s[i+j];
		}
		ans = min(ans, cnt);
	}
	
	cout << ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, K);
  double ans = 0;
  FORIN(i, 1, N + 1) {
    double per = 1.0 / N;
    int now = i;
    while (now < K) {
      now *= 2;
      per /= 2.0;
    }
    ans += per;
  }
  printf("%1.10f", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
#define lp(i,n) for(ll i = 0;i < ll(n);i++)
#define rlp(i,n) for(ll i = ll(n);i >= 0;i--)
#define rg(i,a,b) for(ll i = ll(a);i <= ll(b);i++)
#define wh(t) while(t)
#define re return
#define pb push_back
#define sz(s) (ll)(s.size())
#define fx(n) fixed<<setprecision(n)
#define NeverGiveUp ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
/*freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);*/
using namespace std;
/*ll mx = INT_MIN;
ll mn = INT_MAX;*/
/*ll xd,dx[4]={1,0,-1,0};
ll yd,dy[4]={0,1,0,-1};
bool valid(ll xd,ll yd,ll n,ll m){return xd>-1&&xd<n&&yd>-1&&yd<m;}*/
const int sz = 2e6+5;
const ll md = 1e9+7;
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
ll n,a[sz],g2,g,l,v[sz],x,y;bool f;
void fac(ll n){
        for(int i=1;i*i<=n;i++){
            if(!(n%i)){
                x=i;
                y=n/i;
                if(x==y){
                    x=i;
                    y=1;
                }
                if(x!=1){
                    if(v[x]){
                        f=1;
                        return;
                    }
                    v[x]++;
                }
                if(y!=1){
                    if(v[y]){
                        f=1;
                        return;
                    }
                    v[y]++;
                }
            }
        }
}
int main()
{
    NeverGiveUp
    cin>>n;
    lp(i,n)cin>>a[i];
    /*lp(j,n){
        fac(j);
    }*/
    g2=a[0];
    fac(0);
    for(int i=1;i<n;i++){
        if(!f)fac(a[i]);
        g2=__gcd(g2,a[i]);
    }
    //cout<<l<<' '<<mul<<'\n';
    if(!f)cout<<"pairwise coprime";
    else if(g2==1)cout<<"setwise coprime";
    else cout<<"not coprime";
    re 0;
}


Measured memory_bytes: 12004
#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<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

vt GCD(vt a, vt b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main() {
	ll k;
	cin >> k;
	ll s = 0;
	reps(a, 1, k + 1) {
		reps(b, 1, k + 1) {
			reps(c, 1, k + 1) {
				ll x = GCD(b, c);
				ll y = GCD(x, a);
				s += y;
			}
		}
	}
	cout << s;
	return 0;
}

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

using namespace std;
using ll = long long;

ll gcd(ll a,ll b){
    while(a&&b){
        if(a>b) a = a%b;
        else b = b%a;
    }
    return a+b;
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

int main()
{
    int a, b; cin >> a >> b;
    cout << lcm(a,b) << endl;
}

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

signed main() {
  string s, t;
  cin >> s >> t;
 
  static int cs[101010], ct[101010];
  cs[0] = ct[0] = 0;
  for (int i = 1; i <= s.size(); i++) {
    cs[i] += cs[i - 1];
    if (s[i - 1] == 'A') {
      cs[i] += 2;
    } else {
      cs[i]++;
    }
    cs[i] %= 3;
  }
 
  for (int i = 1; i <= t.size(); i++) {
    ct[i] += ct[i - 1];
    if (t[i - 1] == 'A') {
      ct[i] += 2;
    } else {
      ct[i]++;
    }
    ct[i] %= 3;
  }
 
  int q;
  cin >> q;
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((cs[b] - cs[a - 1] + 3) % 3 == (ct[d] - ct[c - 1] + 3) % 3) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 1664