akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<string>
main(){
        using namespace std;
        string lv[8] = {"AAA","AA","A","B","C","D","E","NA"};
        double ind1,ind2,lvd5[7] = {35.5,37.5,40.0,43.0,50.0,55.0,70.0};
        int i,j,lvd1[7] = {71,77,83,89,105,116,148};
        while(~scanf("%lf %lf",&ind1,&ind2)){
                i = j = -1;
                while(++i<7)
                  if(ind1 < lvd5[i])
                    break;
                while(++j<7)
                  if(ind2 < lvd1[j])
                    break;
                printf("%s\n", i <= j ? lv[j].c_str() : lv[i].c_str());
        }
        return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
int main() {
  double a,b,c,d;
  while(cin >> a >> b >> c >> d && a) {
    double x=a/b;
    int ans=0;
    while(x<c) {
      a+=d;
      x=a/b;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3204
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <functional>

int main() {
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);

  if (N == 2)
    return !printf("Borys\n");

  printf("%s\n", (B-A)%2? "Borys":"Alice");
}


Measured memory_bytes: 128
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    println(a-1+ifelse(a<=b,1,0))
end
main()

Measured memory_bytes: 109524
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,j,N,H,W,ans=0;
  cin>>N;
  vec v(N);
  rep(i,N)cin>>v[i];
  rep(i,N){
    for(j=i+1;j<N;j++){
      ans+=v[i]*v[j];
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
 	int n;
	char cs[4][3][10];
	memset(cs,'0',sizeof(cs));
	scanf("%d",&n);
	while(n--){
 		int b,f,r,v;
		scanf("%d %d %d %d",&b,&f,&r,&v);
		cs[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				printf(" %c",cs[i][j][k]);
			}
			printf("\n");
		}
		if(i<3)printf("####################\n");
	}
}


Measured memory_bytes: 2036
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n;
    ll a=0,w=0,t=0,r=0;
    scanf("%lli",&n);
    fr(i,0,n) {
        char s[4];
        scanf("%s",s);
        if (s[0] == 'A') {a++;} 
        else if(s[0] == 'W') {w++;} 
        else if(s[0] == 'T') {t++;}
        else {r++;}
    }
    printf("AC x %lli\n",a);
    printf("WA x %lli\n",w);
    printf("TLE x %lli\n",t);
    printf("RE x %lli\n",r);
    return 0;
}

Measured memory_bytes: 1732
import java.util.*;


public class Main {
	private void doit(){
		Scanner sc = new Scanner(System.in);
//		while(sc.hasNext()){
//		}
		int n = sc.nextInt();
		System.out.println(0);
		String leftStr = sc.next();
		if(leftStr.equals("Vacant")){
			return;
		}
		
		System.out.println(n-1);
		String rightStr = sc.next();
		if(rightStr.equals("Vacant")){
			return;
		}
		
		int mid, left = 0, right = n -1;
		while(left <= right){
			mid = (left + right) / 2;
			System.out.println(mid);
			String res = sc.next();
			if(res.equals("Vacant")) return;
			
			if((right - mid) % 2 == 1){
				if(res.equals(rightStr)){
					left = mid;
					leftStr = res;
				}
				else{
					right = mid;
					rightStr = res;
				}
			}
			else{
				if(res.equals(rightStr)){
					right = mid;
					rightStr = res;
				}
				else{
					left = mid;
					leftStr = res;
				}
			}
			
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 24356
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   ll n;
   cin>>n;
   ll a[n],i;
   for(i=0;i<n;i++)
   cin>>a[i];
   
   aisort;
   for(i=0;i<n-1;i++)
   {
       if(a[i]==a[i+1])
       break;
   }
   if(i==(n-1))
   cout<<"YES";
   else
   cout<<"NO";
}



Measured memory_bytes: 5124
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Kaiden
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  if (a >= k) puts("1");
  else if (a <= b) puts("-1");
  else printf("%lld\n", (k - a + a - b - 1) / (a - b) * 2 + 1);

  return 0;
}


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


int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A >= B) {
		cout << B*C + (A - B)*D << endl;
	}else
	{
		cout << A*C<< endl;
	}
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int m,f,r;
    char g;
    while(1) {
        cin >> m >> f >> r;
        if (m==-1 && f==-1 && r==-1) break;
        if (m==-1 || f==-1) g='F';
        else if (m+f>=80) g='A';
        else if (m+f>=65) g='B';
        else if (m+f>=50) g='C';
        else if (m+f>=30 ) {
            g='D';
            if (r>=50) g='C';
        }
        else g='F';
        cout << g << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N = I()
A,B = [],[]  # x+y,x-y たちのリスト
for i in range(N):
    x,y = MI()
    A.append(x+y)
    B.append(x-y)

print(max(max(A)-min(A),max(B)-min(B)))


Measured memory_bytes: 91556
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;
vector <int> num;
int n, m;
int32_t main()
{
    cin >> n >> m;
    num.resize(n);
    fill(all(num),-1);
    while(m--)
    {
        int s, c;
        cin >> s >> c;
        if (num[s-1]!=-1 && num[s-1]!=c)
        {
            cout << -1 << '\n';
            return 0;
        }
        num[s-1] = c;
    }
    if (n == 1)
    {
        for (int i = 0; i<=9; i++)
        {
            if (num[0]==i || num[0] == -1)
            {
                cout << i << '\n';
                return 0;
            }
        }
    }
    if (n == 2)
    {
        for (int i = 10; i<=99; i++)
        {
            if ((num[0]==i/10 || num[0] == -1) && (num[1]==i%10 || num[1] == -1))
            {
                cout << i << '\n';
                return 0;
            }
        }
    }
    if (n == 3)
    {
        for (int i = 100; i<=999; i++)
        {
            if ((num[0]==i/100 || num[0] == -1) && (num[1]==((i%100)/10) || num[1] == -1) && (num[2]==i%10 || num[2] == -1))
            {
                cout << i << '\n';
                return 0;
            }
        }
    }
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 256
/*
 *  低知能マン
 */

#include <stdio.h>
#include <stdlib.h>

int dp[11][2001];
int books[10][2001];
int book_nums[10];
int sell_prices[10][2001];

int greater_int(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int main() {
    int a, b, c, d;
    int n, k;
    int max;

    scanf("%d %d", &n, &k);
    for (a=0; a<n; a++) {
        int c, g;
        int ind;

        scanf("%d %d", &c, &g);
        --g;
        ind = book_nums[g];
        books[g][ind] = c;
        ++book_nums[g];
    }
        
    for (a=0; a<10; a++) {
        qsort(books[a], book_nums[a], sizeof(int), greater_int);

        sell_prices[a][1] = books[a][0];
        for (b=2; b<=book_nums[a]; b++) {
            sell_prices[a][b] = sell_prices[a][b-1] + books[a][b-1] + (b-1)*2;
        }
    }

    for (a=0; a<10; a++) {
        for (b=0; b<k; b++) {
            int num;

            num = book_nums[a];
            if (num > k-b) {
                num = k-b;
            }

            for (c=0; c<=num; c++) {
                int val = dp[a][b] + sell_prices[a][c];
                int *p = &dp[a+1][b+c];

                if (*p < val) *p = val;
            }
        }
    }

    max = 0;
    for (a=0; a<=10; a++) {
        if (max < dp[a][k]) {
            max = dp[a][k];
        }
    }

    printf("%d\n", max);
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define mod 1000000009
#define int long long
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
	return ans;
}
signed main() {
	 garou;
	 int a,b;
	 cin>>a>>b;
	 cout<<a*b;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

ll rui(ll a,ll b){
    if(b==1) return a%mod;
    else if(b==0) return 1;
    else if(b%2==0) return (rui(a,b/2)*rui(a,b/2))%mod;
    else return (rui(a,b-1)*a)%mod;
}

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

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){

    int N,K;cin>>N>>K;
    make();
    cout<<comb(N-1,K-1)<<endl;
}




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

#define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef CMP
using namespace std;
#else
#endif
#ifdef ANS
#define DEBUG(...)
void init(){}
#else
#define DEBUG(...) PRINT("##DEBUG##","file :",__FILE__,", line :",__LINE__,"[");PRINT(__VA_ARGS__);PRINTl("]");
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif

void solve();

int main(int argc, char *argv[]) {

  init();
  DEBUG();
  solve();

  return 0;
}

void solve(){

  DEBUG("SOLVE START");

  ll x;cin>>x;
  ll p=x;
  ll c=0;
  while(p>0){
    c++;p=p/10;
  }
  DEBUG(c,p);
  ll ans = 0;
  REP(i,c/2){ans*=100;ans+=9;}
  if(c%2==1){
    auto base = 1;
    REP(i,c-1)base*=10;
    ans+=x-base+1;
  }
  PRINT(ans);

}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N, INF);
    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        for (int k = 1; k <= K; ++k) {
            if (i - k >= 0) {
                dp[i] = min(dp[i], dp[i-k] + abs(h[i] - h[i-k]));
            }
        }
    }

    cout << dp[N-1] << endl;
}


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

int main() {
	string n; cin >> n;
    int ans = 0;
    rep(i, n.size()) ans += n[i] - '0';
    if(ans%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 3724
var main = (standardInput) => {
  var lengthList = standardInput.split('\n');
  var length = parseInt(lengthList[0], 10);
  var string = lengthList[1];
  var ans = 0;
  for (var index = 0; index < 1000; index++) {
    var x0 = Math.floor(index / 100);
    var x1 = Math.floor((index / 10)) % 10;
    var x2 = index % 10;

    for (var i = 0; i < length; i++) {
      if (string[i] == x0) {
        for (var j = i+ 1; j < length; j++) {
          if (string[j] == x1) {
            for (var k = j + 1; k < length; k++) {
              if (string[k] == x2) {
                ans += 1;
                break;
              }
            }
            break;
          }
        }
        break;
      }
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 9548
#include <iostream>
#include <cmath>

enum IntersectionType{
  INCLUDED = 0,
  INSCRIBED = 1,
  INTERSECTED = 2,
  CIRCUMSCRIBED = 3,
  NOT_INTERSECTED = 4,
};

struct Circle2D{
  int JudgeIntersection(const Circle2D& another){
    const auto distance = std::hypot(x - another.x, y - another.y);
    const auto sumRadius = r + another.r;
    if(distance == sumRadius){
      return CIRCUMSCRIBED;
    }
    if(distance > sumRadius){
      return NOT_INTERSECTED;
    }
    const auto smallerRadius = r < another.r ? r : another.r;
    const auto greaterRadius = r > another.r ? r : another.r;
    const auto sumDistSmaller = distance + smallerRadius;
    if(sumDistSmaller < greaterRadius){
      return INCLUDED;
    }
    if(sumDistSmaller > greaterRadius){
      return INTERSECTED;
    }
    return INSCRIBED;
  }
  double x;
  double y;
  double r;
};

int main(){
  Circle2D c1;
  Circle2D c2;
  std::cin >> c1.x >> c1.y >> c1.r;
  std::cin >> c2.x >> c2.y >> c2.r;
  std::cout << c1.JudgeIntersection(c2) << std::endl;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) \
  for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int main() {
  string s;
  cin >> s;
  string res = "";
  for (int n = 0; n < s.sz; ++n) {
    if (s[n] == '0')
      res += '0';
    else if (s[n] == '1')
      res += '1';
    else {
      if (res.sz > 0) res.erase(--res.end());
    }
  }
  cout << res << endl;
  return 0;
}

// Built using Sublime-CHelper plug-in (beta)


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

int main()
{
    int n; cin>>n;
    set<int> s;
    for(int i=0; i<n; ++i) {
        int a; cin>>a;
        s.insert(a);
    }
    cout<<(s.size()==n ? "YES" : "NO")<<endl;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    lld a[n], b[n];
    rep(i, 0, n){
        scanf("%lld", &a[i]);
        b[i] = a[i];
    }
    lld sum_a = 0, sum_b = 0;
    lld cost_a = 0, cost_b = 0;
    rep(i, 0, n){
        sum_a += a[i];
        sum_b += b[i];
        if(i%2){
            if(sum_a >= 0){
                cost_a += -1*(-1 - sum_a);
                sum_a = -1;
            }
            if(sum_b <= 0){
                cost_b += 1 - sum_b;
                sum_b = 1;
            }
        }else{
            if(sum_a <= 0){
                cost_a += 1 - sum_a;
                sum_a = 1;
            }
            if(sum_b >= 0){
                cost_b += -1*(-1 - sum_b);
                sum_b = -1;
            }
        }
    }
    printf("%lld", cost_a<cost_b ? cost_a : cost_b);

    return 0;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc079/tasks/abc079_c

"""
import sys
from sys import stdin
from itertools import product
input = stdin.readline


def main(args):
    temp = input().strip()
    A = int(temp[0])
    B = int(temp[1])
    C = int(temp[2])
    D = int(temp[3])

    op1, op2, op3 = None, None, None
    exp = None
    for op1, op2, op3 in product('+-', repeat=3):
        exp = '{}{}{}{}{}{}{}'.format(A, op1, B, op2, C, op3, D)
        if eval(exp) == 7:
            break
    print(exp + '=7')


if __name__ == '__main__':
    main(sys.argv[1:])
    


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

const int maxn = 1e6;

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

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

	vector<int> res(maxn+2);
   
	for(int i=0;i<n;i++){
		if(arr[i]>0) res[arr[i]-1]++;
		if(arr[i]<maxn) res[arr[i]+1]++;
		res[arr[i]]++;
	}
	int ans = 0;
	for(int i=0;i<maxn+2;i++) {
		ans = max(res[i],ans);
	}
	cout<<ans;

}

Measured memory_bytes: 4480
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let buf: Vec<&str> = iter.collect();
	let mut d = Vec::new();
	for n in buf {
			d.push(
				match n.to_string().parse::<i32>(){
					Ok(m) => m,
					_ => panic!(""),
				}
			);
	}
	let mut ret = 0;
	for i in 0..d.len() {
		for j in (i+1)..d.len() {
			ret = ret + d[i]*d[j];
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
h,w = map(int,input().split())
a_list = [[s for s in input()] for _ in range(h)]

return_list = []

for i,row in enumerate(a_list):
    if i == 0:
        return_list.append(['#' for _ in range(w+2)])
    row.insert(0,'#')
    row.append('#')
    return_list.append(row)
    if i == len(a_list)-1:
        return_list.append(['#' for _ in range(w+2)])

for elem in return_list:
    print(''.join(elem))

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;
int main(){
  long long H, W;
  cin >> H >> W;

  long long first_row, second_row;
  long long sum;

  if(W%2==0){
    first_row=W/2;
    second_row=first_row;
  }
  else{
    first_row=(W+1)/2;
    second_row=first_row-1;
  }

  if(H%2==0){
    sum = (first_row+second_row)*(H/2);
  }
  else{
    sum = (first_row+second_row)*((H+1)/2) - second_row;
  }

  if(W==1 || H==1)
      sum = 1;
  cout << sum << endl;

}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  sort(vec.begin(),vec.end());
  
  vector<int> mochi;
  mochi.push_back(vec[0]);
  
  for(int i=1; i<N; i++){
    if(vec.at(i)!=vec.at(i-1)){
      mochi.push_back(vec[i]);
    }
  }
  cout << mochi.size() << endl;
}

Measured memory_bytes: 256
def area(p,q):return p[0]*q[1]-p[1]*q[0]
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(s*0.5)

Measured memory_bytes: 7728
#include<bits/stdc++.h>
using namespace std;int n,q,X,A,i,j,s,t;int main(){cin>>n;for(i=0;i<n;i++){s=0;cin>>q;X=q;while(X>9){A=0;for(j=1;j<10;j++){t=pow(10.0,j);if(q/t<1){break;}A=max((X/t)*(X%t),A);}s++;if(s>=1000){s=-1;break;}X=A;}cout<<s<<endl;}}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int p[3];
    int donkaku=0,eikaku=0,tyokkaku=0;
    while(cin>>p[0]>>p[1]>>p[2]){
        sort(p,p+3);
        if(p[0]+p[1]<=p[2]){
            cout<<donkaku+eikaku+tyokkaku<<" "<<tyokkaku<<" "<<eikaku<<" "<<donkaku<<endl;break;
        }
        if(p[2]*p[2]<p[1]*p[1]+p[0]*p[0])eikaku++;
        else if(p[2]*p[2]>p[1]*p[1]+p[0]*p[0])donkaku++;
        else tyokkaku++;
        
    }
    return 0;
    
}


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

int main() {
  bool ans = false;
  vector<int> num(4);
  int number;
  cin >> number;
  
  num.at(3) = number % 10;
  num.at(2) = (number % 100 - number % 10) / 10;
  num.at(1) = (number % 1000 - number % 100) / 100 ;
  num.at(0) = number / 1000;
  
  for (int i = 0; i < 2; i++) {
    if (num.at(i) == num.at(i+1) && num.at(i+1) == num.at(i+2))
      ans = true;
  }
  
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

int main(){
    ll n,a[200005],cnt=0,sum=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(i>0){
            if(a[i]<=a[i-1]){
                cnt++;
                if(sum<cnt){
                    sum=cnt;
                }
            }else{
                cnt=0;
            }
        }
    }
    cout<<sum;
}

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

int main(){
    string n;
    cin >> n;
    int sum = 0;
    rep(i, n.size()){
        sum += n[i] - '0';
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0; 
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{
  ll to,id;
  Edge(ll to,ll id):to(to),id(id){}
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;

ll N,M;
vi A(100000),B(100000);
Graph G(100000);
vi vis(100000,0);
list<ll> path;

int main() {
  cin>>N>>M;
  REP(i,M) {
    cin>>A[i]>>B[i]; A[i]-=1; B[i]-=1;
    G[A[i]].PB(Edge(B[i],i));
    G[B[i]].PB(Edge(A[i],i));
  }

  ll l,r; l=r=0;
  vis[0]=true;
  path.PB(0);

  while_start:
  for(Edge e:G[r]) {
    if(!vis[e.to]) {
      vis[e.to]=true;
      r=e.to;
      path.push_back(e.to);
      goto while_start;
    }
  }

  for(Edge e:G[l]) {
    if(!vis[e.to]) {
      vis[e.to]=true;
      l=e.to;
      path.push_front(e.to);
      goto while_start;
    }
  }

  cout<<path.size()<<endl;
  for(auto it=path.begin();it!=path.end();++it) {
    if(next(it)==path.end()) cout<<(*it)+1<<endl;
    else cout<<(*it)+1<<' ';
  }

}


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

using namespace std;

int main()
{
    int a, b, sum = 0;
    char c;
    double num = 0, N = 0;
    while (cin >> a >> c >> b) {
        sum += a * b;
        num += b;
        N += 1.0;
    }
    cout << sum << '\n' << (int)(num / N + 0.5) << endl;
    return 0;
}

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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
int main(){
	std::vector<int> graph[10];
	for(int i=0;i<3;i++){
		int a,b;
		cin>>a>>b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	std::vector<int> v;
	for(int i=1;i<=4;i++){
		v.pb(graph[i].size());
	}
	sort(v.begin(),v.end());
	if(v[0]==1 and v[1]==1 and v[2]==2 and v[3]==2){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M;
string S;
ll DP[5001][5001];

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

int main() {
	cin >> N >> S;
	M = S.size();
	DP[0][0] = 1;
	for (int i = 0; i < N; ++i) {
		DP[i + 1][0] = DP[i][0];
		for (int j = 0; j < N; ++j) {
			DP[i + 1][j + 1] = DP[i][j] * 2 % mod;
			DP[i + 1][j - 1] = (DP[i + 1][j - 1] + DP[i][j]) % mod;
		}
	}
	cout << DP[N][M] * modinv(pw(2, M)) % mod << endl;
}

Measured memory_bytes: 195584
n, m = gets.split(' ').map(&:to_i)

$roots = (0...n).map {|i| i }
$counts = (0...n).map { 1 }

def root(i)
  return i if $roots[i] == i
  r = root($roots[i])
  $roots[i] = r
  r
end

def unite(i, j)
  ri = root(i)
  rj = root(j)
  return if ri == rj
  $roots[rj] = ri
  $counts[ri] += $counts[rj]
end

m.times do |i|
  a, b = gets.split(' ').map(&:to_i)
  a -= 1
  b -= 1
  unite(a, b)
end

puts $counts.max


Measured memory_bytes: 17748
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

    string s,t;
    cin >> s;
    cin >> t;
    int ans=0;
    for(int i=0; i<3; i++){
        if(s[i]==t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	int N;
	cin >> N;
	map<string, int> dic;
	string str;
	rep(i, N)
	{
		cin >> str;
		dic[str]++;
	}
	int max = 0;
	for(auto itr = dic.begin(); itr != dic.end(); ++itr)
	{
		if(itr->second>max)
		{
			max = itr->second;
		}
	}
	for(auto itr = dic.begin(); itr != dic.end(); ++itr)
	{
		if(max==itr->second)
		{
			cout << itr->first << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    string s;
    int n, k, cnt0 = 0, cnt1 = 0;
    cin >> n >> k >> s;
    vector<int> a, b;
    rep(i, n){
        if(s[i] == '0')cnt0++;
        if(s[i] == '1'){
            if(!i);  
            else if(s[i-1] == '0')a.push_back(cnt0); 
            cnt0 = 0;
        }
        if(s[i] == '1')cnt1++;
        if(s[i] == '0'){
            if(!i);
            else if(s[i-1] == '1')b.push_back(cnt1);
            cnt1 = 0;
        }
    }
    if(s[0] == '0')b.insert(b.begin(), 0);
    if(s[n-1] == '1'){
        b.push_back(cnt1);
    }else{
        b.push_back(0);
        a.push_back(cnt0);
    }
    vector<int> vec; vec.push_back(b[0]);
    rep(i, b.size()-1){
        vec.push_back(a[i]);
        vec.push_back(b[i+1]);
    }
    int num = 0, sum = 0, ans = 0;
    rep(i, min((int)vec.size(), 2*k+1))sum += vec[i];
    ans = sum;
    for(int i = 2*k+2; i < vec.size(); i+=2){
        sum += vec[i] + vec[i-1];
        sum -= vec[i-2*k-2] + vec[i-2*k-1];
        chmax(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4544
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

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

int main() {
	string s;
	cin >> s;
	deque<char> Q(s.begin(), s.end());
	int q;
	cin >> q;
	int dir = 0, typ, f;
	char c;
	while (q--) {
		cin >> typ;
		if (typ == 1) {
			dir ^= 1;
		} else {
			cin >> f >> c;
			f--;
			if (dir ^ f)
				Q.push_back(c);
			else
				Q.push_front(c);
		}
	}
	string res(Q.begin(), Q.end());
	if (dir == 1)
		reverse(res.begin(), res.end());
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1280
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())


if (b1 - a1) * t1 == (a2 - b2) * t2:
    print("infinity")
    import sys
    sys.exit()

p1 = (b1 - a1) * t1 
p2 = (b1 - a1) * t1 + (b2 - a2) * t2

if p1 * p2 > 0:
    print(0)
    import sys
    sys.exit()

import math

if abs(p1)%abs(p2) == 0:
     print(2*math.ceil(abs(p1)/abs(p2)))
else:
    print(2*math.ceil(abs(p1)/abs(p2))-1)

Measured memory_bytes: 38384
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
# import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 10
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = [na() for _ in range(n)]

    query = []

    for i, di in enumerate(d):
        s = di[0] - di[1]
        t = di[0] + di[1]
        query.append((s, 1, i))
        query.append((t, 0, i))

    query.sort(key=lambda x: x[1])
    query.sort()

    ans = 0
    idx = -1
    for x, st, i in query:
        if st == 0:
            if idx == i:
                idx = -1
        if st == 1:
            if idx == -1:
                idx = i
            else:
                if d[idx][0] + d[idx][1] > d[i][0] + d[i][1]:
                    idx = i
                ans += 1

    print(n - ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 55260
import sys
N = int(input())
W = []
for i in range(N):
    W.append(input())
if len(set(W)) != len(W):
    print("No")
else:
    for i in range(len(W)-1):
        if W[i][-1] != W[i+1][0]:
            print("No")
            sys.exit()
    print("Yes")


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> img(H);
  for (int i = 0; i < H; ++i) {
    cin >> img.at(i);
  }
  
  cout << "#";
  for (int j = 0; j < W; ++j) cout << "#";
  cout << "#" << endl;
  
  for (int i = 0; i < H; ++i) {
    cout << "#";
    cout << img.at(i);
    cout << "#" << endl;
  }
  
  cout << "#";
  for (int j = 0; j < W; ++j) cout << "#";
  cout << "#" << endl;
}


Measured memory_bytes: 256
n = int(input())
result = [input() for i in range(n)]

ans = [0,0,0,0]

for i in range(n):
    if result[i] == "AC":
        ans[0] += 1
    elif result[i] == "WA":
        ans[1] += 1
    elif result[i] == "TLE":
        ans[2] += 1
    elif result[i] == "RE":
        ans[3] += 1

print("AC x",ans[0])
print("WA x",ans[1])
print("TLE x",ans[2])
print("RE x",ans[3])

Measured memory_bytes: 16332
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(int(n/l[2])+1):
    for j in range(int(n/l[1])+1):
        x = l[2]*i
        y = l[1]*j
        if (n-x-y) < 0:
            break
        if (n-x-y) >= 0 and (n-x-y)%l[0] == 0:
            count = count + 1
print(count)

Measured memory_bytes: 40684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main()
{
    vector<string> week = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
    string s;
    cin >> s;
    int index = 0;
    for(int i = 0; i < week.size();i++){
        if (week[i] == s){
            index = i;
            break;
        }
    }
    int ans = 6-index;
    if(ans == 0){
        ans = 7;
    }
    cout << ans << endl;
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X[101010];
int cnt[101010];
ll mo=1000000007;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	int fail=0,prex=0;
	FOR(i,N) {
		cin>>X[i];
		
		cnt[(fail+1)/2]++;
		if(i==0) {
			X[0]=1;
		}
		else{
			
			if(X[i]>=X[i-1]+2) X[i]=X[i-1]+2;
			if(X[i-1]+1==X[i]) fail++;
		}
	}
	
	ll ret=1;
	ll tot=0;
	FOR(i,N) {
		tot += cnt[i];
		(ret *= tot)%=mo;
		tot--;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 896
local s = io.read("l")
local t = {}
for i=1,4 do
    local x = string.sub(s, i, i)
    t[x] = (t[x] or 0) + 1
end
for k,v in pairs(t) do
    if v ~= 2 then
        print("No")
        return
    end
end
print("Yes")

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

int n;
vector<int> v;

int solve();
int calc(int x);

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  n = v[n - 1];
  v.erase(v.begin() + (v.size() - 1));
  cout << n << " " << solve() << endl;
  return 0;
}

int solve() {
  int ans = v[0];
  for(int i = 1; i < v.size(); ++i)
    if(calc(v[i]) < calc(ans)) ans = v[i];
  return ans;
}

int calc(int x) {
  if(n % 2) return abs(((n + 1) / 2) - x);
  return min(abs((n / 2) - x), abs((n + 2) / 2 - x));
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        long mod = 1000_000_000 + 7;

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        long ans = 0;
        for (int i = 0; i < 60; i++) {
            int countZero = 0;
            int countOne = 0;
            for (int j = 0; j < n; j++) {
                if ((a[j] >> i) % 2 == 1) {
                    countOne++;
                } else {
                    countZero++;
                }
            }
            long tmp = (((power(i) % mod) * countOne % mod) * countZero) % mod;
            // System.out.println(power(i) + ":" + countOne + ":" + countZero + ":" + tmp);
            ans += tmp;
            ans = ans % mod;
        }

        System.out.println(ans);

        sc.close();
    }

    static long power(int num) {
        long ret = 1;
        for (int i = 0; i < num; i++) {
            ret *= 2;
        }
        return ret;
    }
}


Measured memory_bytes: 98756
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    int n = (int)s.length();

    vector<int> v(1, n);
    rep(n-1){
        if(s[i] != s[i+1]){
            v.push_back(max(i+1, n-i-1));
        }
    }
    cout << *min_element(all(v)) << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a < 10 && b < 10) {
		cout << a*b << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	long long n;
	string s,a,ans;
	cin >> n >> s >> a;

	for (long long i = 0; i < n; i++)
	{
		ans.push_back(s[i]);
		ans.push_back(a[i]);
	}
	
	
	cout << ans << std::endl;
}

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

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

#define clr( a , x ) memset ( a , x , sizeof a )

const int MAXN = 400005 ;

struct Node {
	char s[27] ;
	int idx ;
} ;

vector < Node > G[MAXN] ;

int nxt[MAXN][26] ;
int letter[MAXN] ;
int pre[MAXN] ;
int siz[MAXN] ;
int is[MAXN] ;
int word[MAXN] ;
int cur = 0 ;
int n , q ;
char s[MAXN] ;
int sum[26][26] ;
int to[26] ;
int ans[MAXN] ;

int newnode () {
	clr ( nxt[cur] , 0 ) ;
	siz[cur] = 0 ;
	is[cur] = 0 ;
	return cur ++ ;
}

int insert ( char s[] , int idx ) {
	int now = 0 ;
	for ( int i = 0 ; s[i] ; ++ i ) {
		int x = s[i] - 'a' ;
		if ( nxt[now][x] == 0 ) nxt[now][x] = newnode () ;
		pre[nxt[now][x]] = now ;
		now = nxt[now][x] ;
		letter[now] = x ;
		siz[now] ++ ;
	}
	is[now] ++ ;
	return now ;
}

void get ( int u ) {
	while ( u ) {
		for ( int i = 0 ; i < 26 ; ++ i ) if ( i != letter[u] ) {
			sum[i][letter[u]] += siz[nxt[pre[u]][i]] ;
		}
		sum[letter[u]][letter[u]] += is[pre[u]] ;
		u = pre[u] ;
	}
}

void solve () {
	cur = 0 ;
	newnode () ;
	clr ( sum , 0 ) ;
	for ( int i = 1 ; i <= n ; ++ i ) {
		scanf ( "%s" , s ) ;
		G[i].clear () ;
		word[i] = insert ( s , i ) ;
	}
	scanf ( "%d" , &q ) ;
	for ( int i = 0 ; i < q ; ++ i ) {
		Node tmp ;
		int u ;
		scanf ( "%d%s" , &u , tmp.s ) ;
		tmp.idx = i ;
		G[u].push_back ( tmp ) ;
	}
	for ( int i = 1 ; i <= n ; ++ i ) {
		clr ( sum , 0 ) ;
		get ( word[i] ) ;
		for ( int j = 0 ; j < G[i].size () ; ++ j ) {
			int tmp = 0 ;
			for ( int k = 0 ; k < 26 ; ++ k ) {
				to[k] = G[i][j].s[k] - 'a' ;
			}
			for ( int k = 0 ; k < 26 ; ++ k ) {
				for ( int l = k ; l < 26 ; ++ l ) {
					tmp += sum[to[k]][to[l]] ;
				}
			}
			ans[G[i][j].idx] = tmp ;
		}
	}
	for ( int i = 0 ; i < q ; ++ i ) {
		printf ( "%d\n" , ans[i] + 1 ) ;
	}
}

int main () {
	while ( ~scanf ( "%d" , &n ) ) solve () ;
	return 0 ;
}

Measured memory_bytes: 61952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

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

    ll g = gcd(a, b);
    auto f = factorize(g);

    cout << f.size() + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, m;
signed main() {
	cin >> n >> m;
	if (n == m) {
		cout << n + 1 << endl; return 0;
	}
	//N>=b^2
	for (int i = 2; i * i <= n; i++) {
		int nn = n, sum = 0;
		while (nn) {
			sum += nn % i;
			nn /= i;
		}
		if (sum == m) {
			cout << i << endl; return 0;
		}
	}
	//N<b^2
	int k = n - m, ans = -1;
	for (int i = 1; i * i <= k && i <= m; i++) {
		if (k % i)continue;
		int b = k / i + 1;
		if (m - i < b)ans = b;
	}
	cout << ans << endl;
}

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++)

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

    int p, q;
    cin >> p >> q;
    int g = __gcd(p, q);
    q /= g;
    int ans = 1;
    for (int i = 2; i * i <= q; i++) {
        if (q % i == 0) {
            ans *= i;
            while (q % i == 0) {
                q /= i;
            }
        }
    }
    if (q > 1) ans *= q;
    cout << ans << endl;
}



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

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

    int n = s.size(),
        m = t.size();
    
    int i, j, ct = 0, ans = __builtin_inf();
    for (i = 0; i + m <= n; ++i) {
        auto sex = s.substr(i, m);
        for (j = 0; j < m; ++j)
            if (sex[j] != t[j])
                ++ct;
            
        ans = min(ans, ct);
        ct = 0;
    }

    cout << ans;
    return 0;
}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C>> K;
    int count = 0;
    while(B <= A) {
        B*=2;
        count++;
    } 
    while(C <= B) {
        C*=2;
        count++;
    }
    if(count <= K) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3636
a,b = map(int,input().split(' '))

ans = 0

if max(a,b) == a:
    ans += a
    a -= 1
else:
    ans += b
    b -= 1

if max(a,b) == a:
    ans += a
    a -= 1
else:
    ans += b
    b -= 1

print(ans)



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

int main()
{
    int N;
    int data[1000];

    while (cin >> N, N != 0) {
        vector < int > vec;
        bool flag = false;
        N++;
        for ( int i = 0; i < N; i++ ) {
            cin >> data[i];
        }

        for ( int i = 0; i < N - 1; i++ ) {
            vec.push_back(data[i + 1] - data[i]);
        }

        sort(begin(vec), end(vec));
        vec.erase(unique(begin(vec), end(vec)), end(vec));

        for ( int i = 0; i < vec.size(); i++ ) {
            int d = vec[i];
            for ( int j = 0; j < N; j++ ) {  //naniwonukuka
                vector < int > dat;
                for ( int k = 0; k < N; k++ ) {
                    if ( k != j ) {
                        dat.push_back(data[k]);
                    }
                }
                int d = dat[1] - dat[0];
                bool differ = false;
                for ( int k = 1; k < N - 2; k++ ) { //mawasu
                    if ( d != (dat[k + 1] - dat[k]) ) {
                        differ = true;
                    }
                }
                if ( !differ ) {
                    cout << data[j] << endl;
                    flag = true;
                    break;
                }
            }
            if ( flag ) {
                break;
            }
        }

    }
    return ( 0 );
}



Measured memory_bytes: 3152