akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
scanf("%d%d",&k,&n);
int ar[200000+5];
  for(int i=0;i<n;i++)
    scanf("%d",&ar[i]);
  sort(ar,ar+n);
  int ans = INT_MIN;
  for(int i=0;i<n-1;i++)
  {
  if(ans<ar[i+1]-ar[i])
  	ans = ar[i+1]-ar[i];
    
    
  }
  ans = max(ans, k-ar[n-1]+ar[0]);
	printf("%d\n",k-ans);
}


Measured memory_bytes: 1024
#include <iostream>

int n;

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	if (n == (n & -n)) return printf("No"), 0;
	printf("Yes\n");
	for (int i = 2; i < n; i += 2)
		printf("1 %d\n1 %d\n%d %d\n%d %d\n", i, i + 1, i, n + i + 1, i + 1, n + i);
	printf("%d %d\n", n + 1, n + 3);
	if (n % 2 == 0)
		for (int i = 2; i < n; ++i)
			if ((n ^ i ^ 1) < n) { printf("%d %d\n%d %d\n", i, n, n ^ i ^ 1, 2 * n); break; }
	return 0;
}


Measured memory_bytes: 2304
import java.util.*;

public class Main{

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = Integer.parseInt(sc.next());

    String[] a = new String[n];
    int[] b = new int[n];

    for (int i=0; i<n; i++){
      a[i] = sc.next();
    }


    Arrays.sort(a);
    b[0] = 1;
    for (int i=1;i<n;i++){
      if(a[i].equals(a[i-1]))
        b[i] = b[i-1] + 1;
      else
        b[i] = 1;
    }
    int max = b[0];
    for(int i=0;i<n;i++){
      if (max<b[i])
        max = b[i];
    }

    for (int i=0; i<n; i++){
      if (b[i] == max)
        System.out.println(a[i]);
    }
  }
}


Measured memory_bytes: 79472
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  string s;
  cin>>n>>s>>k;
  rep(i,s.size() ){
    if(s[i]!=s[k-1]) s[i]='*';
  }
  cout<<s<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#define rep(i,a,b) for(register int i = a; i <= b; i++)
using namespace std;

#define ll long long
const int N = 100000+10;
inline int read() { 
	int s = 0,t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

int fa[N], f[N];
bool vis[N], pd[N];
int cnt; ll ans;
inline int getfa(int x){
    if ( !fa[x] ) return x;
    int t = getfa(fa[x]);
    f[x] ^= f[fa[x]];
    return fa[x] = t;
}
int main(){
	int n, m, x, y, l, r;
    n = read(), m = read();
    rep(i,1,m){
        vis[x=read()] = vis[y=read()] = 1;
        l = getfa(x), r = getfa(y);
        if (l<r){
            swap(l,r);
            swap(x,y);
        }
        if ( l == r && f[x] == f[y]) pd[l]=1;
        if ( l == r ) continue;
        pd[fa[l] = r] |= pd[l];
        f[l] = f[x] ^ f[y] ^ 1;
    }
    rep(i,1,n) if (!vis[i]) cnt++;
    ans=(ll)cnt*(n-cnt)*2+(ll)cnt*cnt;
    cnt=0;
    rep(i,1,n) if (vis[i]&&!fa[i]) cnt++;
    ans+=(ll)cnt*cnt;
    cnt=0;
    /*fo(i,1,n)
        if (vis[i]&&fa[i]){
            y=getfa(i);
            if (!pd[y]&&f[i]!=f[y]) cnt++;
        }*/
    rep(i,1,n) if (vis[i]&&!fa[i]&&!pd[i]) cnt++;
    rep(i,1,n) if (vis[i]&&!fa[i]&&!pd[i]) ans+=(ll)cnt;
    printf("%lld\n",ans);
}

Measured memory_bytes: 1280
import java.util.Scanner;
import java.util.Arrays;

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

    long K = sc.nextLong();
    long P = 0L;
    long Dif = 1L;

    for(int i = 1; i <= K; i++){
      P += Dif;
      if(helper(P + Dif) > helper(P + 2 * Dif))
      Dif *= 10L;
      System.out.println(P);
    }
  }
  public static double helper(long n){
    double S = (double) n;
    double sum = 0.0;
    while(n != 0){
      sum += (double) n%10;
      n = n/10;
    }
    return S/sum;
  }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll N;
vector<ll> a(410), s(410, 0);
ll dp[410][410];

ll rec(ll L, ll R){
	if(dp[L][R]>=0) return dp[L][R];
	if(R-L<2) return 0;

	ll res = (1ll<<60);
	for(ll i=L+1;i<R;i++){
		ll tmp = 0;
		tmp += rec(L, i);
		tmp += rec(i, R);
		tmp += s[R]-s[L];
		res = min(res, tmp);
	}

	dp[L][R] = res;
	return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 410)REP(j, 410) dp[i][j] = -1;

    cin >> N;
    REP(i, N) cin >> a[i];
    REP(i, N) s[i+1] = s[i] + a[i];

    cout << rec(0, N) << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static bool sameStringExist(char W[100][11], const size_t N, const char *w)
{
	bool sameStringExist = false;
	for (size_t idx = 0; idx < N; idx++) {
		if (strcmp(W[idx], w) == 0) {
			sameStringExist = true;
			break;
		}
	}

	return sameStringExist;
}

int main(void) {
	size_t N;
	char W[100][11];
	bool violateRules = false;

	scanf("%zu\n", &N);
	for (size_t idx = 0; idx < N; idx++) {
		scanf("%s", W[idx]);
		if (idx < N - 1) {
			scanf("\n");
		}

		if (0 < idx) {
			if (sameStringExist(W, idx, W[idx])) {
				violateRules = true;
				break;
			}
			if (W[idx][0] != W[idx - 1][strlen(W[idx - 1]) - 1]) {
				violateRules = true;
				break;
			}
		}
	}
	
	puts((violateRules ? "No" : "Yes"));

	return 0;
}


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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int n = (int)s.size();
  int k = (int)t.size();
  int ans = 10000;
  rep(i, n - k + 1) {
    string ss = s.substr(i, k);
    int cnt = 0;
    rep(j, k) {
      if (ss[j] != t[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(){
  int x;
  int y;
  int a, b, c, d;

  while(scanf("%i", &x) == 1){
    y = 0;
    for (a = 0; a < 10; a++){
      for (b = 0; b < 10; b++){
        for (c = 0; c < 10; c++){
          for (d = 0; d < 10; d++){
            if (x == a + b+ c+ d){
              y++;
            }
          }
        }
      }
    }
    printf("%d\n", y);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(){
	int time[100], n, m, r1, r2, sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &time[i]);
		sum += time[i];
	}
	scanf("%d", &m);
	for(int i = 0; i < m; ++i){
		scanf("%d%d", &r1, &r2);
		printf("%d\n", sum - time[r1 - 1] + r2);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    if(n%10==0 or n%10==1 or n%10==6 or n%10==8)cout << "pon" << endl;
    else if(n%10==3)cout << "bon" <<endl;
    else cout << "hon" <<endl;

    return 0;
}





Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

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

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

int main(void){
	int w, h;
	while(cin >> w >> h && w && h){
	ll map[110][110][2][2] = {}; // third->0:up, 1:right fourth->0:ok 1:turned
	REP(i, w){
		map[i][0][1][0] = 1;
	}
	REP(i, h){
		map[0][i][0][0] = 1;
	}
	FOR(i, 1, w){
		FOR(j, 1, h){
			map[i][j][0][0] = (map[i][j-1][0][1] + map[i][j-1][0][0]) % 100000;
			map[i][j][0][1] = map[i][j-1][1][0];
			map[i][j][1][0] = (map[i-1][j][1][0] + map[i-1][j][1][1]) % 100000;
			map[i][j][1][1] = map[i-1][j][0][0];
		}
	}
	cout << (map[w-1][h-1][0][0] + map[w-1][h-1][0][1] + map[w-1][h-1][1][0] + map[w-1][h-1][1][1]) % 100000 << endl;
	}
}

Measured memory_bytes: 3344
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>

using namespace std;

int main(){
	int n;
	string a;

	cin >> n;
	if (n == 0){
		cout << 0 << endl;
		return 0;
	}
	while (1){
		if (n == 0)break;
		if (n % -2 != 0){
			a += '1';
			if (n % -2 < 0)n--;
		}
		else{
			a += '0';
		}
		n /= -2;
	}
	reverse(a.begin(),a.end());

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()

s1 = 1 <= int(S[0:2]) <= 12
s2 = 1 <= int(S[2:4]) <= 12
if s1 and s2:
    ans = 'AMBIGUOUS'
elif s1:
    ans = 'MMYY'
elif s2:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)


Measured memory_bytes: 2940
let () = Scanf.scanf "%d" @@ fun x ->
  Printf.printf "%d\n" @@
  fst @@
  List.find (fun (_, t) -> t <= x) @@
  List.mapi (fun i t -> (i + 1, t)) @@
  [1800; 1600; 1400; 1200; 1000; 800; 600; 400]

Measured memory_bytes: 3792
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)
import math

def isPrime(num):
    for i in range(3,math.floor(math.sqrt(num))+1,2):
        if num%i==0:
            return False
    return True


N = I()
cnt = 0
ans = 0
while N%2==0:
    N /= 2
    cnt += 1
power = 1
while cnt-power>=0:
    cnt -= power
    ans += 1
    power += 1
while True:
    if N==1:
        break
    if isPrime(N):
        ans += 1
        break
    else:
        for i in range(3,math.floor(math.sqrt(N))+1,2):
            cnt = 0
            if isPrime(i) and N%i==0:
                while N%i==0:
                    N /= i
                    cnt += 1
                power = 1
                while cnt-power>=0:
                    cnt -= power
                    ans += 1
                    power += 1

print(ans)


Measured memory_bytes: 10024
#include <stdio.h>
#include <math.h>
int main()
{   int a,b,c,d;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d))
    {   int m,n;
        m=a*b;
        n=c*d;
        if(m>n)
        printf("%d\n",m);
        else
            printf("%d\n",n);
    }

return 0;
}

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

int main()
{
  int a,b;scanf("%d %d",&a,&b);
  if(a<=0&&b>=0){printf("Zero\n");return 0;}
  if(a>0){printf("Positive\n");return 0;}
  if((b-a)%2==1)printf("Positive\n");
  else printf("Negative\n");
}

Measured memory_bytes: 3656
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;
    cin>>n;
    vector<ll> x(n),y(n),h(n);
    int index=0;
    rep(i,0,n){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i])index=i;
    }

    rep(i,0,101){
        rep(j,0,101){
            bool ok=true;
            ll H=h[index]+abs(i-y[index])+abs(j-x[index]);
            rep(k,0,n){
                if(h[k]!=0 && h[k]+abs(i-y[k])+abs(j-x[k])!=H)ok=false;
                if(h[k]==0 && abs(i-y[k])+abs(j-x[k])<H)ok=false;
            }
            
            if(ok){
                cout<<j<<" "<<i<<" "<<H<<endl;
                return 0;
            }
        }
    }

}


/*

*/


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

void rotate_rignt(string &v){
  int i;
  size_t size = v.size();
  string copy;
  copy = v;
  copy[0]=v[size-1];
  for(i=1;i < size;i++){
    copy[i]=v[i-1];
  }
  v = copy;
}

int debug = 0;

int main(){
  string S, T;
  cin >> S >> T;
  while(1){
    debug ++;
    rotate_rignt(S);
    if(S == T){
      cout << "Yes" << endl;
      break;
    }
    else if(debug == S.size()){
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m, c int
	fmt.Scanf("%d %d %d", &n, &m, &c)

	b := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scanf("%d", &b[i])
	}

	cnt := 0
	for i := 0; i < n; i++ {
		s := 0
		for j := 0; j < m; j++ {
			var a int
			fmt.Scanf("%d", &a)
			s += a * b[j]
		}
		if s + c > 0 {
			cnt += 1
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;	char ch=getchar();
	while(ch<'0'||ch>'9')	{if(ch=='-')	f=-1;	ch=getchar();}
	while(ch>='0'&&ch<='9')	{x=(x<<3)+(x<<1)+(ch^48);	ch=getchar();}
	return x*f;
}
int n,m,x,y,z;
int dis[20][20];
int tag[100050],s[100050];
int f[100050][20],sum,ans;
int main()
{
	n=read();	m=read();	tag[0]=-1;
	memset(f,-1,sizeof(f));	f[1][0]=0;
	while(m--)
	{
		x=read()-1;	y=read()-1;	z=read();
		dis[x][y]=dis[y][x]=z;	sum+=z;
	}
	for(int i=1;i<(1<<n);++i)
	{
		x=tag[i]=tag[i>>1]+1;	s[i]=s[i^(1<<x)];
		for(y=0;y<x;++y)
			if(i&(1<<y))	s[i]+=dis[x][y];
	}
	for(int i=1;i<(1<<n);++i)
		for(int j=0;j<n;++j)
		{
			if(f[i][j]==-1)	continue;
			for(int k=0;k<n;++k)
				if(dis[j][k]&&!(i&(1<<k)))
					f[i|(1<<k)][k]=max(f[i|(1<<k)][k],f[i][j]+dis[j][k]);
			int t=((1<<n)-1)^i^(1<<j);
			for(int k=t;k;k=(k-1)&t)
				f[i|k][j]=max(f[i|k][j],f[i][j]+s[k]);
		}
	for(int i=0;i<(1<<n);++i)
		ans=max(ans,f[i][n-1]);
	printf("%d",sum-ans);
	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932
using namespace std;

int main(){
	int n,s[1000];
	double mean;
	while(cin >> n,n){
		double sum=0;
		for(int i=0;i<n;i++){
			cin >>s[i];
			sum+=s[i];
		}
		mean=sum/(double)n;
		sum=0;
		for(int i=0;i<n;i++){
			sum+=(double)((double)s[i]-mean)*((double)s[i]-mean);
		}
		printf("%.6f\n",sqrt((double)sum/n));
	}
	return 0;
}

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

int main(void){
    ll n, m, c;

    cin >> n >> m >> c;

    ll a[n][m], b[m];
    rep(i, m){
        cin >> b[i];
    }
    rep(i, n){
        rep(j, m){
            cin >> a[i][j];
        }
    }

    ll count = 0;
    rep(i, n){
        ll ans = 0;
        rep(j, m){
            ans += a[i][j] * b[j];
        }
        ans += c;
        if(ans > 0){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define GG puts("FUCK")
#define N 100050
int head[N],to[N],nxt[N],fa[N],a[N],b[N],c[N],n,m,vis[N],id[N],cnt;
vector<int>v[N];
ll f[N],s[N];
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
bool cmp(int x,int y) {return c[x]<c[y];}
inline void add(int u,int v) {
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt;
}
void dfs(int x) {
	int i; s[x]=b[x];
	for(i=head[x];i;i=nxt[i]) {
		dfs(to[i]); s[x]+=s[to[i]];
	}
	f[x]=s[x]+c[x];
	for(i=head[x];i;i=nxt[i]) {
		f[x]=min(f[x],s[x]-s[to[i]]+max(f[to[i]],1ll*c[x]));
	}
}
int main() {
	scanf("%d%d",&n,&m);
	int i,x,y,j;
	for(i=1;i<=n;i++) {
		scanf("%d%d",&a[i],&b[i]); c[i]=max(a[i]-b[i],0); fa[i]=id[i]=i;
	}
	for(i=1;i<=m;i++) {
		scanf("%d%d",&x,&y); v[x].push_back(y); v[y].push_back(x);
	}
	sort(id+1,id+n+1,cmp);
	for(i=1;i<=n;i++) {
		x=id[i]; int lim=v[x].size(); vis[x]=1;
		for(j=0;j<lim;j++) {
			y=v[x][j]; if(!vis[y]) continue;
			y=find(y);
			if(x!=y) {
				fa[y]=x; add(x,y);
			}
		}
	}
	dfs(id[n]);
	printf("%lld\n",f[id[n]]);
}

Measured memory_bytes: 13180
class UnionFind:
    def __init__(self, size):
        # 親の番号を格納する。親だった場合は-1
        # -> 親だった場合は、-(その集合のサイズ)とする
        # 作るときはparentの値を全て-1にする
        # こうすると全てバラバラになる
        self.parent = [-1 for _ in range(size)]

    # aがどのグループに属しているか調べる
    # 一番上の親を調べる
    def root(self, a):
        if self.parent[a] < 0:
            # じぶんがリーダー
            return a
        # 繋ぎ変えとく
        self.parent[a] = self.root(self.parent[a])
        return self.parent[a]

    def size(self, a):
        # 自分のいるグループの頂点数を調べる
        # 親をとってきたい
        return -self.parent[self.root(a)]

    def connect(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a == b:
            return False

        #大きい方(a)に小さい方(b)をくっつけたい
        if self.size(a) < self.size(b):
            a, b = b, a
        self.parent[a] += self.parent[b]
        self.parent[b] = a
        return True

n,m = map(int,input().split())
a, b = [0]*m, [0]*m
for i in range(m):
    a[i],b[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

ans = [0 for _ in range(m)]
ans[m-1] = n*(n-1)//2

uf = UnionFind(n)
i = 1
for ai, bi in zip(a[::-1], b[::-1]):
    id = m-1-i
    if id < 0:
        break
    if uf.root(ai) == uf.root(bi):
        ans[id] = ans[id+1]
    else:
        sa = uf.size(ai)
        sb = uf.size(bi)
        ans[id] = ans[id+1] - sa*sb
        uf.connect(ai, bi)
    i += 1

print('\n'.join(map(str, ans)))


Measured memory_bytes: 24600
#include <iostream>
using namespace std;
int main(void){
    // Your code here! 144
	int A,B,C;
	cin >> A >> B >> C;
	if(A == B && B != C){
	    cout << "Yes" << endl;
	}
	else if(B == C && C != A){
	    cout << "Yes" << endl;
	}
	else if(A == C && A != B){
	    cout << "Yes" <<endl;
	}
	else{
	    cout << "No" << endl;
	}
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll ans = 0;
void dfs(int n, vector<int>a,
	vector<vector<int>>ab, int count,int def) {
	if (count == def) {
		ans++;

	}
	else {
		for (int i = 0; i < a.size(); i++) {
			if (ab[n][i] == 1 && a[i] == 0) {
				a[i]++;
				count++;
				dfs(i, a, ab, count, def);
				count--;
				a[i] = 0;
			}
		}
	}
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>map(8, vector<int>(8,0));
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		map[a][b]++;
		map[b][a]++;
	}
	int count = 1;
	vector<int>path(8,0);
	path[0] = 1;
	dfs(0, path, map, count,n);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
LL gcd(LL n, LL m)
{
	return m == 0 ? n : gcd(m, n % m);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL a, b;
	cin >> a >> b;
	LL g = gcd(a, b);
	int ans = 1;
	for (int i = 2; 1LL * i * i <= g; i++)
	{
		if (g % i) continue;
		while (g % i == 0) g /= i;
		ans++;
	}
	if (g > 1) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

jisho = defaultdict(int)
n = int(input())
for _ in range(n):
    s = input()
    jisho[s] += 1

kotae = ["AC", "WA", "TLE", "RE"]
for i in range(4):
    k = kotae[i]
    print(str(k) + " x " + str(jisho[k]))


Measured memory_bytes: 9472
#include<iostream>
#include<cmath>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;

int main(){
	int num[101]={0};
	int a,maxin=0;
	while(cin>>a){
		num[a]++;
		maxin=max(maxin,num[a]);
	}
	rep(i,101){
		if(num[i]==maxin)cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
/*
int main()
{
    int x,y;
    cin>>x>>y;
    int a,b,c;
    a=x+y;
    b=x*y;
    c=x-y;
    int maxx;
    maxx=max(a,b);
    maxx=max(maxx,c);
    cout<<maxx<<endl;
    return 0;
}
*/

int main()
{
    int n;
    cin>>n;
    char s[n+1];
    for(int i=0;i<n;i++)
        cin>>s[i];
    int l[27],r[27];
    int flag3=0;

    for(int i=1;i<n;i++)
    {
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        for(int j=0;j<i;j++)
        {
            l[s[j]-'a']++;
        }
        for(int j=i;j<n;j++)
        {
            r[s[j]-'a']++;
        }
        int temp=0;
         for(int j=0;j<26;j++)
         {
             if(l[j]&&r[j])
                temp++;
         }
      if(temp>flag3)
            flag3=temp;
    }
    cout<<flag3<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb 	push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define mod 1000000007LL
#define F first
#define S second
#define speed ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
const int N=2e3+5;
int gcd(int a,int b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
main()
{
	int n,s=0;
	cin>>n;
	vector<int>d(n);
	for(int i=0;i<n;i++)cin>>d[i],d[i]*=2;
	int x=0;
	for(int i=0;i<n;i++)x=d[i]-x;
	x=x/2;
	for(int i=0;i<n;i++)
	{
		cout<<x<<" ";
		x=d[i]-x;
	}
	return 0;
}

Measured memory_bytes: 2048
while True:
    n,x=map(int,input().split())
    if(n==0 and x==0):
        break
    s=0
    for i in range(1,n):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if(i+j+k==x):
                    s=s+1
    print(s)


Measured memory_bytes: 5592
import sys


def bisect_left_callable(fn, x, lo, hi):
    """
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


sys.setrecursionlimit(100000)
INF = float('inf')

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

MAX = 10 ** 20


def check(k):
    """
    :param int k:
    :return: k 回操作して条件を満たせば 0、k が大きすぎたらプラス、小さすぎたらマイナス
    """
    # k を全体に足す
    # N + 1 をちょうど k 回引ければそれが答え
    li = [a + k for a in A]
    sub = 0
    for a in li:
        sub += (a + 1) // (N + 1)
    return k - sub


# このへんに答えがある
ans = bisect_left_callable(check, 0, 0, MAX)
# このへん小さい順に全部調べる（あたまわるい）
ans = max(0, ans - 10000)
while check(ans) != 0:
    ans += 1
print(ans)


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int N,Q,cX[2<<17],cY[2<<17];
main()
{
	cin>>N>>Q;
	long ans=(long)(N-2)*(N-2);
	int mX=N,mY=N;
	for(;Q--;)
	{
		int t,x;cin>>t>>x;
		if(t==1)
		{
			if(x<mX)
			{
				ans-=mY-2;
				while(mX>x)cX[mX--]=mY-2;
			}
			else ans-=cX[x];
		}
		else
		{
			if(x<mY)
			{
				ans-=mX-2;
				while(mY>x)cY[mY--]=mX-2;
			}
			else ans-=cY[x];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
 
int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll sum = 0;
  
  rep(i, n) {
    if (b[i]<=a[i]) {
      sum += b[i];
      continue;
    }
    sum += a[i];
    b[i] -= a[i];
    if (b[i]<=a[i+1]) {
      sum += b[i];
      a[i+1] -= b[i];
    }
    else {
      sum += a[i+1];
      a[i+1] = 0;
    }
    
  }
  cout << sum << endl;
  
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	string s;
	cin >>n;
	
	rep2(i, 1, n) {
		int j = n -i;
		if(i < j) ans++;
	}
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
N = int(input())
res = 0
b_, _a, b_a = 0, 0, 0

for i in range(N):
    s = input()
    res += s.count("AB")
    s = s.replace("AB", "*")
    if s[0] == "B":
        if s[-1] == "A":
            b_a += 1
        else:
            b_ += 1
    elif s[-1] == "A":
        _a += 1

if b_a > 0:
    res += b_a - 1
    if _a > 0:
        res += 1
        _a -= 1
    if b_ > 0:
        res += 1
        b_ -= 1

res += min(_a, b_)
print(res)


Measured memory_bytes: 74304
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))


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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for( i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 16072
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string N;
	std::cin >> N;
	bool flag = true;
	if (N[0] == N[2]) {
		std::cout << "Yes" << '\n';
	}
	else{
		std::cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll n,m,dp[1005][1005];
char s;
int main()
{
    cin>>n>>m;
    dp[0][1]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        cin>>s;
        if(s=='.')
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        else dp[i][j]=0;
    }
    cout<<dp[n][m];
}


Measured memory_bytes: 8064
m, d = map(int, input().split())
ans = 0
for i in range(4, m + 1):
    for j in range(22, d + 1):
        arr = str(j)
        if int(arr[0]) >= 2 and int(arr[1]) >= 2 and i == int(arr[0]) * int(arr[1]):
            ans += 1
print(ans)


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int H, W;
	string smap[51];

	cin >> H >> W;
	rep(i, 0, H)
	{
		cin >> smap[i];
	}

	const int dx[] = { 1,1,1,0,-1,-1,-1,0 };
	const int dy[] = { -1,0,1,1,1,0,-1,-1 };
	rep(i, 0, H)rep(j, 0, W)
	{
		if (smap[i][j] == '#')continue;
		int cnt = 0;
		rep(k, 0, 8)
		{
			int nx = j + dx[k];
			int ny = i + dy[k];
			if (0 <= nx && nx < W && 0 <= ny && ny < H)
			{
				if (smap[ny][nx] == '#')cnt++;
			}
		}
		smap[i][j] = (char)('0' + cnt);
	}

	rep(i, 0, H)
	{
		cout << smap[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci A(N);
    REP(i,N) cin >> A[i];
    veci even,odd;
    REP(i,N) {
        if(i == 0) continue;
        if(i%2 == 0) even.push_back(i);
        else odd.push_back(i);
    }
    if(N%2 != 0) {
        reverse(even.begin(),even.end());
        for(int i:even) cout << A[i] << " ";
        cout << A[0] << " ";
        for(int i:odd) cout << A[i] << " ";
        cout << endl;
    } else {
        reverse(odd.begin(),odd.end());
        for(int i:odd) cout << A[i] << " ";
        cout << A[0] << " ";
        for(int i:even) cout << A[i] << " ";
        cout << endl;
    }
}

Measured memory_bytes: 3956
N, Y = map(int, input().split())
 
for x in range(N+1):
  for y in range(N+1-x):
        if x*10000 + y*5000 + (N-x-y)*1000 == Y:
           print(x, y, N-x-y)
           exit()
 
print("-1 -1 -1")

Measured memory_bytes: 2940
#include <iostream>
#include <stack>
using namespace std;
int main(){
  int n;
  stack<int> s;
  cin >> n;
  while(n != 0){
    if(n != 0){
      if(n % 2){
        s.push(1);
        n -= 1;
      }else{
        s.push(0);
      }
    }
    n /= 2;
    if(n != 0){
      if(n % 2){
        s.push(1);
        n += 1;
      }else{
        s.push(0);
      }
    }
    n /= 2;
  }
  int k = s.size();
  if(k){
    for(int i = 0;i < k;i++){
      cout << s.top();
      s.pop();
    }
  }else{
    cout << 0;
  }
  cout << endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
int n, a[101];

int main() {
	cin >> s;
	n = s.size();
	
	inc(i, n) { a[i] = (s[i] - 'a'); }
	int ans = n + 1;
	inc(i, 26) {
		a[n] = i;
		int c = 0, ma = 0;
		inc(j, n + 1) {
			if(a[j] == i) { setmax(ma, c); c = 0; } else { c++; }
		}
		setmin(ans, ma);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
x,y,z=1,1,1
ans=[0]*(n+1)
while x>0:
    while y>0:
        while z>0:
            num=x*x+y*y+z*z+x*y+y*z+z*x
            if num>n:
                z=1
                break
            ans[num]+=1
            z+=1
        if x*x+y*y+1+x*y+y+x>n:
            y=1
            break
        y+=1
    if x*x+2+x+x+1>n:
        break
    x+=1
for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 68472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int sum = 0;
  
  vector<int>A(M);
  for (int i = 0; i < M; i++) {
    cin >> A.at(i); 
    sum += A.at(i); 
  }
  
  if (sum <= N){
    cout << N-sum << endl;
  }
  else {
    cout << -1 << endl;
  }
}



Measured memory_bytes: 3608
n = int(input())
al = list(map(int, input().split()))

als =list(sorted(al))
m = als[n-1]

import bisect
x = bisect.bisect(als,m/2)

if abs(m/2 - als[x-1]) > abs(m/2 - als[x]):
    print(m,als[x])
else:
    print(m,als[x-1])

Measured memory_bytes: 20004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100009];
ll val[100009];
ll n;
ll frog(ll i)
{
    if(i==n-1)return 0;
    if(i>n-1)return 989898;
   // cout<<"I = "<<i<<endl;

//    if(i==n-1)return (abs(val[i]-val[n-1]));
//    if(i==n-2)return (abs(val[i]-val[n-2]));
        if(dp[i]!=-1)return dp[i];
        ll f1,f2;
        f1=frog(i+1)+abs(val[i]-val[i+1]);
      //  cout<<"f1 = "<<f1<<endl;
        f2=frog(i+2)+abs(val[i]-val[i+2]);
       // cout<<" f2 = "<<f2<<endl;

        dp[i]=min(f1,f2);
        return dp[i];
}
int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ll d;cin>>d;
        val[i]=d;
    }
    memset(dp,-1,sizeof(dp));
    ll ans=frog(0);
    cout<<ans<<endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;
  cin>>n;
  int a=0;
  int w=0;
  int t=0;
  int r=0;
  string s;
  rep(i,n){
    cin>>s;
    if(s=="AC") a++;
    if(s=="WA") w++;
    if(s=="TLE") t++;
    if(s=="RE") r++;
  }
  
  cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<w<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<t<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<r<<endl;
  
}

Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma comment(linker, "/STACK:2000000")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'
using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 3e5 + 5, LG = 19, MOD = 998244353;
const int SQ =320;
const long double EPS = 1e-7;
void printCase(int cs){
  cout << "Case #" << cs<<": ";
}
int K;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  ll n, k;
  cin >> n >> k;
  n%=k;
  ll ans = min(n,abs(n-k));

  cout<<ans<<'\n';

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
    }
    if n < 105 {
        println!("0");
        return;
    } else if n == 105 {
        println!("1");
        return;
    } else {
        let mut result = 1;
        for dividend in 107..n + 1 {
            if dividend % 2 != 1 {
                continue;
            }
            let mut cnt = 2;
            for divisor in 2..dividend {
                if dividend % divisor == 0 {
                    cnt += 1;
                }
            }
            if cnt == 8 {
                result += 1;
            }
        }
        println!("{}", result)
    }
}


Measured memory_bytes: 4352
N, C = map(int, input().split())
STC = [list(map(int, input().split())) for _ in range(N)]

M = 10**5+1
merge = [[0]*(M+1) for _ in range(31)]
for i in range(N):
    s, t, c = STC[i]
    merge[c][s:t+1] = [1]*(t-s+1)
print(max(map(sum, zip(*merge))))


Measured memory_bytes: 86920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k; cin >> n >> k;
	string s;
	cin >> s;
	vector<P> res;
	int cnt = 1;
	rrep(i, n) {
		if (s[i] == s[i - 1]) cnt++;
		else {
			if (s[i] == '0') res.emplace_back(P(1, cnt));
			else res.emplace_back(P(0, cnt));
			cnt = 1;
		}
	}
	if (s.back() == '1') res.emplace_back(P(1, cnt));
	else res.emplace_back(P(0, cnt));
	int p = res.size();
	if (p <= 2 * k) {
		dunk(n);
		return 0;
	}
	int ans = 0;
	vector<ll> sum(n + 3 * k);
	sum[0] = 0;
	rep(i, res.size()) sum[i + 1] = sum[i] + res[i].second;
	ll j_ans = 0;
	rrep(i, res.size() + 1) {
		if (res[i - 1].first) {
			ll tmp = sum[min(p,i + 2 * k)] - sum[i - 1];
			j_ans = max(j_ans, tmp);
		}
		else {
			ll tmp = sum[min(p,i + 2 * k - 1)] - sum[i - 1];
			j_ans = max(j_ans, tmp);
		}
	}
	dunk(j_ans);
	return 0;
}


Measured memory_bytes: 2676
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,ans=0;
  cin>>N;
  vector<int> A(N);
  map<int,int> mp;
  REP(i,N){
    cin>>A[i];
    if(A[i]>100000){
      ans++;
    }else{
      mp[A[i]]++;
    }
  }
  for(auto e : mp){
    if(e.first<e.second)ans+=e.second-e.first;
    if(e.first>e.second)ans+=e.second;
  }
  cout<<ans<<endl;
}


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

const int INF = 1e9 + 5;
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;

	vector<int> all(n);
	for (int i = 0; i < n; i++)
		cin >> all[i];

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a;
    string s;
    cin >> a >> s;
    if (a>=3200)cout << s << endl;
    else cout << "red" <<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 256