akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j -1 ]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    sw = bubbleSort(A, N);

    for ( int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


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

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int64_t msb(int64_t v){
  v = v | (v >>  1);
  v = v | (v >>  2);
  v = v | (v >>  4);
  v = v | (v >>  8);
  v = v | (v >> 16);
  v = v | (v >> 32);
  return v ^ (v >> 1);
}

int main(){
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int64_t ans1 = 0;
    for(int d=0; d<60; d++){
        int num = 0;
        for(int64_t a : A) num += nth_bit(a, d);
        if(num%2){
            ans1 += 1LL<<d;
            for(int64_t& a : A) if(nth_bit(a, d)) a -= 1LL<<d;
        }
    }

    vector<int64_t> V;
    for(int64_t a : A){
        for(int64_t v : V) if(msb(v)&a) a ^= v;
        if(a > 0){
            for(int64_t& v : V) if(msb(a)&v) v ^= a;
            V.push_back(a);
            sort(V.rbegin(), V.rend());
        }
    }

    int64_t ans2 = 0;
    for(int64_t v : V) ans2 ^= v;
    int64_t ans = ans1 + 2*ans2;
    cout << ans << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << (abs(a - b) <= d && abs(b - c) <= d ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	int x,y,z,ans;
	cin>>x>>y>>z;
	ans=(x-z)/(y+z);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int A,B;
	cin>>A>>B;
	if(A%2==0||B%2==0){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes";
	}
    return 0;
} 

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

ll cost[20],mat[20][20];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,X;
	cin>>n>>m>>X;
	for(ll i=0;i<n;i++)
	{
		cin>>cost[i];
		for(ll j=0;j<m;j++)cin>>mat[i][j];
	}
	ll up=(1<<n);
	ll ans=-1;
	for(ll i=1;i<up;i++)
	{
		vector<ll> dig;
		ll x=i;
		while(sz(dig)<n)
		{
			dig.pb(x%2);
			x/=2;
		}
		ll cur[m];
		for(ll k=0;k<m;k++)cur[k]=0;
		ll tcost=0;
		for(ll k=0;k<sz(dig);k++)
			if(dig[k])
			{
				tcost+=cost[k];
				for(ll j=0;j<m;j++)cur[j]+=mat[k][j];
			}
		bool f=1;
		for(ll k=0;k<m;k++)
			if(cur[k]<X)
			{
				f=0;
				break;
			}
		if(f)
		{
			if(ans==-1)ans=tcost;
			else ans=min(ans,tcost);
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3660
using System;
using System.Text;

class Program
{
  static void Main(string[] args)
  {
    string[] l_sPins = Console.ReadLine().Split(' ');
    int l_iN = int.Parse(l_sPins[0]);
    int l_iM = int.Parse(l_sPins[1]);

    int iRet = 1;
    for (int i = l_iM / l_iN; 1 <= i; i--)
    {
      if (l_iM % i == 0 && l_iN <= (l_iM / i))
      {
        iRet = i;
        Console.WriteLine(iRet);
        break;
      }
    }
  }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;


const i64 MAXN = 300004;

i64 n, d, b;
pair<i64, i64> a[MAXN];



int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
    cin >> n >> d >> b;

    for (i64 i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }

    sort(a, a + n);

    map<i64, i64> q;

    i64 R = 0;
    i64 s = 0;

    for (i64 i = 0; i < n; i++) {
        s -= q[i];

        i64 l = max(0ll, a[i].second - s);

        i64 c = (l / b) + (l % b ? 1 : 0);
        R += c;
        s += b * c;

        i64 j = upper_bound(a, a + n, make_pair(a[i].first + 2 * d, inf)) - a;
        q[j] += b * c;
    }

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 16896
chomp (my $n = <STDIN>);
my @c;
for my $i (0..$n-2) {
  chomp (my $in = <STDIN>);
  my @s = split ' ', $in;
  $c[$i][0] = $s[0];
  $c[$i][1] = $s[1];
  $c[$i][2] = $s[2];
}
for my $i (0..$n-2) {
  my $a = 0;
  for my $j ($i..$n-2) {
    if ($a <= $c[$j][1]) {
      $a = $c[$j][1];
    } else {
      my $b = $a - $c[$j][1];
      if ($b % $c[$j][2] > 0) {
        $a -= $b;
        $a += int($b / $c[$j][2]) * $c[$j][2];
        $a += $c[$j][2];
      }
    }
    $a += $c[$j][0];
  }
  print "$a\n";
}
print "0\n";

Measured memory_bytes: 768
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int main(){
	while(cin>>n){
		int pos =n%39;
		printf("3C%02d\n",pos==0?39:pos);
	}
	return 0;
}

Measured memory_bytes: 1160
integer N
character(200) S
integer x,saituyo
read*,N,S
x=0
saituyo=0
do i=1,N
	if(S(i:i)=="I")x=x+1
    if(S(i:i)=="D")x=x-1
	saituyo=max(saituyo,x)
end do
print"(I0)",saituyo
end

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <random>

using namespace std;

void pass(){
	return;
}

#define prev _prev
#define hash _hash;
#define rand() rand()<<15+rand()
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(rand());
const int MOD = 1e9 + 7;
const ll BIG_MOD = 1e18 + 7;
const int MAXN = 1e5 + 7;


signed main(){
	cout.tie(NULL);
	cout.precision(20);
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << max(0, a - b);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <typename T, typename U>
vector<U> make_vector(T&& n, U&& val) {
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
decltype(auto) make_vector(T&& n, Args&&... args) {
  return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...));
}

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

void solve() {
  int n;
  cin >> n;
  vi32 a(n), b(n);
  cin >> a >> b;
  auto dp = make_vector(n, 60, (i64) 0);
  rep(i, n) {
    dp[i][0] = bit64(b[i]);
  }
  rep(i, n) rep(j, 55) {
    i64 s = dp[i][j];
    rep(k, 55) if (dp[i][j] >> k & 1) {
      if (j <= k) break;      
      int now = k;
      while (now <= 55) {
        s |= bit64(now);
        now += j;
      }
    }
    dp[i][j + 1] = s;
  }
  i64 ans = 0;
  auto v = make_vector(n, (i64) 0);
  rep(i, n) {
    v[i] = bit64(a[i]);
  }
  rrep(m, 55) {
    bool must = false;
    rep(i, n) {
      if ((dp[i][m + 1] & v[i]) == 0) {
        must = true;
      }
    }
    if (must) {
      ans += bit64(m + 1);
      rep(i, n) {
        i64 next = v[i];
        rep(j, 55) if (v[i] >> j & 1) {
          next |= bit64(j % (m + 1));
        }
        v[i] = next;
      }
    }
  }
  bool ok = true;
  rep(i, n) {
    if ((dp[i][0] & v[i]) == 0) {
      ok = false;
    }
  }
  if (!ok) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


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

int main(){
    int n,i,x;
    int ara[100001];

    scanf("%d",&n);
    for(i=1;i<=n;i++){
       scanf("%d",&x);
       ara[x]=i;
    }
    for(i=1;i<=n;i++){
       printf("%d ",ara[i]);
    }

return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n;
  long long int a[200000]={0};
  long long int tmp=0;
  long long int ans=0;
  long long int r=1000000007;

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

  for(int i=0;i<n-1;i++)
  {
    tmp+=a[i];
    ans+=(tmp%r)*a[i+1];
    ans%=r;
  }

  printf("%lld\n",ans);

  return 0;
}

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

int main () {
  int N;
  cin >> N;
  string S1,S2;
  cin >> S1 >> S2;
  string S3 = "";
  for (int i=0; i<N; i++) {
    if (S1[i] == S2[i]) {
      S3 += "t";
    }
    else {
      S3 += "y";
      i++;
    }
  }
  N = S3.size();
  long long ans = 3;
  if (S3[0] == 'y') {
    ans *= 2;
  }
  for (int i=0; i<N-1; i++) {
    if (S3[i] == 't') {
      ans *= 2;
    }
    else if (S3[i+1] == 'y') {
      ans *= 3;
    }
    ans %= 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = -1
sum_ = sum(a)
sunuke = 0
for i in range(n-1):
    sum_ -= a[i]
    sunuke += a[i]
    tmp = abs(sum_ - sunuke)
    if ans == -1:
        ans = tmp
    if ans > tmp:
        ans = tmp
print(ans)

Measured memory_bytes: 24812
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

 int a[5],k;
 for(int i=0;i<5;++i) cin>>a[i];

 int t=0,max=0;
 for(int i=4;i>=0;--i){
  int po;
  po=(a[i]/10+1-!(a[i]%10))*10;
  t+=po;
  if(po-a[i]>max) max=po-a[i];
 }

 t-=max;
 cout<<t<<endl;
 
 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a=0,b=0;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
	    if(a>b)
			   printf("a > b\n");
        else if(a<b)
        	  printf("a < b\n");
        else
        	 printf("a == b\n");
	}
	return 0; 
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

#define MaxN 105
#define INF 2140000000

using namespace std;

int N,X,best[MaxN*MaxN+1];

int main()
{
	cin>>N;
	best[0]=1;
	for(int i=1;i<=N;i++)
	{
		cin>>X;
		for(int i=MaxN*MaxN-X;i>=0;i--)
			if(best[i]!=0)
				best[i+X]=1;
	}
	for(int i=MaxN*MaxN;i>=0;i--)
	{
		if(i%10!=0&&best[i]!=0)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<0;
	return 0;
}

Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    # greatest common divisor
    la = max(a, b)
    sm = min(a, b)
    if la % sm == 0:
        return sm
    else:
        return gcd(sm, la - sm)


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)

import sys

sys.setrecursionlimit(5000)


R, G, B, N = inpl()
ans = 0
for r in range(N // R + 1):
    rest = N - r * R
    for i in range(B):
        if (G * i) % B == rest % B:
            x = i
            break
    else:
        # print(r)
        continue
    if rest - G * x < 0:
        continue
    ans += (rest - G * x) // lcm(B, G) + 1
    # print(r, rest, x, ans)

print(ans)


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

int main()
{
  int n, ans = 0;
  string s;

  cin >> n >> s;
  for (int i = 0; i < n - 2; i++)
  {
    if (s[i] == 'A')
    {
      if (s[i + 1] == 'B')
      {
        if (s[i + 2] == 'C')
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long K, A, B; cin >> K >> A >> B;
    if (B - A <= 2) {
        cout << 1 + K << endl;
        return 0;
    }
    long long t = K - (A - 1);
    if (t < 0) {
        cout << 1 + K << endl;
    } else if (t % 2 == 0) {
        cout << A + t / 2 * (B - A) << endl;
    } else {
        cout << A + t / 2 * (B - A) + 1 << endl;
    }
    return 0;
}

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

int main () {
char a,b,c;
cin >> a >> b >> c;
if (a == 'A' && b == 'A' && c == 'A') {
cout << "No" << endl;
}
else if (a == 'B' && b == 'B' && c == 'B') {
cout << "No" << endl;
}  
else {
cout << "Yes" << endl;
}
}


Measured memory_bytes: 256
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys


def _ia(): return [int(x) for x in sys.stdin.readline().strip().split()]


def main():
    n, k = _ia()
    h = _ia()
    if n <= k:
        return 0

    h.sort(reverse=True)
    return sum(h[k:])


print(main())


Measured memory_bytes: 81896
y, k, d = map(int, input().split())
x = abs(y)
i = int(x / d)
if i >= k:
    p = x - k * d
elif i == x / d:
    if (i + k) % 2 == 0:
        p = 0
    else:
        p = d
else:
    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):
        p = x - i * d
    else:
        p = (i + 1) * d - x
print(int(p))

Measured memory_bytes: 9176
<?php
fscanf(STDIN, "%d%d%d", $N, $K, $C);
$S = str_split(trim(fgets(STDIN)));
$rest = 10**10;
$c = 1;
for($i = 0; $i < $N; ++$i){
    if($S[$i] == "o" && $rest > $C){
        $work[$i] = $c++;
        $rest = 0;
    }else{
        $work[$i] = 0;
    }
    $rest++;
}
$rest = 10**10;
$c = $K;
for($i = $N-1; $i >= 0; --$i){
    if($S[$i] == "o" && $rest > $C){
        $work2[$i] = $c--;
        $rest = 0;
    }else{
        $work2[$i] = 0;
    }
    $rest++;
}
for($i = 0; $i < $N; ++$i){
    if($work[$i] > 0 && $work[$i] == $work2[$i])$ret[] =  $i+1;
}
echo implode("\n", $ret);


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

int main() {
	while(1) {
		int sum;
		cin >> sum;
		if(sum == 0 ) break;
		for(int i=0;i<9;i++) {
			int tmp;
			cin >> tmp;
			sum -= tmp;
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 3104
/*@shutoshsuman99*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define rem1 998244353
#define inf 1e18+1e17
#define F first
#define S second
#define pii pair<long long,long long>
#define p_q priority_queue <ll, vector<ll>, greater<ll> >
#define m_sp multiset <pair <ll,ll> > 
#define el "\n"
#define sp " "
typedef long long ll;
ll Pow(ll x,ll y,ll m) 
{ if (y == 0) return 1; ll p = Pow(x, y/2, m) % m; 
p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m; } 
main()
{ 
	// fast io
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);ll i; 
	ll a,b;
	cin>>a>>b;
	if(a>=13)
	cout<<b<<el;
	else if(a>=6&&a<=12)
	cout<<b/2<<el;
	else
	cout<<0<<el;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7
 
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a - c) > d && (abs(a - b) > d || abs(b - c) > d)){
    print("No");
  }else{
    print("Yes");
  }
  return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int n; cin >> n;

	vector <int> a(n), b(n), c(n);

	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	for(int i = 0; i < n; i++){
		cin >> b[i];
	}

	for(int i = 0; i < n; i++){
		c[i] = i + 1;
	}

	int A, B, step = 0;
	do{
		step++;
		if(c == a){
			A = step;
		}
		if(c == b){
			B = step;
		}
	}while(next_permutation(c.begin(), c.end()));


	cout << abs(A - B) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int d[4044][4044] = {};
int main()
{
        char r[2][4002] = {};
        while (gets (r[0])) {
                gets (r[1]);
memset (d, 0, sizeof d);
                int le, ri, a = 0;
                le = strlen (r[0]), ri = strlen (r[1]);
                for (int i=1; i<=le; i++) {
                        for (int j=1; j<=ri; j++) {
                                if (r[0][i-1] == r[1][j-1]) d[i][j] = d[i-1][j-1] + 1;
                                else d[i][j] = 0;
                                a = a>d[i][j] ? a:d[i][j];
                        }
                }
                printf ("%d\n", a);
        }
        return 0;
}

Measured memory_bytes: 64844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int k = in.nextInt();
            int div = 0;
            for (int i = Math.min(a, b); i >= 1; i--) {
                if (a % i == 0 && b % i == 0)
                    div++;
                if (div == k) {
                    out.println(i);
                    return;
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868
rec = 0
rod = 0
E = 10**-10
while(1):
    try:
        a,b,c = [int(i) for i in input().split(",")]
        if abs(c**2 - (a**2+b**2)) < E:
            rec += 1
        elif a == b:
            rod += 1
    except EOFError:
        print(rec)
        print(rod)
        break


Measured memory_bytes: 5624
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // https://atcoder.jp/contests/abc147/submissions/8921445
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve_A(){
    input!(
        K : i32,
        X : i32,
    );
    println!("{}", if K * 500 >= X{ "Yes" } else { "No" });
}

fn solve_B(){
    input!(
        N : usize,
        S : String,
    );
    let N : usize = N;
    let mut con = 0;
    for i in 0..N-2{
        let ch = &S[i..i+3];
        if ch == "ABC"{
            con += 1;
        }
    }
    println!("{}",con.to_string());
}

fn main() {
    solve_B();
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            cout << i << "x" << j << "=" << i*j << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>

#define INF 100100100

using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;

  vector<string> W(N);
  for (int i = 0; i < N; i++) {
    cin >> W[i];
  }

  set<string> st;
  st.insert(W[0]);

  for (int i = 1; i < N; i++) {
    if (st.count(W[i]) > 0) {
      cout << "No" << endl;
      return 0;
    }

    if (W[i - 1][W[i - 1].size() - 1] != W[i][0]) {
      cout << "No" << endl;
      return 0;
    }

    st.insert(W[i]);
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,i,j,ans,sum,num[100005];
string s[100005],now;
int main(){
	scanf("%lld\n",&n);
	for(i=0;i<n;i++){
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	for(i=0;i<n;i++){
		if(now!=s[i]){
			now=s[i];
			num[sum]=1;
			sum++;
		}
		else num[sum-1]++;
	}
	for(i=0;i<sum;i++)
		ans+=(num[i]*(num[i]-1))/2;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 8064
from collections import deque

H,W = map(int,input().split())
C_h,C_w = map(lambda x:int(x)-1,input().split())
D_h,D_w = map(lambda x:int(x)-1,input().split())
S = [input() for _ in range(H)]

INF = int(1e10)
dist = [[INF]*(W) for _ in range(H)]
deq = deque()
deq.append((C_h,C_w,0))

move_a = [(1,0),(0,1),(-1,0),(0,-1)]
move_b = [(i,j)for i in range(-2,2+1) for j in range(-2,2+1) if abs(i)+abs(j)>=2]

while len(deq):
  h,w,c = deq.popleft()
  if dist[h][w] <= c:
    continue
  dist[h][w] = c
  for dh,dw in move_a:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c:
      deq.appendleft((nh,nw,c))
  for dh,dw in move_b:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c+1:
      deq.append((nh,nw,c+1))
  
print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)

Measured memory_bytes: 173496
#include<bits/stdc++.h>
using namespace std;
int64_t mod=1e9+7;
int64_t pw(int64_t x,int64_t y){
  int64_t z;
  if(y==0) return 1;
  else{
    z=pw(x*x%mod,y/2);
    if(y%2==1) z=z*x%mod;
    return z;
  }
}
int64_t comb(int64_t n,int64_t r){
  int64_t x=1,i,ans;
  if(n<r) return 0;
  for(i=1;i<=r;i++){
    x=x*(n-i+1)%mod;
    x=x*pw(i,mod-2)%mod;
  }
  return x;
}
int main(){
  int n,p,q,i,k;
  cin>>n;
  vector<int> a(n+1);
  set<int> s;
  for(i=0;i<n+1;i++){
    cin>>a.at(i);
    if(!s.count(a.at(i))) s.insert(a.at(i));
    else q=i;
  }
  for(i=0;i<q;i++){
    if(a.at(i)==a.at(q)){
      p=i;
      break;
    }
  }
  p++;q++;
  vector<int64_t> comb1(n+2),comb2(n+1);
  comb1.at(0)=1;
  comb2.at(0)=1;
  for(i=1;i<=n+1;i++){ //comb(n+1,i);
    comb1.at(i)=comb1.at(i-1)*(n+2-i)%mod;
    comb1.at(i)=comb1.at(i)*pw(i,mod-2)%mod;
  }
  for(i=1;i<=n+p-q;i++){ //comb(n+p-q,i);
    comb2.at(i)=comb2.at(i-1)*(n+p-q+1-i)%mod;
    comb2.at(i)=comb2.at(i)*pw(i,mod-2)%mod;
  }
  for(k=1;k<=n+1;k++) cout<<(comb1.at(k)-comb2.at(k-1)+mod)%mod<<endl;
}

Measured memory_bytes: 9852
import math

N = int(input())
ans = float("inf")


#print(int(math.sqrt(N))+1)
for i in range(1,int(math.sqrt(N))+1):
	if N % i == 0:
		j = N // i
		ans = min(ans,i+j-2)
		#print(i,j)
	#print(i)

print(ans)

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
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; }
//template end

template<unsigned mod>struct mint {
    int val;
    int inv() const{
        int tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        if(x<0)x+=mod; return x;
    }
    mint():val(0){}
    mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
    mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    mint& operator*=(const mint& x){val=(ll)val*x.val%mod; return *this;}
    mint& operator/=(const mint& x){val=(ll)val*x.inv()%mod; return *this;}
    mint operator+(const mint& x)const{return mint(*this)+=x;}
    mint operator-(const mint& x)const{return mint(*this)-=x;}
    mint operator*(const mint& x)const{return mint(*this)*=x;}
    mint operator/(const mint& x)const{return mint(*this)/=x;}
    bool operator==(const mint& x)const{return val==x.val;}
    bool operator!=(const mint& x)const{return val!=x.val;}
};
using Mint=mint<1000000007>;
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

Mint dp[4050][4050];

int main(){
   int n; scanf("%d",&n);
   map<pair<int,int>,int> mp;
   rep(i,0,n){
      int x,y; scanf("%d%d",&x,&y);
      mp[{x,y}]++;
   }
   for(auto p:mp)dp[2010-p.first.first][2010-p.first.second]+=p.second;
   rep(i,1,4030)rep(j,1,4030)dp[i][j]+=dp[i-1][j]+dp[i][j-1];
   Mint res; factorial fact(8020);
   for(auto p:mp){
      res+=dp[2010+p.first.first][2010+p.first.second]*p.second;
      res-=fact.nCr((p.first.first+p.first.second)*2,p.first.first*2)*p.second;
   } res/=2;
   printf("%d\n",res.val);
   return 0;
}

Measured memory_bytes: 76928
S = "0" + input()

digits = [int(c) for c in S.rstrip("0")]
N = len(digits)

# Track number of bills necessary to create digits[:i]
# Can either pay exact or overpay by one bill to flip the sign of the balance
dpPos = [None] * len(digits)
dpNeg = [None] * len(digits)

dpPos[-1] = digits[-1]
dpNeg[-1] = 10 - digits[-1]

for place in reversed(range(len(digits) - 1)):
    # Positive balance case
    exact = digits[place]
    dpPos[place] = exact + min(dpPos[place + 1], 1 + dpNeg[place + 1])
    # Negative balance case
    exact = 10 - digits[place] - 1
    dpNeg[place] = exact + min(dpNeg[place + 1], 1 + dpPos[place + 1])
print(dpPos[0])


Measured memory_bytes: 92772
n,k=map(int,input().split())
V=list(map(int,input().split()))
ans=0
for i in range(n+1):
    for j in range(n-i+1):
        #print(i, j)
        if i+j>k:
            continue
        tmp=V[:i]+V[n-j:]
        tmp.sort(reverse=True)
        for l in range(k-i-j):
            if tmp and tmp[-1]<0:
                tmp.pop()
            else:
                break
        ans=max(ans,sum(tmp))
print(ans)

Measured memory_bytes: 41836
#include <iostream>

using namespace std;

class A {
	int a, b;
public:
	void solve()
	{
		cin >> a >> b;

		if ((~a | ~b) & 1) cout << "Even" << endl;
		else cout << "Odd" << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#define llint long long
#define inf 1000000000000000
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, m, V, D;
llint s, t;
vector<edge> G[300005];
llint dist[300005];
llint numS[300005], numT[300005], num[300005];
bool valid[300005];
bool used[300005];
vector<int> topo;

void dijkstra(llint S, llint dist[])
{
	for(int i = 1; i <= V; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, S) );
	
	llint v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

void tpsort(int v)
{
	used[v] = true;
	if(!valid[v]){
		for(int i = 0; i < G[v].size(); i++){
			int u = G[v][i].to;
			if(used[u]) continue;
			if(dist[u] > D || dist[u] == D && !valid[u]) continue;
			if(dist[v] + G[v][i].cost == dist[u]) tpsort(u);
		}
	}
	topo.push_back(v);
}

llint calc(llint S, llint num[])
{
	dijkstra(S, dist);
	for(int i = 1; i <= V; i++) used[i] = false;
	topo.clear(), tpsort(S);
	reverse(topo.begin(), topo.end());
	
	for(int i = 1; i <= V; i++) num[i] = 0;
	num[S] = 1;
	for(int i = 0; i < topo.size(); i++){
		int v = topo[i];
		if(valid[v]) continue;
		for(int j = 0; j < G[v].size(); j++){
			int u = G[v][j].to;
			if(dist[u] > D || dist[u] == D && !valid[u]) continue;
			if(dist[v] + G[v][j].cost == dist[u]) (num[u] += num[v]) %= mod;
		}
	}
}

int main(void)
{
	cin >> n >> m;
	cin >> s >> t;
	llint u, v, d;
	for(int i = 1; i <= m; i++){
		cin >> u >> v >> d;
		d *= 2;
		G[u].push_back(edge(v, d));
		G[v].push_back(edge(u, d));
	}
	
	V = n;
	dijkstra(s, dist);
	D = dist[t]/2;
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < G[i].size(); j++){
			int u = G[i][j].to;
			if(dist[i] + G[i][j].cost != dist[u]) continue;
			if(dist[i] < D && dist[u] > D){
				V++;
				G[i].push_back(edge(V, D-dist[i]));
				G[V].push_back(edge(i, D-dist[i]));
				G[u].push_back(edge(V, dist[u]-D));
				G[V].push_back(edge(u, dist[u]-D));
			}
		}
	}
	
	for(int i = 1; i <= V; i++) valid[i] = true;
	dijkstra(s, dist);
	for(int i = 1; i <= V; i++) if(dist[i] != D) valid[i] = false;
	dijkstra(t, dist);
	for(int i = 1; i <= V; i++) if(dist[i] != D) valid[i] = false;
	
	calc(s, numS);
	calc(t, numT);
	
	for(int i = 1; i <= V; i++) num[i] = numS[i]*numT[i]%mod;
	llint sum = 0;
	for(int i = 1; i <= V; i++){
		if(!valid[i]) continue;
		sum += num[i], sum %= mod;
	}
	llint ans = sum*sum%mod;
	for(int i = 1; i <= V; i++){
		if(!valid[i]) continue;
		ans += mod - num[i]*num[i]%mod;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int a, b;
  cin >> a >> b;
  if((a <= 0 && b >= 0 ) || (a >= 0 && b <= 0) || (a == 0 || b == 0)){
    cout << "Zero" << endl;
    return 0;
  }
  if(a < 0 || b < 0){
    int cnt = min(max(a, b), 0) - min(a, b) + 1;
    if(cnt % 2 == 0){
      cout << "Positive" << endl;
      return 0;
    }
    else{
      cout << "Negative" << endl;
      return 0;
    }
  }
  cout << "Positive" << endl;
}

Measured memory_bytes: 256
def p_d():
    from bisect import bisect_right
    A, B, Q = map(int, input().split())
    INF = 10 ** 18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    ans = []
    for _ in range(Q):
        x = int(input())
        b, d = bisect_right(s, x), bisect_right(t, x)
        res = INF
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min((d1, d2, res))
        ans.append(str(res))
    print("\n".join(ans))


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 94680
/* 165b.c */
#include <stdio.h>
#include <math.h>
double floor(double);

int main(void){
    double x=0;
    double risi=0;
    double yokin=100;
    scanf("%lf",&x);
    for(int i=1;i<yokin;i++){
        risi=floor((double)yokin*1/100);
        yokin=floor((double)yokin+(double)risi); 
        if(x<=yokin){
            printf("%d",i);
            return 0;
        }
        //printf("%lf\n",yokin);
    }
    printf("error");
}

Measured memory_bytes: 1740
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	x := Scan()
	fs := make([]int, n+1)
	for i := 1; i <= n; i++ {
		fs[i] = f(i)
	}
	ones := 0
	for _, v := range x {
		if string(v) == "1" {
			ones++
		}
	}
	u, d := ones+1, ones-1
	umod, dmod := make([]int, n), make([]int, n)
	p, q := 1, 1
	for i := 0; i < n; i++ {
		umod[i] = p % u
		p = umod[i] * 2
	}
	if d != 0 {
		for i := 0; i < n; i++ {
			dmod[i] = q % d
			q = dmod[i] * 2
		}
	}
	uc, dc := 0, 0
	for i := 0; i < n; i++ {
		if string(x[n-i-1]) == "1" {
			uc += umod[i]
			dc += dmod[i]
		}
	}
	for i := 0; i < n; i++ {
		if string(x[i]) == "1" {
			if d == 0 {
				fmt.Println(0)
			} else {
				fmt.Println(fs[(dc-dmod[n-i-1])%d] + 1)
			}
		} else {
			fmt.Println(fs[(uc+umod[n-i-1])%u] + 1)
		}
	}
}
func f(n int) int {
	c := 0
	for n != 0 {
		c++
		n %= bits.OnesCount(uint(n))
	}
	return c
}


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

int main(){
	string s;
 	cin >> s;
    if(s[0] == 'A' && s[1] == 'A' && s[2] == 'A' ||
	   s[0] == 'B' && s[1] == 'B' && s[2] == 'B')
	   puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = 0,0
for i in range(N):
    if A[i]>B[i]:
        b += A[i]-B[i]
    else:
        a += (B[i]-A[i])//2+(B[i]-A[i])%2
if (sum(B)-sum(A))>=max(a,b):
    print("Yes")
else:
    print("No")

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

int main(int argc, char *argv[]) {
	int current_hour = 0;
	int hour_later = 0;

	std::cin >> current_hour;
	std::cin >> hour_later;

	std::cout << ((current_hour + hour_later) % 24) << std::endl;
	return 0;
}


Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

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

const int maxn = 2000009;
string s;
bool chk(int l, int r){
    int m = (r-l)/2;

    for(int i = l, j = 0;i<=(l+m);i++,j++){
        if(s[i]!=s[r-j]){
            return false;
        }
    }

    return true;
}
void solve(){
    
   int n;
   cin >> n;
   int a[n+2];
   map<int,int> m,ans,ans1;
   int sum = 0;
   for(int i = 1;i<=n;i++){
    cin >> a[i];
    m[a[i]]++;
   }

   for(auto i:m){

        ans[i.first] = (i.second)*(i.second-1)/2;
        ans1[i.first] = (i.second-1)*(i.second-2)/2;
   }

   for(auto i:ans){

        sum+=i.second;
   }

   for(int i = 1;i<=n;i++){

        cout << sum-ans[a[i]]+ans1[a[i]] <<  endl;
    }
    

} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        
        solve();
        //cout << endl;
    }
    return 0;
} 

 


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

int main(){
  
  string s;
  cin >> s;
  int k=s.size();
  
  for(int i=0;i<s.size()-1;i++){
    if(s.size()>i+2&&s.at(i)==s.at(i+1)&&s.at(i+1)==s.at(i+2)){
      k--;
      i=i+2;
    }else if(s.size()>i+4&&s.at(i)==s.at(i+1)&&s.at(i+2)==s.at(i+3)
             &&s.at(i+3)==s.at(i+4)){
      k--;
      i=i+2;
    }else if(s.size()>i+3&&s.at(i)==s.at(i+1)&&s.at(i+2)==s.at(i+3)){
      k--;
      i=i+3;
    }else if(s.at(i)==s.at(i+1)){
      k--;
      i++;
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    double p[n];
    rep(i,n){
        cin >> p[i];
    }
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= n; j++){
            dp[i + 1][j] += (1 - p[i]) * dp[i][j];
            if(j - 1 < 0) continue;
            dp[i + 1][j] += p[i] * dp[i][j - 1];
        }
    }
    double ans = 0;
    for(int i = n / 2 + 1; i <= n; i++){
        ans += dp[n][i];
    }
    printf("%.12lf\n", ans);
    return 0;
}

Measured memory_bytes: 70784
use proconio::input;
use core::cmp;

fn main() {
    input! {
        n: usize,
        mut a: [isize; n],
    }
    a.insert(0, 0);
    a.push(0);

    let mut previous = a[0];
    let mut travel_all = 0;
    for na in a.iter().skip(1) {
        travel_all += (na - previous).abs();
        previous = *na;
    }

    for skip in 1..n + 1 {
        let previous_direction = if a[skip - 1] == a[skip] {
            Direction::Stay
        } else if a[skip - 1] < a[skip] {
            Direction::Left
        } else {
            Direction::Right
        };
        let next_direction = if a[skip] == a[skip + 1] {
            Direction::Stay
        } else if a[skip] < a[skip + 1] {
            Direction::Left
        } else {
            Direction::Right
        };

        if previous_direction == Direction::Stay
            || next_direction == Direction::Stay
            || previous_direction == next_direction
        {
            println!("{}", travel_all);
        } else {
            let sub = cmp::min((a[skip - 1] - a[skip]).abs() * 2, (a[skip + 1] - a[skip]).abs() * 2);
            println!("{}", travel_all - sub);
        }
    }
}

#[derive(PartialEq)]
enum Direction {
    Left,
    Right,
    Stay,
}


Measured memory_bytes: 3528
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M; cin >> N >> M;
    vector<LLONG> as(M); for (auto &ai : as) cin >> ai;
    LLONG sum = accumulate(as.begin(), as.end(), 0LL);
    if (sum > N)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << N - sum << endl;
    }
}


Measured memory_bytes: 3704
from collections import deque
def main():
    s=deque(input())
    for i in range(0,len(s)):
        s.pop()
        if len(s)%2==1:
            continue
        else:
            if "".join(s)[0:len(s)//2]=="".join(s)[len(s)//2:len(s)]:
                print(len(s))
                break;
if __name__=='__main__':
    main()


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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    string S;
    cin>>S;
    bool A=false,B=false;
    rep(i,3){
        if(S[i]=='A')A=true;
        if(S[i]=='B')B=true;
    }
    if(A&&B)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
nt=list(map(int,input().split()))
n=nt[0]
t=nt[1]
ct=[[] for i in range(n)]
for i in range(n):
    ct[i]=list(map(int,input().split()))
cmin=10000
for i in range(n):
    if ct[i][1]<=t:
        cmin=min(cmin,ct[i][0])
if cmin==10000:
    print("TLE")
else:
    print(cmin)
    

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

using namespace std;

char a, b;

int main() {
  scanf("%c %c", &a, &b);
  if (b == 'H') {
    putchar(a);
  } else {
    if (a == 'H') putchar('D');
    else putchar('H');
  }
  return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
S = [input() for _ in range(n)]
m = int(input())
T = [input() for _ in range(m)]

s = collections.Counter(S)
t = collections.Counter(T)
gain = 0
for text in s.keys():
  if text in t.keys():
    gain_0 = s[text]-t[text]
    if gain < gain_0:
      gain = gain_0
  else:
    gain_0 = s[text]
    if gain < gain_0:
      gain = gain_0
        
print(gain)

Measured memory_bytes: 3444
import java.util.Scanner;
public class Main {

  
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String data = sc.next();
        char C=data.charAt(0);
        int asc=(int)C;
        //System.out.println(asc);
        asc++;
        char D=(char)asc;
        System.out.println(D);
    }
}


Measured memory_bytes: 21844
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n)
{
  int i;
  for ( i = 1; i <= n; i++ )
    {
      if ( i > 1 ) printf(" ");
      printf("%d", A[i]);
    }
  printf("\n");
}

int main()
{
  int n, i, j, key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(i = 2; i < n+1; i++)
    {
      key = A[i];  // insert A[i] into the sorted sequence A[0,...,j-1]
      j = i-1;
      while(j >= 0 && A[j] > key)
	{
	  A[j+1] = A[j];
	  j--;
	}
      A[j+1] = key;
      trace(A, n);
    }
  return 0;
}

Measured memory_bytes: 604