akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string S;
    cin >> S;

    int len = S.size();
    int count = 0;
    for (int i = 0; i < len / 2; i++) {
        if (S[i] != S[len-i-1]) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,m,a[100010],s[3];
bool vis[100010],f;
long long ans,cnt;
vector<int> v1[100010],v2[100010];
void dfs(int x,int c)
{
	if (vis[x])
	{
		if (a[x]!=c)
		{
			f=false;
		}
		return;
	}
	a[x]=c;
	s[c]++;
	vis[x]=true;
	cnt+=v1[x].size();
	for (int i=0;i<v1[x].size();i++)
	{
		int y=v1[x][i];
		dfs(y,(c+1)%3);
	}
	for (int i=0;i<v2[x].size();i++)
	{
		int y=v2[x][i];
		dfs(y,(c+2)%3);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	while (m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v1[x].push_back(y);
		v2[y].push_back(x);
	}
	for (int i=1;i<=n;i++)
	{
		if (!vis[i])
		{
			f=true;
			cnt=s[0]=s[1]=s[2]=0;
			dfs(i,0);
			if (!f)
			{
				ans+=1LL*(s[0]+s[1]+s[2])*(s[0]+s[1]+s[2]);
			}
			else if (s[1] && s[2])
			{
				ans+=1LL*s[0]*s[1]+1LL*s[1]*s[2]+1LL*s[2]*s[0];
			}
			else
			{
				ans+=cnt;
			}
		}
	}
	printf("%lld\n",ans);
    return 0;
}
//庾郎最年少，芳草妒春袍。
//——李商隐《春游》

Measured memory_bytes: 17920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int MCXItoI(char *MCXI,int len);
int ctoi(char c);		//char to integer
void ItoMCXI(int integer,char ans[]);
char itoc(int i);


int main(void) {
	int n;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++){
		char MCXI1[8],MCXI2[8];
		scanf("%s %s",MCXI1,MCXI2);
		int num1,num2;
		int len1,len2;
		len1 = strlen(MCXI1);
		len2 = strlen(MCXI2);
		num1 = MCXItoI(MCXI1,len1);
		num2 = MCXItoI(MCXI2,len2);
		char ans[8];
		ItoMCXI(num1+num2,ans);
		printf("%s\n",ans);
	}

	return 0;
}

int MCXItoI(char *MCXI,int len){
	char work;
	int temp = 1;
	int M = 0;
	int C = 0;
	int X = 0;
	int I = 0;
	int i = 0;

	while(i<len){
		work = *(MCXI + i++);
		if('0'<work && work<='9'){
			temp = ctoi(work);
		}
		else{
			switch (work){
			case 'm': M = temp;
					  temp = 1;
					  break;
			case 'c': C = temp;
					  temp = 1;
					  break;
			case 'x': X = temp;
					  temp = 1;
					  break;
			case 'i': I = temp;
					  temp = 1;
					  break;
			}
		}
	}
	int result;
	result = M*1000 + C*100 + X*10 + I;
	return result;
}

int ctoi(char c){
	int i;
	i = c -'0';
	return i;
}

void ItoMCXI(int integer,char ans[]){
	int M = 0;
	int C = 0;
	int X = 0;
	int I = 0;

	M = integer / 1000;
	C = (integer-1000*M) /100;
	X = (integer-1000*M-100*C) / 10;
	I = (integer-1000*M-100*C-10*X);

	int i =0;

	if(M != 0){
		if(M != 1){ans[i++] = itoc(M);}
		ans[i++] ='m';
	}
	if(C != 0){
		if(C!=1){ans[i++] = itoc(C);}
		ans[i++] ='c';
	}
	if(X != 0){
		if(X!=1){ans[i++] = itoc(X);}
		ans[i++] ='x';
	}
	if(I != 0){
		if(I!=1){ans[i++] = itoc(I);}
		ans[i++] ='i';
	}
	ans[i] = '\0';
}

char itoc(int i){
	char c;
	c = i + '0';
	return c;
}

Measured memory_bytes: 580
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double num;
        double area, circ;

        num = Double.parseDouble(scan.next());
        area = num * num * Math.PI;
        circ = num * 2.0 * Math.PI;

        System.out.print(BigDecimal.valueOf(area).toPlainString() + " ");
        System.out.println(BigDecimal.valueOf(circ).toPlainString());
    }
}



Measured memory_bytes: 26528
import numpy as np

n,m,x=map(int,input().split(' '))
text=[0]*n
for i in range(n):
    text[i]=np.array(list(map(int,input().split(' '))))

money=float('inf')
    
for i in range(2**n):
    buy=np.zeros(m+1)
    for j in range(n):
        if (i>>j) & 1:
            buy += text[j]
        if buy[1:].min() >=x:
            if buy[0] < money:
                money = buy[0]
                
if money == float('inf'):
    print(-1)
else:
    print(int(money))

Measured memory_bytes: 27160
#include <iostream>

using namespace std;

int main (){
	int n;
	long long d;
	cin >>n>>d;
	int count=0;
	for (int i=1; i<=n; i++){
	    long long x,y;
	    cin >>x>>y;
	    if (  (x*x + y*y) <= d*d){
	        count ++;
	    }
	}
	cout <<count;
	return 0;
}



Measured memory_bytes: 3180
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_line(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // 入力を受け取る
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let t: usize = iter.next().unwrap().parse().unwrap();

    // t秒間に，ビスケット生産装置が動作する回数を求める
    let num_process: usize = t / a;
    // 生産したビスケットの枚数を求める
    let num_biscuit: usize = num_process * b;
    
    println!("{}", num_biscuit);
}

Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  ll n,k;
  cin>>n>>k;
  
  vector<ll> p(n);
  rep(i,n){
  cin>>p[i];
  }
  
  ll ans = 1;
  
  while(k){
    if(k & 1) ans=p[ans-1];
    
  vector<ll> q(n);
    rep(i,n) {
    q[i]=p[p[i]-1];
    }
  
  swap(p,q);
    
  k/=2;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 6720
S = input()

ans = 0
temp = 0

# import pdb;pdb.set_trace()
for s in S:
    if s=='A' or s=='C' or s=='G' or s=='T':
        temp += 1
    else:
        if ans<temp:
            ans = temp
        temp = 0
if ans<temp:
    ans = temp
        
print(ans)


Measured memory_bytes: 2940
N = int(input())
A = [int(input()) for _ in [0]*N]
B = [A[0]]
ans = 1

for a in A[1:]:
    l = 0
    r = ans - 1
    if B[0]<a:r=0
    while l+1<r:
        i = (l+r)//2
        if B[i] < a:
            r = i
        else:
            l = i
    if B[r]<a:B[r] = a
    else:
        B.append(a)
        ans += 1
print(ans)

Measured memory_bytes: 55256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    int l;
    REP(i,2*n) {
        cin >> l;
        v.push_back(l);
    }
    
    sort(v.begin(), v.end());
    
    int ans = 0;
    REP(i,n) {
        ans += min(v[2*i+1], v[2*i]);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    ll n;
    ll ans=0;
    cin>>n;
    if(n%2!=0)
    {
        ans=0;
    }
    else
    {
        n=n/2;
        while(n)
        {
            ans+=n/5;
            n/=5;

        }
    }
    cout<<ans<<endl;


}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> x(N), y(N), z(N);
	rep(i, N) cin >> x[i] >> y[i] >> z[i];

	ll ret = LLONG_MIN;

	for (int i : {-1, 1}) {
		for (int j : {-1, 1}) {
			for (int k : {-1, 1}) {
				priority_queue<ll> que;
				rep(p, N) {
					que.push(x[p] * i + y[p] * j + z[p] * k);
				}
				ll s = 0;
				rep(tt, M) {
					s += que.top(); que.pop();
				}
				ret = max(ret, s);
			}
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//printf<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll a,b,c,d;
    cin >>a>>b>>c>>d;

    //-----------------------------------
    ll ans=a*c;
    chmax(ans, a*d);
    chmax(ans, b*d);
    chmax(ans, b*c);

    cout << ans <<'\n';

    return (0);
}

Measured memory_bytes: 3648
N = input()
N = int(N)
X = input().split()
A = []

min = 100
max = 0
for x in X:
  x = int(x)
  A.append(x)
  if max < x:
    max = x
  if x < min:
    min = x

ans = 0
count = 1
for p in range(min, max):
  sum = 0
  for a in A:
    sum += (a - p) * (a - p) 
  if ans > sum:
    ans = sum
  if count == 1:
    ans = sum
  count += 1

print(ans)


Measured memory_bytes: 3064
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

type AreaSum struct {
  Sum int
  Index int
}
type ASVec []AreaSum
func (AS ASVec) Len() int { return len(AS) }
func (AS ASVec) Less(i, j int) bool {
  if AS[i].Sum == AS[j].Sum { return AS[i].Index < AS[j].Index }
  return AS[i].Sum < AS[j].Sum
}
func (AS ASVec) Swap(i, j int) { AS[i], AS[j] = AS[j], AS[i] }

type Item struct {
  Value int
  Left int
  Right int
}
type SegmentTree struct {
  Size int
  Data []Item
}
func (ST SegmentTree) Update(i int) {
  idx := ST.Size + i
  for idx > 0 {
    ST.Data[idx].Value += 1
    idx /= 2
  }
}
func (ST SegmentTree) GetAfter(x, i int) int {
  if x < ST.Data[i].Left { return ST.Data[i].Value }
  if ST.Data[i].Right <= x { return 0 }
  return ST.GetAfter(x, 2 * i) + ST.GetAfter(x, 2 * i + 1)
}
func InitST(N int) *SegmentTree {
  Size := 1
  for Size < N {
    Size *= 2
  }
  Data := make([]Item, 2 * Size)
  for i := Size; i < 2 * Size; i++ {
    Data[i] = Item{0, i - Size, i - Size}
  }
  for i := Size - 1; i > 0; i-- {
    Data[i] = Item{0, Data[2 * i].Left, Data[2 * i + 1].Right}
  }
  return &SegmentTree{
    Size: Size,
    Data: Data,
  }
}

func main() {
  NK := NextIntVec()
  N := NK[0]
  K := NK[1]
  AS := make([]AreaSum, N + 1)
  for i := 0; i < N; i++ {
    a := NextInt()
    AS[i + 1] = AreaSum{AS[i].Sum + a - K, i + 1}
  }
  sort.Sort(ASVec(AS))
  ST := InitST(N + 1)
  cnt := 0
  for _, as := range AS {
    cnt += N - as.Index - ST.GetAfter(as.Index, 1)
    ST.Update(as.Index)
  }
  Write(cnt)
  Output()
}

Measured memory_bytes: 23424
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    char ans[2 * n + 1];
    ans[2 * n] = '\0';
    rep (i, n)
    {
        ans[2 * i] = s[i];
        ans[2 * i + 1] = t[i];
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
int x,y;

while(1){
	cin>>x>>y;
		if (x==0 && y==0)break;
if(x>y){
	cout<<y<<" "<<x<<endl;
}else{
	cout<<x<<" "<<y<<endl;
}
}
	return 0;
}


Measured memory_bytes: 3076
n = int(input())
l = [int(input()) for _ in range(n)]
bef,aft = {},{}
cnt =  0
for i in range(n):
  bef[l[i]] = i%2
l.sort()
for i in range(n):
  aft[l[i]] = i%2
for x in l:
  if bef[x]^aft[x]:
    cnt += 1
print(cnt//2)

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    for (int i=0; i<n; i++) cin >> v[i];
    for (int i=0; i<n; i++) cin >> c[i];
    vector<int> diff(n);
    for (int i=0; i<n; i++) diff[i] = v[i] - c[i];
    sort(diff.begin(), diff.end());
    int sum = 0;
    for (int i=n-1; i>=0 && diff[i]>0; i--) sum += diff[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

char f(char c,int n)
{
//	cout << c << ' ';
	REP(i,n)
	{
		if(c == 'a')
			c = 'Z';
		else if(c == 'A')
			c = 'z';
		else
			c--;
	}
//	cout << c << endl;
	return c;
}

int main()
{
	int n;
	
	while(cin >> n,n)
	{
		iv v;
		REP(i,n)
		{
			int tmp;
			cin >> tmp;
			v.PB(tmp);
		}
		
		string str;
		cin >> str;
		
		REP(i,str.size())
		{
			str[i] = f(str[i],v[i%n]);
		}
		
		cout << str << endl;
	}
	
	return 0;
}

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

int main() {

  vector<vector<int>> bingo(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    cin >> bingo.at(i).at(0) >> bingo.at(i).at(1) >> bingo.at(i).at(2);
  }

  int N;
  cin >> N;
  vector<int> B(N);
  for (int k = 0; k < N; k++) {
      cin >> B.at(k);
      for (int i = 0; i < 3; i++) {
          for (int j = 0; j < 3; j++) {
              if(bingo.at(i).at(j)==B.at(k)) bingo.at(i).at(j)=0;
          }
      }  
  }

  bool judge = false;

  for (int i = 0; i < 3; i++) {
      if(bingo.at(i).at(0)==bingo.at(i).at(1)&&bingo.at(i).at(1)==bingo.at(i).at(2)) 
         judge = true;
      else if(bingo.at(0).at(i)==bingo.at(1).at(i)&&bingo.at(1).at(i)==bingo.at(2).at(i))
         judge = true;
  }
  
  if(bingo.at(0).at(0)==bingo.at(1).at(1)&&bingo.at(1).at(1)==bingo.at(2).at(2))
         judge = true;
  else if(bingo.at(0).at(2)==bingo.at(1).at(1)&&bingo.at(1).at(1)==bingo.at(2).at(0))
         judge = true;

  if (judge) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
#B
N = int(input())

X = N // 1.08
Xminus = X - 1
Xplus = X + 1

X_list = [X, Xplus, Xminus]
# print(X_list)
flug = False

for x in X_list:
#     print(x * 1.08)
    if int(x * 1.08) == N:
        print(int(x))
        flug = True
        break

if flug == False:
    print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K, count;
    cin >> N >> K;
    count =0;
    vector<long long>vec(N+1);
    vector<long long>ARE(N+1);
    int A, B;
    for(int i=1;i<N+1;i++){
        cin >> vec.at(i);//標高
    }
    for(int j=0;j<K;j++){
        cin >> A >> B;
        if(ARE.at(A)==1 && ARE.at(B)==1)continue;
if(vec.at(A)<=vec.at(B)){
    ARE.at(A)=1;
}
if(vec.at(B)<=vec.at(A)){
    ARE.at(B)=1;
}
    }
    for(int i=1;i<N+1;i++){
        if(ARE.at(i)==0){count++;}
    }
    cout << count << endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define fr first
#define se second
const ll mod = 998244353;

void solve(ll cas){
    ll n,x,m;
    cin>>n>>x>>m;
    unordered_set<ll> s;
    vector<ll> v;
    while(s.find(x)==s.end()){
        v.pb(x);
        s.insert(x);
        x = (x%m * x%m)%m;
    }
    ll idx;
    for(ll i=0;i<v.size();i++){
        if(v[i]==x){
            idx=i;break;
        }
    }
    ll ans=0;
    if(n<v.size()){
        for(ll i=0;i<n;i++) ans+=v[i];
        cout<<ans<<endl;
        return;
    }

    for(ll i=0;i<idx;i++){
        ans+=v[i];
        n--;
    }
    ll q=n/(v.size()-idx), r=n%(v.size()-idx);
    ll sum=0;
    for(ll i=idx;i<v.size();i++){
        sum+=v[i];
    }
    ans += sum*q;
    for(ll i=idx,j=0;j<r;j++,i++){
        ans+=v[i];
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        solve(cas);
    }
}


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int n,a[200005],s;

stack <pi> p;

bool can(int k){
    while(p.sz) p.pop();
    for(int i=1;i<=n;i++){
        if(a[i]>a[i-1]) continue;
        while(p.sz && p.top().x>a[i]) p.pop();
        int t=a[i];
        while(p.sz && p.top().x==t && p.top().y==k-1) t--,p.pop();
        if(p.sz && p.top().x==t) p.top().y++;
        else if(t>0) p.push({t,1});
        else return 0;
    }
    return 1;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        if(a[i]<=a[i-1]) s=1;
    }
    if(!s){
        cout << 1;
        return 0;
    }
    int l=2,r=n;
    while(l!=r){
        int mid=(l+r)/2;
        if(can(mid)) r=mid;
        else l=mid+1;
    }
    cout << l;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] d = new int[n];
		for(int i=0; i<n; i++){
			d[i] = scn.nextInt();
		}
      	Arrays.sort(d);
      	int count = 0;
      	for(int i=1; i<n; i++){
          if(d[i]==d[i-1]) count++;
        }
      	System.out.println(n-count);
	}
}


Measured memory_bytes: 35972
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl G = vv(200000, 0, 0, ll);
vector<pair<bool, bool>> t(200000,  make_pair(false, false));

ll n, m;
void dfs(int now, int from, int mode){
  if(mode==1?t[now].second:t[now].first){
    std::cout << (n*(n-1))/2 - m << '\n';
    exit(0);
  }
  if(mode==1?t[now].first:t[now].second) return;
  (mode==1?t[now].first:t[now].second) = true;
  for(int i=0;i<G[now].size();i++){
    if(G[now][i]==from) continue;
    dfs(G[now][i], now, -1*mode);
  }
}
int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> n >> m;
  re(i, m){
    std::cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1, -1, 1);
  ll x = 0, y=0;
  for(int i=1;i<=n;i++){
    if(t[i].second) x++;
    if(t[i].first) y++;
  }
  std::cout << x*y - m << '\n';
  return 0;
}


Measured memory_bytes: 9600
while 1:
    n,w=map(int,input().split())
    if n==w==0:break
    a=[0]*100
    s=h=int(0)
    while n:
        b=int(input())
        a[b//w]+=1
        s=max(s,b//w)
        h=max(h,a[b//w])
        n-=1
    ans=0.01
    for i in range(int(s)+1):
        ans+=a[i]/h*(s-i)/s
    print(ans)


Measured memory_bytes: 5624
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
A = [0]
for i in range(n):
  A.append(A[-1]+a[i])
A = Counter(A)
ans = 0
for x,y in A.items():
  if y >= 2: ans += (y-1)*y//2
print(ans)

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int count = 0;
  int sum = 0;
  for (int i = 1; i < N + 1; i++) {
    sum = 0;
    sum += i % 10;
    sum += ((i- i % 10) % 100) / 10;
    sum += ((i- i % 100) % 1000) / 100;
    sum += ((i- i % 1000) % 10000) / 1000;
    sum += ((i- i % 10000) % 100000) / 10000;

    if (sum >= A && sum <= B) {
      count += i;
    }
  }
  cout << count << endl;

  return 0;
}



Measured memory_bytes: 256
def main():
    a, b = map(int, input().split())
    data = [int(input()) for i in range(a)]
    data.sort()
    ans = data[-1] - data[0]

    for i in range(a - b + 1):
        now_data = data[i + b - 1] - data[i]
        if now_data < ans:
            ans = now_data

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 7384
#include<cstdio>
#include<map>
#include<string>
#include<algorithm>
#include<iostream>
const int MAXN=200+5;
std::map<std::string,int>map;
std::string str[MAXN];int n,m,cnt;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		std::cin>>str[++cnt];
		map[str[cnt]]++;
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		std::cin>>str[++cnt];
		map[str[cnt]]--;
	}
	int ans=0;
	for(int i=1;i<=cnt;i++)
		ans=std::max(ans,map[str[i]]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
A,B,C=map(int,input().split())
cnt=0
while True:
    if A % 2 == B % 2 == C % 2 == 1:
        break
    elif A==B==C:
        cnt-=1
        break
    elif A%2==B%2==C%2==0:
        hA=A//2
        hB=B//2
        hC=C//2
        A=hB+hC
        B=hA+hC
        C=hA+hB
        cnt+=1
    else:
        break

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
 
#define REP(i,b,n) for(int i=b;i<n;++i)
#define REPR(i,b,n) for(int i=n-1;i>=b;--i)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
static const int LIM = 2000000;

string s;
int var[3];

int parse(int x){
	
	if( '0' <= s[x] && s[x] <= '2' ){
		return s[x] - '0';
	}
	if( 'P' <= s[x] && s[x] <= 'R'){
		return var[s[x]-'P'];
	}
	if( s[x] == '-'){
		return 2-parse(x+1);
	}
	
	if( s[x] == '(' ){
		
		int y = x+1, par = 0;
		
		while(1){
			
			if(s[y] == '('){
				par++;
			}
			else if(s[y] ==')'){
				par--;
			}
			
			if( (s[y] == '*' || s[y] == '+') && par==0){
				break;
			}
			
			y++;
		}
		
		if(s[y]=='*'){
			return min(parse(x+1), parse(y+1));
		}
		else{
			return max(parse(x+1), parse(y+1));
		}
	}
}

int main(){

	while(cin >> s, s[0]!='.'){	
		
		int cnt = 0;
		
		for(var[0]=0; var[0]<3; ++var[0]){
			for(var[1]=0; var[1]<3; ++var[1]){
				for(var[2]=0; var[2]<3; ++var[2]){
					
					cnt += parse(0) == 2;
				}
			}
		}
		
		cout << cnt << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
 
long N,n;
vector<long> A;
 
int main(){
    cin>>N;
    for(;cin>>n;)A.push_back(n);
    auto a=A.begin(),t=a+1,d=A.end()-1,b=t+1;
    partial_sum(a,d+1,a);
    n=1LL<<50;
    for(;t+1!=d;++t){
        while(a+1!=t)
            if(*a<*t-*(a+1)) ++a;
            else break;
        if(b==t)++b;
        while(b+1!=d)
            if(*b-*t<*d-*(b+1)) ++b;
            else break;
        n=min(n,max({*a,*t-*a,*b-*t,*d-*b})-min({*a,*t-*a,*b-*t,*d-*b}));
    }
    cout<<n<<" ";
}


Measured memory_bytes: 2548
#include <iostream>
#include <stack>
#include <stdio.h>

#define BUF_SIZE 120000

using namespace std;

int main(){

	int n;
	scanf("%d",&n);

	int S[n];

	for(int i = 0; i < n; i++){
		scanf("%d",&S[i]);
	}

	int q;
	scanf("%d",&q);

	int count = 0;
	int tmp;

	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		for(int k = 0; k < n; k++){
			if(tmp == S[k]){
				count++;
				break;
			}
		}
	}

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

}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

int main()
{
  int n, m;
  while (n = in(), m = in()){
    vector<int> p;
    for (int i = 0; i < n; i++){
      p.push_back(in());
    }
    p.push_back(0);
    n++;

    vector<int> pp;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        pp.push_back(p[i] + p[j]);
      }
    }
    int maxi = 0;
    sort(pp);
    for (int i = 0; i < n; i++){
      for (int j = 0; j < n; j++){
        int s = p[i] + p[j];
        int v = *(upper_bound(pp.begin(), pp.end(), m - s) - 1);
        if (s + v <= m){
          maxe(maxi, s + v);
        }
      }
    }
    printf("%d\n", maxi);
  }

  return 0;
}

Measured memory_bytes: 9308
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <cstdint>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 1000000007;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << N + N * N + N * N*N;

    cout << endl;
    return 0;

}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

struct ANS {
    pii s, t;
};

void solve() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    vector<vector<pii>> Path;
    vector<pii> P;
    int x = -1, y = -1;
    for (int i = 0; i < H; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < W; j++) {
                if (A[i][j] % 2 != 0) {
                    if (x == -1) {
                        x = j, y = i;
                    } else {
                        P.push_back({j, i});
                        Path.push_back(P);
                        x = -1, y = -1;
                        P.clear();
                    }
                }

                if (x != -1) {
                    P.push_back({j, i});
                }
            }
        } else {
            for (int j = W - 1; j >= 0; j--) {
                if (A[i][j] % 2 != 0) {
                    if (x == -1) {
                        x = j, y = i;
                    } else {
                        P.push_back({j, i});
                        Path.push_back(P);
                        x = -1, y = -1;
                        P.clear();
                    }
                }
                if (x != -1) {
                    P.push_back({j, i});
                }
            }
        }
    }
/*
    for (int i = 0; i < Path.size(); i++) {
        for (int j = 0; j < Path[i].size(); j++) {
            cout << Path[i][j].first << ", " << Path[i][j].second << " ";
        }
        cout << endl;
    }

    */

    vector<ANS> ans;
    for (int i = 0; i < Path.size(); i++) {
        reverse(all(Path[i]));
        ans.push_back({{Path[i][0].first, Path[i][0].second}, {Path[i][1].first, Path[i][1].second}});
        for (int j = 1; j < Path[i].size() - 1; j++) {
            ans.push_back({{Path[i][j].first, Path[i][j].second}, {Path[i][j + 1].first, Path[i][j + 1].second}});
        }
    }

    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        pii s = ans[i].s;
        pii t = ans[i].t;
        cout << s.second + 1 << " " << s.first + 1 << " " << t.second + 1 << " " << t.first + 1 << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 14128
n,a,b = gets.chomp.split.map(&:to_i)
ans = 0
for i in 1..n
  s = i.to_s
  # p s
  tmp = 0
  s.length.times do |j|
    tmp += s[j].to_i
  end
  # p tmp
  # puts
  if a <= tmp and tmp <= b
    ans += i
  end
end
puts ans



Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
int N;
ll M, a[100005];

// gcd lcm
ll calc_gcd(ll a, ll b) {
    if (b == 0) return a;
    return calc_gcd(b, a % b);
}

ll calc_lcm(ll a, ll b) {
    ll g = calc_gcd(a, b);
    return a / g * b;
}

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

  cin >> N >> M;
  rep(i, N) cin >> a[i];
  ll lcm = a[0]/2;
  ll gcd = a[0]/2;

  rep(i, N) {
    gcd = calc_gcd(gcd, a[i]/2);
    lcm = calc_lcm(lcm, a[i]/2);
  }

  rep(i, N) {
    if ((a[i]/2/gcd)%2==0) {
      cout << 0 << "\n";
      return 0;
    }
  }

  ll cnt=M/lcm; //1-M間で初項がlcm,等差が2*lcmの等差数列の個数
  cout << (cnt+1)/2 << "\n";
  return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
P = list(map(int, input().split()))

def expectation(p):
    return (p - 1) / 2 + 1

h = {}

answer = 0
for i in range(N):
    if i < K - 1:
        answer += expectation(P[i])
    elif i == K - 1:
        answer += expectation(P[i])
        h[i] = answer
    else:
        answer += expectation(P[i])
        answer -= expectation(P[i - K])
        h[i] = answer
print(max(list(h.values())))


Measured memory_bytes: 40480
MOD = 10 ** 9 + 7

# エラトステネスの篩(コピペ用)
table_len = 1010
prime_list = [] # 必要に応じて
isprime = [True] * (1010)
isprime[0] = isprime[1] = False
for i in range(table_len):
    if isprime[i]:
        for j in range(2*i, table_len, i):
            isprime[j] = False
        prime_list.append(i) # 必要に応じて

N = int(input())
As = list(map(int, input().split()))
factor_counts = [0] * len(prime_list)
big_factors = set() # 1000より大きな素数がAの素因数として含まれるとき、その素因数は一乗のみだから
for A in As:
    for i, p in enumerate(prime_list):
        count = 0
        while A % p == 0:
            A //= p
            count += 1
        factor_counts[i] = max(factor_counts[i], count)
        if A == 1:
            break
    else:
        big_factors.add(A)

A_lcm = 1
for p, count in zip(prime_list, factor_counts):
    A_lcm *= pow(p, count, MOD)
    A_lcm %= MOD

for p in big_factors:
    A_lcm *= p
    A_lcm %= MOD

ans = 0
for A in As:
    ans += A_lcm * pow(A, MOD - 2, MOD) % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 69192
n = int(input())
s = list(input())

# print(s)

r = s.count('R')
g = s.count('G')
b = s.count('B')

# print('total RGB: ', r * g * b)

ans = r * g * b

for i in range(n):
  for j in range(i + 1, i + (n - i) // 2 + 1):
    if (j + (j-i)) < n:
      if s[i] != s[j]:
        if (s[j] != s[j + (j-i)]) and (s[i] != s[j + (j-i)]):
          # print(i, j, j + j-i, s[i], s[j], s[j + (j-i)])
          ans -= 1

print(ans)

Measured memory_bytes: 9212
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce

nCr = {}


def cmb(n, r):
    #print("nCr", n, r)
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n, r) in nCr: return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


n, a, b = list(map(int, input().split()))

value = list(map(int, input().split()))

# 価値の高い順にソート
value = list(reversed(sorted(value)))

# 対象よりも高いものの個数を数える
takai = 0
avg = 0
for i in range(a):
    if value[i] > value[a]:
        takai += 1
    avg += value[i]
# 上からA番目まで選ぶのが最も平均が高い
avg /= a
print(avg)

cc = value.count(value[a])

# 以下組み合わせ
##最も高価なものとA番目のものが同じときa個からb個まで  nCccの組み合わせ数
if value[0] == value[a]:
    sum = 0
    #print(a, b, cc, min(cc, b) + 1,1)
    for i in range(a, min(cc, b) + 1):
        sum += cmb(cc , i)
    print(sum)
else:
    print(cmb(cc, a - takai))

##違うときは a-takai個を (b-takai) or ccの組み合わせ数


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

using namespace std;

typedef long long ll;
int main() {
   // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int best = 1e9;
    string s;
    cin >> s;
    for (char c = 'a'; c <= 'z'; c++) {
        string t = s;
        if (find(t.begin(), t.end(), c) == t.end()) continue;
        while (true) {
            bool ok = true;
            for (int j = 0; j < t.size(); j++) {
                ok &= (t[j] == c);
            }
            if (ok) {
                best = min(best, (int)s.size() - (int)t.size());
                break;
            }
            string nt;
            for (int j = 0; j + 1 < t.size(); j++) {
                if (t[j] == c || t[j + 1] == c) nt += c;
                else nt += t[j];
            }
            t = nt;
        }
    }
    cout << best;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;

const int M = 256;

int N;
#define MN 256
int I[MN + 1];
bool input() {
    cin >> N;
    if (cin.fail()) return false;
    if (N == 0) return false;
    for (int i = 0; i < N; i++) {
        cin >> I[i];
    }
    return true;
}

void MakeR(int S, int A, int C, vector<int>& R) {
    R.resize(N + 1, 0);
    R[0] = S;
    for (int i = 1; i <= N; i++) {
        R[i] = (A * R[i - 1] + C) % M;
    }
}
double H(int S, int A, int C) {
    double Ret = 0;
    vector<int> R;
    MakeR(S, A, C, R);
    vector<int> Occ(256, 0);
    //cout << S << " " << A << " " << C << endl;
    for (int i = 0; i < N; i++) {
        int O = (I[i] + R[i + 1]) % M;
        //cout << O << " ";
        Occ[O]++;
    }
    for (int i = 0; i < 256; i++) {
        if (Occ[i] == 0) continue;
        double x = Occ[i];
        Ret -= (x / N) * log(x / N);
    }
    //cout << " -> " << Ret << endl;
    return Ret;
}

const double EPS = 1e-8;
#define EQ(x, y) (abs((x) - (y)) <= EPS)

void solve() {
    int Ans[3];
    double MinH = 1e10;
    for (int S = 0; S <= 15; S++) {
        for (int A = 0; A <= 15; A++) {
            for (int C = 0; C <= 15; C++) {
                double h = H(S, A, C);
                //cout << h << endl;
                if (EQ(MinH, h)) {
                    if (Ans[0] < S) continue;
                    if (Ans[0] > S) {
                        Ans[0] = S;
                        Ans[1] = A;
                        Ans[2] = C;
                        continue;
                    }
                    if (Ans[1] < A) continue;
                    if (Ans[1] > A) {
                        Ans[0] = S;
                        Ans[1] = A;
                        Ans[2] = C;
                        continue;
                    }
                    if (Ans[2] < C) continue;
                    if (Ans[2] > C) {
                        Ans[0] = S;
                        Ans[1] = A;
                        Ans[2] = C;
                        continue;
                    }
                }
                if (MinH - h > EPS) {
                    MinH = h;
                    Ans[0] = S;
                    Ans[1] = A;
                    Ans[2] = C;
                }
            }
        }
    }
    cout << Ans[0] << " " << Ans[1] << " " << Ans[2] << endl;
}

int main() {
    while (input()) solve();
    return 0;
}

Measured memory_bytes: 1240
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = math.MaxUint64 >> 1

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, K := getInt(), getInt()
	p := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = getInt() - 1
	}
	c := getInts(N)
	ans := -inf

	for i := 0; i < N; i++ {
		used := make([]bool, N)
		pos := p[i]
		sum := 0
		l := 0
		for used[pos] == false {
			used[pos] = true
			l++
			sum += c[pos]
			pos = p[pos]
		}
		n := K / l
		m := K % l
		if n > 0 {
			n--
			m += l
		}
		if sum > 0 {
			sum = sum * n
		} else {
			sum = 0
		}

		pos = p[i]
		ma := -inf
		for j := 0; j < m; j++ {
			sum += c[pos]
			pos = p[pos]
			ma = max(ma, sum)
		}
		ans = max(ans, ma)
	}

	out(ans)
}


Measured memory_bytes: 6316
# N, M<=10なので全探索の気持ちが生える
# -> N個のスイッチについて0,1のすべての状態を想定し、
#   それぞれについてみたとき、各電球が条件を満たしているか都度判断する

n, m = map(int, input().split())
balbs = [[] for _ in range(m)]
for i in range(m):
    # zero order
    connectswtiches = list(map(lambda x: int(x) - 1, input().split()))[1:]
    balbs[i] = connectswtiches

correct_state = list(map(int, input().split()))

# 2^N
def f(cur, n):
    if n == 0:
        # 判定
        for i, balb in enumerate(balbs):
            on_switch_count = 0
            for swtich_n in balb:
                if cur[swtich_n] == 1:
                    on_switch_count += 1
            if correct_state[i] != on_switch_count % 2:
                return 0
        return 1

    ret = 0
    lnh = len(cur)
    nex = cur[:]
    nex[lnh - n - 1] = 1
    ret += f(nex, n - 1)
    nex[lnh - n - 1] = 0
    ret += f(nex, n - 1)
    return ret


print(f([0 for _ in range(n)], n))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k;cin >> h >> w >> k;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    int ans=h+w-2;
    vector<int> b(h);
    for(int i=0;i<(1<<(h-1));i++){
        int cnt=0;
        b[0]=cnt;
        for(int j=0;j<h-1;j++){
            if(i&1<<j){
                cnt++;
            }
            b[j+1]=cnt;
        }
        int res=cnt;
        vector<int> v(cnt+1),u(cnt+1);
        bool f=true;
        for(int j=0;j<w;j++){
            for(int l=0;l<h;l++){
                if(s[l][j]=='1'){
                    u[b[l]]++;
                }
            }
            bool g=true;
            for(int l=0;l<=cnt;l++){
                if(v[l]+u[l]>k){
                    g=false;
                }
                if(u[l]>k){
                    f=false;
                    break;
                }
            }
            if(!f){
                break;
            }
            if(g){
                for(int l=0;l<=cnt;l++){
                    v[l]+=u[l];
                    u[l]=0;
                }
            }
            else{
                res++;
                for(int l=0;l<=cnt;l++){
                    v[l]=u[l];
                    u[l]=0;
                }
            }
        }
        if(!f){
            continue;
        }
        chmin(ans,res);
    }
    cout << ans << endl;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).ToArray();
        var n = l[0]; var k = l[1];
        var nl = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
        var res = 0;
        for (var i = 0; k > i; i++)
        {
            res += nl[i];
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 28572
a,b=map(int,input().split())
ans=[['#' for i in range(100)] for j in range(50)]
ans+=[['.' for i in range(100)] for j in range(50)]
for i in range(a-1):
    ans[(i//50)*2][(i%50)*2]='.'
for i in range(b-1):
    ans[(i//50)*2+52][(i%50)*2]='#'
print(100,100)
for i in range(100):
    print(''.join(ans[i]))


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

int main() {
  
  int N,A;
  cin >> N;
  int BeniTakemata=100;
  
  for (int ShunkiOgawa=0; ShunkiOgawa<N; ShunkiOgawa++) {
  cin >> A;
  int YutoSakai=0;  
  while (A%2==0) {
   A/=2;
   YutoSakai++;
  }
   
  if (BeniTakemata<YutoSakai) BeniTakemata+=0;
  else BeniTakemata=YutoSakai;
  }
  
  cout << BeniTakemata << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        mut xy: [(i64, i64); n]
    }

    xy.sort();
    let mut ans = 1<<62;
    for i in 0..n {
        for j in i+k..n+1 {
            let w = xy[j-1].0 - xy[i].0;
            let mut p = xy[i..j].to_vec();
            p.sort_by_key(|&(_, y)| y);
            for t in 0..p.len()-k+1 {
                let h = p[t+k-1].1 - p[t].1;
                ans = min(ans, w * h);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2236