akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int num=scan.nextInt();
String sent=scan.next();
String[] alph=sent.split("");

int i=0;
int j=0;
for(i=0;i<num;i++){
    for(j=0;j<alph.length;j++){

if(alph[j].equals("A")){
    alph[j]="B";
}
else if(alph[j].equals("B")){
    alph[j]="C";
}
else if(alph[j].equals("C")){
    alph[j]="D";
}
else if(alph[j].equals("D")){
    alph[j]="E";
}
else if(alph[j].equals("E")){
    alph[j]="F";
}
else if(alph[j].equals("F")){
    alph[j]="G";
}
else if(alph[j].equals("G")){
    alph[j]="H";
}
else if(alph[j].equals("H")){
    alph[j]="I";
}
else if(alph[j].equals("I")){
    alph[j]="J";
}
else if(alph[j].equals("J")){
    alph[j]="K";
}
else if(alph[j].equals("K")){
    alph[j]="L";
}
else if(alph[j].equals("L")){
    alph[j]="M";
}
else if(alph[j].equals("M")){
    alph[j]="N";
}
else if(alph[j].equals("N")){
    alph[j]="O";
}
else if(alph[j].equals("O")){
    alph[j]="P";
}
else if(alph[j].equals("P")){
    alph[j]="Q";
}
else if(alph[j].equals("Q")){
    alph[j]="R";
}
else if(alph[j].equals("R")){
    alph[j]="S";
}
else if(alph[j].equals("S")){
    alph[j]="T";
}
else if(alph[j].equals("T")){
    alph[j]="U";
}
else if(alph[j].equals("U")){
    alph[j]="V";
}
else if(alph[j].equals("V")){
    alph[j]="W";
}
else if(alph[j].equals("W")){
    alph[j]="X";
}
else if(alph[j].equals("X")){
    alph[j]="Y";
}
else if(alph[j].equals("Y")){
    alph[j]="Z";
}
else if(alph[j].equals("Z")){
    alph[j]="A";
}

    }
}
String sente=String.join("",alph);
System.out.println(sente);



}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	ll t,n,k,r;
	cin>>r;
	cout<<(double)2*3.14159265358*r<<"\n";
	return 0;
}

Measured memory_bytes: 3756
n, x = map(int, input().split())
l = list(map(int, input().split()))
data_list = [0]
result = []

for i in range(1, n + 1):
    temp = data_list[i - 1] + l[i - 1]
    data_list.append(temp)

for item in data_list:
    if item <= x:
        result.append(item)
print(len(result))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	string s,t;
 	cin>>s>>t;
 	ll n=s.length(),m=t.length(),ans=2e18,z=0,k=0;
 	for(ll int i=0;i<=(n-m);i++)
 	{
 		z=0;k=0;
 		for(ll int j=i;j<i+m;j++)
 		{
 			if(s[j]!=t[k])
 				z++;
 			k++;
 		}
 		ans=min(ans,z);
 	}
 	cout<<ans;
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

Measured memory_bytes: 3648
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def solve(N):

    ans = 0
    for x in range(1, N + 1):
        y = int(N / x)
        ans += y * (y + 1) * x // 2

    return ans


def main():

    N = in_n()
    print(solve(N))


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4,)')(solve)
    cc.compile()


if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
        from my_module import solve
    main()


Measured memory_bytes: 9036
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();

  vector<int> cnt(n);
  cnt.assign(n,0);

  vector<int> start,end;
  vector<int> pl,pr;
  start.push_back(0);
  for(int i=0;i<n-1;i++){
    if(s[i] == 'L' && s[i+1] == 'R'){
      end.push_back(i);
      start.push_back(i+1);
    }
  }
  end.push_back(n-1);

  for(int i=0;i<n-1;i++){
    if(s[i] == 'R' && s[i+1] == 'L'){
      pl.push_back(i);
      pr.push_back(i+1);
    }
  }

  /*
  cout << "pl"<<endl;
  for(int i=0;i<pl.size();i++){
    cout << pl[i];
    if(i!=pl.size()-1) cout <<" ";
    else cout  << endl;
  }
  cout << "pr"<<endl;
  for(int i=0;i<pr.size();i++){
    cout << pr[i];
    if(i!=pr.size()-1) cout <<" ";
    else cout  << endl;
  }
  cout << "start"<<endl;
  for(int i=0;i<start.size();i++){
    cout << start[i];
    if(i!=start.size()-1) cout <<" ";
    else cout  << endl;
  }
  cout <<"end"<<endl;
  for(int i=0;i<end.size();i++){
    cout << end[i];
    if(i!=end.size()-1) cout <<" ";
    else cout  << endl;
  }
  */


  for(int i=0;i<pl.size();i++){
    if(pl[i] != start[i]){
      cnt[pl[i]] += (pl[i]-start[i])/2;
      cnt[pr[i]] += (pl[i]-start[i])/2;
      if((pl[i]-start[i])%2 == 1) cnt[pr[i]]++;
    }
    cnt[pl[i]] += 1;
    if(pr[i] != end[i]){
      cnt[pl[i]] += (end[i]-pr[i])/2;
      cnt[pr[i]] += (end[i]-pr[i])/2;
      if((end[i]-pr[i])%2 == 1) cnt[pl[i]]++;
    }
    cnt[pr[i]] += 1;
  }

  for(int i=0;i<n;i++){
    cout << cnt[i];
    if(i != n-1) cout << " ";
    else cout << endl;
  }
}


Measured memory_bytes: 1980
#include<stdio.h>
#include<string.h>
 
int main(void)
{
    int num[101], tempn, index[101][31], i, j, k, l, m, alc, count;
    char word[101][31],tempw[31],dict[101][31];
 
    i = 0;
    while (~scanf("%s %d", word[i], &num[i]))
        i++;
    i = i - 1;
    j = 0;  
    while (j < i)    
    {      
        if (strcmp(word[j], word[j+1]) > 0)
        {
            strcpy(tempw, word[j]);
            strcpy(word[j], word[j+1]);
            strcpy(word[j+1], tempw);
            tempn = num[j];
            num[j] = num[j+1];
            num[j+1] = tempn;      
            j=0;
        }    
        else
            j++;
    }
 
    l = 0;
    alc = 0;
    count = 0;
    for (k = 0; k <= i; k++)    
    {      
        if (k == 0)
        {      
            strcpy(dict[0], word[0]);
            index[0][0] = num[0];
            l++;
        }      
        else   
        {      
            if (strcmp(dict[l-alc-1], word[k]) != 0)
            {          
                count = 0;
                strcpy(dict[l-alc], word[k]);
                index[l-alc][0] = num[k];
                l++;
            }      
            else
            {
                count++;
                alc++;
                index[l-alc][count] = num[k];
                l++;
            }
        }
    }
    for (k=0;k<i;k++)
    {
        m = 0;
        while (index[k][m+1] != 0)
        {
            if (index[k][m] > index[k][m+1])
            {
                tempn = index[k][m];
                index[k][m] = index[k][m+1];
                index[k][m+1] = tempn;
                m = 0;
            }
            else
                m++;
        }
    }
    for (k = 0; k < l-alc; k++)
    {
        m = 0;
        printf("%s\n", dict[k]);
        while (index[k][m+1] != 0)
        {
            printf("%d ", index[k][m]);
            m++;
        }
        printf("%d\n", index[k][m]);
    }
 
    return 0;
}

Measured memory_bytes: 1072
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
//#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, x, m; cin >> n >> x >> m;
    ll ans = 0, s = x;
    ll now = x;
    vector<ll> hato(m+1, 0);
    REP(i, 0, m-1){
        hato[x] = (x * x) % m;
        x =  (x * x) % m;
    }
    ll mid = 0, mid1 = 0;
    vector<int> flag(m+1, 0);
    while(1){
        if(flag[now] == 1){
            break;
        }else{
            flag[now] = 1;
            mid += hato[now];
            now = hato[now]; 
        }
    }
    vector<int> flag1(m+1, 0);
    ll count = 0;
    while(1){
        if(flag1[now] == 1){
            break;
        }else{
            flag1[now] = 1;
            mid1 += hato[now];
            now = hato[now]; 
            count++;
        }
    }
    REP(i, 0, n){
        ans += s;
        s = hato[s];
        if(s == now){
            ll k = max(0LL, (n-(i+1LL)) / count);
            ans += k * mid1;
            i += count * k;
        }
    }
    cout << ans << endl;
}

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

int main(){
	int a,b,c,tmp;
	cin >>a>>b>>c;
	
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	if (b>c){
		tmp=b;
		b=c;
		c=tmp;
	}
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	
	cout <<a<<" "<<b<<" "<<c<< endl ;
	
	return 0;
}

Measured memory_bytes: 1168
#include<stdio.h>

#define MAX 1000000

int parent(int i){ return i/2; }
int left(int i){ return 2*i; }
int right(int i){ return 2*i+1; }

int main(){
  int H, i, A[MAX+1];

  scanf("%d",&H);
  for ( i = 1; i <= H; i++ )scanf("%d",&A[i]);

  for ( i = 1; i <= H; i++ ){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H)printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        while(n > 0){
            ret += n / 5;
            n /= 5;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    char c;
    cin>>c;
    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
        cout<<"vowel"<<endl;
    }
    else{
        cout<<"consonant"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        LinkedList<Integer> l = new LinkedList<>();
        for(int i=0; i<n; i++) {
            l.add(a[i]);
        }
        int min = l.pollFirst();
        int max = l.pollLast();
        List<Tuple> operations = new ArrayList<>();
        int m = min;
        while(!l.isEmpty()) {
            Tuple t = new Tuple();
            int next = l.pollLast();
            if(next > 0) {
                t.x = m;
                t.y = next;
                m -= next;
            }
            else {
                t.x = max;
                t.y = next;
                max = max - next;
            }
            operations.add(t);
        }
        Tuple t = new Tuple();
        t.x = max;
        t.y = m;
        operations.add(t);
        m = max - m;
        System.out.println(m);
        for(int i=0; i<operations.size(); i++) {
            Tuple t2 = operations.get(i);
            System.out.print(t2.x);
            System.out.print(" ");
            System.out.println(t2.y);
        }
    }
}
class Tuple {
    int x;
    int y;
}

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

struct load{
    int c, t;
};

int main(){
    int n, t;
    cin >> n >> t;
    struct load load[n];
    for(int i = 0; i < n; i++){
        cin >> load[i].c >> load[i].t;
    }

    int min = 10000;
    for(int i = 0; i < n; i++){
        if(load[i].t <= t){
            if(load[i].c < min){
                min = load[i].c;
            }
        }
    }

    if(min == 10000){
        cout << "TLE" << endl;
    }
    else{
        cout << min << endl;
    }

    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a+b==15){
        cout << '+' << endl;
    }else if((a*b) == 15){
        cout << '*' << endl;
    }else{
        cout << 'x' << endl;
    }
}

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

struct square{
	int x;
	int y;
	//struct square *left;	//0
	//struct square *down;	//1
	//struct square *right;	//2
	//struct square *up;	//3
};

int main(){
	struct square data[200];
	int N, n, d;

	while( 1 ){
		int top = 0, bottom = 0, left_side = 0, right_side = 0;
		data[0].x = 0;
		data[0].y = 0;
		cin >> N;
		if( N == 0 ) break;
		for( int i = 1; i < N; i++ ){
			cin >> n >> d;
			switch( d ){
				case 0:
				//data[i]->right = *data[n];
				data[i].x = (data[n].x) - 1;
				data[i].y = data[n].y;
				break;
				case 1:
				//data[i]->up = *data[n];
				data[i].x = data[n].x;
				data[i].y = (data[n].y) - 1;
				break;
				case 2:
				//data[i]->left = *data[n];
				data[i].x = (data[n].x) + 1;
				data[i].y = data[n].y;
				break;
				case 3:
				//data[i]->down = *data[n];
				data[i].x = data[n].x;
				data[i].y = (data[n].y) + 1;
				break;
			}
			if( top < data[i].y ) top = data[i].y;
			if( bottom > data[i].y ) bottom = data[i].y;
			if( left_side > data[i].x ) left_side = data[i].x;
			if( right_side < data[i].x ) right_side = data[i].x;
		}
		bottom *= -1;
		left_side *= -1;
		cout << left_side + right_side + 1 << ' ' << top + bottom + 1 << endl;
	}
}

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

// Otoshidama
int main() {
	int N, Y;
	cin >> N >> Y;

	int x, y, z;
	bool res = false;
	int Y_k = Y / 1000;

	for (x=0; x<=N; x++) {
		for (y=0; y<=N-x; y++) {
			z = N - x - y;
			if (10*x + 5*y + 1*z == Y_k) {
				res = true;
				break;
			}
		}
		if (res == true)
			break;
	}

	if (res == false)
		x = y = z = -1;

	cout
	 << x << " "
	 << y << " "
	 << z << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll X, N; cin >> X >> N;
    vll p(N);
    rep(i, 0, N){
        cin >> p[i];
    }
    ll a; ll b = 1000;
    vb k(1000, false);
    rep(i, 0, N){
        k[p[i]] = true;
    }
    rep(i, 0, 1000){
        if(k[i]){
            continue;
        }
        if(abs(X - i) < b){
            a = i;
            b = abs(X - i);
        }
    }
    prt(a);
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < h.length; i++) {
            h[i] = sc.nextInt();
        }
        boolean ok = true;
        for (int i = h.length - 2; i >= 0; i--) {
            if (h[i] - h[i + 1] == 1) {
                h[i]--;
            } else if (h[i] > h[i + 1]) {
                ok = false;
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	string s;
	cin >> s;
	cout << s.front() << s.size()-2 << s.back() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <sstream>
 
using namespace std;
typedef unsigned int ui;
 
int main(){
    int Q;
 
    double c[7];
    for(int i = 0 ; i < 7 ; i++){
	c[i] = pow(0.5,i+1);
    }
 
    cin >> Q;
    while(Q--){
	ui s;
 
	scanf("%x" ,&s);
	ui integer = (s & 0x7fffffff) >> 7;
	ui decimal = (s & 0x0000007f);
 
	double d = 0;
	for(int i = 0 ; i < 7 ; i++){
	    if((1 << i) & decimal)
		d += c[6-i];
	}    
 
	char str[10];
	sprintf(str,"%.7f" ,d);
 
	int pos = -1;
	for(int i = 8 ; i >= 0 ; i--){
	    if(str[i] != '0' && str[i] != '.'){
		pos = i;
		break;
	    }
	}
 
	if((s >> 31) & 1) cout << '-';
	cout << integer << '.';
     
	if(pos == -1) cout << '0' << endl;
	else{
	    for(int i = 2 ; i <= pos ; i++){
		cout << str[i];
	    }
	    cout << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3356
X = int(input())

maxVal1 = 0
maxVal2 = 0
maxVal3 = 0
maxVal4 = 0
maxVal5 = 0
val = 0


for i in range(33):
	if i**2 > X:
		maxVal1 = i-1
		break

for j in range(12):
	if j**3 > X:
		maxVal2 = j-1
		break

for k in range(7):
	if k**4 > X:
		maxVal3 = k-1
		break

for k in range(5):
	if k**5 > X:
		maxVal4 = k-1
		break

for k in range(4):
	if k**6 > X:
		maxVal5 = k-1
		break


maxVal = max(maxVal1**2, maxVal2**3, maxVal3**4, maxVal4**5, maxVal5**6)
print(maxVal)

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

int main(){
  int N;
  cin>>N;
  string S[N];
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  int M;
  cin>>M;
  string T[M];
  for(int i=0;i<M;i++){
    cin>>T[i];
  }
  int ans=0;

  for(int i=0;i<N;i++){
      int temp=0;
    for(int j=0;j<N;j++){
      if(S[i]==S[j]){
        temp++;
      }
    }
    for(int j=0;j<M;j++){
      if(S[i]==T[j]){
        temp--;
      }
    }
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}
  
    
    
      

Measured memory_bytes: 256
//##MohK
//16/2/2020 .....4,25.
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll n,m,x,y,max=-9999,min=9999;
    cin>>n>>m>>x>>y;
    ll a[n],b[m];
    ll z=0;
    bool ok=false;
    vector<int>v;
    for(ll i=0;i<n;i++){
        cin>>a[i];
         if(a[i]>max){
               max=a[i];
            }
    }
     for(ll i=0;i<m;i++){
        cin>>b[i];
        if(b[i]<min){
               min=b[i];
            }
    }
    for(ll i=0;i<n+m;i++){
         if((a[i]>x&&a[i]<=y)){
               z=a[i];
               v.push_back(z);
            }
         if((b[i]>x&&b[i]<=y)){
               z=b[i];
               v.push_back(z);
            }
    }
    for(ll i=0;i<v.size();i++){
        if(v[i]>max&&v[i]<=min){
            cout<<"No War"<<endl;
            ok=true;
            break;
        }
    }
    if(ok==false)cout<<"War"<<endl;

   return 0;
}





Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int X = Integer.parseInt(sc.next());
	int Y = Integer.parseInt(sc.next());
	int Z = Integer.parseInt(sc.next());
	int K = Integer.parseInt(sc.next());

	Long[] A = new Long[X];
	Long[] B = new Long[Y];
	Long[] C = new Long[Z];

	for(int i = 0; i<X; i++) A[i] = Long.parseLong(sc.next());
	for(int i = 0; i<Y; i++) B[i] = Long.parseLong(sc.next());
	for(int i = 0; i<Z; i++) C[i] = Long.parseLong(sc.next());

	PriorityQueue<Long> pq = new PriorityQueue<Long>(K);
	for(int i = 0; i<K; i++) pq.add(0L);

	Arrays.sort(A,Comparator.reverseOrder());
	Arrays.sort(B,Comparator.reverseOrder());
	Arrays.sort(C,Comparator.reverseOrder());

	int cnt = 0;
	for(int i = 0; i<Math.min(X,K); i++) {
	    for(int j = 0; j<Math.min(Y,K); j++) {
		for(int l = 0; l<Math.min(Z,K); l++) {
		    if(i*j*l>K) break;
		    long sum = A[i]+B[j]+C[l];
		    if(sum > pq.peek()) {
			pq.poll();
			pq.add(sum);
		    }
		}
	    }
	}

	Long[] ans = pq.toArray(new Long[0]);
	Arrays.sort(ans, Comparator.reverseOrder());
	for(int i = 0; i<K; i++) System.out.println(ans[i]);

    }
}

Measured memory_bytes: 29716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class APC2020A
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var Ia = RIa(3);
            var L = Ia[0];
            var R = Ia[1];
            var D = Ia[2];

            int all = R / D;
            int prev = (L - 1)/ D;


            Console.WriteLine(all - prev);


#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int RI()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] RIa(int n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = int.Parse(sa[i]);
            }
            return la;
        }
    }
}


Measured memory_bytes: 27380
// Aizu 2005: Water Pipe Construction
// 2017.9.24 bal4u@uu

#include <stdio.h>
#include <string.h>
#define INF 0x7fffff

int dist[102][102];

int main()
{
	int n, m, s, g1, g2, b1, b2, c, i, j, k, x, ans;

	while (scanf("%d%d%d%d%d", &n, &m, &s, &g1, &g2) && n > 0) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) dist[i][j] = INF;
			dist[i][i] = 0;
		}
		for (i = 0; i < m; i++) {
			scanf("%d%d%d", &b1, &b2, &c);
			dist[b1][b2] = c;
		}
        for (k = 1; k <= n; k++) for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) {
			x = dist[i][k] + dist[k][j];
	        if (dist[i][j] > x) dist[i][j] = x;
        }
		for (ans = INF, i = 1; i <= n; i++) {
			if ((x = dist[s][i] + dist[i][g1] + dist[i][g2]) < ans) ans = x;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;

    int d = 0, o = 0;
    for(int i=0;i<S.size();i++){
        if(S[i] == 'a'){
            if(d + o < A + B){
                cout << "Yes" << endl;
                d++;
            }else{
                cout << "No" << endl;
            }
        }else if(S[i] == 'b'){
            if(d + o < A + B && o < B){
                cout << "Yes" << endl;
                o++;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }

}

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define test() ll t;cin>>t;for(ll test = 1;test<=t;test++)
#define f first
#define s second
#define pb push_back
#define ins insert
#define nl cout<<"\n"
#define P 1000000007
#define N 3005
#define MOD(x) ((x%P)+P)%P
#define show(x) cout<<x<<" "
#define vec(v) loop(i,0,v.size()) show(v[i]); nl

ll dp[N][N];
bool vis[N][N];
ll arr[N];

ll solve(int i, int j)
{
	if(vis[i][j])
		return dp[i][j];

	vis[i][j] = 1;

	if(i==j)
	{
		dp[i][j] = arr[i];
		return arr[i];
	}

	dp[i][j] =  max( arr[i] - solve(i+1,j) , arr[j] - solve(i,j-1));

	return dp[i][j];
}

int main()
{
	fastio();

	ll n;
	cin>>n;

	memset(dp,0,sizeof(dp));
	memset(vis,0,sizeof(vis));

	loop(i,0,n)
		cin>>arr[i];

	ll diff = solve(0,n-1);
	cout<<diff,nl;

	// int i = 0, j = n-1;

	// while(i<=j)
	// {
	// 	if(diff == (arr[i] - dp[i+1][j]))
	// 	{
	// 		diff = dp[i+1][j];
	// 		cout<<i<<" ";
	// 		i++;
	// 	}
	// 	else
	// 	{
	// 		diff = dp[i][j-1];
	// 		cout<<j<<" ";
	// 		j--;
	// 	}
	// }



	//cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
	return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int N,y;
  cin >> N >> y;
  for(int i = 0; i<= N; i++){
    for(int j = 0; i+j<= N; j++){
      if(10000*i+5000*j+(N-i-j)*1000==y){
        cout << i << " " << j << " " << N-i-j << endl;
        return 0;
      }
    }
  }
  
  cout << "-1 -1 -1" << endl;
}      

Measured memory_bytes: 3596
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from bisect import bisect_left,bisect_right
from collections import deque

    
def main():
    n,k = map(int,input().split())
    ans = 0
    G = [0] * (1 + k)
    for g in range(k,0,-1):
        ret = pow((k//g),n,MOD)
        for j in range(2 * g,k + 1,g):
            ret -= G[j]
        G[g] = ret
        ans += ret * g
        ans %= MOD
    
    print(ans) 

if __name__ =='__main__':
    main()  

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

typedef long long ll;
//const int INF = 2e9;
const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N,vector<ll>(M));
    for (int i=0;i<N;i++){
        cin >> C[i];
        for (int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    ll ans = INF;
    for (int i=0;i<(1<<N);i++){
        vector<ll> skill(M);
        ll money = 0;
        for (int j=0;j<N;j++){
            int bit = (i >> j) & 1;
            if (bit) {
                money += C[j];
                for (int k=0;k<M;k++){
                    skill[k] += A[j][k];
                }
            }
        }
        bool flag = true;
        for (int j=0;j<M;j++){
            if (skill[j] < X){
                flag = false;
                break;
            }
        }
        if (flag) {
            ans = min(ans, money);
        }
    }
    if (ans == INF) cout << -1 << "\n";
    else cout << ans << "\n";
}

Measured memory_bytes: 3664
def ismonth(m):
    if 1 <= m and m <= 12:
        return True
    else:
        return False

S = input()
S1 = int(S[:2])
S2 = int(S[2:])

if ismonth(S1):
    if ismonth(S2):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if ismonth(S2):
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 2940
import java.io.*
import java.util.*
import java.lang.Math.*


fun main() {
    val A = rd.readInt()

    val ans = A + A*A + A*A*A

    println(ans)
}


//val rd = debug.Reader("abc", "172", "a", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 34592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int ans = 0;
  for(int i=0;i<=100;i++){
    if(A<=i && i<B && C<=i && i<D) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

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

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

int main()
{
  long long H, N;
  cin >> H >> N;
  vector<long long> A(N), B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i] >> B[i];
  }
  vector<vector<long long>> dp(N + 1, vector<long long>(H + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= H; j++)
    {
      chmin(dp[i + 1][j], dp[i][j]);

      if (j >= A[i])
      {
        chmin(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
      }
      else
      {
        chmin(dp[i + 1][j], dp[i][0] + B[i]);
      }
    }
  }
  cout << dp[N][H] << endl;
}


Measured memory_bytes: 78592
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s[9];
  s[0]=".,!?S";
  s[1]="abc";
  s[2]="def";
  s[3]="ghi";
  s[4]="jkl";
  s[5]="mno";
  s[6]="pqrs";
  s[7]="tuv";
  s[8]="wxyz";
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string t;
    cin>>t;
    int c=0;
    for(int j=0;j<t.size();j++){
      if(t[j]=='0'){
	if(j-1>=0)if(t[j-1]!='0'){
	  if(s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()]=='S')cout<<" ";
	  else cout<<s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()];
	}
	c=j+1;
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
i,j=map(int,input().split())
li=[]
for s in range(i):
    p=str(input())
    li.append(p)
def provre(x):
    lll=0
    br=0
    for z in range(len(x)):
        if x[z]=='.':
            br+=1
    if br==len(x):
        lll=1
    return(lll)
li2=[]
for a in range(len(li)):
    if provre(li[a])==0:
        li2.append(li[a])
li=li2

def prost(x):
    sd=[]
    L = [1] * len(x[0])
    for i in range(len(x[0])):
        ooo=1
        cnt = 0
        for s in range(len(x)):
            if x[s][i]=='.':
                cnt += 1
        if cnt == len(x):
            ooo = 0
        if ooo==0:
            L[i] = 0
              
    for j in range(len(x)):
        s = ""
        for q in range(len(x[0])):
            if L[q]==1:
                s+=x[j][q]
        sd.append(s)
    for ka in range(len(sd)):
        print(sd[ka])


prost(li)

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

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

typedef long long ll; //64bit型
using namespace std;

const long long INF = 1LL << 60; //無限大の値
static const int N = 100;

int main()
{
    stack<int> S;
    int a, b;
    string s;
    while (cin >> s)
    {

        if (s[0] == '+')
        {
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a + b);
        }
        else if (s[0] == '-')
        {
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a - b);
        }
        else if (s[0] == '*')
        {
            b = S.top();
            S.pop();
            a = S.top();
            S.pop();
            S.push(a * b);
        }
        else
        {
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;
    return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<math.h>


using namespace std;

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

#define INF 1050000000




int main() {

	int N;

	cin >> N;

	vector<int> A(N);

	int max = 0;
	int max2 = 0;
	int key=0;

	bool flag=false;

	rep(i, N) {
		cin >> A[i];

		
		if (A[i] > max) {
			max = A[i];
			flag = false;
			key = i;
		}
		else if (max2 < A[i]) {
			max2 = A[i];
		}
		else if (max == A [i]) {
			flag == true;
		}
		
	}



	rep(i, N) {
		
		if (flag == false && i == key) {
			cout << max2 << endl;
			continue;
		}

		cout << A[key] << endl;
	}
	


	return 0;
}

Measured memory_bytes: 2432
H,W=map(int,input().split())
if H==1 or W==1:
  print(1)
else:
  if H==2 and W==2:
    print(2)
  else:
    if H*W%2==0:
      print(H*W//2)
    else:
      print((H*W+1)//2)

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll A, V, B, W, T, x, y;
  cin >> A >> V >> B >> W >> T;
  if(A > B){
    x = A - (V*T);
    y = B - (W*T);
      if(x <= y) cout << "YES";
      else cout << "NO";
  }
  
  if(A <= B){
    x = A + (V*T);
    y = B + (W*T);
      if(x >= y) cout << "YES";
      else cout << "NO";
  }
}

Measured memory_bytes: 3612
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private int n;
    private int[] a;

    private void run() {
        n = sc.nextInt();
        a = new int[n+1];
        a[n] = 1000001;

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

        boolean[] check = new boolean[1000001];
        Arrays.sort(a);
        Arrays.fill(check, true);

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i + 1] != a[i] && check[a[i]]) {
                ans++;
            }

            for (int j = a[i]; j <= a[n - 1]; j += a[i]) {
                check[j] = false;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 60548
#include <stdio.h>
#include <math.h>
 
int main(int argc, const char * argv[]) {
    // insert code here...
    int a[6];
    int g[4];
int c;
c=0;
    for(int i=0;i<=5;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<=3;i++){
        g[i]=0;
    }
    for(int i=0;i<=5;i++){
        switch(a[i]){
            case 1:
c=g[0];
                g[0]=c+1;
break;
            case 2:
c=g[1];
                g[1]=c+1;
break;
            case 3:
c=g[2];
                g[2]=c+1;
break;
            case 4:
c=g[3];
                g[3]=c+1;
break;
        }
    }
    if(g[0]==3 || g[1]==3 || g[2]==3 || g[3]==3){
        printf("NO");
    }
    else printf("YES");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    vector<int> A(3);
    for (int i = 0; (i < 3); ++i) {
        cin >> A[i];
    }

    sort(A.rbegin(), A.rend());

    cout << (A[0] * 10 + A[1] + A[2]) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		int a=sc.nextInt();
		double p=3.141592653589793;
		System.out.println(2*a*p);
		//String S=sc.next();
		//int v[]=new int[a];
		
		
		 
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 35916
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int N = S.length();
	vector<int> s(N);
	vector<int> dif(N + 1);
	for(int i = 0; i < N; i++) {
		s[i] = S[i] == '1';
		dif[i] = (i ? (s[i - 1] ^ s[i]) : s[i]);
	}
	dif[N] = s[N - 1];
	int ans = N;
	for(int i = 0; i < N + 1; i++) {
		if(dif[i]) ans = min(ans, max(i, N - i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	g := make([][]int, n)
	ss := make(osushi, 0)
	for i := 0; i < n; i++ {
		t := getNextInt(scanner) - 1
		d := getNextInt(scanner)
		g[t] = append(g[t], -d)
	}
	for i := 0; i < n; i++ {
		sort.Ints(g[i])
		for j := 0; j < len(g[i]); j++ {
			ss = append(ss, createSushi(i, j, g[i][j]))
		}
	}
	sort.Sort(ss)
	m := map[int]int{}
	var ans, x int64
	rem := make([]int, 0)
	for i := 0; i < n; i++ {
		if i < k {
			m[ss[i].t] = ss[i].i + 1
			x += int64(ss[i].d)
			if ss[i].i > 0 {
				rem = append(rem, -ss[i].d)
			}
		}
	}
	sort.Ints(rem)
	first := make([]int, 0)
	for i := 0; i < n; i++ {
		if len(g[i]) == 0 {
			continue
		}
		if m[i] > 0 {
			continue
		}
		first = append(first, g[i][0])
	}
	x -= pow2(len(m))
	ans = x
	sort.Ints(first)
	mm := len(m)
	for i := 0; i < len(first) && i < len(rem); i++ {
		ans = minint(ans, x-int64(mm*2+1)+int64(first[i]+rem[i]))
		x = x - int64(mm*2+1) + int64(first[i]+rem[i])
		mm++
	}

	fmt.Fprintln(writer, -ans)
}

func pow2(m int) int64 {
	return int64(m) * int64(m)
}
func minint(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func createSushi(t, i, d int) sushi {
	return sushi{
		t: t,
		i: i,
		d: d,
	}
}

type sushi struct {
	t, i int
	d    int
}

type osushi []sushi

func (a osushi) Len() int      { return len(a) }
func (a osushi) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a osushi) Less(i, j int) bool {
	if a[i].d == a[j].d {
		return a[i].i < a[j].i
	}
	return a[i].d < a[j].d
}


Measured memory_bytes: 22016
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(a,b,c);
    cout << (a*b)/2 << nn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{  int n,i,j,f=1,k;
  double sum=0;
 cin>>n;
 int x[n];
 int y[n];
 for(i=0;i<n;i++)
 {
     cin>>x[i]>>y[i];
 }
 for(i=n;i>=1;i--)
 {
     f=f*i;
 }
 double d=0;
      for(i=0;i<n-1;i++)
   {
       for(j=i+1;j<n;j++)
      {
         d+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      }
   }
   
   
  cout<<fixed<<setprecision(10)<<d*2/n;
 
 
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

void output(vector<int> s){
    int n=s.size();
    for(int i=0;i<n;i++){
        //if(i!=0) cout<<" ";
        cout<<s[i]<<endl;
    }
    //cout<<endl;
}


int D,score;
vector<int> c(27);
vector<int> last_day(27);
vector<vector<int>> s(D,vector<int>(27));

int unpresure(int d,int i){
    return c[i]*(d-last_day[i]);
}

void day(int d,int i){
    score+=s[d][i];
    last_day[i]=d;
    for(int j=1;j<=26;j++){
        score-=unpresure(d,j);
    }
}

signed main(){ 
   cin>>D; score=0;
   last_day.assign(27,0);
   s.assign(D+1,vector<int>(27));


   for(int i=1;i<=26;i++) cin>>c[i];

   for(int i=1;i<=D;i++){
       for(int j=1;j<=26;j++){
           cin>>s[i][j];
       }
   }

   vector<int> v;
   for(int i=1;i<=D;i++){
       int ti; cin>>ti;
       day(i,ti);
       v.push_back(score);
   }

   output(v);

}  

Measured memory_bytes: 3604