akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	string s;
  cin>>s;
  if(s[s.length()-1]=='s')
    cout<<s<<"es"<<endl;
  else
    cout<<s<<"s"<<endl;
    
}
 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	for (int i = 0; i < 12; i++) {
		if (i == 4) {
			cout << " ";
		}
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[(n+1)/2] - d[(n-1)/2] << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
main(){
	while(0);
	int Q;
	cin>>Q;
	for(int loop=0;loop<Q;++loop){
		int c,a,n,co=0;
		cin>>c>>a>>n;
		while(1){
			if(c>0&&a>0&&n>0){
				c--;
				a--;
				n--;
				co++;
			}else break;
		}
		while(1){
			if(c>1&&a>0){
				c-=2;
				a--;
				co++;
			}else break;
		}
		while(1){
			if(c>2){
				c-=3;
				co++;
			}else break;
		}
		cout<<co<<endl;
	}
}

Measured memory_bytes: 1164
x,y=map(int,input().split())
ans=0
if x*y==0:
  if x>y:
    ans=abs(y+x)+1
  else:
    ans=abs(y-x)
elif x*y<0:
  ans=abs(y+x)+1
else:
  if x>y:
    ans=abs(y-x)+2
  else:
    ans=abs(y-x)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;
// return a^b O(log b)
template<typename T>
T mypow(T a, T b){
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

// return nCk 前処理 O(K) + query あたり O(1)
long long combk(int n, int k){
	if (k < 0 || n < k) return 0;
	long long res = 1;
	for (ll i = 1; i <= k; i++) {
		res = (res * (n - i + 1)) % MOD;
		res = (res * mypow(static_cast<long long>(i), MOD - 2)) % MOD;
	}
    return res;
}

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

    ll n, a, b;
    cin >> n >> a >> b;
    ll res = (mypow(2LL, n) - 1 + (MOD - combk(n, a)) % MOD + (MOD - combk(n, b)) % MOD) % MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
s = int(input())
f = lambda n: (n/2) if n%2==0 else (3*n + 1)
prevval = s
history = [s]
c = 2
while True:
    newval = f(prevval)
    if newval in history:
        break
    history.append(newval)
    c += 1
    prevval = newval
print(c)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)


int main(){
    int n;
    scanf("%d",&n);
    printf("%lf\n",(double)n*M_PI*2);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a[10],b[10];
     for(int i=0;i<10;i++) cin >> a[i];
     for(int i=0;i<10;i++) cin >> b[i];
     
     sort(a,a+10);  sort(b,b+10);
     
     cout <<a[7]+a[8]+a[9]<<" "<<b[7]+b[8]+b[9]<<endl;
}




Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll h, w;
    cin >> h >> w;

    ll a[h][w];
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> a[i][j];
        }
    }
    vector<ll> ans1;
    vector<ll> ans2;
    vector<ll> ans3;
    vector<ll> ans4;

    ll count = 0;
    rep(i, 0, h){
        if(count % 2 == 0){
            rep(j, 0, w-1){
                if(a[i][j] % 2 != 0){
                    a[i][j]--;
                    a[i][j+1]++;
                    ans1.push_back(i+1);
                    ans2.push_back(j+1);
                    ans3.push_back(i+1);
                    ans4.push_back(j+2);
                }
            }
            if(a[i][w-1] % 2 != 0 && i != h-1){
                a[i][w-1]--;
                a[i+1][w-1]++;
                    ans1.push_back(i+1);
                    ans2.push_back(w);
                    ans3.push_back(i+2);
                    ans4.push_back(w);
            }
        }
        if(count % 2 == 1){
            rrep(j, w-1, 1){
                if(a[i][j] % 2 != 0){
                    a[i][j]--;
                    a[i][j-1]++;
                    ans1.push_back(i+1);
                    ans2.push_back(j+1);
                    ans3.push_back(i+1);
                    ans4.push_back(j);
                }
            }
            if(a[i][0] % 2 != 0 && i != h-1){
                a[i][0]--;
                a[i+1][0]++;
                    ans1.push_back(i+1);
                    ans2.push_back(1);
                    ans3.push_back(i+2);
                    ans4.push_back(1);
            }
        }
        count++;
    }

    cout << ans1.size() << endl;
    rep(i, 0, ans1.size()){
        cout << ans1[i] << " " << ans2[i] << " " << ans3[i] << " " << ans4[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8148
N=int(input())
B=list(map(int,input().split()))
B=eval(f"[{B[0]}]")+B+eval(f"[{B[N-2]}]")
A=[0]*N
for i in range(N-1):
  A[i]=min(B[i],B[i+1])
A[N-1]=B[N-1]
print(sum(A))


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

int main()
{
    int q;
    while(cin >> q)
    {
        if(q==-1)break;
        double qz = (double)q;
        double x=qz/2;
        double e;
        while(1)
        {
            e = x*x*x-qz;
            if(fabs(e)*100000 < qz) break;
            x= x-e/(3*x*x);
        }
        printf("%.6f\n",x);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n; cin >> n;
        int odd = (n + 2 - 1) / 2;
        long double p = (long double)odd / (long double)n;
        cout << fixed << setprecision(20) << p << endl;
    return 0;
}


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

const int N = 200005;

int n, m;
int a[N];

int ans[N];

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

  for (int i = 1; i <= 100; ++i) {
    for (int j = 1; j <= 100; ++j) {
      for (int k = 1; k <= 100; ++k) {
        int t = i*i + j*j + k*k + i*j + j*k + k*i;
        if (t <= n) ++ans[t];
      }
    }
  }

  for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);

  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3788
var n,i,store:int64;
    flag:boolean;
begin
read(n);flag:=true;
store:=trunc(n / 1.08);
for i := store-5 to store+5 do
if trunc(i*1.08)=n then
 begin
  write(i);
  flag:=false;
  break;
 end;
 
if flag then write(':(');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=51 ;
int main()
{
   fast ;
   ll tests=1 ;
   //cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
     ///cout<<"Case #"<<testcase<<": " ;
     ///Read ,Think and Test Properly,then code
     ld x ;
     cin>>x ;
     ld y=x/3.0 ;
     ld ans=y*y*y ;
     cout<<fixed<<setprecision(10)<<ans ;

   }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, w, h;
	int ah[114514] = {}, aw[114514] = {};
	cin >> n >> w >> h;
	for (int i = 0; i < n; i++) {
		int x, y, wi; cin >> x >> y >> wi;
		aw[max(0, x - wi)]++;
		aw[min(w, x + wi)]--;
		ah[max(0, y - wi)]++;
		ah[min(w, y + wi)]--;
	}
	bool b1 = true;
	int v = 0;
	for (int i = 0; i < w; i++) {
		v += aw[i];
		if (v <= 0)b1 = false;
	}
	bool b2 = true;
	v = 0;
	for (int i = 0; i < h; i++) {
		v += ah[i];
		if (v <= 0)b2 = false;
	}
	cout << (b1 || b2 ? "Yes" : "No") << endl;
	char c; cin >> c;
}

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

const int MAXN = 100005;

int a[MAXN], n;

int main()
{
	scanf("%d", &n);
	long long sum = 0;
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i];
	long long tot = (1ll+n)*n/2;
	if (sum%tot != 0) puts("NO");
	else {
		sum /= tot;
		long long cnt = 0;
		a[n+1] = a[1];
		for (int i = 1; i <= n; i++) {
			if (a[i+1]-a[i] > sum) {
				puts("NO");
				return 0;
			}
			if ((sum-(a[i+1]-a[i]))%n != 0) {
				puts("NO");
				return 0;
			}
			cnt += (sum-(a[i+1]-a[i]))/n;
		}
		if (cnt != sum) puts("NO");
		else puts("YES");
	}
	return 0;
}


Measured memory_bytes: 640
// Problem : D - Not Divisible
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	vi a(n);
	vi cnt(2e6+1,0);
	vi ncnt(2e6+1,0);
	loop(i,n)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	int ans=0;
	for(int i=1;i<2e6+1;i++)
	{
		for(int j=i;j<2e6+1;j+=i)
			ncnt[j]+=cnt[i];
	}
	l00p(i,1,2e6+1)
	{
		if(ncnt[i]==1 && cnt[i])
		ans+=cnt[i];
	}
	cout<<ans;
		
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

int main() {
	int A, B;
	cin >> A >> B;
	
  	if ( (A + B) % 2 != 0 ){
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  
  cout << (A + B)/2 << endl;
	
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int MOD = 1000000007;

int main() {
    int N, K;
    cin>>N>>K;
    vector<long> Table(N+1);
    Table[0] = N + 1;
    long a = 0, b = N;
    REP(i, 1, N+1){
        a += i; b += (N-i);
        Table[i] = (b - a + 1) % MOD;
    }
    long ans = 0;
    REP(i, K-1, N+1){
        ans += Table[i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
from bisect import bisect

s = input()
t = input()

d = dict()

for i in range(26):
    d[chr(i+97)] = []

for i, si in enumerate(s):
    d[si].append(i)

ans = 0
res = -1

for i in range(len(t)):
    if d[t[i]] == []:
        print(-1)
        exit()
    index = bisect(d[t[i]], res)
    if index == len(d[t[i]]):
        ans += len(s) - res + d[t[i]][0]
        res = d[t[i]][0]
    else:
        ans += d[t[i]][index] - res
        res = d[t[i]][index]

print(ans)

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

int e;
int main() {
    while (cin >> e, e != 0) {
        int m = 1<<28;
        for (int z = 0; z*z*z <= e; z++) {
            for (int y = 0; y*y <= e-z*z*z; y++) {
                int x = e-z*z*z-y*y;
                m = min(m, x+y+z);
            }
        }
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
H, W = map(int, input().split())

grid = []
for i in range(H):
    grid.append(input())

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            if i > 0:
                if grid[i-1][j] == '#':
                    continue
            if i < H-1:
                if grid[i+1][j] == '#':
                    continue
            if j > 0:
                if grid[i][j-1] == '#':
                    continue
            if j < W-1:
                if grid[i][j+1] == '#':
                    continue
            print('No')
            quit()
print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<stack>
#include<string>

using namespace std;

class m
{
public:
	int start;
	int mizu;
};

int main()
{
	stack<int> s1;
	stack<m> s2, s3;
	m a;
	int all = 0, i, j;
	string s;
	cin >> s;
	for (i = 0; i < (int)s.length(); i++)
	{
		if (s.substr(i, 1) == "\\")
		{
			s1.push(i);
		}
		else if (s.substr(i, 1) == "/")
		{
			if (s1.size() == 0)continue;
			all += i - s1.top();
			if (s2.size() == 0)
			{
				a.start = s1.top();
				a.mizu = i - s1.top();
				s2.push(a);
			}
			else
			{
				a.start = s1.top();
				a.mizu = 0;
				while (s2.size() != 0 && s2.top().start > s1.top())
				{
					a.mizu += s2.top().mizu;
					s2.pop();
				}
				a.mizu += i - s1.top();
				s2.push(a);
			}
			s1.pop();
		}
	}
	cout << all << endl << s2.size();
	j = (int)s2.size();
	for (i = 0; i < j; i++)
	{
		s3.push(s2.top());
		s2.pop();
	}
	for (i = 0; i < j; i++)
	{
		cout << " " << s3.top().mizu;
		s3.pop();
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
vector<int> a , f;
int n , k;

int check(int x){
  int delta = 0;
  for(int i=0;i<n;i++){
    if(a[i] * f[i] > x){
      delta += (a[i] - x/f[i]);
    }
  }
  return delta <= k;
}


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

  cin >> n >> k;
  a = f = vector<int>(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> f[i];
  }
  sort(a.begin() , a.end());
  sort(f.rbegin() , f.rend());
  int l = 0 , h = 1e12 , mid;
  int ans = 1e12;
  while(l<=h){
    mid = (l + h ) / 2;

    if(check(mid)){
       h = mid - 1;
       ans = min(ans , mid);
    }
    else l = mid + 1;
  }
  cout << ans << '\n';
  
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
	long long k, n;
	int i, f;

	scanf("%lld", &k);

	if (k % 2 == 0) {printf("-1\n"); return 0;}

	n = 0;
	for (i = 1; i < 10000000; i++)
	{
		f = (n*10 + 7) / k;
		n = (n*10 + 7) % k;
		if (n == 0 && f > 0) {printf("%d\n", i); return 0;}
	}

	printf("-1\n");

	return 0;
}


Measured memory_bytes: 1728
namespace VainZero.Procon.FSharp

open System
open System.Collections.Generic

[<AutoOpen>]
module Operators =
  let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let [|h; w|] = read int64

    let calc () =
      let crossCase h w =
        seq {
          for y in 1L..(h - 1L) do
            let x = w / 2L
            let s1 = y * (w - x)
            let s2 = y * x
            let s3 = (h - y) * x
            let s4 = (h - y) * (w - x)
            yield (s1 + s2, s3, s4)
            yield (s2 + s3, s4, s1)
            yield (s3 + s4, s1, s2)
            yield (s4 + s1, s2, s3)
        }
      let noncrossCase h w =
        seq {
          for y1 in 1L..(h - 2L) do
            let y2 = y1 + (h - y1) / 2L
            yield (y1 * w, (y2 - y1) * w, (h - y2) * w)
        }
      let cases =
        crossCase h w
        |> Seq.append (crossCase w h)
        |> Seq.append (noncrossCase h w)
        |> Seq.append (noncrossCase w h)
      seq {
        for (s0, s1, s2) in cases ->
          let max = s0 |> max s1 |> max s2
          let min = s0 |> min s1 |> min s2
          max - min
      } |> Seq.min

    printfn "%d" (calc ())

    0


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

int main(){
  int i,j,k;
  vector<int> si(5);
  for(i=0;i<5;++i){
    cin >> si[i];
  }
  cin >> k;
  for(i=0;i<5;++i){
    for(j=i+1;j<5;++j){
      if((si[j]-si[i])>k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,res=1;
signed main(){
	scanf("%lld",&n);
	while(n--){
		int a; scanf("%lld",&a);
		if(a==0) return puts("0"),0;
		else if(1000000000000000000/a<res) res=-1;
		if(res!=-1) res*=a;
		if(res>1000000000000000000) res=-1;
	}
	printf("%lld",res);
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    ll A, B;
    cin >> A >> B;

    if(A + B >= 10){
        cout << "error" << endl;
    }else{
        cout << A + B << endl;
    }

}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc134/tasks/abc134_c

N = int(input())
A = []
max1 = 0
max2 = 0

for _ in range(N):
    a = int(input())
    if max1 <= a:
        max2 = max1
        max1 = a
    elif max2 <= a:
        max2 = a
    A.append(a)

for a in A:
    print(max1 if a != max1 else max2)


Measured memory_bytes: 12520
import java.io.*;
import java.util.*;

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    public void go() throws IOException
    {
        ntok();
        int n = ipar();
        int k = ipar();
        int q = ipar();
        int[] arr = new int[n];
        for (int i = 0; i < q; i++)
        {
            ntok();
            arr[ipar()-1]++;
        }
        for (int i = 0; i < n; i++)
        {
            out.println(q - arr[i] < k ? "Yes" : "No");
        }

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

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


Measured memory_bytes: 34900
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int n, m;
vector<string> s, t;
bool check(int a, int b) {
    for ( int i=0; i<m; i++ ) {
        for ( int j=0; j<m; j++ ) {
            if ( s[a+i][b+j]!=t[i][j] ) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;   
    s.resize(n); t.resize(m);
    REP(i,n) cin >> s[i];
    REP(i,m) cin >> t[i];
    for ( int i=0; i<=n-m; i++ ) {
        for ( int j=0; j<=n-m; j++ ) {
            if ( check(i,j) ) {
                cout << "Yes" << '\n';
                return 0;
            }            
        }
    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll>x(m);
    vector<ll>xdiff(m-1);
    rep(i, 0, m){
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    ll ans = x.back()-x[0];
    rep(i, 0, m-1){
        xdiff[i] = x[i+1]-x[i];
    }
    sort(xdiff.begin(), xdiff.end(), greater<int>());
    lrep(i, 0, min(n-1, m-1)){
        ans -= xdiff[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string S, L, R;
	int Q;
	cin >> S;
	cin >> Q;
	int revcount = 0;
	rep(t, Q) {
		int A;
		cin >> A;
		if (A == 1) {
			revcount++;
		}
		else {
			int F;
			char C;
			cin >> F >> C;
			if ((F + revcount) % 2 == 0) {
				R.push_back(C);
			}
			else
				L.push_back(C);
		}
	}
	reverse(L.begin(), L.end());
	string ans = L + S + R;
	if (revcount % 2 == 1)
		reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1348
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST


template <typename T>
inline T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}

ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(ll i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N, X;
    cin >> N >> X;
    vector<ll> x(N+1);
    for(size_t i=0;i<N; i++)
    {
        cin >> x[i];
    }
    x[N] = X;
    sort(x.begin(), x.end());
    //for(auto i : x) cerr << i << endl;
    vector<ll> x_dist(N);
    for(size_t i=0;i<N; i++)
    {
        x_dist[i] = x[i+1] - x[i];
        //cerr << x_dist[i] << endl;
    }

    cout <<  ngcd(x_dist) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);
        var x = int.Parse(spl[2]);

        var ca = new int[n][];

        for(int i=0; i<n; i++) {
            ca[i] = ToIntArray(input.ReadLine(), m + 1);
        }

        //var score = new long[m+1];

        long bmax = Pow(2, n);
        long b = 0;

        long min = long.MaxValue;

        while (b <= bmax) {
            var sum = 0L;
            var score = new long[m + 1];

            for(int i=0; i<n; i++) {
                var on = (b >> i) & 0x01;
                if (on == 1) { 
                    for(int j=1; j<=m; j++) {
                        score[j] += ca[i][j];
                    }
                    sum += ca[i][0];
                }
            }
            var ok = true;
            for (int j = 1; j <= m; j++) {
                ok &= score[j] >= x;
            }
            if (ok) {
                min = Math.Min(sum, min);
            }

            b += 1;
        }

        if (min == long.MaxValue) return -1;

        return min;
    }

    static long Pow(long x, long n) {
        long ans = 1;
        while (n > 0) {
            if (n % 2 == 1) {
                ans = ans * x;
            }
            x = x * x;
            n /= 2;
        }
        return ans;
    }

    /*
    static long min;

    static void f(int n, int m, int x, int[][] ca, long[] score, HashSet<int> subs, long sum) {
        if (sum >= min) return;

        var ok = true;
        for (int i = 1; i <= m; i++) {
            ok &= score[i] >= x;
        }
        if (ok) {
            min = Math.Min(sum, min);
            return;
        }

        for (int i=0; i<n; i++) {
            if (!subs.Contains(i)) {
                var hash = new HashSet<int>(subs);
                hash.Add(i);

                var sco = new long[m + 1];
                for (int j = 1; j <= m; j++) sco[j] = score[j] + ca[i][j];
                
                f(n, m, x, ca, sco, hash, sum + ca[i][0]);
            }
        }
    }*/


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 27816
#include <stdio.h>
int n, q, x;
int f, l, r, ans;
char c;
char s[500010];
int t[200][30];
int v[30];
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	scanf("%d", &q);
	for (int i = 0; i < n; i++) {
		x = i / 2500;
		t[x][s[i] - 'a'] ++;
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d", &f, &l);
		l--;
		if (f == 1) {
			scanf(" %c", &c);
			t[l / 2500][s[l] - 'a']--;
			t[l / 2500][c - 'a']++;
			s[l] = c;
		}
		if (f == 2) {
			scanf("%d", &r);
			r--;
			for (int j = 0; j < 26; j++)v[j] = 0;
			if (r - l < 2500) {
				for (int j = l; j <= r; j++) {
					v[s[j] - 'a']++;
				}
			}
			else {
				if (l % 2500) {
					if (l % 2500 < 1250) {
						for (int j = 0; j < 26; j++) {
							v[j] += t[l / 2500][j];
						}
						for (int j = l / 2500 * 2500; j < l; j++) {
							if (j < n)v[s[j] - 'a']--;
						}
					}
					else {
						for (int j = l; j < (l / 2500 + 1) * 2500; j++) {
							if (j < n)v[s[j] - 'a']++;
						}
					}
				}
				if ((r + 1) % 2500) {
					if (r % 2500 > 1250) {
						for (int j = 0; j < 26; j++) {
							v[j] += t[r / 2500][j];
						}
						for (int j = r + 1; j < (r / 2500 + 1) * 2500; j++) {
							if (j < n)v[s[j] - 'a']--;
						}
					}
					else {
						for (int j = r / 2500 * 2500; j <= r; j++) {
							if (j < n)v[s[j] - 'a']++;
						}
					}
				}
				for (int j = 0; j < 200; j++) {
					if (l <= j * 2500 && (j + 1) * 2500 - 1 <= r) {
						for (int k = 0; k < 26; k++) {
							v[k] += t[j][k];
						}
					}
				}
			}
			ans = 0;
			for (int j = 0; j < 26; j++) {
				if (v[j])ans++;
			}
			printf("%d\n", ans);
		}
	}
}

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

struct route
{
    int cost,time;
};

bool operator<(route a,route b)
{
    if(a.cost!=b.cost)
        return a.cost<b.cost;
    else
        return b.cost<a.cost;
}
int main()
{
    int n,t;

    while(cin>>n>>t)
    {
        route r[n];

        for(int i=0;i<n;i++)
        {
            cin>>r[i].cost>>r[i].time;
        }
        sort(r,r+n);

        int flag=0;
        for(int i=0;i<n;i++)
        {
            if(r[i].time<=t)
            {
                cout<<r[i].cost<<endl;
                flag=1;
                break;
            }
        }
        if(flag==0)
            cout<<"TLE"<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(auto& si:s)cin>>si;
  for(int i=0;i<h;++i)for(int j=0;j<w;++j){
    if(s[i][j]=='#'){
      bool ok=false;
      for(int k=0;k<4;++k){
        int ni=i+dy[k];
        int nj=j+dx[k];
        if(ni==-1||nj==-1||ni==h||nj==w)continue;
        if(s[ni][nj]=='#')ok=true;
      }
      if(!ok){
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    x = int(input())
    ans = (x//11)*2
    rest = x % 11
    if rest > 6:
        ans += 2
    elif 0 < rest <= 6:
        ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;cin>>n;
  int i,j,k;
  vector<int> v;
  for(i=0;i<n;i++){
    cin >> k;
    v.push_back(k);
  }
  for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
      if(v[j]>v[i]){
	k=v[i];
	v.erase(v.begin()+i);
	v.insert(v.begin()+j,k);
	break;
      }
    }
    for(j=0;j<n;j++) cout << v[j] << (j==n-1?'\n':' ');
  }
  return 0;
}



Measured memory_bytes: 3168
#ABC095C
N=int(input())
A=list(map(int,input().split()))
A=[[A[i],i] for i in range(N)]
A.sort(key=lambda x:x[0]) #ascending
x=A[N//2-1][0]
y=A[N//2][0]
A=[[A[i][0],A[i][1],i] for i in range(N)]
A.sort(key=lambda x:x[1]) #input oder
for i in range(N):
	if A[i][2]>=N//2:
		print(x)
	else:
		print(y)


Measured memory_bytes: 65984
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for (int i = 1 ; i <= n ; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                ans += (long) i;
            }
        }
        System.out.println(ans);
    }

}


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

// ldというのもある
main(){
  vector<int64_t> vec(86);
  vec[0] = 2;
  vec[1] = 1;
  for(int i = 0; i < 84; i++){
    vec[i + 2] = vec[i] + vec[i + 1];
  }
  int N;
  cin >> N;
  if(N != 86){
    printf("%ld", vec[N]);
  }
  else{
    printf("%ld", vec[N - 2] + vec[N - 1]);
  }
}

Measured memory_bytes: 256
/*
有一组面值为1~N的牌，已知每种面值的个数
卡牌a,b可以组成一对(a, b)当且仅当|a面值 - b面值|<=1
问最多能组多少对。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int arr[N];
signed main(){
	int n,s=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	for(int i=2;i<=n;i++){
		if(arr[i-1]%2){
			if(arr[i]){
				arr[i-1]++;
				arr[i]--;
			}
		}
	}
	for(int i=1;i<=n;i++){
		s+=arr[i]/2;
		if(arr[i]%2) arr[i]=1;
		else arr[i]=0;
	}
	for(int i=2;i<n;i++){
		if(arr[i]&&arr[i-1]) arr[i]=0,arr[i-1]=0,s++;
		else if(arr[i]&&arr[i+1]) arr[i]=0,arr[i+1]=0,s++;
	}
	cout<<s;
	return 0;
}

/*
3
1
2
1

*/

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

#define long long long int
using namespace std;


#ifdef JUDGE
std::ifstream cin("input.txt");
std::ofstream cout("output.txt");
#else
using std::cin;
using std::cout;
#endif

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(6);


    int n, m, c;
    cin >> n >> m >> c;
    int cnt = 0;
    vector<int> b(m);
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        vector<int> a(m);
        for (int j = 0; j < m; ++j) {
            cin >> a[j];
        }
        int tmp = 0;
        for (int j = 0; j < m; ++j) {
            tmp += b[j] * a[j];
        }
        if (tmp + c > 0)
            cnt++;
    }
    cout << cnt;

    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((ll)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
ll INF = 1e18;
using namespace std;

int main(){
  ll N, K; cin >> N >> K;
  vector<pair<ll,ll>> TD(N);
  rep(i,N){
    ll t,d; cin >> t >> d;
    TD[i] = {d, t};
  }
  
  sort(all(TD), greater<pair<ll,ll>>());
  
  map<ll,ll> m;
  ll kinds;
  ll ans = 0;

  rep(i,K){
    ll t = TD[i].second;
    ll d = TD[i].first;
    m[t]++;
    ans += d;
  }
  kinds = m.size();
  ans += kinds * kinds;
  ll sum = ans;

  ll r = K-1;
  REP(i, K, N){
    ll current_t = TD[i].second;
    ll current_d = TD[i].first;
    if(m.count(current_t) == 0){
      while(r>=0 and m[TD[r].second]==1) --r;
      if(r == -1) break;
      m[TD[r].second]--;
      m[current_t]++;
      
      sum = sum - TD[r].first + current_d;
      --r;
      sum -= kinds * kinds;
      kinds++;
      sum += kinds * kinds;
    
    // cout << "sum = " << sum << endl;
    // for(auto mm: m){
    //   cout << mm.first << endl;
    // }
      
      ans = max(ans, sum);
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 5760
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def fact(n: int, mod: int):
    ret = [1]
    for i in range(1, n+1):
        ret.append(ret[-1] * i % mod)

    return ret


def fact_inv(fac: list, mod: int):
    ret = []
    for faci in fac:
        ret.append(pow(faci, mod-2, mod))

    return ret


def apb_pow(n: int, a:int, b:int, mod: int):
    ret = [1]
    for i in range(1, 2*n + 1):
        ret.append(ret[-1] * (a+b) % mod)

    return ret


n, a, b, c = li()
MOD = 10**9 + 7
MAXN = 10**5+1

ans = 0

fac = fact(2*MAXN, MOD)
fac_inv = fact_inv(fac, MOD)
apbp = apb_pow(2*MAXN,a,b, MOD)

for m in range(n, 2*n):
    cur = fac[m] * (pow(a, n, MOD) * pow(b, m-n, MOD) + pow(b, n, MOD) * pow(a, m-n, MOD))
    cur %= MOD

    cur *= fac_inv[m-n] * fac_inv[n-1]
    cur %= MOD

    cur *= pow(apbp[m] * (100-c), MOD-2, MOD)
    cur %= MOD

    ans += cur
    ans %= MOD

print(100 * ans % MOD)

Measured memory_bytes: 74228
N = int(input())
S = [input() for _ in range(N)]

char_lst = [chr(i) for i in range(97,97+26)]

solver = []
for i in range(len(char_lst)):
  var = 100
  for j in range(N):
    var = min(var, S[j].count(char_lst[i]))
  solver.extend([char_lst[i]]*var)
solver.sort()
ans = ''.join(solver)
print(ans)

Measured memory_bytes: 3064
a = list(input())
b = len(a)
c = int(b/2)
x = []
result = []
if b%2 == 0:
    A = a[:c]
    B = a[c:]
    BB = B[::-1]
    for v in range(c):
        if A[v] != BB[v]:
            result.append(v)
        else:
            x.append(v)
        
else:
    C = a[:c]
    D = a[c+1:]
    DD = D[::-1]
    for v in range(c):
        if C[v] != DD[v]:
            result.append(v)
        else:
            x.append(v)
print(len(result))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)

struct UnionFind {
    vi par; // par[i]:iの親の番号 
    vi sizes; //根ノードiの木に含まれるデータの数

    UnionFind(int N) : par(N), sizes(N, 1){ //最初は全てが根であるとして初期化
        fr(i,N) par[i] = i;
    }

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

    void unite(int x, int y){ //xの木とyの木を併合
        int rx = find(x);
        int ry = find(y);
        if(rx == ry) return;
        if(sizes[x] < sizes[y]) swap(x,y);
        par[ry] = rx;
        sizes[rx] += sizes[ry];
        sizes[ry] = 0;
    }

    bool same(int x, int y){ // 同じ木に属するかどうか
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

    int size(int x){
        return sizes[find(x)];
    }
};

int main(){
  ll n,m;cin>>n>>m;
  int p[n];
  fr(i,n){
    cin>>p[i];
    p[i]--;
  }
  UnionFind uf(n);
  fr(i,m){
    int x,y;cin>>x>>y;
    x--;
    y--;
    uf.unite(x,y);
  }
  ll ans = 0;
  fr(i,n){
    if(uf.same(i,p[i]))ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;
typedef long long ll;
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 #define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) FOR(i,0,sz(v)-1) cout << v[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll MOD = 1e10;
const ll N = 2e4 + 1;
const ll m = MOD;
struct comp
{
	bool operator() (const pi &a,const pi &b) const
	{
		int l1=a.se - a.fi + 1;
		int l2=b.se-b.fi + 1;
		if(l1==l2) return a.fi<b.fi;
		else
		return l1>l2;
	}
};
signed main()
{
read(n); int x=n%10;
if(x==3) cout<<"bon"<<endl;
else if(x==2 || x==4 || x==5 ||x==7|| x==9 )
cout<<"hon" <<endl;
else if(x==0 ||x==1 ||x==6 ||x==8 )
cout<<"pon"<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	ll a, b, v, w, t;
	cin >> a >> v >> b >> w >> t;
	cout << (abs(a - b) <= (v - w) * t ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    
    cin>>s;
    long long n=s.size();
    vector<long long> cts(26,0);
    for(char c:s){
        cts[c-'a']++;
    }
    long long ans=n*(n-1)/2;
    //cout<<ans<<endl;
    for(auto i:cts){
        ans-=i*(i-1)/2;
        
    }
    
    cout<<ans+1;
    return 0;
    
}

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

    using namespace std;

    #define ll long long
    #define pii pair<int, int>
    #define MAX 200005

    int h[MAX], dp[MAX];


    int main() {

        int n, k;
        cin >> n >> k;
        for(int i = 1; i <= n; i++) cin >> h[i];

        for(int i = n - 1; i > 0; i--) {
            int x = INT_MAX;
            for(int j = i + 1; j <= i + k && j <= n; j++) x = min(x, dp[j] + abs(h[i] - h[j]));
            dp[i] = x;
        }


        cout << dp[1] << '\n';

        return 0;
    }


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a;
	int al[26] = {0};
	ll ans;
	cin >> a;
	ans = a.size()*(a.size()-1.0)/2.0;
	FOR(i,0,a.size()){
		++al[ a[i] - 'a'];
	}
	FOR(i,0,26){
		ans -=  al[i]*(al[i]-1.0)/2.0;
	}
	cout << ans+1 << endl;
	return 0;
}

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

using namespace std;

struct C {
  int w, d;
  C(int w, int d) : w(w), d(d) {}
  bool operator<(const C& c) const { return w*d<c.w*c.d; }
};

int main() {
  int N, W, D;
  while(cin >> N >> W >> D && (N|W|D)) {
    vector<C> cs;
    cs.push_back(C(W, D));
    while(N--) {
      int p, s; cin >> p >> s; p--;
      C c = cs[p]; cs.erase(cs.begin()+p);
      s %= (c.w+c.d)*2;
      int rem = s, ang = -1;
      for(int i=0; i<2; i++) {
	ang++;
	rem -= c.w;
	if(rem < 0) break;
	ang++;
	rem -= c.d;
	if(rem < 0) break;
      }
      
      rem = -rem;
      
      if(ang == 0 || ang == 2) {
	int a = rem, b = c.w-a;
	if(b<a) swap(a, b);
	cs.push_back(C(a, c.d));
	cs.push_back(C(b, c.d));
      }
      else {
	int a = rem, b = c.d-a;
	if(b<a) swap(a, b);
	cs.push_back(C(c.w, a));
	cs.push_back(C(c.w, b));
      }
    }
    sort(cs.begin(), cs.end());
    for(int i=0; i<cs.size(); i++) {
      if(i) cout << ' ';
      cout << cs[i].w*cs[i].d;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }

double solve1(int x1, int y1, int x2, int y2, int x3, int y3) {
    complex<double> a1(x1 - x3, y1 - y3);
    complex<double> a2(x2 - x3, y2 - y3);
    double arg1 = abs(arg(a1 / a2));
    double arg2 = M_PI - abs(arg((a1 - a2) / a2));
    double scale = abs(a2);
    return scale / (2 + 1 / tan(arg1 / 2) + 1 / tan(arg2 / 2));
}

int main() {
    // input
    int x1, y1; scanf("%d%d", &x1, &y1);
    int x2, y2; scanf("%d%d", &x2, &y2);
    int x3, y3; scanf("%d%d", &x3, &y3);
    // solve
    double result = 0;
    setmax(result, solve1(x1, y1, x2, y2, x3, y3));
    setmax(result, solve1(x2, y2, x3, y3, x1, y1));
    setmax(result, solve1(x3, y3, x1, y1, x2, y2));
    // output
    printf("%.12lf\n", result);
    return 0;
}


Measured memory_bytes: 256