akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


#define N 	 100005
void solve(){
	int k, s, ans = 0;
	cin>>k>>s;
	rep(i,0,k+1){
		rep(j,0,k+1){
			int z = s-i-j;
			if(z>=0 && z<=k)
				ans++;
		}
	}
	cout<<ans<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
d={}
try:
    while True:
        n=int(input())
        if n in d:
            d[n]+=1
        else:
            d[n]=1
except EOFError:
    pass
a=[]
m=max(d.values())
for key, value in d.items():
    if value == m:
        a.append(key)
a.sort()
for i in a:
    print(i)

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

using namespace std;

int const size = 1e5 + 5;

int dp[103][size];
int arr[size];
int mod = 1e9 + 7;

int solve(int n ,int k){
	int ans;
	dp[0][0] = 1;
	for(int x=0;x<=k;x++) dp[0][x] = 1;
	for(int x=1; x<=n; x++){
		for(int i=0; i<=k; i++){
			dp[x][i] = dp[x-1][i];
			if(i - arr[x] - 1 >=0) dp[x][i] = (dp[x][i] + mod - dp[x-1][i-arr[x]-1])%mod;
		}
		 if(x == n) ans = dp[n][k];
		for(int i=1;i<=k;i++) dp[x][i] = (dp[x][i] + dp[x][i-1])%mod;
	}
	// for(int x=0;x<=k;x++) cout<<dp[n][x]<<" ";
	// // cout<<"\n";
	// if(k - arr[n] - 1 >= 0) ans = (dp[n][k] + mod - dp[n][k - arr[n] -1])%mod;
	return ans;
}

int main(){
	int n, k;
	scanf("%d %d",&n, &k);
	for(int x=1;x<=n;x++) scanf("%d", &arr[x]);
	cout<<solve(n,k);
	return 0;
}

Measured memory_bytes: 39680
using System;//fAIR, LATER, OCCASIONALLY CLOUDY.
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = "abcdefghijklmnopqrstuvwxyz";
            string c = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            int d = a.Length;
            int f;
            for (int e = 0; e < d; e++)
            {
               for( f =0;f!=26;f++)
                {
                   
                    if (a[e] == b[f]) { Console.Write(c[f]); break; }
                    else if (a[e] == c[f]) { Console.Write(b[f]); break; }
                   
                }
              if(f==26)   Console.Write(a[e]); 
            }
            Console.Write("\n");


        }
    }
}

//fAIR, LATER, OCCASIONALLY CLOUDY.

Measured memory_bytes: 8744
#解説AC

import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

n,m=map(int,input().split())
es=[[] for i in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    es[x-1].append(y-1)

dp=[-1]*n

def memo(v):
    if dp[v]+1: #更新済 dp[v]!=-1
        return dp[v]
    a=0
    for i in es[v]:
        a=max(a,memo(i)+1)
    dp[v]=a
    return a

ans=0
for i in range(n):
    ans=max(ans,memo(i))

print(ans)


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

using namespace std;
struct node
{
    int k,score;
    char city[200];
}res[102];
int main()
{
    int N;
    while(scanf("%d\n",&N)!=EOF)
    {
        int i,j;
        for(i=1;i<=N;i++)
        {
            res[i].k=i;
            scanf("%s %d",res[i].city,&res[i].score);
           // printf("    %s   %d\n",res[i].city,res[i].score);
        }
        for(j=1;j<N;j++)
            for(i=1;i<=N-j;i++)
        {
            if(strcmp(res[i].city,res[i+1].city)>0)
            {
                res[101]=res[i];
                res[i]=res[i+1];
                res[i+1]=res[101];
            }
            if(strcmp(res[i].city,res[i+1].city)==0&&res[i].score<res[i+1].score)
            {
                res[101]=res[i];
                res[i]=res[i+1];
                res[i+1]=res[101];
            }
        }
        for(i=1;i<=N;i++)
            printf("%d\n",res[i].k);
    }
    return 0;
}


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

using namespace std;
using ll = long long;
const int INF = 1 << 30;

int main() {
    int N = 0;
    cin >> N;
    int K = 0;
    cin >> K;
    vector<int> A(N*2,0);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> ans(2*N,INF);
    ans.at(0) = 0;
    for (size_t i = 0; i < N+1; i++)
    {
        for (size_t j = 1; j < K+1; j++)
        {
            if (i+j>=2*N)
            {
                continue;
            }
            
            ans.at(i+j) = min(ans.at(i) + abs(A.at(i+j)-A.at(i)),ans.at(i+j));
        }
        
    }
    cout << ans.at(N-1) << endl;
    

    return 0;
}

Measured memory_bytes: 4852
/*
 *
 * <equation> ::= <formula> "=" <formula>
 * <formula>  ::= "T" | "F" |
 * "a" | "b" | "c" | "d" | "e" | "f" |
 * "g" | "h" | "i" | "j" | "k" |
 * "-" <formula> |
 * "(" <formula> "*" <formula> ")" |
 * "(" <formula> "+" <formula> ")" |
 * "(" <formula> "->" <formula> ")"
 */
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<sstream>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } //t=min
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } //t=max
using namespace std;


vector<bool> var_pattern;
bool equation(string& s, int& i);
bool formula(string& s, int& i);


bool equation(string& s, int& i)
{
	bool left = formula(s,i);
	i++; //=
	i++; //formula
	bool right = formula(s,i);

	//cout << left << "=" << right << endl;

	return left == right;
}


bool formula(string& s, int& i)
{
	bool left=false,right=false;	
	char ope=0;
	bool ans = false;

	switch(s[i])
	{
		case 'T':
			ans = true;
			break;
		case 'F':
			ans = false;
			break;
		case '-':
			i++;
			return !formula(s,i);
		case '(':
			i++;
			left = formula(s,i);
			i++; 
			ope = s[i];
			if (ope == '-') { i++; ope='>'; } //->
			i++;
			right = formula(s,i);

			if (ope == '*') {
				ans = left * right;	
			}
			else if (ope == '+') {
				ans = left + right;	
			}
			else if (ope == '>') {
				ans = (!left) + right;
			}
			i++; //')'
			break;

		default:
			if ('a' <= s[i] && s[i] <= 'k') {
				int var_num = (int)(s[i] - 'a');
				ans = var_pattern[var_num];
			}
			//cout << "index=" << var_num << " var=" << s[i] << endl;
			//cout << s[i] << " = " << var_pattern[var_num] << endl;
			break;
	}

	return ans;
}



int main() {
	string line;
	
	while(cin >> line)
	{
		if (line[0] == '#') break;

		bool is_yes = true;
		rep(j,2048) {
			int i=0;
			int num = j;
			rep(k,11)
			{
				var_pattern.push_back((num & 1));
				//cout << (num & 1) << " ";
				num >>= 1;
			}
			//cout << endl;
			if (!equation(line,i)) { is_yes = false; break; }
			var_pattern.clear();
		}
		cout << (is_yes ? "YES" : "NO") << endl;
		//cout << "-----------" << endl;
	}

	return 0;
}

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

const long double PI = acos(-1);
 
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); }

 bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    char c;
    cin >> c;
    cout << char(c + 1) << endl;
    return 0;
}

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

typedef pair<int,int> P;

int main(){
	int n;
	int a[100010];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&a[i]);
	}
	
	int p=-10000,m=10000;
	int ret = 0;
	vector<int> vec;
	for(int i = 0 ; i < n ; i ++){
		p = max( p , a[i] );
		m = min( m , a[i] );
		ret += max( a[i] , -a[i] );
	}
	if(m > 0)cout << ret-2*m << endl;
	else if(p < 0)cout << ret+2*p << endl;
	else cout << ret << endl;
	
	int x = p,y = m;
	int pi = -1, mi = -1;
	for(int i = 0 ; i < n ; i ++){
		if(a[i] == p && pi == -1){
			pi = i;
			continue;
		}
		if(a[i] == m && mi == -1){
			mi = i;
			continue;
		}
		if(a[i] >= 0){
			printf("%d %d\n",y,a[i]);
			y -= a[i];
		}
		else {
			printf("%d %d\n",x,a[i]);
			x -= a[i];
		}
	}
	printf("%d %d\n",x,y);
}

Measured memory_bytes: 2304
inte = int(input())
inputs = list(map(int, input().split()))
length = len(inputs)
s = [0 for i in range(length)]
for i in range(length):
    s1 = 0
    s2 = 0
    for j in range(length):
        if j <= i:
            s1 += inputs[j]
        else:
            s2 += inputs[j]
    s[i] = abs(s1 - s2)
s = sorted(s)
print(s[0])

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

ll n, m, p[1000], d[600000];

int main() {
  while (scanf("%lld%lld", &n, &m), n) {
    for (ll i = 0; i < n; i++) scanf("%lld", &p[i]);
    ll counter = 0;
    for (ll i = 0; i < n; i++) for (ll j = 0; j <= i; j++) d[counter++] = p[i] + p[j];
    for (ll i = 0; i < n; i++) d[counter++] = p[i];
    sort(d, d + counter);
    ll ans = 0;
    for (ll i = 0, j = counter - 1; i < counter; i++) {
      while (d[i] + d[j] > m) j--;
      if (i > j) break;
      if (ans < d[i] + d[j]) ans = d[i] + d[j];
    }
    printf("%lld\n", ans);
  }
}



Measured memory_bytes: 6592
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;
    static int[] a;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        a = cin.ArrayInt(N);
    }
    static void solve()
    {
        input();
        Dictionary<int, int> dict = new Dictionary<int, int>();
        for(int i = 0; i < N; i++)
        {
            if (!dict.ContainsKey(a[i]))
                dict.Add(a[i], 0);
            dict[a[i]]++;

            if (!dict.ContainsKey(a[i] + 1))
                dict.Add(a[i] + 1, 0);
            dict[a[i] + 1]++;

            if (!dict.ContainsKey(a[i] - 1))
                dict.Add(a[i] - 1, 0);
            dict[a[i] - 1]++;
        }
        int max = 0;
        foreach(var i in dict)
        {
            if (i.Value > max) max = i.Value;
        }
        WriteLine(max);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 26208
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

ll commChar(string s1, string s2){
    ll cnt = 0;
    set<char> s1set(s1.begin(), s1.end());
    set<char> s2set(s2.begin(), s2.end());

    for(auto x: s1set){
        if(s2set.count(x))
            cnt++;
    }
    return cnt;
}
void solve(long long N, std::string S){
    ll ans = 0;
    for(ll i=1; i<= N-1; i++){
        string s1 = S.substr(0, i);
        string s2 = S.substr(i, N-i);
        ll cnt = commChar(s1, s2);
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;



const int MAX_LOG_N = 100;
int64 p[MAX_LOG_N], e[MAX_LOG_N];

int solve(int64 N){
	int psz = 0;
	for (int64 d = 2; d*d <= N; ++d){
		if(N%d == 0){
			p[psz] = d;
			while(N%d == 0)	N /= d, ++e[psz];
			psz++;
		}
	}	
	if(N != 1)	p[psz] = N, e[psz] = 1, ++psz;
	return psz;
}
int main(){
	int64 N;	scanf("%lld",&N);
	int psz = solve(N);
	int ans = 0;
	for (int i = 0; i < psz; ++i){
		int j = 1;
		while(e[i] >= j) e[i] -= j++, ++ans;
	}
	printf("%d\n",ans);

}




Measured memory_bytes: 3828
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	
	long long int s = 0;
	string N;

	cin >> N;

	rep(i, N.length()){
		s += (N[i] - '0');
	}

	cout << (s%9 == 0 ? "Yes" : "No");
 
 
	return 0;
}

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

using namespace std;

int main(void)
{
    int N, M, i, j, k, l, judge=1, ans=0;
    string A[52], B[52];

    cin >> N >> M;

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

    for(i=0; i<M; i++){
        cin >> B[i];
    }

    for(i=0; i<=N-M; i++){
        for(j=0; j<=N-M; j++){ // Aの中を移動
            judge = 1;

            for(k=0; k<M; k++){
                for(l=0; l<M; l++){
                    if(A[i+k][j+l] != B[k][l]){
                        judge = 0;
                    }
                }
            }

            if(judge == 1){
                ans = 1;
            }
        }
    }

    if(ans == 1){
        cout << "Yes" << endl;
    }

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

    return 0;
}

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



int main() {

	int n;
	cin >> n;
	bool ans = false;

	for (int i = 0; i <= n/4; i++) {
		for (int j = 0; j <= n/7; j++) {
			int sum = 4 * i + 7 * j;
			if (sum == n)ans = true;
		}
	}

	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}




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

ll mod=1e9+7;



int main() {
  ll num;
  cin >> num;
  map<ll,ll> res;
  for(ll j=2;j<=num;j++) {
    ll n=j;
    for(int i=2;i*i<=n;i++) {
      while(n%i==0) {
        res[i]++;
        n/=i;
      }
    }
    if(n!=1) {
      res[n]++;
    }
  }
  ll ans=1;
  for(auto p:res) {
    ans=ans*(p.second+1)%mod;
  }
  cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double d;
	cin >> d;
	double ans = -1;
	if (d + EPS > 1)ans = floor(d) + 1;
	cout <<fixed<<setprecision(12)<< max(ans, sqrt(2)*d) << endl;
	return 0;
}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl



int main(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    FOR(i,1,n+1){
        int t = i;
        double kaku = 1.0/n;
        while(t<k){
            t *= 2;
            kaku /= 2.0;
        }
        ans+= kaku; 
    }
    cout << setprecision(20) << ans << endl;
    return 0;
}    


Measured memory_bytes: 256
N=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(N-1):
    if p[i]==i+1:
        tmp=p[i]
        p[i]=p[i+1]
        p[i+1]=tmp
        ans+=1
if p[-1]==N:
    ans+=1
print(ans)

Measured memory_bytes: 13880
def main():
    N,X,Y = [int(n) for n in input().split()]
    X -= 1
    Y -= 1
    res = [0] * N
    for i in range(N):
        for j in range(i,N):
            dis = min([j - i, abs(i - X) + 1 + abs(j-Y), abs(i - Y) + 1 + abs(j-Y)])
            # print(i,j,X,Y)
            # print(dis)
            res[dis]+=1
    for i in range(1,N):
        print(res[i])
main()

Measured memory_bytes: 44892
#include <iostream>
using namespace std;
bool ok(string s)
{
	if(s.size() % 2 != 0)
	{
		return 0;
	}
	string s1 = s.substr(0,s.size() / 2);
	string s2 = s.substr(s.size() / 2);
	return s1 == s2 ? 1 : 0;
}
int main()
{
	string s;
	cin>>s;
	for(int i = 1;i < s.size(); ++i)
	{
		string curs = s.substr(0,s.size() - i);
		if(ok(curs))
		{
			cout<<curs.size()<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int M = 100000007;

int dp[2][3][59049], h, w, d[11];
char m[10][10];

main(){
  d[0] = 1;
  for(int i=0;i<10;i++) d[i+1] = d[i] * 3;
  cin >> h >> w;
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> m[i][j];
  int c = 0;
  dp[0][0][0] = 1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      memset(dp[1-c], 0, sizeof(dp[1-c]));
      for(int k=0;k<3;k++){
        for(int l=0;l<d[w];l++){
          if(dp[c][k][l]){
            int s = l / d[j] % 3;
            if(m[i][j] == '.'){
              if(k && s) continue;
              if(k == 0 || j < w - 1) (dp[1-c][k][l] += dp[c][k][l]) %= M;
            }else{
              for(int u=0;u<3;u++){
                int t = m[i][j] - '0' - k - s - u;
                if(t < 0 || t > 2) continue;
                if(u == 0 || j < w - 1) (dp[1-c][u][l+d[j]*(t-s)] += dp[c][k][l]) %= M;
              }
            }
          }
        }
      }
      c = 1 - c;
    }
  }
  cout << dp[c][0][0] << endl;
}

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

int main(void){
  int N, K;
  int A[200010];
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  //整数の個数リストを作って，その上からK個を取って，その個数の和を求める。
  //N個からその個数の和を引けば良い。
  int integer_num[200010] = {0};
  for(int i = 0; i < N; i++){
        integer_num[A[i]]++;
    }
  sort(integer_num, integer_num + N + 1, greater<int>());
  int sumK = 0;
  for(int i = 0; i < K; i++){
    sumK += integer_num[i];
  }
  cout << N - sumK << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

int D(P p){
	int x = p.first;
	int y = p.second;
	return (x * x + y * y);
}

void solve(){
	int x=0, y=0, dx, dy, ans_d=0;
	vector<P> vp;
	P ans_p;
	bool flag = false;

	while( cin >> dx >> dy , dx || dy ){
		x += dx;
		y += dy;
		P p(x,y);
		vp.push_back(p);
	}
	for(int i=0 ; i < vp.size() ; i++ ){
		ans_d = max( ans_d , D(vp[i]) );
	}
	for(int i=0 ; i < vp.size() ; i++ ){
		if( ans_d == D(vp[i]) ){
			if( flag == false ){
				flag = true;
				ans_p = vp[i];
			}else{
				ans_p = max( ans_p , vp[i] );
			}
		}
	}
	cout << ans_p.first << " " << ans_p.second << endl;
}

int main(){
	int N;
	cin >> N;
	for(int i=0 ; i < N ; i++ )
		solve();
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll , ll > pii;
ll mod=998244353;
ll p=1e9+7;
double PI= 3.14159265;
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k; cin>>k;
    string s; cin>>s;
    for(int i=0; i<s.length(); i++){
        if( i+1 <= k ) cout<<s[i];
        else break;
    }
    if(s.length()>k){
        cout<<"...";
    }
    return 0;
}
 

Measured memory_bytes: 3644
#include<iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    int n,a,b;
    cin >> n;
    
    if(n == 1)
    {
        cout << "Hello World" << endl;
    }
    if(n == 2)
    {
        cin >> a >> b;
        cout << a + b;
    }
    return 0;
}


Measured memory_bytes: 256
program main
    character (10) :: cx, ca, cb
    integer :: x, a, b
    read *, cx, ca, cb
    read (cx, *) x
    read (ca, *) a
    read (cb, *) b
    if (abs(x-a) < abs(x-b)) then
        print *, "A"
    else
        print *, "B"
    end if
end program main

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    set<char> s;
    rep(i, 3) {
        char c; cin >> c;
        s.insert(c);
    }
    if(s.count('7')) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

void solve()
{
  int a,b;
  cin >> a >> b;

  if(a+b < 24)
    cout << a+b << endl;
  else
    cout << a+b-24 << endl;
}

int main(){cin.tie(0);ios_base::sync_with_stdio(false);solve();return 0;}


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

int main(){

  double W,H,x,y;
  cin >> W >> H >> x >> y;

  cout << std::setprecision(9) << W*H/2.0 << " " << flush;
  if(W/2.0==x && H/2.0==y){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
constexpr int MX = 100005;
int n,m,k,a,b;
int p[MX], d[MX];
int find(int x){return (p[x] < 0 ? x : p[x] = find(p[x]));}
void uni(int x, int y){
	x = find(x); y = find(y);
	if(x != y){
		if(p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
	}
}
int main(){
	scanf("%d%d%d", &n, &m, &k);
	fill(p, p+n, -1);
	rep(i,m){
		scanf("%d%d", &a, &b);
		a--; b--;
		d[a]--; d[b]--;
		uni(a,b);
	}
	rep(i,k){
		scanf("%d%d", &a, &b);
		a--; b--;
		if(find(a) == find(b)){
			d[a]--;
			d[b]--;
		}
	}
	rep(i,n) printf("%d%c",-p[find(i)]+d[i]-1,i==n-1?'\n':' ');
}

Measured memory_bytes: 1664
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		System.out.print(N * A <= B ? N * A : B);

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 20820
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int a,b,x[100]={0},y[100]={0},num[100]={0},count=0;
	cin>>a>>b;
	for (int i=1;i<=b;i++){
		cin>>x[i]>>y[i];
		num[x[i]]++;num[y[i]]++;
	}
	for (int i=1;i<=a;i++)
		if (num[i]==1){
			for (int j=1;j<=b;j++)
				if (x[j]==i){
					num[y[j]]--;
					i=0;
					x[j]=0;y[j]=0;
					count++;
					break;
				}
				else if (y[j]==i){
					num[x[j]]--;
					x[j]=0;y[j]=0;
					i=0;
					count++;
					break;
				}
		}
	cout<<count;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) cout << S << endl;
    else cout << S.substr(0, K) << "..." << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

string s;
int a,b;

int main(){
  cin >> s;
  for(auto c:s){
    if(c=='A'){++a;}
    if(c=='B'){++b;}
  }
  if(a && b){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
  return 0;
}


Measured memory_bytes: 256
N,M,X = map(int, input().split())
CA_array = list()
for i in range(N):
    CA_list = [int(e) for e in input().split()]
    CA_array.append(CA_list)
    
ans = 13*(10**5)
    
#N<=12なので全探索しても4096.全探索する。
for i in range(2**(N)): #4096
    bit_array = str(bin(i)[2:]).zfill((N))
    #print(bit_array)

    CA_on_bit_array = [0 for _ in range(M+1)]
    
    for j in range(len(bit_array)): #12

        if bit_array[j]=="0":
            #OFF時の処理
            pass
        elif bit_array[j]=="1":
            #ON時の処理
            for k in range(M+1): #13
                CA_on_bit_array[k] += CA_array[j][k]

    #ON・OFFの状態設定後の処理
    for k in range(1,M+1):
        if CA_on_bit_array[k] < X:
            break
    else:
        if CA_on_bit_array[0] < ans:
            ans = CA_on_bit_array[0]

if ans != 13*(10**5):
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;

ll a[50];
ll N;
ll p,n;
vector<pair<ll,ll>> v;
vector<ll> pv,nv;
ll pl,nl;

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    p = n = 0;
    pl = nl = -1;
    for(int i=0;i<N;i++){
        if(a[i] > 0){
            p += a[i];
            pv.push_back(i+1);
            pl = i+1;
        }
        if(a[i] < 0){
            n -= a[i];
            nv.push_back(i+1);
            if(nl == -1) nl = i+1;
        }
    }
    if(pl == -1 && nl == -1){
        cout << 0 << endl;
        return 0;
    }
    if(p > n){
        for(int i=1;i<pv.size();i++){
            v.push_back(make_pair(pv[i-1],pv[i]));
        }
        for(int i=0;i<nv.size();i++){
            v.push_back(make_pair(pl,nv[i]));
        }
        for(int i=1;i<N;i++) v.push_back(make_pair(i,i+1));
    }else{
        for(int i=nv.size()-1;i>=1;i--){
            v.push_back(make_pair(nv[i],nv[i-1]));
        }
        for(int i=0;i<pv.size();i++){
            v.push_back(make_pair(nl,pv[i]));
        }
        for(int i=N;i>1;i--) v.push_back(make_pair(i,i-1));
    }
    cout << v.size() << endl;
    for(int i=0;i<v.size();i++){
        cout << v[i].first << " " << v[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

constexpr long MOD = 1000000000 + 7;

long EXC[100009];

long exc(long a)
{
    return EXC[a];
}

long pw(long a, long p)
{
    if (p == 1)
        return a;

    if (p % 2 == 0) {
        long b = pw(a, p / 2);
        b *= b;
        b %= MOD;
        return b;
    }

    long b = pw(a, p - 1);
    b *= a;
    b %= MOD;
    return b;
}

long IEXC[100009];

long iexc(long a)
{
    return IEXC[a];
}

void init()
{
    EXC[0] = 1;
    IEXC[0] = 1;

    long v = 1;
    for (long i = 1; i < 100009; ++i) {
        v *= i;
        v %= MOD;
        EXC[i] = v;
        IEXC[i] = pw(v, MOD - 2);
    }
}

long comb(long a, long b)
{
    if (b > a)
        return 0;
    if (a - b < b)
        return comb(a, a - b);

    long p = exc(a);
    long q = iexc(a - b);
    long r = iexc(b);

    long v = p;
    v *= q;
    v %= MOD;
    v *= r;
    v %= MOD;
    // cerr << "COMB " << a << " " << b << " " << v << " (" << p << " " << q << " " << r << ")" << endl;
    return v;
}

int main()
{
    init();

    int N;
    cin >> N;
    ++N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    set<int> s;
    int dupe = -1;
    for (int x : a) {
        if (s.find(x) != s.end()) {
            dupe = x;
            break;
        }
        s.insert(x);
    }

    int l = -1;
    int r = -1;
    for (int i = 0; i < N; ++i) {
        if (a[i] == dupe) {
            if (l == -1)
                l = i;
            else
                r = i;
        }
    }

    assert(r != -1);

    int osz = l + (N - 1) - r;

    for (int k = 1; k <= N; ++k) {
        long p = comb(N, k);
        long q = comb(osz, k - 1);
        long v = (p + MOD - q) % MOD;
        cout << v << '\n';
    }

    return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
int H,W;
char G[1100][1100],JOI[2][2];
int ok[1100][1100];
int dx[] = {0,1,0,1};
int dy[] = {0,0,1,1};
 
int ndx[] = {1,0,1,0};
int ndy[] = {1,1,0,0};
 
char Flag[3] = {'J','O','I'};
 
bool isValid(int x,int y){ return 0 <= x && x < W && 0 <= y && y < H; }
 
int main(){
  scanf("%d %d",&H,&W);
  rep(i,H) rep(j,W){
    cin >> G[i][j];
    ok[i][j] = -1;
  }
  rep(i,2) rep(j,2) cin >> JOI[i][j];
 
  int ans = 0;
 
  rep(i,H)rep(j,W){
    int res = -1;
    int out = 0, op = -1;
    rep(k,4){
      int nx = j + dx[k], ny = i + dy[k];
      if( !isValid(nx,ny) ) {
        out = 100;
        break;
      }
      if( JOI[dy[k]][dx[k]] != G[ny][nx] ) {
        out++;
        op = k + 1;
      }
    }
    if( out == 0 ) res = 0, ++ans;
    if( out == 1 ) res = op;
    if( out >= 2 ) res = -1;
    ok[i][j] = res;
  }
 
  int maxi = ans;
  rep(y,H)rep(x,W){
    rep(i,3){
      int cost = ans;
      int sx = x - 1, sy =  y - 1;
      char c = Flag[i];
      rep(j,4){
        int nx = sx + dx[j], ny = sy + dy[j];
        if( !isValid(nx,ny) ) continue;
        if( ok[ny][nx] == -1 ) continue;
        int nnx = nx + ndx[j], nny = ny + ndy[j];
        if( !isValid(nnx,nny) ) continue;
        if( ok[ny][nx] == 0 && G[nny][nnx] != JOI[ndy[j]][ndx[j]] ) {
          cost--;
          continue;
        }
        if( ( 1 <= ok[ny][nx] && ok[ny][nx] <= 4 ) ){ 
          int dir = ok[ny][nx] - 1;
          int bx = nx + dx[dir], by = ny + dy[dir];
          if( !isValid(bx,by) ) continue;
          if( bx != nnx || by != nny ) continue;
          if( c == JOI[dy[dir]][dx[dir]] ) cost++;
        }
      }
      maxi = max(maxi,cost);
    }
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 6604
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;

const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e5 + 5;

char str[MAXN];

int main() {
	scanf("%s", str);
	int len = strlen(str);
	int ans = 0;
	for(int i = len - 2; i >= 0; --i) {
		if(str[i] != str[i + 1]) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
ls = len(S)
lt = len(T)
dp = [[0] * (lt+1) for i in range(ls+1)]

for i in range(ls):
  for j in range(lt):
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j], dp[i][j+1], dp[i][j] + 1 if S[i] == T[j] else 0)

ans = ""
while ls > 0 and lt > 0:
  if   dp[ls][lt] == dp[ls-1][lt]: ls -= 1
  elif dp[ls][lt] == dp[ls][lt-1]: lt -= 1
  else:
    ans = S[ls-1] + ans
    ls -= 1
    lt -= 1

print(ans)

Measured memory_bytes: 113372
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int sum=0;
		
		for(int i=0;i<N;i++) {
			sum+=sc.nextInt();
		}
		if(sum>=H) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
	
}


Measured memory_bytes: 48696
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<double> x(N);vector<string> u(N);
  double sum = 0;
  for (int i=0; i<N; i++) cin >> x[i] >> u[i];
  
  for (int i=0; i<N; i++) {
    if (u[i] == "BTC") {
      sum += x[i] * 380000;
    }
    else {
      sum += x[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
//#include <tourist>
#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桁
//-std=c++14
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;
};
int n, b, c;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    n=s.size();
    int ans=n;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){
            ans=min(ans,max(i+1,n-i-1));
        }
    }
    cout<<ans<<"\n";
}
/*
アルファベットn個ずらして
string s1 = "test";
int N = 5;
printf("%c", (s1[0]+N)); 
*/


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var l = from str in Console.ReadLine().Split(' ')
					select int.Parse(str);
			var p = new List<int>(l);

			int count = 0;
			for (int i = 0; i < n - 2; i++)
			{
				if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) ||
					(p[i + 2] < p[i + 1] && p[i + 1] < p[i]))
				{
					count++;
				}
			}
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13268
N, M = map(int, input().split())

LRDi = []
for _ in range(M):
    a = list(map(int, input().split()))
    LRDi.append(a)

#tree = [None] * (N + 1)
tree = [[i, 0] for i in range(N + 1)]

def parent(n):
    p = n
    while tree[p][0] != p:
        p = tree[p][0]
    if p == n:
        return tree[n]
    if p == tree[n][0]:
        return tree[n]
    d = distance_to_root(n)
    tree[n][0] = p
    tree[n][1] = d
    return tree[n]

def distance_to_root(n):
    ret = 0
    nn = n
    while tree[nn][0] != nn:
        ret += tree[nn][1]
        nn = tree[nn][0]
    return ret

for l, r, d in LRDi:
    lp = parent(l)
    rp = parent(r)
    if lp[0] != rp[0]:
        rd = distance_to_root(r)
        tree[rp[0]] = [lp[0], lp[1] + d - rd]
    else:
        d1 = distance_to_root(l)
        d2 = distance_to_root(r)
        if d1 + d != d2:
            print("No")
            exit()

print("Yes")



Measured memory_bytes: 105432
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n)-1, n)+str(chr(ord('a')+X%n))
    return str(chr(ord('a')+X%n))

x10 = int(input())
x26 = Base_10_to_n(x10-1, 26)
print(x26)

Measured memory_bytes: 9176
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(input())
        for j in range(m):
            x, y = map(int, input().split())
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h = set()
        u = set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
            else:
                u.add(j+1)
        b = True
        for k in list(h):
            k -= 1
            h |= A[k][1]
            u |= A[k][0]
            if h & u:
                b = False
                break
        if b:
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int N_MAX = 100;
const int X_MAX = 100;

using P = pair<int, int>;

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

    int p;
    vector<bool> f(X_MAX + 1, true);
    rep(i, N)
    {
        cin >> p;
        f[p] = false;
    }

    if (N == 0)
    {
        cout << X << endl;
        return 0;
    }

    P ans(INF, -1);
    rep(x, X_MAX + 2)
    {
        if (f[x])
        {
            ans = min(ans, P(abs(X - x), x));
        }
    }

    cout << ans.second << endl;
}


Measured memory_bytes: 3616
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;


int main()
{
    int s, w;
    cin >> s >> w;

    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		//int b = scan.nextInt();
		int cnt = 0;
		/*N以下の自然数
		奇数である
		約数が8個ちょうど存在する*/
		for( int i = 1; i <= N; i += 2 ) {
			int yakusuu = 0;
			for( int j = 1; j <= i; j++  ) {
				if( i % j == 0 ) {
					yakusuu++;
				}
			}
			if( yakusuu == 8 ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22868
import sys
input = sys.stdin.buffer.readline
import heapq

def main():
    N,M,S = map(int,input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        u,v,a,b = map(int,input().split())
        edge[u-1].append((v-1, a, b))
        edge[v-1].append((u-1, a, b))
    
    change = [tuple(map(int,input().split())) for _ in range(N)]
    MAX_COST = 50*50
    S = min(S, MAX_COST)
    
    q = [(0,(0,S))]
    ans = [-1]*N
    visited = set()
    heapq.heapify(q)
    
    while q:
        time, data = heapq.heappop(q)
        now, money = data
        if ans[now] == -1:
            ans[now] = time
            if -1 not in ans:
                break
        if data in visited:
            continue
        visited.add(data)
        for fol, a, b in edge[now]:
            if money >= a:
                fol_data = (fol, money-a)
                if fol_data in visited:
                    continue
                heapq.heappush(q, (time+b, fol_data))
        c, d = change[now]
        if money+c > MAX_COST:
            continue
        heapq.heappush(q, (time+d, (now, money+c)))
    
    print(*ans[1:], sep="\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 57892
N, M, X, Y = [int(n) for n in input().split()]
x = sorted([int(n) for n in input().split()])
y = sorted([int(n) for n in input().split()])

Z = range(X + 1, Y + 1)

flag = 'War'

for z in Z:
  if x[-1] < z and y[0] >= z:
    flag = 'No War'
    break

print(flag)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using namespace std;

// long long gcd(long long a, long long b){
//     if (a < b){
//         a ^= b;
//         b ^= a;
//         a ^= b;
//     }
//     return b ? gcd(b, a % b) : a;
// }

// long long lcm(long long a, long long b){
//     return a * b / gcd(a, b);
// }

int main(){
    long long n,k,a[100001],ans=0;
    cin >> n >> k;
    rep(i,n){
        cin >> a[i];
    }
    n--;
    while(n>0){
        n -= k-1;
        ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var s int
	fmt.Scan(&s)
	// 	一般性を失わず、x1 = 0, y1 = 0として良い
	//　三角形の面積の公式 s = abs(x2*y3 - x3*y2)/2
	// 題意からabs(x2*y3 - x3*y2) = S (入力)
	// 1<= S <= 10^18 という制約を満たすためには、
	// x2 = 10^9, y = 1として良い
	const v = 1000000000
	y3 := (s + v - 1) / v
	x3 := v*y3 - s
	fmt.Printf("0 0 %d 1 %d %d\n", v, x3, y3)
	// fmt.Printf("debug - calculated s*2 %d\n", v*y3-x3)
}


Measured memory_bytes: 512