akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vvi f(n,vi(10));
  rep(i,n)rep(j,10) cin >> f[i][j];
  vvi p(n,vi(11));
  rep(i,n)rep(j,11) cin >> p[i][j];

  int ans = -INF;
  rep(b,1<<10) {
    if (b == 0) continue;
    int profit = 0;
    rep(i,n) {
      int cnt = 0;
      rep(j,10) {
        if (b&(1<<j) && f[i][j]) cnt++;
      }
      profit += p[i][cnt];
    }
    ans = max(ans, profit);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	string S; cin >> S;
	int ans = 1;
    int now = 0;
	rep(i,S.size()-1){
		if(S[i+1] == S[i] && now == 0){
			i++;
			if(i < S.size()-1)ans++;
			now = 1;
		}
		else{
			ans++;
			now = 0;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	D := sc.NextInt()
	v := make([][]int, N)
	for i := 0; i < N; i++ {
		v[i] = make([]int, D)
		for j := 0; j < D; j++ {
			v[i][j] = sc.NextInt()
		}
	}
	ans := 0
	for i := 0; i < N; i++ {
		for j := 0; j < i; j++ {
			dd := 0
			for k := 0; k < D; k++ {
				dd += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k])
			}
			// check
			for a := 0; a*a <= dd; a++ {
				if a*a == dd {
					ans++
					break
				}
			}
		}
	}
	fmt.Println(ans)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


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

int main(){
  int n,ttl=0,a=0;cin>>n;
  vector<int> x(n,0);
  
  REP(i,n) cin>>x.at(i);
  sort(x.begin(),x.end());

  REP(i,n){
    ttl+=x.at(i);
    if((x.at(i)%10)&&(!a)) a=x.at(i);
  }
  
  if(!(ttl%10)) ttl-=a;
  cout<<(ttl%10?ttl:0);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] x = new int[3];
		int t=scan.nextInt();
		for (int i = 0; i < t; i++) {
			for (int j = 0; j < x.length; j++) {
				x[j] = scan.nextInt();
			}
			Arrays.sort(x);
			if (x[2] * x[2] == x[1] * x[1] + x[0] * x[0]) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 23376
/*
    Author: isaf27 (Ivan Safonov)
*/

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int dxt[6] = {0, 0, -1, -1, 1, 1};
const int dyt[6] = {-2, 2, 1, -1, -1, 1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll bt = 30;
const ld eps = 1e-8;
const ll INF = 1e18 + 239;
const int BIG = 1e9 + 239;
const int MOD = 1e9 + 7; //998244353;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937 rnd(239); //rnd(chrono::high_resolution_clock::now().time_since_epoch().count())

//constants
const int M = 2e5 + 239;
const int N = 2e3 + 239;
const int L = 20;
const int T = (1 << 20);
const int B = trunc(sqrt(M)) + 1;
const int X = 1e4 + 239;

int n;
ll a[M], f1[M], f2[M], f3[M], pref[M];

ll gett(int l, int r)
{
    return (pref[r + 1] - pref[l]);
}

int32_t main()
{
    #ifdef ONPC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    pref[0] = 0;
    for (int i = 0; i < n; i++)
        pref[i + 1] = pref[i] + a[i];
    f1[n] = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        f1[i] = f1[i + 1];
        if ((a[i] % 2) == 1)
            f1[i]++;
        else if (a[i] == 0)
            f1[i] += 2;
        f1[i] = min(f1[i], gett(i, n - 1));
    }
    f2[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        f2[i] = f2[i - 1];
        if ((a[i - 1] % 2) == 1)
            f2[i]++;
        else if (a[i - 1] == 0)
            f2[i] += 2;
        f2[i] = min(f2[i], gett(0, i - 1));
    }
    f3[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        f3[i] = f3[i - 1] + (ll)((a[i - 1] % 2) == 0);
        f3[i] = min(f3[i], f2[i]);
    }
    ll ans = INF;
    for (int i = 0; i <= n; i++)
        ans = min(ans, f3[i] + f1[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<stdio.h>
using namespace std;

void reverse(int* a, int* b) {
	int t;
	t = *a;
	*a = *b;
	*b = t;
}	

int selectionsort(int a[], int n) {
	int b = 1;
	int c = 0;
	for (int i = 0; i < n; i++) {
		b = i;
		for (int j = i; j < n; j++) {
			if (a[b] > a[j])
				b = j;
		}
		if (a[i] > a[b]) {
			reverse(&a[i], &a[b]);
			c++;
		}
	}
	return c;
}

int main() {
	int n;
	int a[100];
	int vv;

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

	vv = selectionsort(a, n);

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	cout << vv;
	cout << endl;

	return 0;
}


Measured memory_bytes: 3212
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S, T;
  cin >> S >> T;
  const int64_t L = static_cast<int64_t>(T.length());
  vector<char> from_s_to_t('z' - 'a' + 1, -1);
  vector<char> from_t_to_s('z' - 'a' + 1, -1);
  bool result = true;
  for (int64_t i = 0; i < L; ++i) {
    if (from_s_to_t[S[i] - 'a'] >= 0 && from_s_to_t[S[i] - 'a'] != T[i] - 'a') {
      result = false;
      break;
    }
    if (from_t_to_s[T[i] - 'a'] >= 0 && from_t_to_s[T[i] - 'a'] != S[i] - 'a') {
      result = false;
      break;
    }
    from_s_to_t[S[i] - 'a'] = T[i] - 'a';
    from_t_to_s[T[i] - 'a'] = S[i] - 'a';
  }
  if (result) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
const int maxn=10;
char s[maxn][maxn];
int a[maxn],b[maxn];
int n,m,k;
int main()
{
	cin>>n>>m>>k;
	for(int i=0;i<n;++i) cin>>s[i];
	int sum=0;
	memset(a,0,sizeof a);
	memset(b,0,sizeof b);
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<m;++j)
		{
			if(s[i][j]=='#') a[i]++,b[j]++,sum++; 
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);++i)
	{
		for(int j=0;j<(1<<m);++j)
		{
			int t=sum;
			for(int y=0;y<n;++y)
			{
				if(i&(1<<y)) t=t-a[y];
			}
			for(int y=0;y<m;++y)
			{
				if(j&(1<<y)) t=t-b[y];
			}
			for(int x=0;x<n;++x)
			{
				for(int y=0;y<m;++y)
				{
					if(i&(1<<x)&&j&(1<<y))
					{
						if(s[x][y]=='#') t++;
					}
				}
			}
			if(t==k) ans++;
		}
	 }
	 cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 3608
#include <string>
#include<vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <set>
using namespace std;

int abc103_a(set<int> &a) {
	int sum = 0;

	set<int>::iterator i = a.begin();

	int prev = *i;
	i++;
	while (i != a.end()){
		sum += *i - prev;
		prev = *i;
		i++;
	}
	return sum;

}

void abc103_a_test() {
	{
		set<int> s{ 1, 6, 3 };
		assert(abc103_a(s) == 5);
	}
	{
		set<int> s{ 11,5,5 };
		assert(abc103_a(s) == 6);
	}
	{
		set<int> s{ 100, 100,100 };
		assert(abc103_a(s) == 0);
	}
}


int main()
{
	//abc103_a_test();
	set<int> a;
	for (int i = 0; i < 3; i++) {
		int x;
		cin >> x;
		a.insert(x);
	}

	cout << abc103_a(a) << endl;

	return 0;
}



Measured memory_bytes: 256
// Author - Abhishek giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 100000000007
#define V(type) vector<type> 
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)

/*##################################################################################*/


/*
int prime[1000001] ;
vector<ll> v ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(ll i = 2 ; (ll)i*i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            v.pb(i);
            for(ll j = i*i ; j <= 1000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}



ll fib(int n) 
{ 
  ll a = 0, b = 1, c, i; 
  if( n == 0) 
    return a; 
  for (i = 2; i <= n; i++) 
  { 
    c = (a + b); 
    a = b; 
    b = c; 
  } 
  return b; 
}


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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(ll arr[], ll n) 
{ 
    ll ans = arr[0]; 
  
    for (ll i = 1; i < n; i++) 
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));
  
    return ans; 
}



ll powerwithmod(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

ll setBitNumber(ll n) 
{ 
    n |= n >> 1; 
    n |= n >> 2; 
    n |= n >> 4; 
    n |= n >> 8; 
    n |= n >> 16; 
    n |= n >> 32;
    n = n + 1; 
  
    return (n >> 1); 
} 

void decToBinary(ll n,string &s) 
{ 
    for (int i = 63; i >= 0; i--) { 
        int k = n >> i; 
        if (k & 1) 
            s += "1"; 
        else
            s += "0"; 
    } 
}

void countdiv(ll l,set<ll> &v){
    int div = 0 ;
    for(ll i = 2 ;i*i <= l ; i++){
        if(l % i == 0){
            v.insert(i);
            v.insert(l/i);
        }
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll testcases = 1;
    //cin>>testcases;
    while(testcases--)
    {
        string s,t;
        in(s)>>t;
        int size = s.size();
        t.erase(size,1);
        //cout<<t;
        if(t == s){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    return 0;
}

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

signed main(void)
{
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size())
		cout << "GREATER" << endl;
	else if (a.size() < b.size())
		cout << "LESS" << endl;
	else
	{
		rep(i, a.size())
		{
			if (a[i] > b[i])
			{
				cout << "GREATER" << endl;
				return 0;
			}
			else if (a[i] < b[i])
			{
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

//ａをbで割る
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

ll dp[3333][3333];

int main(){
	
	ll n,m;cin >> n >> m;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	REP(i,n)REP(j,n)if(v[i] < v[j])dp[i][j] = 1;
	ll inv = mod_div(1, 2);
	
	REP(q,m){
		int a,b;cin >> a >> b;
		a--;b--;
		REP(i,n){
			if(i != a && i != b){
				ll tmp = (dp[i][a] + dp[i][b]) % MOD * inv % MOD;
				dp[i][a] = dp[i][b] = tmp;
				tmp = (dp[a][i] + dp[b][i]) % MOD * inv % MOD;
				dp[a][i] = dp[b][i] = tmp;
			}
		}
		ll tmp = (dp[a][b] + dp[b][a]) % MOD * inv % MOD;
		dp[a][b] = dp[b][a] = tmp;
	}
	
	ll ans = 0;
	REP(i,n)REP(j,i)ans = (ans + dp[i][j]) % MOD;
	REP(i,m)ans = (ans * 2) % MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
long long mod = 1000000007;
 
long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}
 
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
 
int main() {
    long long n, a = 0, max = 0;
    cin >> n >> a;
    if (n < a){
        cout << 1 << endl;
        return 0;
    }
    if (n % a == 0){
        cout << n / a << endl;
    }else{
        cout << n / a + 1<< endl;
    }
}

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

void solve()
{
    int n, m;
    cin >> n >> m;
    ll mod=1e9+7;

    char mat[n][m];
    int dp[n][m];
    memset(dp, 0, sizeof(int) * n * m);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> mat[i][j];

    dp[0][0]=1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(i>0 && mat[i-1][j]=='.')dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            if(j>0 && mat[i][j-1]=='.')dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }

    cout << dp[n - 1][m - 1] << endl;
}

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

    // while(n--)
    solve();

    return 0;
}

Measured memory_bytes: 5120
#import <Foundation/Foundation.h>
typedef long long Int;
int main() {
	@autoreleasepool{
		char c, s='\0', e, prev='\0';
		Int current = 1;
		NSMutableArray *a = [NSMutableArray array];
		while((c=getchar())!='\n'){
			if(prev==c){
				current++;
			}else if(s!='\0'){
				[a addObject:@(current)];
				current = 1;
			}
			if(s=='\0') s=c;
			prev = c;
		}
		e=prev;
		Int k;
		scanf("%lld",&k);
		[a addObject:@(current)];
		if(s!=e){
			Int ans = 0;
			for(NSNumber *v in a) ans += [v integerValue]/2;
			printf("%lld\n",ans*k);
		}else{
			Int n = [a count];
			Int p = [[a objectAtIndex:0] integerValue];
			if(n>1){
				Int q = [[a objectAtIndex:n-1] integerValue];
				Int ans = p/2 + q/2;
				ans += (p+q)/2*(k-1);
				for(Int i=1;i<=n-2;i++) ans += [[a objectAtIndex:i] integerValue]/2 * k;
				printf("%lld\n",ans);
			}else{
				printf("%lld\n",p*k/2);
			}
		}
	}
}

Measured memory_bytes: 9248
fun main(args: Array<String>) {
    readLine()
    var numbers = readLine()!!.split(" ").map { it.toInt() }

    var c = 0

    var flag = true
    while (true) {
        for (n in numbers) {
            if (n % 2 == 1) {
                flag = false
                break
            }
        }
        if (flag) {
            numbers = numbers.map { it / 2 }
            c++
        } else {
            break
        }
    }
    println("$c")
}

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

ll a[2005];
ll c[2005][2005];

int main(){
  ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
  int n; ll x; cin >> n >> x;
  for(int i = 0 ; i < n ; i++) cin >> a[i];
  for(int i = 0 ; i < n ; i++){
    c[i][0] = i;
    for(int j = 1 ; j < n ; j++){
        if(a[c[i][j-1]]<a[(n+i-j)%n]) c[i][j] =  c[i][j-1];
        else c[i][j] = (n+i-j)%n;

    }
  }
  ll ans = 1e15;
  for(int i = 0 ; i < n ; i++){
    ll stot = i*x;
    for(int j = 0 ; j < n ; j++){
      stot += a[c[j][i]];
    }
    ans = min(ans,stot);
  }
  cout << ans;
}


Measured memory_bytes: 31616
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)


int n, t;
double x[1010], h[1010];
int main() {
	cin >> n >> t;
	double ans = 0.0;
	REP(i, n) {
		cin >> x[i] >> h[i];
		ans = max(ans, h[i] / x[i] * t);
	}
	cout << fixed<<setprecision(13)<<ans << endl;
}


Measured memory_bytes: 3300
#include <iostream>
using namespace std;
int main(){
	int mp[105][105]={},h,w,wcou=0,hcou=0,n,a[10005]={};
	
	cin>>h>>w>>n;
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		
		for(int j=0;j<a[i];j++)
		{
			mp[hcou][wcou]=i+1;
			if(hcou%2==0&&wcou==w-1)
			{
				hcou++;
				
			}else if(hcou%2==1&&wcou==0)
			{
				hcou++;
				
			}
			else if(hcou%2==0)
			{
				wcou++;
			}else{
				wcou--;
				}
		}
		
	}
	
	
	
	for(int i=0;i<h;i++)
	{
		
		
		for(int j=0;j<w;j++)
		{
			cout<<mp[i][j]<<" ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 384
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
#define dis(p,q,r) ((p)*(p)+(q)*(q)+(r)*(r))
struct pi{
  bool operator()(const pair<pair<int,int>,double>& p,const pair<pair<int,int>,double>& q){
    return p.second<q.second;
  }
};
int main(){
  int i,j,k;
  int n;
  while(scanf("%d",&n),n){
    double x[100],y[100],z[100],r[100];
    vector<pair<pair<int,int>,double> > a;
    a.reserve(n*(n-1)/2);
    for(i=0;i<n;++i){
      scanf("%lf%lf%lf%lf",x+i,y+i,z+i,r+i);
      for(j=0;j<i;++j)
	a.push_back(make_pair(make_pair(j,i),max(0.0,sqrt(dis(x[i]-x[j],y[i]-y[j],z[i]-z[j]))-r[i]-r[j])));
    }
    sort(a.begin(),a.end(),pi());
    int b[100];
    for(i=0;i<n;++i)
      b[i]=i;
    double sm=0;
    j=1;
    for(i=0;j<n;++i){
      int p,q;
      double r;      
      p=a[i].first.first;
      q=a[i].first.second;
      r=a[i].second;
      if(b[p]==b[q])
	continue;
      sm+=r;
      for(k=0;k<n;++k){
	if(k!=q&&b[k]==b[q])
	  b[k]=b[p];
      }
      b[q]=b[p];
      ++j;
    }
    printf("%.3lf\n",sm);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int a, b;
    cin >> a >> b;
    int n = 6;
    cout << n - (a + b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define MP make_pair

inline int gn(){
    int s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

inline ll gl(){
    ll s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

const int N=2e5+100;
ll a,b,n;

void solve(){
    string s;
    cin>>s;
    if(s=="ABC"){
        puts("ARC");
    }
    else puts("ABC");
}

int main(){
    // int t;
    // t=gn();
    // while(t--)
        solve();
}

/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/


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

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

Measured memory_bytes: 3728
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <cmath>
#include <sstream>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<unsigned, unsigned> uu;
typedef pair<ll, ll> l4;


#define pb push_back
#define mp make_pair

const int maxn = 2e5+1;
ll cnt[300]={0};
char a[maxn];

int main()
{
    scanf("%s", a);
    ll len = strlen(a);
    ll ans = len*(len-1)/2+1;
    for (int i = 0; i < len; ++i)
        cnt[a[i]] += 1;
    for (char c = 'a'; c <= 'z'; ++c)
        ans -= cnt[c]*(cnt[c]-1)/2;
    printf("%lld\n", ans);
    
}

Measured memory_bytes: 384
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------
 
int main(void){
  ll x,y,z;cin>>x>>y>>z;
  //cout<<pow(x,0.5)+pow(y,0.5)<<endl;
  //cout<<pow(z,0.5)<<endl;
  ll p=z-x-y;
  if( p>0 && p*p >4*x*y )cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){

	int i, j;

	int w, n;

	cin >> w;
	cin >> n;

	int S[w];
	int a, b;
	int temp;

	for(i=0 ; i<w ; i++){
		S[i] = i+1;
	}

	for(i=0 ; i<n ; i++){
		scanf("%d,%d",&a, &b);
		temp = S[a-1];
		S[a-1] = S[b-1];
		S[b-1] = temp;
	}
	for(i=0 ; i<w ; i++){
		cout << S[i] << endl;
	} 

	return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    int m=1000;
    int tank=0;
    rep(i,n){
        cin >> a[i];
        tank += a[i];
        m = min(m,a[i]);
    }
    int cnt=n;
    cnt+= (x-tank)/m;
    cout << cnt;
    

    return 0;
}

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

int main(){
  map<int, int> mp;
  int X,N;cin>>X>>N;
  for(int i=0; i<N; i++){
    int f;cin>>f;mp[f]++;
  }
  int i,j;
  i=j=X;
  while(1){
    if(mp.find(i)==mp.end()){
      cout<<i<<endl;
      break;
    }
    if(mp.find(j)==mp.end()){
      cout<<j<<endl;
      break;
    }
    i--;j++;
  }
}


Measured memory_bytes: 3640
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef pair<ll,ll> p;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
map<ll,ll>mp;
for(ll i=-10000;i<=10000;i++)
{
    ll val=(ll)pow(i,5ll);
    mp[val]=i;
    //cout<<val<<endl;
}
ll x;
cin>>x;
ll a,b;
for(auto y:mp)
{
    ll z=y.first;
    ll h=y.second;
    ll val=z-x;
    if(mp.count(val))
    {
        a=h;
        b=mp[val];
        break;
    }
}
cout<<a<<" "<<b<<endl;
return 0;
}


Measured memory_bytes: 4988
#include <iostream>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	char s[n];
	scanf("%s", s);
	int l = 0, m = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '(')
			l++;
		else
			l--;
		m = max(-l, m);
	}
	for (int i = 0; i < m; i++) printf("(");
	for (int i = 0; i < n; i++) printf("%c", s[i]);
	for (int i = 0; i < l + m; i++) printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //test only

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
typedef pair<int,int> P;

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(n-1));
  int i,j;
  rep(i,n)rep(j,n-1)
  {
    cin >> a[i][j];
    a[i][j]--;
  }
  set<P> s;
  multiset<P> add;
  multiset<P> new_add;
  vector<int> counts(n,0);
  rep(i,n)
  {
    int p1 = i;
    int p2 = a[i][0];
    if(p1 > p2) swap(p1,p2);
    P nowp = make_pair(p1,p2);
    if(s.find(nowp) == s.end())
    {
      s.insert(nowp);
    }
    else
    {
      s.erase(nowp);
      counts[p1]++;
      counts[p2]++;
      int q1,q2;
      q1 = a[p1][counts[p1]];
      if(p1 > q1) swap(p1,q1);
      add.insert(make_pair(p1,q1));
      q2 = a[p2][counts[p2]];
      if(p2 > q2) swap(p2,q2);
      add.insert(make_pair(p2,q2));
    }
  }
  bool ok = true;
  int day = 1;
  while(true)
  {
    day++;
    auto it = add.begin();
    while(it != add.end())
    {
      P nowp = *it;
      if(s.find(nowp) == s.end())
      {
        s.insert(nowp);
      }
      else
      {
        s.erase(nowp);
        int p1 = nowp.first;
        int p2 = nowp.second;
        counts[p1]++;
        counts[p2]++;
        if(counts[p1] < n-1)
        {
          int q1 = a[p1][counts[p1]];
          if(p1 > q1) swap(p1,q1);
          new_add.insert(make_pair(p1,q1));
        }
        if(counts[p2] < n-1)
        {
          int q2 = a[p2][counts[p2]];
          if(p2 > q2) swap(p2,q2);
          new_add.insert(make_pair(p2,q2));
        }
      }
      it++;
    }
    add.clear();
    if(new_add.size() == 0 && s.size() == 0)
    {
      break;
    }
    else if(new_add.size() == 0)
    {
      ok = false;
      break;
    }
    add = new_add;
    new_add.clear();
  }
  if(ok) cout << day << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define lint long long

lint solve(lint a, lint b){
    lint L = a * b - 1;
  	if(L == 0) return 0;
    lint min = 1, max = L / 2 + 1;
    while(max - min > 1){
        lint n = (min + max) / 2;
        if(n > L / n) max = n;
        else min = n;
    }
    lint p = min; lint res;
    if(a == b) res = p * 2;
    else if(L/p < p+1) res = p * 2 - 2;
    else res = p * 2 - 1;
    return res;
}

int main(){
    int q; cin >> q;
    rep(i, q){
        lint a, b, res; cin >> a >> b;
        if(a > b) res = solve(b, a);
        else res = solve(a, b);
        cout << res << endl;
    }
}


Measured memory_bytes: 256
s = input()

a = s.replace("x","")

if a == a[::-1]:
	pass
else:
	print("-1")
	exit()

a = s
count1 = 0
count2 = len(a)-1
count = 0
while(count1 < count2):
	if a[count1] == a[count2]:
		count1 += 1
		count2 -= 1
	if a[count1] == "x" and a[count2] != "x":
		count += 1
		count1 += 1
	if a[count1] != "x" and a[count2] == "x":
		count += 1
		count2 -= 1


print(count)




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

void solve(long long N, long long K, std::vector<long long> D) {
  auto valid = [&](long long x) {
    while (x) {
	int dig = x%10;
	x/=10;
        if (D[dig]) {
	    return false;
        }
    }
    return true;
  };
  while (true) {
    if (valid(N)) {
      cout << N << endl;
      return;
    }
    N++;
  }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> D(10, 0);
  for (int i = 0; i < K; i++) {
    long long temp;
    cin >> temp;
    D[temp] = 1;
  }
  solve(N, K, std::move(D));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using pii = pair<int, int>;

void Main() {
	string s, t; cin >> s >> t;
	vvi dp(s.size() + 1, vi(t.size() + 1, 0));
	FOR(i,1,s.size() + 1) {
		FOR(j,1,t.size() + 1) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
		}
	}
	string r_answer = "";
	int n = s.size();
	int m = t.size();
	while (n > 0 && m > 0) {
		if (dp[n][m] == dp[n - 1][m]) --n;
		else if (dp[n][m] == dp[n][m - 1]) --m;
		else {
			r_answer += s[n - 1];
			--n;
			--m;
		}
	}
	REP(i,r_answer.size()) {
		cout << r_answer[r_answer.size() - i - 1];
	}
	cout << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define ll long long
#define ii pair<int,int>
ll ara[200005];char st[200004];
ll aa[200004]; ll bb[200004];
int main()
{
    ll a,b,c,d,m,n,i,j,k,l,t,x,y,z;

        ll ans=0;
        ll maxi=0,mini=0,sum=0,mul=1;
        cin>>n;
        a=n+(n*n)+(n*n*n);
        cout<<a<<endl;


    return 0;
}






Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll factorial(int n) {
  if (n == 1)
    return 1;
  return n * factorial(n - 1);
}

double dist(pii x, pii y) {
  int x1 = x.first;
  int x2 = y.first;
  int y1 = x.second;
  int y2 = y.second;
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

double calc(vector<int> perm, vector<pii> cities) {
  double res = 0;
  for (int i = 0; i < perm.size() - 1; i++) {
    res += dist(cities[perm[i]], cities[perm[i + 1]]);
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  ll perm_n = factorial(n);
  vector<pii> cities(n);
  vector<int> permutation(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    cities[i] = pii(x, y);
    permutation[i] = i;
  }
  double sum = 0;
  do {
    sum += calc(permutation, cities);
  } while (next_permutation(permutation.begin(), permutation.end()));
  cout << fixed << setprecision(10) << sum / (double)perm_n << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int H = input.nextInt();
            int W = input.nextInt();
            if (H == 0 && W == 0) break;
            for (int i = 1; i <= H; i++) {
                char[] cs = new char[W];
                for (int j = 1; j <= W; j++) {
                    cs[j-1] = (j == 1 || j == W || i == 1 || i == H) ? '#' : '.';
                }
                System.out.println(cs);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 21164
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int a[25];
		for (int i = 0; i < n; ++i)
			scanf("%d", a+i);

		int left = 32;
		for (int i = 0; left; ++i)
		{
			if (i & 1)
				left -= min(left, a[(i/2) % n]);
			else
				left -= (left - 1) % 5;
			printf("%d\n", left);
		}
	}

	return 0;
}

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

using namespace std;
int main(){
    string s, t;
    getline(cin, s);
    getline(cin, t);
    t.pop_back();
    if(s == t){
        cout << "Yes" << '\n';
    }
    else{
        cout << "No" << '\n';
    }

}

Measured memory_bytes: 3628
s=input()
ans=0
cnt=0
flag=0
for i in range(len(s)-1,-1,-1):
  if flag==0:
    if s[i]=='C':
      flag=1
    elif s[i]=='A':
      ans+=cnt
    elif s[i]=='B':
      cnt=0
  elif flag==1:
    if s[i]=='B':
      flag=0
      cnt+=1
    elif s[i]=='C':
      cnt=0
    elif s[i]=='A':
      flag=0
      cnt=0
print(ans)

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

int nCnt = 0;

void insertionSort(int nIn[], int nNum, int g)
{
	for (int i = g; i < nNum; ++i)
	{
		int v = nIn[i];
		int j = i - g;
		while (j >= 0 && nIn[j] > v)
		{
			nIn[j + g] = nIn[j];
			j -= g;
			nCnt++;
		}
		nIn[j + g] = v;
	}
}

void shellSort(int nIn[], int nNum)
{
	nCnt = 0;
	vector<int> vecG;
	int nH = 1;
	while (nH <= nNum)
	{
		vecG.push_back(nH);
		nH = nH * 3 + 1;
	}
	cout << vecG.size() << endl;
	for (int i = vecG.size() - 1; i >= 0; --i)
	{
		cout << vecG[i];
		if (i)
		{
			cout << " ";
		}
	}
	cout << endl;
	for (int i = vecG.size() - 1; i >= 0; --i)
	{
		insertionSort(nIn, nNum, vecG[i]);
	}
}

int main()
{
	int nNum = 0;
	cin >> nNum;
	int nIn[1000000] = { 0 };
	for (int i = 0; i < nNum; ++i)
	{
		cin >> nIn[i];
	}
	shellSort(nIn, nNum);

	cout << nCnt << endl;
	for (int i = 0; i < nNum; ++i)
	{
		cout << nIn[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 7060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ld W, H , x , y;
    cin >> W >> H >> x >> y;
    

    cout << (W * H / (ld)2.0) << " " << (((x+x) == W) && ((y+y) == H)) << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X = sc.nextLong();
		
		long[] Xn = new long[N + 1];
		for (int i = 0; i < N; i++) {
			Xn[i] = sc.nextLong();
		}
		
		Xn[N] = X;
		
		Arrays.sort(Xn);
		
		long[] Dn = new long[N];
		for (int i = 0; i < N; i++) {
			Dn[i] = Xn[i+1] - Xn[i];
		}
		
		long ans = Dn[0];
		for (int i = 0; i < Dn.length; i++) {
			ans = gcd(ans, Dn[i]);
			if (ans == 1)
				break;
		}
		
		System.out.println(ans);
	}
	
	static long gcd(long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}

}


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

int main() {
	float f;
	while (cin >> f) {
		if (f <= 48)puts("light fly");
		else if (f <= 51)puts("fly");
		else if (f <= 54)puts("bantam");
		else if (f <= 57)puts("feather");
		else if (f <= 60)puts("light");
		else if (f <= 64)puts("light welter");
		else if (f <= 69)puts("welter");
		else if (f <= 75)puts("light middle");
		else if (f <= 81)puts("middle");
		else if (f <= 91)puts("light heavy");
		else puts("heavy");
	}
	return 0;
}

Measured memory_bytes: 3040
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,a=0,s=0;
  cin>>n;
  int x[n+1];
  for(int i=0;i<n;i++)
  {
    cin>>x[i];
    a+=x[i];
    s+=x[i]*x[i];
  }
  if((double)a/n==a/n)
  {
    cout<<s-a*a/n;
    return 0;
  }
  int p=(floor)((double)a/n+0.5);
  cout<<s+n*p*p-2*a*p;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000000000;
ll INF=10000000000000000;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    for (int i=n-1;i>0;i--){
        if (a.at(i)+1<a.at(i-1)) {cout << "No" << endl;return 0;}
        if (a.at(i)+1==a.at(i-1)) a.at(i-1)--;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int w,a,b,x,y;
  cin>>w>>a>>b;
  x = max(a,b);
  y = min(a,b);
  cout<<(y+w>=x?0:abs(x-y-w))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    vi c(4);
    rep(i,6){
        int b;
        cin >> b;
        b--;
        c[b]++;
    }
    rep(i,4){
        if(c[i]==3){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    
    return 0;
}

Measured memory_bytes: 3580
N = int(input())
s = list(map(int, input().split()))

m = s[0]
M = s[N-1]

lis = []
ans = 0

for i in range(1000):
  for j in range(N):
  	ans += (s[j] - i) ** 2
  lis.append(ans)
  ans = 0
  
print(min(lis))

Measured memory_bytes: 39024
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
const ll MAX = 6e5+5;

// structure to store queries 
struct Query 
{ 
	ll l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(ll idx, ll val, ll bit[], ll n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
ll query(ll idx, ll bit[], ll n) 
{ 
	ll sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(ll arr[], ll n, Query queries[], ll q) 
{ 
	// initialising bit array 
	ll bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	ll last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	ll ans[q+1]; 
	ll query_counter = 0; 
	for (ll i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)-query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (ll i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
	ll n,q;
    cin>>n>>q;
    ll a[n];
    for(ll i=0;i<n;++i)cin>>a[i];
    
    Query queries[q]; 
    for(ll i=0;i<q;++i){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        queries[i].l=x;
        queries[i].r=y;
        queries[i].idx=i;
    }
	sort(queries, queries+q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 31860
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, A, B;
  std::cin >> n >> A >> B;
  A -= B;
  std::vector<lint>h(n);
  std::cin>>h;

  auto ck = [&] (lint X) {
    lint cost = 0;
    for (lint x : h) {
      x -= B*X;
      if (x <= 0) continue;
      // debug(x,A);
      cost += (x+A-1) / A;
    }
    // debug(X,cost);
    return cost <= X;
  };
  lint ng = -1, ok = 1e9;
  while (ok - ng > 1) {
    lint mid = (ng+ok) / 2;
    (ck(mid) ? ok : ng) = mid;
  }
  lint ans = ok;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024