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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> h(N + 1, 0);
    rep(i, N) cin >> h[i];
    int l, r, min_val;
    int cnt = 0;
    while (1)
    {
        l = 0;
        min_val = 1000;
        rep(i, N + 1)
        {
            if (h[i] == 0)
            {
                r = i;
                reps(j, r, l)
                {
                    h[j] -= min_val;
                }
                if (l != r)
                {
                    cnt+=min_val;
                    min_val = 1000;
                }
                l = i + 1;
            }
            else
            {
                min_val = min(min_val, h[i]);
            }
        }

        if (accumulate(h.begin(), h.end(), 0) == 0)
        {
            break;
        }
    }
    cout << cnt << endl;
 //   system("pause");
    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<int> a(9);
        for(int i = 0; i < 9; ++i){
            cin >> a[i];
        }
        cout << n - accumulate(begin(a), end(a), 0)  << "\n";
    }
    return 0;
}


Measured memory_bytes: 3100
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;
string s;
int main() {

	cin>>s;
	int ans=0;
	int a0,a1,a2,a3;

	for(a0=0;a0<s.size();a0=a3){
		for(a1=a0;s[a1]=='J';a1++);
		for(a2=a1;s[a2]=='O';a2++);
		for(a3=a2;s[a3]=='I';a3++);
		if(a1-a0>=a2-a1&&a2-a1<=a3-a2)ans=max(ans,a2-a1);

	}

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

Measured memory_bytes: 3940
//https://atcoder.jp/contests/abc137/tasks/abc137_a
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#define aakriti long long int
using namespace std;
int main()
{
	aakriti a, b;
	cin >> a >> b;
	vector<int> V(3);
	V[0] = a * b;
	V[1] = a - b;
    V[2] = a + b;
	sort(V.begin(), V.end());
	cout << V[2];
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import defaultdict

def main():
	n,m=MI()
	A=[0]+LI()

	for i in range(n):
		A[i+1]+=A[i]
		A[i+1]%=m
	#print(A)

	d=defaultdict(int)

	for i in A:
		d[i]+=1
	#print(d)

	ans=0
	for k,v in d.items():
		ans+=v*(v-1)//2
	print(ans)











if __name__ == "__main__":
	main()


Measured memory_bytes: 19892
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

n,x,c = Ri()

print(ceil(n/x) * c)


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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;
int main() {
  int N;
  string res;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  
  cin >> N;
  
  for (int i=0; i<N; ++i){
    cin >> res;
    if (res == "AC") {
      ++ac;
    }
    else if (res == "WA") {
      ++wa;
    }
    else if (res == "TLE") {
      ++tle;
    }
    else if (res == "RE") {
      ++re;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main()
{
	int kaisuu = 0;
	int tasu = 0;
	cin >> kaisuu >> tasu;
	int kazu = 0;
	kazu = 1;
	for (int i = 0;i <= kaisuu - 1;i++) {
		if (kazu * 2 <= kazu + tasu) {
			kazu = kazu * 2;
		}
		else {
			kazu += tasu;
		}
	}
	cout << kazu << endl;
	return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

ll findroot(ll x)
{
	ll lo=0,hi=(ll)sqrtl(x)+10,mid,ans=0;
	while(lo<=hi)
	{
		mid=(lo+hi)/2;
		if(mid*mid <= x)
		{
			lo=mid+1;
			ans=mid;
		}
		else hi=mid-1;
	}
	return ans;
}

void solve()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int cnt=0;
		for(int x=1;x*x<i;x++)
		for(int y=1;x*x+y*y+x*y<i;y++)
		{
			int rem=i-(x*x+y*y+x*y);
			int sum=x+y;
			int underroot=sum*sum+4*rem;
			int root=findroot(underroot);
			if(root*root != underroot || sum>=root) continue;
			if((-sum+root)%2) continue;
			cnt++;
		}
		cout<<cnt<<'\n';
	}
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3536
(let ((n (read))
      (a (make-array 1 :element-type 'integer
                       :initial-element 0
                       :adjustable t
                       :fill-pointer 1))
      (flg 0))
     (loop repeat n do
           (vector-push-extend (read) a))
     (dotimes (i (1+ n))
       (if (not (= (aref a i) i)) (incf flg)))
     (princ (if (or (= flg 2) (= flg 0)) "YES" "NO")))

Measured memory_bytes: 16356
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
const int maxn=2e5+7;
int a[maxn],b[maxn];
long long sum1[maxn],sum2[maxn];
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=m;i++) {
	cin>>b[i];
	sum2[i]=sum2[i-1]+1ll*b[i]; 
	}
	for(int i=1;i<=n;i++) sum1[i]=sum1[i-1]+1ll*a[i];
	int d=0;
	int t=m;
	for(int i=0;i<=n;i++){
	if(sum1[i]>k ) break;
	while(t>0&&sum1[i]+sum2[t]>k) t--;
	d=max(d,i+t);
	 }
  cout<<d<<endl;
} 
	
	
	



Measured memory_bytes: 8308
a,b=input().split()
c=input()
a=int(a)
b=int(b)
d=0
if c[a]=="-":
  for i in range(a+b+1):
    if c[i]=="-":
      d=d+1
  if d==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

int32_t main() { 
    boost;
    int n;
    cin>>n;
    int cur = 100;
    int ans=0;
    while(cur<n){
    	cur += cur/100;
    	ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef vector<int>      vi;
typedef vector<bool>     vb;
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

int n,k;
vector<int> a;

bool ok(int md){
	int cnt = 0;
	for(int  i = 0; i < n; i++){
		cnt += (a[i] - 1) / md;
	}
	//cout<<" :: "<<cnt<<" :: "<<endl;
	if(cnt <= k)
            return true;

  return false;
}

int main(){

	cin >> n >> k;
	a.resize(n);

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

	int low = 1;
	int high = 1e9;
	int ans = 1e9;

	while(low <= high)
      {
		int md = (low + high) / 2;

    //cout<<low<<" . "<<md<<" ? "<<high<<endl;

		if(ok(md)){
			high = md - 1;
			ans = min(ans,md);
		}else{
			low = md + 1;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4024
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        int[] num;
        string s;

        while((s = Console.ReadLine() ) != null)
        {
            num = s.Split(' ').Select(int.Parse).ToArray();
            if (num[0] == 0 || num[1] == 0) break;
            Console.WriteLine("{0} {1} {2:0.00000}", num[0] / num[1], num[0] % num[1], (double)num[0] / (double)num[1]);
        }
    }
}

Measured memory_bytes: 9772
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (H, W) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };

  let mut v: Vec<Vec<char>> = Vec::new();

  for i in 0..H {
    let s: Vec<char> = read::<String>().chars().collect();
    v.push(s);
  }

  let mut res: Vec<Vec<String>> = vec![vec!["#".to_string(); W]; H];

  for i in 0..H {
    for j in 0..W {
      if v[i][j] != '#' {
        res[i][j] = count(i, j, H, W, &v).to_string();
      }
    }
  }

  for e in res {
    println!("{}", e.join(""));
  }
}

fn count(i: usize, j: usize, h: usize, w: usize, v: &Vec<Vec<char>>) -> u64 {
    let indx = [(i - 1, j - 1), (i - 1, j), (i - 1, j + 1),
                (i, j - 1), (i, j + 1),
                (i + 1, j - 1), (i + 1, j), (i + 1, j + 1)];
    let mut res = 0;
    for &(k, l) in &indx {
      if 0 <= k && k <= h - 1 && 0 <= l && l <= w - 1 && check(v, k, l) {
        res += 1;
      }
    }
    return res;
}

fn check(v: &Vec<Vec<char>>, i: usize, j: usize) -> bool {
    v[i][j] == '#'
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
int n;
std::string st;

int main(){
    std::cin>>n;
    std::cin>>st;
    int c=1;
    for (int i=0;i<=n-2;i++){
        if (st[i]!=st[i+1]){
            c++;
        }
    }
    std::cout<<c;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  vector<vector<ll>> a(n,vector<ll>(n));
  vector<vector<ll>> b(n,vector<ll>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
      b[i][j]=2e9;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        if(i!=j&&i!=k){
          b[j][k]=min(b[j][k],a[j][i]+a[i][k]);
        }
      }
    }
  }
  ll cnt=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i][j]<b[i][j]){
        cnt+=a[i][j];
      }
      if(a[i][j]>b[i][j]){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << cnt/2 << endl;
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main()
{
    char s[100];int i,k=1,t1=0,t2=0;
    scanf("%s",s);
    if(s[0]!='A')
    {printf("WA\n");return 0;}
    if(s[1]<'a'||s[i]>'z') {printf("WA\n");return 0;}
    for(i=2;i<strlen(s);i++)
    {
        if(s[i]<'a'||s[i]>'z') t2++;
        if(s[i]=='C') t1++;
        if(s[strlen(s)-1]=='C') t1=0;
    }
    if(t1==1) k=1;
    else  k=0;
    if(t2>1) k=0;
    if(k)
    printf("AC\n");
    else printf("WA\n");
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
string S;

signed main(){
	cin >> N >> S;
	int ans = N;
	rep(i, N-1){
		if(S[i] == S[i+1]) ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<string> N(n);
  vector<string> M(m);
  for(int i=0;i<n;i++){
    cin>>N[i];
  }
  for(int i=0;i<m;i++){
    cin>>M[i];
  }
  string ans="No";
  
  for(int i=0;i+m<=n;i++){
    for(int j=0;j+m<=n;j++){
      bool b=true;
      for(int k=0;k<m;k++){
        if(N[i+k].substr(j,m)!=M[k]){b=false;continue;}
      }
      if(b){ans="Yes"; break;}
    }
  }
  cout<<ans;
}

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

int main()
{
 int n,m;
    cin>>n;
     int t[n];
     int s[n];
        for(int a=0;a<n;a++)
        {
            cin>>t[a];

            s[a]=t[a];
        }
        cin>>m;
        int p[m]={0};
        int x[m]={0};
        int sum[m]={0};
        for(int a=0;a<m;a++)
        {
           cin>>p[a]>>x[a];
        }
        for (int z=0;z<m;z++)
        {
            for(int i=0;i<n;i++)
            {
                if(p[z]==(i+1))
                {
                    t[i]=x[z];
                }
                    sum[z]+=t[i];
                    t[i]=s[i];
            }
        }
        for(int z=0;z<m;z++)
        {
            printf("%d \n",sum[z]);
        }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, m;
	cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	cin >> m;
	VI b(m); rep(i, m)cin >> b[i];

	VI re;
	set_intersection(all(a), all(b), inserter(re, end(re)));
	for (auto x : re)cout << x << endl;
}


Measured memory_bytes: 4764
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll n,i,ans=0;
    cin>>n;
    ll x;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(i%2){
            if(x%2) ans++;
        }
    }
    cout<<ans<<endl;


    return 0;
}





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

int N;
string s;

int judge(string s)
{
    if(s == "Male"){
        return 0;
    }
    else if(s == "Female"){
        return 1;
    }
    else {
        return -1;
    }

}

void bs(int lb, int ub, int even, int odd)
{
    int mid;
    while(ub - lb > 1){
        mid = (ub + lb) / 2;
        printf("%d\n", mid);
        cin >> s;
        int gender = judge(s);
        if(gender < 0){
            break;
        }
        if(mid % 2){
            if(gender == odd){
                lb = mid;
            }
            else {
                ub = mid;
            }
        }
        else {
            if(gender == even){
                lb = mid;
            }
            else {
                ub = mid;
            }
        }
    }
    return;
}

signed main()
{
    cin >> N;
    printf("0\n");
    cin >> s;
    int gender = judge(s);
    if(gender < 0)return 0;
    ///male:0 female:1
    ///even:0 odd:1
    int even = gender;
    int odd = (gender + 1) % 2;
    bs(0, N, even, odd);

    return 0;
}
/*


*/




Measured memory_bytes: 852
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
 
using namespace std;
 
int main() {
	fast
	//ll a,b,c,d,n,k,p;
	//ll t;
	ll n,k;
	cin>>n>>k;
	ll sum=0;
	vector<ll> v1,v2;
	for(ll i=k;i<=n;i++){
		ll x=(i*(i-1))/2;
		v1.pb(x);
		ll y=(i*(2*n-i+1))/2;
		v2.pb(y);
	}
//	ll sum=0;
	ll m=v1.size();
	/*forn(i,m){
		cout<<v1[i]<<' '<<v2[i]<<endl;
	}*/
	forn(i,m){
		sum+=abs(v2[i]-v1[i]+1);
		sum%=mod;
	}
	cout<<sum+1;
}

Measured memory_bytes: 6612
h, w = map(int,input().split())
a = [''] *h
for i in range(h):
    a[i] = input()

row = [False]*h
col = [False]*w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end = '')
        print()

Measured memory_bytes: 9216
A, B = map(int, input().split())
if B != 0:
    li = list(map(int, input().split()))

if B == 0:
    print(A)
else:
    count = 0
    while(1):
        if A - count  not in li:
            print(A-count)
            break
        if A + count not in li:
            print(A + count)
            break
        count += 1

Measured memory_bytes: 61704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

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

    if (n >= m)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(X.begin(), X.end());
    ll moto = X[m - 1] - X[0];
    vector<ll> sa(m - 1);
    rep(i, m - 1) sa[i] = X[i + 1] - X[i];
    ll hiku = 0;
    sort(sa.begin(), sa.end(), greater<ll>());
    rep(i, n - 1) hiku += sa[i];

    cout << moto - hiku << endl;
}

Measured memory_bytes: 4632
#include<algorithm>
#include<cstdio>
int n,num[200500],t=0;
int main()
{
	scanf("%d",&n);
	for(;t<n;t++)
	{
		scanf("%d",&num[t]);
	}
	std::sort(num,num+n);
 	for(t=0;t<n-1;t++)
	{
		if(num[t]==num[t+1])
		{
			printf("NO");
			return 0;
		}
	}
 	printf("YES");
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int H, W, K;
vector<vector<int>> field;
int x, y;
vector<vector<int>> cnt;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> K;

    field.resize(H);
    for(int i=0; i<H; i++)
        field[i].resize(W, 0);

    cnt.resize(H);
    for(int i=0; i<H; i++)
        cnt[i].resize(W, -1);

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            char ch;
            cin >> ch;
            if(ch == '#') field[i][j] = 1;
            else if(ch == 'S'){
                x = j;
                y = i;
            }
        }
    }

    cnt[y][x] = 0;
    queue<pair<int, int>> que;
    que.push(make_pair(x, y));
    while(!que.empty()){
        pair<int, int> xy = que.front();
        que.pop();
        int xx = xy.first;
        int yy = xy.second;
        int num = cnt[yy][xx];
        for(int i=0; i<4; i++){
            int xxx = xx + dx[i];
            int yyy = yy + dy[i];
            if(xxx < 0 || W <= xxx || yyy < 0 || H <= yyy) continue;
            if(field[yyy][xxx] == 1 || cnt[yyy][xxx] != -1) continue;
            cnt[yyy][xxx] = num + 1;
            que.push(make_pair(xxx, yyy));
        }
    }

    int ans = 1 << 30;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(cnt[i][j] == -1 || cnt[i][j] > K) continue;
            if(i == 0 || i == H-1 || j == 0 || j == W-1){
                cout << 1 << endl;
                return 0;
            }
            int tmp1 = min(i, H-1-i);
            int tmp2 = min(j, W-1-j);
            int tmp = min(tmp1, tmp2);
            if(tmp % K == 0){
                ans = min(ans, 1 + tmp / K);
            }else{
                ans = min(ans, 2 + tmp / K);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5376
//package solve;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		for ( int i = 0; sc.hasNext(); ) {
			list.add(i, sc.nextInt());
			if ( list.get(i) == 0 ) {
				System.out.println(list.get(i-1));
				i--;
			}
			else i++;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    int a,b,i;
    cin >> a >> b;
    for (i=1; i<=2000; i++) {
        if ((floor(i*0.08)==a)&&(floor(i*0.1)==b)) {
            cout << i;
            return 0;
        }
    }
        cout << -1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define vi vector<int>
#define vl vector<long long>
#define fio  cin.tie(nullptr); ios::sync_with_stdio(false); cout.tie(nullptr);
 
int main()
{
    fio;
    int a;cin>>a;
    cout<<(a+(a*a)+(a*a*a));
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<tuple>
using namespace std;
#define MAX_N 1 << 20
int n, d, size_, dat[2][2][MAX_N];//[xy][minmax][pos]
tuple<int, int, int>x[MAX_N];
inline void init(int n) {
	for (size_ = 1; size_ <= n;) size_ *= 2;
	for (int i = 0; i < 2; i++) { for (int j = 0; j < MAX_N; j++) { dat[i][0][j] = 1 << 30; dat[i][1][j] = -(1 << 30); } }
}
inline void update(int pos, int x, int p1) {
	pos += size_; dat[p1][0][pos] = x; dat[p1][1][pos] = x;
	while (pos != 1) {
		pos >>= 1;
		dat[p1][0][pos] = min(dat[p1][0][pos * 2], dat[p1][0][pos * 2 + 1]);
		dat[p1][1][pos] = max(dat[p1][1][pos * 2], dat[p1][1][pos * 2 + 1]);
	}
}
inline int query(int a, int b, int k, int l, int r, int p1, int p2) {
	if (r <= a || b <= l) { if (p2 == 0)return 1 << 30; return -(1 << 30); }
	if (a <= l && r <= b) return dat[p1][p2][k]; k <<= 1;
	int lc = query(a, b, k, l, (l + r) / 2, p1, p2);
	int rc = query(a, b, k + 1, (l + r) / 2, r, p1, p2);
	if (p2 == 0)return min(lc, rc);
	if (p2 == 1)return max(rc, lc);
}
inline int rmqw(int x, int y, int p) {
	int V1 = query(x, y + 1, 1, 0, size_, p, 1), V2 = query(x, y + 1, 1, 0, size_, p, 0);
	return V1 - V2;
}
int main() {
	cin >> n >> d; init(n); for (int i = 1; i <= n; i++) { cin >> get<1>(x[i]) >> get<2>(x[i]) >> get<0>(x[i]); }
	sort(x + 1, x + n + 1); long long maxn = 0;
	for (int i = 1; i <= n; i++) { update(i, get<1>(x[i]), 0); update(i, get<2>(x[i]), 1); }
	for (int i = 1; i <= n; i++) {
		int R = lower_bound(x + 1, x + n + 1, make_tuple(get<0>(x[i]) + d, 1 << 30, 1 << 30)) - x; R--;
		maxn = max(maxn, 1LL*rmqw(i, R, 0)*rmqw(i, R, 1));
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 21800
#include <iostream>
#include <cmath>
using namespace std;
int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int answer = -1;
		double good = 0.0;

		for ( int i = 0; i < n; i++ )
		{
			int no, h, w;
			cin >> no >> h >> w;
			double bmi = (double)w / ( h * h / 10000.0 );
			double score = fabs( 22.0 - bmi );
			if ( answer == -1 || score < good )
			{
				answer = no;
				good = score;
			}
		}

		cout << answer << endl;
	}
}

Measured memory_bytes: 0
s = input()

s_norm = list(s)
s_rev = list(reversed(s))
if s_norm == s_rev:
    s_len = len(s)
    second = round((s_len -1)/2)
    s_new = s_norm[0:second]
    s_new_rev = list(reversed(s_new))
    if s_new == s_new_rev:
        third = round((s_len +3)/2)
        s_last = s_norm[third-1:s_len+1]
        s_last_rev = list(reversed(s_new))
        if s_last == s_last_rev:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")



Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
















int main(){
    ll n;
    cin >> n;
    ll cnt[10][10] = {};
    for(ll a = 1, k = 1; a <= n; a++){
        if(a >= k * 10) k *= 10;
        cnt[a / k][a % 10]++;
    }
    ll ans = 0;
    REP(i, 10){
        REP(j, 10){
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
long long int N;
cin >>N;  double M[N]; double s;
for(long long int i=0;i<N;i++){
cin >> M[i];
}
for(long long int i=0;i<N;i++){
  s+=1/M[i];
}
s=1/s;
printf("%.8f",s);


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
# define M_PI           3.14159265358979323846  /* pi */
using namespace std;

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

	if ((a * b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else cout << "Odd" << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  
  if ((A + B) < (C + D))  {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 
nu = int(readline())
if nu % 2 == 1:
    print(0)
else:
    nu //= 2
    answ = 0
    while nu:
        nu //= 5
        answ += nu
    print(answ)

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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define f  first
#define s  second

#define sortall(x) sort(x.begin(), x.end());
#define sz(x) (int)x.size()

typedef long long         ll  ;

typedef vector < ll >     vl  ;
typedef vector < int >    vi  ;

typedef pair < ll, ll >   pl  ;
typedef pair < int, int > pi  ;

typedef vector < pl >     vpl ;
typedef vector < pi >     vpi ;

void solve() {
	ll n, temp;
	cin >> n;
	ll count  = 0;
	ll d;
	cin >> d;
	for (ll i = 0; i < n; ++i) {
		ll a, b;
		cin >> a >> b;
		ll p = a * a;
		ll q = b * b;
		if (sqrt((p + q)) <= d)count++;
	} cout << count;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	// freopen ("in.txt", "r", stdin);
//  freopen ("err.txt", "w", stderr);
//  freopen ("out.txt", "w", stdout);

	ll tc = 1;
	//cin >> tc;

	while (tc--) {
		solve();
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()

const int MOD = 1000000007;


//いろんなstlの使い方　https://qiita.com/tukejonny/items/f4013547df761a0b3523
//http://y-mazun.hatenablog.com/entry/20111202/1322840281


using namespace std;

const int MAX = 100001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    COMinit();

    long long N;
    string S;
    cin>>N>>S;
    long long a[26];
    for(int i=0;i<26;i++){
        a[i]=0;
    }

    for(int i=0;i<N;i++){
        a[S[i]-'a']++;
    }
    long long shurui=0;
    for(int i=0;i<26;i++){
        if(a[i]>0){
            shurui++;
        }
    }
    long long ans=1;
    for(int i=0;i<26;i++){
        if(a[i]>0){
            ans*=(a[i]+1);
            ans%=MOD;
        }
    }
    cout<<ans-1<<endl;





}














Measured memory_bytes: 2816
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

constexpr int Mod = 1000000007;

constexpr int Add(int A, int B) { return (A + B) % Mod; }

int main() {
  int N, M;
  cin >> N >> M;
  static int F[100001];
  static int G[100002];
  F[0] = 1;
  for (auto i = 0; i < N; ++i) {
    int x;
    cin >> x;
    partial_sum(F, F + M + 1, G + 1, Add);
    for (auto j = M; j >= 0; --j)
      F[j] = Add(G[j + 1], -G[max(0, j - x)]);;
  }
  cout << Add(F[M], Mod) << endl;
  return 0;
}


Measured memory_bytes: 1024
/*
	Author :- Vipin Kumar
*/
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>

#define int long long
using namespace std;

vector<int> mp[100005];


signed main(){
//	freopen("input.txt","r",stdin);
	int n,m;
	cin>>m>>n;
	pair<int,int> p[n];
	for(int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second;
		mp[p[i].first].push_back(p[i].second);
	}
	for(int i=1;i<=m;i++){
		sort(mp[i].begin(),mp[i].end());
	}
	for(int i=0;i<n;i++){
	//	cout<<p[i].first<<" "<<p[i].second<<endl;
		int p1 = p[i].first;
		int p2 = lower_bound(mp[p1].begin(),mp[p1].end(),p[i].second) - mp[p1].begin();
		p2++;
		string a1,a2;
		ostringstream str1,str2; 
	    str1 << p1; 
	    a1 = str1.str();
	    str2 << p2;
	    a2 = str2.str();
	    int a3 = 6-a1.length();
	    for(int i=0;i<a3;i++){
	    	a1 = "0"+a1;
		}
		a3 = 6 - a2.length();
		for(int i=0;i<a3;i++){
	    	a2 = "0"+a2;
		}
	    cout<<a1<<""<<a2<<endl;
	}	
	return 0;
}

Measured memory_bytes: 8576
#include<iostream>
#include<cstdio>
#include<queue>
#include<map>
using namespace std;
typedef pair< int , int > P;
#define INF (1<<30)
int main(){
  int n,m;
  int a,b,c,d;
  int cost[21][21];
  int min_cost[21];
  cin >> n;
  cin >> m;
  for(int i=0;i<21;i++){
    for(int j=0;j<21;j++){
      cost[i][j]=INF;
    }
    min_cost[i]=INF;
  }
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    cost[a][b] = c;
    cost[b][a] = d;
  }
  scanf("%d,%d,%d,%d",&a,&b,&c,&d);
  queue<P> que;
  que.push(P(0,a));
  min_cost[a]=0;
  while(!que.empty()){
    P p;
    p = que.front();
    que.pop();
    int v = p.second;
    for(int i=1;i<=n;i++){
      if(cost[v][i] != INF){
	if(min_cost[i] > cost[v][i] + p.first){
	  min_cost[i] = cost[v][i] + p.first;
	  que.push(P(cost[v][i] + p.first,i));
	}
      }
    }
  }
  c -= min_cost[b];
  for(int i=0;i<21;i++){
    min_cost[i] = INF;
  }
  que.push(P(0,b));
  min_cost[b]=0;
  while(!que.empty()){
    P p;
    p = que.front();
    que.pop();
    int v = p.second;
    for(int i=1;i<=n;i++){
      if(cost[v][i] != INF){
	if(min_cost[i] > cost[v][i] + p.first){
	  min_cost[i] = cost[v][i] + p.first;
	  que.push(P(cost[v][i] + p.first,i));
	}
      }
    }
  }
  cout << c - min_cost[a] - d << endl;
}

Measured memory_bytes: 1244
#include <stdio.h>

#define SIZE 2000000

int main() {
  setvbuf(stdin, NULL, _IOFBF, 4000);
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp, n;
  char com[21], buf[20];
  buf[19]='\n';
  char *p,*c1,*c2;
  c1 = com+1;
  c2 = com+2;
  do {
    fgets(com, 20, stdin);
    if (*com == 'i') {
      n = 0;
      p = com+7;
      while (*p!='\n') {
        n = n*10+*p-'0';
        p++;
      }
      A[++H] = n;
      for (i=H; i>1 && A[i>>1]<A[i];i>>=1) {
        tmp = A[i>>1];
        A[i>>1] = A[i];
        A[i] = tmp;
      }

    } else if (*c1=='x') { // extract
      n = A[1];
      for (i=18; n>0; n/=10) buf[i--]=(n%10)+'0';
      fputs(buf+i+1, stdout);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i<<1;
        if (l < H && A[l] > A[i])        largest = l;
        else         largest = i;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (*c2!='d');
  return 0;
}


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

int main() {
	long long int N, A, B;
	cin >> N >> A >> B;
	long long int dif = B - A;
	if (dif % 2 == 0) {
		cout << dif / 2 << endl;
	}
	else {
		long long int tmp1 = N - A, tmp2 = B - 1, _min;
		_min = min(tmp1, tmp2);
		tmp1 = (N - B) + dif / 2 + 1;
		tmp2 = (A - 1) + dif / 2 + 1;
		cout << min({_min, tmp1, tmp2}) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A[4];
  for (int i = 0; i < 4; i++) {
    cin >> A[i];
  }
  sort(A, A+4);
  if (A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n, m;

const int maxn = 2e5 + 5;
string s;
int a[maxn], b[maxn];
int red[maxn], blue[maxn];

vector<int> G[maxn];

bool vis[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    cin >> s;
    for(int i = 1;i <= m;i++){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
        if(s[a[i]] == 'A'){
            red[b[i]]++;
        }else{
            blue[b[i]]++;
        }
        if(s[b[i]] == 'A'){
            red[a[i]]++;
        }else{
            blue[a[i]]++;
        }
    }
    queue<int> q;
    for(int i = 0;i < n;i++){
        if(red[i] == 0 or blue[i] == 0){
            q.push(i);
            vis[i] = true;
        }
    }
    while(!q.empty()){
        int p = q.front();q.pop();
        for(auto v : G[p]){
            if(s[p] == 'A'){
                red[v]--;
            }else{
                blue[v]--;
            }
            if(!vis[v] and (red[v] == 0 or blue[v] == 0)){
                q.push(v);
                vis[v] = true;
            }
        }
    }
    for(int i = 0;i < n;i++){
        if(!vis[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 14160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans=-1e18;
int n,k,a[10005],c[10005],tmp[10005];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>c[i];
	for(int s=1;s<=n;s++){
		ll tk=k;
		tmp[0]=0;
		ll sum=0;
		tmp[++tmp[0]]=c[a[s]],sum+=c[a[s]];
		int now=a[s];
		while(now!=s)tmp[++tmp[0]]=c[a[now]],sum+=c[a[now]],now=a[now];
		if(sum>0){
			ll o=sum;
			sum*=k/tmp[0],k%=tmp[0];
			ll tmps=-1e18,tp=0;
			if(k==0)tmps=0;
			for(int i=1;i<=k;i++)tmps=max(tmps,tp+=tmp[i]);
			ans=max(ans,sum+tmps);
			k=tk;
			if(k<tmp[0])continue;
			sum=o*(k/tmp[0]-1);
			tmps=-1e18,tp=0;
			for(int i=1;i<=tmp[0];i++)tmps=max(tmps,tp+=tmp[i]);
			ans=max(ans,sum+tmps);
			continue;
		}
		else sum=0;
		ll tmps=-1e18,tp=0;
		if(k>tmp[0])k=tmp[0];
		if(k==0)tmps=0;
		for(int i=1;i<=k;i++)tmps=max(tmps,tp+=tmp[i]);
		ans=max(ans,sum+tmps);
		k=tk;
	}
	cout<<ans;
} 
/*
8 10
6 7 4 5 3 8 2 1 
1 2 2 2 -3 -1 -4 -4 
*/

Measured memory_bytes: 3656
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}
vector<char> non_duplication; //change if you need
template <class T>
void without_duplication(T a) {
  non_duplication.emplace_back(a[0]);
  for (int i = 1; i < a.size(); i++)
    if (a[i] != a[i - 1]) non_duplication.push_back(a[i]);
}
class AShrinking {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    string s;
    cin >> s;
    int N   = s.size();
    int ans = INF;
    non_duplication = {};
    without_duplication(s);
    if (non_duplication.size() == 1) {
      cout << 0 << endl;
      return;
    }
    rep(i, N) {
      char temp2 = s[i];
      string temp{};
      rep(j, N) temp += s[j];
      int time = 0;
      while (true) {
        rep(j, N - 1) {
          if (temp[j] != temp2 and temp[j + 1] == temp2) {
            temp[j] = temp2;
          }
        }
        temp.pop_back();
        time++;
        non_duplication = {};
        without_duplication(temp);
        if (non_duplication.size() == 1) {
          ans = min(ans, time);
          break;
        }
      }
    }
    cout << ans << endl;
  }
};


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


Measured memory_bytes: 256
N=int(input())
S=input()
ans=0

def Z_algorithm(s):
    N = len(s)
    Z_alg = [0]*N

    Z_alg[0] = N
    i = 1
    j = 0
    while i < N:
        while i+j < N and s[j] == s[i+j]:
            j += 1
        Z_alg[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < N and k + Z_alg[k]<j:
            Z_alg[i+k] = Z_alg[k]
            k += 1
        i += k
        j -= k
    return Z_alg

ans=0  
for i in range(N):
  d=S[i:]
  D=Z_algorithm(d)
  for j in range(N-i):
    ans=max(ans,min(j,D[j]))
print(ans)

Measured memory_bytes: 49628
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	string s;
	cin >> s;

	cout << s.substr(0,s.size() - 8) << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[200005];
int main(){
    ll n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i+=2){
        sum^=(a[i]^a[i+1]);
    }
    for(int i=1;i<=n;i++){
        cout<<(sum^a[i])<<" ";
    }cout<<endl;
}   

Measured memory_bytes: 5088
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

const int N = 3e5+5;

bool ispalidrome(string s){
    for(int i=0;i<s.size()/2;++i){
        if(s[i]!=s[sz(s)-1-i])
            return false;
    }
    return true;
}


int main(){
    int l;
    cin>>l;
    double ans = l/3.0;
    pd(ans*ans*ans);
    p();
    return 0;
}

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

signed main(){
  cin >> n;
  rep(i,n){
    string a;
    cin >> a;
    if(a=="insert"){
      string s;
      cin >> s;
      A.insert(s);
    }
    else{
      string b;
      cin >> b;
      if(A.count(b)) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  //cout << ans << endl;
  return 0;
}



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

using namespace std;
int main(){
  int a,b=0,c=0,i;
  vector<int> p(110);
  cin>>a;
  for(i=0;i<a;i++){
    cin>>p.at(i);
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  }
  for(i=0;i<a;i+=2){
    b+=p.at(i);
   }
  for(i=1;i<a;i+=2){
    c+=p.at(i);
  }
  cout<<b-c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	vector<int> box(n);
	fill( box.begin(), box.end(), 1 );
	bitset<100000> bs;
	bs.set(0);
	while( m-- ){
		int x, y;
		cin >> x >> y;
		--x; --y;
		--box[x]; ++box[y];
		if( bs[x] == true ) bs.set(y, true);
		if( box[x] == 0 ) bs.set(x, false);
	}
	cout << bs.count() << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    int n,m,ans=0,sum=0;
    cin>>n;
    vector<int> a(10000000);
    vector<int> b(10000000);
    for(int i=0;i<n-1;i++){
    	cin>>a[i];
    	b[i]=0;
    }
    b[n-1]=0;
    for(int i=0;i<n-1;i++){
    	b[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
    	cout<<b[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 81404
#include<bits/stdc++.h>
using namespace std;
 
int main(){
        int w, h, x, y, r;
        cin >> w >> h >> x >> y >> r;
        int circle_left = x - r;
        int circle_right = x + r;
        int circle_top = y + r;
        int circle_bottom = y - r;
        if(circle_left < 0 || circle_right > w || circle_top > h || circle_bottom < 0){
                cout << "No" << endl;
        }else{
                cout << "Yes" << endl;
        }
}

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

int a, b;
char c;

int main() {
	cin >> a;

	while (1)
	{
		cin >> c;

		if (c == '=') {
			break;
		}

		if (c == '+') {
			cin >> b;
			a += b;
		}
		if (c == '-') {
			cin >> b;
			a -= b;
		}
		if (c == '*') {
			cin >> b;
			a *= b;
		}
		if (c == '/') {
			cin >> b;
			a /= b;
		}
	}

	cout << a << endl;

	return 0;

}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> sums;
    for (int i=0; i < n; i++) cin >> v[i];
    int ans = 0, s=0;
    sums[0] = 1;
    for (int i=0; i < n; i++){
        s += v[i];
        sums[s]++;
        ans += sums[s]-1;
    }
    cout << ans;
}



Measured memory_bytes: 14336