akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a;i<(ll)b;i--)
#define Fi fiest
#define Se second
const ll MAX = 1000000;
const char ENDL = '\n';

ll ans = 0;

void grf(vector<ll> visited, map<ll, set<ll>> branch, ll N) {
	if (visited.size() == N) {
		ans++;
		return;
	}

	for (auto x : branch[visited[visited.size() - 1]]) {
		bool flag = 1;
		for (auto y : visited) {
			if (x == y) {
				flag = 0;
				break;
			}
		}

		if (flag) {
			vector<ll> visiteded = visited;
			visiteded.push_back(x);
			grf(visiteded, branch, N);
		}
	}
}

int main() {
	ll N, M, a, b;
	cin >> N >> M;
	map<ll, set<ll>> branch;
	rep(i, M) {
		cin >> a >> b;
		branch[a].insert(b);
		branch[b].insert(a);
	}
	vector<ll> visited = { 1 };
	grf(visited, branch, N);

	cout << ans << ENDL;
	return 0;
}

Measured memory_bytes: 764
import sys


fin = sys.stdin.readline
N = int(fin())
A_list = [int(elem) for elem in fin().split()]
B_list = [int(elem) for elem in fin().split()]
max_num_beaten = 0
for i, B in enumerate(B_list):
    cur_power = B
    A0 = A_list[i]
    num_beaten = min(A0, cur_power)
    A_list[i] -= num_beaten
    max_num_beaten += num_beaten
    cur_power -= num_beaten

    A1 = A_list[i + 1]
    num_beaten = min(A1, cur_power)
    A_list[i + 1] -= num_beaten
    max_num_beaten += num_beaten

print(max_num_beaten)


Measured memory_bytes: 73316
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
using VB  = vector<bool>;
using VI  = vector<int>;
using PII = pair<int, int>;
using VP  = vector<PII>;
using VVP = vector<VP>;
VB viz;
VI color;
VVP g;
int n, cmax;
inline void DFS(int x, int w) {
    viz[x] = true;
    int temp(1), y, i;
    for (const PII& P : g[x]) {
        tie(y, i) = P;
        if (!viz[y]) {
            DFS(y, temp + (temp >= w));
            color[i] = temp + (temp >= w);
            ++temp;
        }
    }
}
int x, y;
int main() {
    DAU
    cin >> n;
    g = VVP(n + 1);
    for (int i = 1; i < n; ++i) {
        cin >> x >> y;
        g[x].emplace_back(y, i);
        g[y].emplace_back(x, i);
    }
    viz = VB(n + 1);
    color = VI(n);
    DFS(1, n);
    for (int i = 1; i < n; ++i)
        cmax = max(cmax, color[i]);
    cout << cmax << '\n';
    for (int i = 1; i < n; ++i)
        cout << color[i] << '\n';
    PLEC
}


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

int main(){
  long long x, k, d;
  cin >> x >> k >> d;
  
  if (x < 0) {
    x = -x;
  }

  if (x / d >= k) {
    cout << x - d * k << endl;
  } else {
    k -= x / d;
    x %= d;
    
    if (k % 2 == 0){
      cout << x << endl;
    } else {
      cout << d - x << endl;
    }
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	int x; cin >> x; int ch = 0;
	if (x % 2 == 0 && x != 2) {
		x += 1;
		for (;;) {
			int pq = floor(sqrt(x));
			for (int i = 3; i <= pq; i++) {
				if (x % i == 0)
					break;
				if (i == pq)
					ch = 1;
			}
			if (ch == 1)
				break;
			x += 2;
		}
	}
	if (x % 2 == 1 && x != 2) {
		for (;;) {
			int pq = floor(sqrt(x));
			for (int i = 3; i <= pq; i++) {
				if (x % i == 0)
					break;
				if (i == pq)
					ch = 1;
			}
			if (ch == 1)
				break;
			x += 2;
		}
	}
	cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{
	string s;
	cin >> s;
	int x;
	x = s.size();
	if (s[x - 1] == 's')
	{
		cout << s << "es" << endl;
	}

	else
	{
		cout << s << "s" << endl;
	}


}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S; cin >> S;
    int a = 0, b = 0;
    for (int i = 0; i < S.size(); i++) {
        a += S[i] - '0';
        b += i == 0 ? S[i]-'0'-1 : 9;
    }
    cout << max(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
al=[]
bl=[]
for _ in range(n):
    al.append(input())
for _ in range(m):
    bl.append(input())

bl_left_top=bl[0][0]

ans=0
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if al[i+k][j:j+m]!=bl[k]:
                break
            if k==m-1:
                ans=1
    if ans==1:
        break

print('Yes') if ans==1 else print('No')

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

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

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

string s;

int main(){
	cin >> s;
	int c = 0;
	for(int i = 1; i < s.size(); i++){
		if(s[i-1] != s[i]) c++;
	}
	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF = 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a[3];
    cin >> a[0];
    cin >> a[1];
    cin >> a[2];
    sort(a, a + 3);
    intl cnt = 3;
    if(a[0] == a[1])cnt--;
    if(a[1] == a[2])cnt--;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const long long SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑





int main() {

	int a, b;
	cin >> a >> b;
	cout << (b + 3 * a) / 2 << endl;







}

Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
to = [[] for _ in range(n)]
v = []
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)
    v.append((a,b))
ans = m
seen = [False]*n
stk = deque()
for i in range(m):
    a,b = v[i]
    stk.clear()
    stk.append((a,-1))
    for j in range(n): seen[j] = False
    seen[a] = True
    flag = True
    while stk and flag:
        cur,prev = stk.pop()
        seen[cur] = True
        for nxt in to[cur]:
            if nxt == b:
                if cur == a: continue
                ans -= 1
                flag = False
                break
            if nxt == prev: continue
            if seen[nxt]: continue
            stk.append((nxt,cur))

print(ans)

Measured memory_bytes: 3316
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    if A[0] > 0:
        print(-1)
        return
    for n in range(N - 1):
        if  A[n + 1] >= A[n] + 2:
            print(-1)
            return
    # 後ろから見ていく。前項以上なら加算、前項未満なら加算せず。
    A = A[::-1]
    ans = A[0]
    for n in range(N - 1):
        if A[n + 1] >= A[n]:
            ans += A[n + 1]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18620
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "";
        for(int i = 0; i < s.length(); i++){
            ans += "x";
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 23764
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            summy = 500*i + 100*j + 50*k
            if summy == X:
                count = count + 1

print(count)

Measured memory_bytes: 3060
import sys

x, y = map(int, input().split())

if (x + y) % 3 != 0:
  print (0)
  sys.exit(0)

mod = 10 ** 9 + 7

def inv(x):
  return pow(x, mod-2, mod)

def fac(n):
  ans = 1
  for i in range(1, n+1):
    ans = (ans * i) % mod
  return ans

a = y - (x + y) // 3
b = x - (x + y) // 3

if a < 0 or b < 0:
  print (0)
  sys.exit(0)

ans = fac(a+b)
ans = (ans * inv(fac(a))) % mod
ans = (ans * inv(fac(b))) % mod
print (ans)



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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read() 	        freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n) 	        scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n) 	        scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%ull",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps 	        1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod 1000000007
#define var    int i,j,k,n,m,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};
string s;
int main()
{
    var;
    cin>>n>>s;
    c=0,z=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='E')c++;
        else z++;
    }
    x=0;y=0;m=0,r=0;
    int ans=inf;
    for(i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            m+=x;
            m+=(c-y);
            ans=min(ans,m);
            m=0;
            x++;
        }
        else
        {
            m+=x;
            y++;
            m+=(c-y);
            ans=min(ans,m);
            m=0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 900
using System;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    double result = 0;
    
    for (int a=1;a<=n;a++) {
      for (int b=1;b<=n;b++) {
        int gpd_ab = Gpd(a, b);
        for (int c=1;c<=n;c++) {
          result += Gpd(gpd_ab, c);
        }
      }
    }
    
    Console.WriteLine(result.ToString());
  }
  
  static int Gpd(int x, int y) {
    if (x < y) {
      return Gpd(y, x);
    } else {
      int r = x%y;
      if (r!=0) {
        return Gpd(y, r);
      } else {
        return y;
      }
    }
  }
}

Measured memory_bytes: 27548
#include <cstdio>
#include <cstdint>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

int testcase_ends() {
  char buf[1024];
  scanf("%s", buf);
  std::string s = buf;
  if (s == "#") return 1;

  std::vector<int> d;
  {
    size_t i = 0;
    while (i < s.length()) {
      if (s[i] == 'n') {
        d.push_back(0);
        i += 5;
      } else if (s[i] == 'w') {
        d.push_back(1);
        i += 4;
      }
    }
  }

  std::reverse(d.begin(), d.end());
  int a1 = (d[0]? 90: 0);
  int a0 = 1;
  for (size_t i = 1; i < d.size(); ++i) {
    if (d[i]) {
      a1 *= 2;
      a1 += 90;
    } else {
      a1 *= 2;
      a1 -= 90;
    }
    a0 *= 2;
  }
  while (a1 % 2 == 0 && a0 % 2 == 0) {
    a1 /= 2;
    a0 /= 2;
  }

  printf("%d", a1);
  if (a0 > 1) printf("/%d", a0);
  puts("");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2848
#include <stdio.h>
#include <stdlib.h>
int desc(const void *a,const void *b){
    return *(int*)b-*(int*)a;
}
int main(void){
    int a[3],i,k;
    long sum=0;
    for(i=0;i<3;i++) scanf("%d",&a[i]);
    scanf("%d",&k);
    qsort(a,3,sizeof(int),desc);
    for(i=0;i<k;i++){
        a[0]*=2;
    }
    for(i=0;i<3;i++) sum+=a[i];
    printf("%ld",sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <string.h>
#include <algorithm>

using namespace std;


int N,W;
int v[1100],w[1100];
int dp[11000][1100];

int nup(int, int);

int main(){
  	
    cin >> N >> W;
    for(int i = 0; i<W; i++){
        for(int j = 0; j < 110000; j++){
          dp[i][j] = -1;
      }
    }
    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }

    cout << nup(W,0) << endl;
}

int nup(int inh, int k){
    int va;
  	if(dp[inh][k] != -1) return dp[inh][k];
    if(k  == N) return 0;
    if(inh < w[k]){
        va = nup(inh, k+1);
    }else{
        va = max(nup(inh, k+1), nup(inh-w[k], k+1) + v[k]);
    }
	dp[inh][k] = va;
    return va;
}


Measured memory_bytes: 46508
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> A;
  cin >> S;
  if (A >=3200) cout << S << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

int main(){
	ll n; cin >> n;
	ll ans=0;
	for(int i=1;i<n;i++){
		for(int j=i;j<n;j+=i){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

def f(x):
    i = 0
    res = 0 
    while (x>>i)>0:
        r = 1<<i
        if i == 0:
            if x%4 == 1 or x%4 == 2:
                res |= 1
            else:
                res |= 0
        else:
            d = x % (r<<1)
            if d >= r:
                res |= ((d-1)%2)<<i
        i += 1      
    return res

print(f(b)^f(a)^a)



Measured memory_bytes: 3060
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    long N;
    scan(N);

    foreach(h ; 1 .. 3501) {
        foreach (n ; 1 .. 3501) {
            long x = 4L * h * n;
            long hn = 1L * h * n;

            //writeln(x, " " , hn);
            
            if (x % N) {
                continue;
            }

            long denom = 4L * h * n / N - n - h;

            //writeln(denom);

            if (denom <= 0 || hn % denom) {
                continue;
            }

            debug {
                //writeln(hn, denom);
            }

            long w = hn / denom;

            if (0 < w && w <= 3500) {
                writeln(h, " ", n, " ", w);
                return;
            }

        }
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main(){

int n,a,b,c,d,cnt=0,max=0,k,cnt2=0;
char s[200000];

scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
scanf("%s",&s);

k=c>d?c:d;

for(int j=a;j<k-1;j++){
	if(s[j]=='#'&&s[j+1]=='#'){cnt2++;break;}
	}
	
if(cnt2!=0){
	printf("No");
	}
else{
		
		
if(c>d){
	for(int i=b-1;i<d;i++){
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
			printf("Yes");
			return 0;
			}
	}
	printf("No");
	return 0;
}
if(d>c){
	printf("Yes");
}

}
return 0;
}

Measured memory_bytes: 384
import numpy as np
 
N, K = map(int, input().split())
A = list(map(int, input().split()))
M = 10**9 + 7
 
def prod(X):
    ans = 1
    for x in X:
        ans = ans * x % M
    return ans
 
def solve():
    # Case 1: N == K
    if N == K:
        return prod(A)
 
    # Case 2: ans is negative
    if all(a < 0 for a in A) and K % 2 == 1:
        return prod(sorted(A)[-K:])
 
    # Case 3: ans is positive
    posA = np.int64(sorted([a for a in A if a >= 0]))
    negA = np.int64(sorted([a for a in A if a < 0]))
 
    ans = 1
    if K % 2 == 1: # Keep the largest positive
        ans = ans * posA[-1] % M
        posA = posA[:-1]
    
    # Construct largest value by pairing items
    if len(posA) % 2 == 1: # Discard the one with smallest absolute value
        posA = posA[1:]
    if len(negA) % 2 == 1: # Discard the one with smallest absolute value
        negA = negA[:-1]
    pos_pairs = posA[0::2] * posA[1::2]
    neg_pairs = negA[0::2] * negA[1::2]
    pairs = np.concatenate([pos_pairs, neg_pairs], axis=0).tolist()
    pairs = sorted(pairs, reverse=True)[:K//2]
    ans = ans * prod(pairs) % M
 
    return ans
 
print(solve())

Measured memory_bytes: 50048
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
signed main(){
	while(true){
		double x,h;
		scanf("%lf",&x);
		scanf("%lf",&h);
		if(x==0&&h==0) break;
		double s = sqrt(h*h+x*x/4.0);
		printf("%f\n",x*x+x*s*2.0);
	}
	return 0;
}

Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>
int main(void){
	char s[3][15];
	int sl[3];
	int i;
	
	scanf("%s %s %s",s[0],s[1],s[2]);
	for(i=0;i<3;i++){
		sl[i]=strlen(s[i]);
	}
	/*printf("(a:b)(%c %c),(b:c)(%c %c)\n",
		s[0][sl[0]-1],s[1][0],s[1][sl[1]-1],s[2][0]);
	printf("%d %d %d\n",sl[0],sl[1],sl[2]);*/
	if(s[0][sl[0]-1]==s[1][0]){
		if(s[1][sl[1]-1]==s[2][0]){
			puts("YES");
		}else{
			puts("NO");
		}
	}else{
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll l = 2, r = 3;
    Rrep(i,N){
        ll nl = (l + a[i] - 1) / a[i], nr = (r - 1) / a[i];//下限、上限を考える
        if(nl > nr) {
            cout<<-1<<endl;
            return 0;
        }else{
            l = nl * a[i];
            r = (nr + 1) * a[i];
        }
    }
    cout<<l<<' '<<r - 1<<endl;
}


Measured memory_bytes: 4052
#include<iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
 
int x,y;
cin >> x >> y;
 
while(!(x==0&&y==0)){
	if(x<y){
		cout << x << " " << y << "\n";
	}else{
		cout << y << " " << x << "\n";
	}
	
	cin >> x >> y;
}
 
return 0;
}

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

int main(){
    long int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    long int res = 0;

    if (k <= a) {
        res = k;
    } else if (k <= a + b) {
        res = a;
    } else {
        res = a - (k - a - b);
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)



signed main(){

	string key = "keyence";
	string s;
	cin >> s;
	string s1 = s;

	for (int i = 0; i < s.length(); i++){
		for (int j = 0; j < s.length() - i; j++){
			s1.erase(i, j);
			if (key == s1){
				cout << "YES" << endl;
				return 0;
			}
			s1 = s;
		}
	}
	cout << "NO" << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n%2 == 0){
			System.out.println(n/2);
		}else{
			System.out.println(n/2 + 1);
		}

		sc.close();
	}



}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k, a;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a;
  }
  n -= k;
  cout << (n % (k - 1) ? n / (k - 1) + 1 : n / (k - 1)) + 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll ans;
int n, k;
int a[10000];
vector<vector<ll> > v(100000);
void add_edge(int i, int j){
    v[i].push_back(j);
    v[j].push_back(i);
}
void dfs(int i, vector<bool> used,int color,int d){
    used[i]=true;
    ans*=color;
    ans%=MOD;
    if(d<1)color=k-1;
    else color=k-2;
    d++;
    //cout << ans<< "\n";
    int count=0;
    for(int j=0;j<v[i].size();j++){
        if(used[v[i][j]]==true) continue;
        dfs(v[i][j],used,max(color-count,0),d);
        count++;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>k;
    for (int i = 0; i < n-1; i++)
    {
        int tempi, tempj;
        cin >> tempi>>tempj;
        add_edge(tempi-1,tempj-1);
    }
    vector<bool> used(n,false);
    ans=1;
    dfs(0,used,k,0);
    cout << ans<< "\n";
}


Measured memory_bytes: 932516
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int A;
    cin >> A;
    fin(1-A);
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int x;
    cin>>x;
    int at = 400;
    int i = 8;
    while (at+200<=x) {
	i--;
	at += 200;
    }
    out(i);
    
    
    return 0;
}


Measured memory_bytes: 3624
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
struct dot{
	int val=0;
	vector<int> from;
}dots[100005];
int n,m;

int dfs(int px){
	if(dots[px].from.empty())
		return dots[px].val=0;
	if(dots[px].val)
		return dots[px].val;
	int res=0;
	for(auto i: dots[px].from){
		res=max(res,dfs(i));
	}
	return dots[px].val=res+1;
}

int main(){
	IOS
	while(cin>>n>>m){
		for(int i=0,a,b ; i<m ; i++){
			cin>>a>>b;
			dots[b].from.push_back(a);
		}
		int ans=0;
		for(int i=1 ; i<=n ; i++){
			ans=max(ans,dfs(i));
		}
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 14244
n = int(input())
*a,=map(int, input().split())
mapa=[0]*(10**6+1)

n0 = 10**6
primes = [0]*(n0+1)
for i in range(2, n0+1):
    if primes[i]==0:
        x=i
        multi=1
        while x<=n0:
            if primes[x]==0:
                primes[x]=i
            x//=multi
            multi+=1
            x*=multi

def func(m):
    while m>1:
        mapa[primes[m]]+=1
        pm=primes[m]
        while m>1 and m%pm==0:
            m//=pm

for ai in a:
    func(ai)

tmp=max(mapa)

if tmp==n:
    print('not coprime')
elif tmp>1:
    print('setwise coprime')
else:
    print('pairwise coprime')

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

int main() {

  int N,k=0;
  string S;
  cin>>N>>S;
  
    for (int i = 0; i < N/2; i++) {
    if(S.at(i) ==S.at(N/2+i)){
      k++;
      }
  	}
  
    if(S.size() % 2 != 0 ){
    cout << "No" << endl;
    }
  	else if(k == N/2){
      cout << "Yes" << endl; 
    }
    else{
        cout << "No" << endl; 
    }
}


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


int main() {

	int H, W;
	cin >> H >> W;
	vector<vector<char>> S(H + 2, vector<char>(W + 2));
	for (int i = 1;i < H + 1;i++) {
		for (int j = 1;j < W + 1;j++) {
			cin >> S.at(i).at(j);
		}
	}

	for (int i = 1;i < H + 1;i++) {
		for (int j = 1;j < W + 1;j++) {

			int count_i_j = 0;
			if (S.at(i).at(j) == '.') {
				for (int k = i - 1;k < i + 2;k++) {
					for (int l = j - 1;l < j + 2;l++) {
						if (S.at(k).at(l) == '#')
							count_i_j++;
					}
				}
				cout << count_i_j;
			}
			else {
				cout << S.at(i).at(j);
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N, ans = -1, p, q, r;
  bool inc;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      inc = true;
      p = A[i] * A[j];
      q = p%10+1;
      while (p) {
	r = p%10;
	p /= 10;
	if (q - r == 1) {
	  q = r;
	} else {
	  inc = false;
	  break;
	}
      }
      if (inc) ans = max(ans, A[i]*A[j]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

/*計算過程が最大公約数を求めていることと同じだから、与えられた値についての最大公約数を求めればよい？(その最大公約数は作ることができるので?)*/

int gcd(int a, int b){
  if(b == 0)
    return a;
  else if(a > b)
    return gcd(b, a%b);
  else
    return gcd(a, b%a);
}

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

  int a, b;
  cin >> a >> b;
  int g = gcd(a, b);

  for(int i = 0; i < N-1; i++){
    int val;
    cin >> val;
    g = gcd(g, val);
  }

  cout << g << endl;
  return 0;
  
}

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

const int maxn = 1e5 + 5;
int dp[maxn][4];
int day[maxn][4];

int main(){
	int n; scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= 3; j++){
			scanf("%d",&day[i][j]);
		}
	}

	for(int i = 1; i <= 3; i++){
		dp[1][i] = day[1][i];
	}

	for(int i = 2; i <= n; i++){
		dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + day[i][1];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + day[i][2];
		dp[i][3] = max(dp[i - 1][2], dp[i - 1][1]) + day[i][3];
	}

	int ans = max(dp[n][1], max(dp[n][2], dp[n][3]));

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            string T;
            cin >> T;
            if(T == "snuke") cout << (char)('A' + j) << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n,d;
    cin >> n >> d;
    print((n+d+d)/(d+d+1));
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3560
# include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
            continue;
        else
            sum=sum+i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		String s=sc.next();

		List<Integer> list=new ArrayList<>();

		int begin=0;
		char now='1';

		for(int i=0;i<N;i++) {
			if(s.charAt(i)!=now) {
				list.add(i-begin);
				now=s.charAt(i);
				begin=i;
			}
		}
		list.add(N-begin);
		if(now == '0')	list.add(0);

		/*
		for(int i:list) System.out.print(i+" ");
		System.out.println();
		 */

		int[] sum=new int[list.size()+1];
		for(int i=0;i<list.size();i++) {
			sum[i+1]=sum[i]+list.get(i);
		}

		int result = 0;


		for(int i = 0; i < list.size(); i+=2) {

			int Left = i;
			int Right = Math.min(i+K*2+1, list.size());

			int tmp=sum[Right]-sum[Left];

			//System.out.println(String.format("left:%d right:%d tmp:%d",Left,Right,tmp));

			result = Math.max(tmp, result);
		}

		System.out.println(result);


		sc.close();
	}

}


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

int v[15];

bool check(int x)
{
	while(x)
	{
		if(v[x%10])
			return false;
		x /= 10;
	}
	return true;
}

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i = 0; i < k ; i++)
	{
		int a;
		scanf("%d",&a);
		v[a] = 1;
	}
	for(int i = n; i <= 1000000; i++)
	{
		if(check(i))
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	map<string, int> m;
	int q; cin >> q;
	rep(i, q) {
		int t, x;
		string key;
		decltype(m)::iterator it;
		cin >> t;

		switch (t) {
		case 0:
			cin >> key >> x;
			m.erase(key);
			m.insert(mp(key, x));
			break;
		case 1:
			cin >> key;
			it = m.find(key);
			if (it != m.end())Cout(m[key]);
			else Cout(0);
			break;
		case 2:
			cin >> key;
			m.erase(key);
		}
	}
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    long double pi = acos(-1);
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    // 長針について
    // alp_1 = m * 12 *pi/360
    // 短針について
    // h * 60 * pi / 360 + m * pi / 360

    long double diff;
    if (60 * h + m > m * 12) diff = 60 * h + m - 12 * m;
    else diff = 12 * m - (60 * h + m);

    long double c = a * a + b * b - (long double) 2 * b * a * cos(diff *  pi / 360);

    printf("%20.20Lf\n", sqrtl(c));
    return 0;
}

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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r;
	int c,s;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	int res = n;
	FOR(i, n-1) {
		if (s[i] != s[i+1]) {
			res = std::min(res, std::max(i+1, n - i - 1));
		}
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 512
n = int(input())
p = list(map(int, input().split()))

count = 0
for i, pi in enumerate(p):
    if i == 0 or i == n-1:
        pass
    else:
        if pi != max(p[i-1:i+2]) and pi != min(p[i-1:i+2]):
            count += 1
print(count)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

struct stNode {
    int key;
    stNode *pParent;
    stNode *pLeft;
    stNode *pRight;
};

class BinaryTree
{
public :
    int key;

    BinaryTree(void) : m_pHead(NULL) {};
    void Insert(int key);
    void PrintInorder(void);
    void PrintPreorder(void);

private :
    stNode *m_pHead;
    void Inorder(stNode *pNode);
    void Preorder(stNode *pNode);
};

void BinaryTree::Insert(int key)
{
    stNode *pNode, *pFind;

    pNode = (stNode*)malloc(sizeof(stNode));
    pNode->key    = key;
    pNode->pLeft  = NULL;
    pNode->pRight = NULL;

    if (m_pHead != NULL) {
        pFind = m_pHead;
        for (;;) {
            if (key < pFind->key) {
                if (pFind->pLeft == NULL) {
                    pFind->pLeft = pNode;
                    break;
                }
                else {
                    pFind = pFind->pLeft;
                }
            }
            else {
                if (pFind->pRight == NULL) {
                    pFind->pRight = pNode;
                    break;
                }
                else {
                    pFind = pFind->pRight;
                }
            }
        }

        pNode->pParent = pFind;
    }
    else {
        m_pHead = pNode;
        pNode->pParent = NULL;
    }

    return;
}

void BinaryTree::PrintInorder(void)
{
    Inorder(m_pHead);
    printf("\n");
    return;
}

void BinaryTree::PrintPreorder(void)
{
    Preorder(m_pHead);
    printf("\n");
    return;
}

void BinaryTree::Inorder(stNode *pNode)
{
    if (pNode != NULL) {
        Inorder(pNode->pLeft);
        printf(" %d", pNode->key);
        Inorder(pNode->pRight);
    }

    return;
}

void BinaryTree::Preorder(stNode *pNode)
{
    if (pNode != NULL) {
        printf(" %d", pNode->key);
        Preorder(pNode->pLeft);
        Preorder(pNode->pRight);
    }

    return;
}

int main(void)
{
    int  i;
    int  num;
    int  key;
    char order[10];
    BinaryTree bTree;

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%s", order);
        switch (order[0]) {
        case 'i' :
            scanf("%d", &key);
            bTree.Insert(key);
            break;
        case 'p' :
            bTree.PrintInorder();
            bTree.PrintPreorder();
            break;
        default :
            break;
        }
    }
}

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

int main(){
    int n, a, b, ans=0;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        int c = 0, t = i;
        for(int j = 0; j < 5; j++){
            c += t % 10; t /= 10;
        }
        if (a <= c && c <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  if (A >= K)
    cout << A - K  << ' ' << B << endl;
  else if (A + B >= K)
    cout << '0' << ' '<< A + B - K << endl;
  else
    cout << '0' << ' ' << '0' << endl;
}

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

using namespace std;

int main() {
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;

    if (a + b >= c) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
import Data.Char
import Data.Array.Unboxed
import Debug.Trace

type Table = Array Char Int
type TableInf = Array Int Char

main :: IO ()
main = do
  s <- getLine
  n <- readLn :: IO Int
  let table = listArray ('a', 'z') [0..25] :: Table
  let table' = listArray (0, 25) ['a'..'z'] :: TableInf
  putStrLn $ solve table table' s n

solve :: Table -> TableInf -> String -> Int -> String
solve tab tab' str allNum = go str allNum
  where
    go [x] n = let m = tab ! x 
                   n' = (m + n `mod` 26) `mod` 26 in
                 [tab' ! n']
    go (x:xs) n = let m = tab ! x
                      n' = (26 - m) `mod` 26 in
                    if n' <= n
                       then 'a' : go xs (n - n')
                       else x : go xs n


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

const ll MOD=1e9+7;
const double EPS=1e-9;
const double PI=acos(-1.0);
//const long double PI=acos(-1.0l);

struct Point{
    double x,y;
    Point(double x=0.0,double y=0.0):x(x),y(y){}

    Point operator +(const Point &b) const {return Point(x+b.x,y+b.y);}
    Point operator -(const Point &b) const {return Point(x-b.x,y-b.y);}
    Point operator *(const double b) const {return Point(x*b,y*b);}
    Point operator /(const double b) const {return Point(x/b,y/b);}
};

double dot(const Point &a,const Point &b) {return (a.x*b.x+a.y*b.y);}
double cross(const Point &a,const Point &b) {return (a.x*b.y-a.y*b.x);}
double norm(const Point &a) {return dot(a,a);}
double abs(const Point &a) {return sqrt(norm(a));}


int main(){
    Point P1,P2;
    cin>>P1.x>>P1.y>>P2.x>>P2.y;
    int Q;
    cin>>Q;

    for(int q=0;q<Q;q++){
        Point p;
        cin>>p.x>>p.y;

        double s=dot(P2-P1,p-P1);
        s/=abs(P2-P1);

        Point ans;
        ans=P1+(P2-P1)*s/abs(P2-P1);
        cout<<fixed<<setprecision(10)<<ans.x<<" "<<ans.y<<endl;
    }

    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int N,A;
	cin>>N>>A;
	
	cout<<(N+A-1)/A<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<map>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    double n,r,c=1;
    cin >> n >> r;
	while(1){
      n/=r;
      if(n<1){
        cout << c;
		return 0;
      }
      c++;
    }
    return 0;
}


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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    int maxa = 0;
    int maxb;
    rep(i, n) {
        cin >> a.at(i) >> b.at(i);
        maxa = max(maxa, a.at(i));
    }
    rep(i, n) {
        if (a.at(i) == maxa) {
            maxb = b.at(i);
        }
    }
    cout << maxa + maxb << endl;
}

Measured memory_bytes: 4052
x = int(input())

al = [i**5 for i in range(0, 1001)]
bl = [i**5 for i in range(0, 1001)]

for i in bl:
    a1 = x - i
    a2 = x + i
    if a1 in al:
        print(al.index(a1), - (bl.index(i)))
        exit()
    if a2 in al:
        print(al.index(a2), bl.index(i))
        exit()


Measured memory_bytes: 9196