akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <list>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    string s; cin>>s;
    string t;
    
    char c=' ';
    REP(i,s.size()){
        if(i==0)c=s[i];
        else{
            if(s[i]!=c){
                t=t+c;
                c=s[i];
            }
        }
        
        if(i==s.size()-1){
            if(t[t.size()-1]!=s[i])t=t+s[i];
        }
    }
    
    cout<<t.size()-1<<endl;
    
    return 0;
}




Measured memory_bytes: 824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

	ll ans = 0;
	ll a = 1;
	while (h >= 2) {
		h = floor(h / 2);
		ans += a;
		a *= 2;
	}

	//cout << ans << ' ' << a << endl;

	ans += a;

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for y in range(0, H):
        for x in range(0, W):
            if (x + y) % 2 == 0:
                print('#', end = '')
            else:
                print('.', end = '')
        print('')
    print('')



Measured memory_bytes: 7008
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {

	string s;
	cin >> s;
	int count = 0;
	for (char c : s) {
		if (c == 'o')
			count++;
	}
	count += 15 - s.size();

	COUT((count >= 8 ? "YES" : "NO"));

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,i,count=0,pre=0;
    scanf("%d",&n);
    int a[n];
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        while(a[i]%2==0)
        {
            count++;
            pre= a[i]/2;
            a[i]=pre;
        }
    }
    printf("%d",count);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	
	void doIt() {
		long A = sc.nextLong();
		long B = sc.nextLong();
		long N = sc.nextLong();
		long x = Math.min(B - 1, N);
		System.out.println((long)((Math.floor((double)(A) *x/B)) - A * Math.floor((double)x / B)));
	}
	
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 35744
// ABC122B - ATCoder

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

typedef unsigned long long int ull;
typedef long long int ll;

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

	int ans = 0;

	for (int i = 0; i < S.size(); i++) {
		int t = 0;
		for (int j = i; j < S.size(); j++) {
			if ((S[j] == 'A')||(S[j] == 'C')||(S[j] == 'G')||(S[j] == 'T')) {
				++t;
			} else {
				break;
			}
		}
		ans = max(ans, t);
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
	int n,sum=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	cout<<((sum-a[n-1]>a[n-1])?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 1e9+7;
signed main(){
  init_io();
  ll n,dsum=0;
  cin >> n;
  vector<ll> dp(n+3,0);
  vector<ll> sum(n+3,0);
  dp[1] = n;
  sum[1] = n;
  dp[2] = (n*n)%MOD;
  sum[2] = (n+n*n)%MOD;
  for(int i=3;i<=n;i++){
    dp[i] = (dp[i-1]+(n-1)*(n-1))%MOD;
    dp[i]+=sum[i-3]+(n-1-(i-3));
    dp[i]%=MOD;
    sum[i] = sum[i-1] + dp[i];
    sum[i]%=MOD;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 18704
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, n; cin >> a >> b >> n;
    if (n >= b) {
        cout << (a * (b - 1)) / b << '\n';
    } else {
        cout << a * n / b << '\n';
    }
    return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  
  //ichigyoume
  for (int i=0; i<W+2; i++){
	cout << "#";
  }
  cout << endl;
  
  //nigyoume
  for (int j=0; j<H; j++){
    cout << "#";
    char a;
    for (int i=0; i<W; i++){
      cin >> a;
      cout << a;
    }
    cout << "#" << endl;
  }
  
  //saisyuugyou
  for (int i=0; i<W+2; i++){
	cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << #x << " = " << x << endl

int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int n;
	cin >> n;
	cout << (n/500 * 1000 + (n%500/5 * 5)) << endl;
	
	return 0;
}

Measured memory_bytes: 3656
s = input()
ans = [0] * 10 ** 3
cnt = 0

for i in range(len(s)):
    for j in range(1, len(s) + 1):
        memo = s[i:j]
        for k in range(len(memo)):
            if memo[k] == 'A' or memo[k] == 'C' or memo[k] == 'T' or memo[k] == 'G':
                cnt += 1
            else:
                break

        ans.append(cnt)
        cnt = 0

print(max(ans))


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    int N, X;
    scanf("%d %d", &N, &X);

    int i, m[N], min=1001;
    for(i=0; i<N; i++) {
        scanf("%d", &m[i]);
        if(min>m[i]) {
            min = m[i];
        }
        X -= m[i];
    }

    printf("%d\n", N+X/min);

    return 0;

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void SMTB2019D()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	vi d1(10, -1);
	for (int k = 0; k < N; ++k)
	{
		int i = S[k] - '0';
		const char x = S[k];
		int j = atoi(&x);
      
		if (x < 48 || x > 57)
			throw "Bad";
		if (d1[i] < 0)
			d1[i] = k;
	}
	vi d2(100, -1);
	for (int k = 1; k < N; ++k)
	{
		int i = S[k] - '0';
		char x = S[k];
		int j = atoi(&x);
//		if (i != j)
//			throw "Bad";
		for (int j = 0; j < 10; ++j)
		{
			if (d1[j] >= 0 && d1[j] < k && d2[j * 10 + i] < 0)
				d2[j * 10 + i] = k;
		}
	}
	vi d3(1000, -1);
	for (int k = 2; k < N; ++k)
	{
		int i = S[k] - '0';
		char x = S[k];
		int j = atoi(&x);
//		if (i != j)
//			throw "Bad";
		for (int j = 0; j < 100; ++j)
		{
			if (d2[j] >= 0 && d2[j] < k && d3[j * 10 + i] < 0)
				d3[j * 10 + i] = k;
		}
	}
	int ct = 0;
	for (int i = 0; i < 1000; ++i)
	{
		if (d3[i] > 0)
		{
			++ct;
		}
	}
	cout << ct << endl;
}int main()
{
	SMTB2019D();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    long long mod = 1000000007;
    long long cnt[1000005];
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      int n;
      cin >> n;
      cnt[0] = 3;
      long long ans = 1;
      for(int i = 0;i < n;i++){
        long long x;
        cin >> x;
        x++;
        ans *= cnt[x-1];
        cnt[x]++;
        cnt[x-1]--;
        ans %= mod;
      }
      cout << ans;
    }

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n,a;
    cin >>n;
    rep(i,n) {
        cin >>a;
        if(a%2==0){
            if(a%3!=0&&a%5!=0) {
                cout << "DENIED" <<endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" <<endl;
    return 0;
}

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

#define chmax(x, y) (x = max(x, y))

int n, m;
int a[5010], b[5010];
int dp[2][5010];

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	a[n] = -1;
	b[m] = -2;

	int res = 0;
	int *src = dp[0], *dst = dp[1];
	for (int i = 0; i <= n; i++){
		fill_n(dst, 5010, 0);
		for (int j = 0; j <= m; j++){
			chmax(res, chmax(dst[j], src[j]));
			if (a[i] == b[j]){
				chmax(res, chmax(dst[j + 1], src[j] + 1));
			}
		}
		swap(src, dst);
	}

	cout << res << endl;
}

Measured memory_bytes: 3172
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

a = I()
print(a+a**2+a**3)

Measured memory_bytes: 77244
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 998244353
using namespace std;
typedef long long LL;
int main()
{
    int n,k;
    int a[maxn*2];
    scanf("%d%d",&k,&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    a[0]=a[n]-k;
    int ans=0;
    for(int i=1;i<=n;i++)
        ans=max(ans,a[i]-a[i-1]);
    printf("%d",k-ans);
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*(66)
for num in a:
    for j in range(60):
        cnt[j] += (num >> j)%2
ans = 0
for b in range(60):
    ans += (cnt[b]*(n-cnt[b])) << b
    ans %= 10**9+7
print(ans)

Measured memory_bytes: 122808
mod = 10**9 + 7

def factorize(n):
    # http://nihaoshijie.hatenadiary.jp/entry/2018/02/03/115759
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append(e)
        b, e = b + 1, 0
    if n > 1:
        fct.append(1)
    return fct

class COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def COM(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

n, m = map(int,input().split())
fct = factorize(m)
ans = 1
COM = COMB_MOD()
for cnt in fct:
    ans = ans*COM.COM(cnt+n-1, cnt) % mod
print(ans)

Measured memory_bytes: 63604
#include <stdio.h>

int main (void){
  int x[3000], y[3000];
  int i = 0, j;

  while(1){
    scanf("%d %d", &x[i], &y[i]);
    if(x[i] == 0 && y[i] == 0){
      break;
    }
    i++;
  }

  for(j = 0; j < i; j++){
    if(x[j] <= y[j]){
      printf("%d %d\n", x[j], y[j]);
    } else {
      printf("%d %d\n", y[j], x[j]);
    }
  }

  return 0;
}

Measured memory_bytes: 1740
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int p[n+1]={};
  int r[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>p[i];
    r[p[i]]=i;
  }

  ll a[n+1]={};
  ll b[n+1]={};

  for(int i=1;i<=n;i++){
    a[i]=3e4*i;
    b[i]=3e4*(n-i)+r[i];
  }
  for(int i=1;i<n;i++){
    cout<<a[i]<<" ";
  }
  cout<<a[n]<<endl;
  for(int i=1;i<n;i++){
    cout<<b[i]<<" ";
  }
  cout<<b[n]<<endl;

  return 0;
}


Measured memory_bytes: 1152
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

struct edge {
    int from, to;
    ll cost;
    //比較演算子のオーバーロード
    bool operator<(const edge& e1) const
    {
        return cost < e1.cost;
    }
    bool operator>(const edge& e1) const
    {
        return cost > e1.cost;
    }
};

int N;

edge X[MAX_N], Y[MAX_N];
P Xcity[MAX_N], Ycity[MAX_N];

int par[MAX_N]; //親
int t_rank[MAX_N]; //木の深さ

ll kruskal();
void init(int n);
int find(int x);
void unite(int x, int y);
bool same(int x, int y);

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

    cin >> N;

    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        Xcity[i] = P(x, i);
        Ycity[i] = P(y, i);
    }

    sort(Xcity, Xcity + N);
    sort(Ycity, Ycity + N);

    for (int i = 0; i < N - 1; i++) {
        edge ex = { Xcity[i].second, Xcity[i + 1].second, Xcity[i + 1].first - Xcity[i].first };
        X[i] = ex;
        edge ey = { Ycity[i].second, Ycity[i + 1].second, Ycity[i + 1].first - Ycity[i].first };
        Y[i] = ey;
    }

    sort(X, X + N - 1);
    sort(Y, Y + N - 1);

    init(N);

    cout << kruskal() << "\n";

    return 0;
}

ll kruskal()
{
    ll res = 0;
    int xi = 0;
    int yi = 0;
    while (xi < N - 1 && yi < N - 1) {
        edge ex;
        if (xi == N - 1) {
            ex = { 0, 0, INF };
        } else {
            ex = X[xi];
        }
        edge ey;
        if (yi == N - 1) {
            ey = { 0, 0, INF };
        } else {
            ey = Y[yi];
        }
        if (ex.cost < ey.cost) {
            if (!same(ex.from, ex.to)) {
                unite(ex.from, ex.to);
                res += ex.cost;
            }
            xi++;
        } else {
            if (!same(ey.from, ey.to)) {
                unite(ey.from, ey.to);
                res += ey.cost;
            }
            yi++;
        }
    }
    return res;
}

// n要素で初期化
void init(int n)
{
    for (int i = 0; i < n; i++) {
        par[i] = i;
        t_rank[i] = 0;
    }
}

// 木の根を求める
int find(int x)
{
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (t_rank[x] < t_rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (t_rank[x] == t_rank[y])
            t_rank[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y)
{
    return find(x) == find(y);
}

Measured memory_bytes: 9128
v=[[3*M=998244353,1]]
gets
$<.map{|e|e.split.map &:to_i}.sort.reverse.map{|x,d|r=1
r=r*v.pop[1]%M while v[-1][0]<x+d
v<<[x,r+1]}
r=1
v.map{|_,y|r=r*y%M}
p r

Measured memory_bytes: 26204
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>     // std::vector
using namespace std;

int main(void){
    int num, sum = 0, i, j, k, a[4], b[4], flag = 0;
    string str, sign = "+++";
    cin >> str;
    num = atoi(str.c_str());

    b[0] = a[0] = (num % 10); num /= 10;
    b[1] = a[1] = (num % 10); num /= 10;
    b[2] = a[2] = (num % 10); num /= 10;
    b[3] = a[3] = (num % 10); num /= 10;

    for (i=0; i<2; i++) {
        for (j=0; j<2; j++) {
            for (k=0; k<2; k++) {
                sign = "+++";
                if(i == 0){
                    sign[0] = '+';
                }else if(i == 1){
                    sign[0] = '-';}
                if(j == 0){
                    sign[1] = '+';
                }else if(j == 1){
                    sign[1] = '-';}
                if(k == 0){
                    sign[2] = '+';
                }else if(k == 1){
                    sign[2] = '-';}
                b[0] = a[0];
                b[1] = a[1];
                b[2] = a[2];
                if(sign[0] == '-'){b[2] = -1*a[2];}
                if(sign[1] == '-'){b[1] = -1*a[1];}
                if(sign[2] == '-'){b[0] = -1*a[0];}
                sum = 0;
                sum = b[0] + b[1] + b[2] + b[3];
                if(sum == 7){
                    flag = 1;
                    break;}
            }
            if(flag == 1){break;}
        }
        if(flag == 1){break;}
    }
    cout << str[0] << sign[0] << str[1] << sign[1] << str[2] << sign[2] << str[3] <<"=7" << endl;
    // cout << str << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <string>

int main() {
	std::ios::sync_with_stdio(false);
	std::string s;
	bool reverse = false;
	std::cin >> s;
	std::deque<char> ini, fin;

	int Q;
	std::cin >> Q;
	int T, F;
	char c;
	for (int i = 0; i < Q; ++i) {
		std::cin >> T;
		if (T == 1) reverse = !reverse;
		else {
			std::cin >> F >> c;
			if (F == 1) {
				if (!reverse) ini.push_back(c);
				else fin.push_back(c);
			}
			else {
				if (!reverse) fin.push_back(c);
				else ini.push_back(c);
			}
		}
	}

	if (reverse) {
		while (!fin.empty()) {
			std::cout << fin.back();
			fin.pop_back();
		}
		for (int i = s.size() - 1; i >= 0; --i) std::cout << s[i];
		while (!ini.empty()) {
			std::cout << ini.front();
			ini.pop_front();
		}
		std::cout << '\n';
	}
	else {
		while (!ini.empty()) {
			std::cout << ini.back();
			ini.pop_back();
		}
		std::cout << s;
		while (!fin.empty()) {
			std::cout << fin.front();
			fin.pop_front();
		}
		std::cout << '\n';
	}
return 0;
}

Measured memory_bytes: 848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;
// 変数初期化
vector<ll> bsv; // binary_search用のvector
ll a,b,c,n,m;
typedef pair<ll, ll> Pll;
vector<Pll> facts; // 素因数分解の結果格納用(基数:乗数)
vector<vector<ll> > bit_search_v; //nit全探索の結果格納用

// index が条件を満たすかどうか
bool isOK(ll index, ll key) {
    if (bsv[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(int key) {
    int ng = -1;
    int ok = (ll)bsv.size();

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    // OK(key以上となる)のindex番号を返す
    return ok;
}

// 最大公約数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

// 最小公倍数
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

//　素因数分解
void prime_fact(ll target){
    ll base=2, exp=0;
    while (base*base<=target) {
        while (target%base==0) {
            target /= base; exp++;
        }
        if (exp>0) {
            facts.push_back(make_pair(base, exp));
        }
        base++; exp=0;
    }
    if (target>1) facts.push_back(make_pair(target,1));
}
// prime_factの結果の確認用
void print_facts(){
    for (int i=0; i<facts.size(); i++) {
        cout << facts[i].first << " " << facts[i].second << endl;
    }
}

// bit全探索
void bit_search(ll target){
    for (ll i=0; i<(1<<target); ++i) {
        if (i==0) continue;
        vector<ll> v;
        for (ll j=0; j<target; ++j) {
            if (i&(1<<j)) v.push_back(j);
            if (i&(1<<j)) cout << i << "  :  " << j << endl;
        }
        bit_search_v.push_back(v);
    }
}
// bit全探索の結果確認用
void print_bit_search(){
    for (ll i=0; i<bit_search_v.size(); ++i) {
        for (ll j=0; j<bit_search_v[i].size(); ++j) {
            cout << bit_search_v[i][j] << " ";
        }
        cout << endl;
    }
}



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

    ll n;
    cin >> n;

    ll tmp = 0;

    string ans = "";

    while(n > 0){
        
        tmp = n%26;
        n = (n-1)/26;
        
        ans += tmp != 0 ? char('a' + (tmp-1)) : 'z';
    }
    reverse(ALL(ans));
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 3044
n = int(input())
a = input().split()
a = sorted(list(map(int, a)))
def check(a):
    for i in range(n-1):
        if a[i] == a[i+1]:
            return 0
    return 1
if check(a) == 0:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 28340
/*
Hanit Banga
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 1e5 + 5;

bool seen[N] = {0};
int mx[N], v[N], d[N], c[N], col[N] = {0};
vector <int> g[N];

void dfs(int v, int d, int c);

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		mx[i] = -1;

	while (m--)
	{
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	int q;
	cin >> q;
	for (int i = 0; i < q; ++i)
		cin >> v[i] >> d[i] >> c[i];

	for (int i = q - 1; i >= 0; --i)
		dfs(v[i], d[i], c[i]);

	for (int i = 1; i <= n; ++i)
		cout << col[i] << endl;
}

void dfs(int v, int d, int c)
{
	if (d <= mx[v])
		return;

	if (!seen[v])
		col[v] = c;

	mx[v] = d;
	seen[v] = true;

	for (auto &i : g[v])
		dfs(i, d - 1, c);
}

Measured memory_bytes: 8568
n, x, y = map(int,input().split())

x-=1
y-=1
cnt = [0] * n

for i in range(n):
    for j in range(i+1, n):
        dist = min(j-i, abs(j-x) + 1 + abs(i-y),  abs(j-y) + 1 + abs(i-x))
        cnt[dist] += 1
        
for i in range(1, n):
    print(cnt[i])

Measured memory_bytes: 3444
package main

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

type Pos struct {
	y    int
	x    int
	turn int
}

func main() {
	vec := []int{1, 0, -1, 0}
	sc := NewScanner()
	H, W := sc.NextInt(), sc.NextInt()
	S := make([]string, H)

	field := make([][]int, H)
	for i := 0; i < H; i++ {
		field[i] = make([]int, W)
	}
	bfs := func(i, j, group int) (int, int) {
		queue := []Pos{}
		queue = append(queue, Pos{i, j, 0})
		black := 1
		white := 0
		field[i][j] = group
		for p := 0; p < len(queue); p++ {
			p := queue[p]

			for k := 0; k < len(vec); k++ {

				y := p.y + vec[k]
				x := p.x + vec[(k+1)%len(vec)]

				if x < 0 || x >= W {
					continue
				}
				if y < 0 || y >= H {
					continue
				}
				if field[y][x] > 0 {
					continue
				}
				if p.turn%2 == 0 && S[y][x] == '#' {
					continue
				}
				if p.turn%2 == 1 && S[y][x] == '.' {
					continue
				}
				queue = append(queue, Pos{y, x, p.turn + 1})
				if S[y][x] == '.' {
					white++
				} else {
					black++
				}
				field[y][x] = group
			}
		}

		return black, white
	}

	for i := 0; i < H; i++ {
		S[i] = sc.NextLine()
	}

	group := 1
	total := 0
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if S[i][j] == '.' || field[i][j] > 0 {
				continue
			}

			black, white := bfs(i, j, group)
			total += black * white
			group++
		}
	}
	fmt.Println(total)
}

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

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 14976
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, k;

    cin >> n >> k;

    ll res = 0;

    for (int i = k + 1; i <= n; i++)
    {
        ll sum = 0;

        ll num = i - k;

        sum += (n / i) * num; //((n - (i - 1)) / i + 1) * num;

        int ma = (n - (i - 1)) / i;

        /*
        int l = k - 1, r = i;

        while (r - l > 1)
        {
            int mid = (l + r) / 2;

            if (mid + i * (ma + 1) > n)
                r = mid;
            else
                l = mid;
        }

        if (r - l)
            sum += l - k + 1;
            */

        //if ((ma + 1) * i + k <= n)
        sum += max(0, (n % i) - k + 1);

        if (k == 0)
            sum--;

        res += sum;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 

#define REP(i,n) for(int i=0;i<n;++i)

string T, P;
struct SuffixArray {
	struct SAComp {
		const int h; const vector<int> &g;
		SAComp(const int h_, const vector<int>&g_) : h(h_), g(g_) { ; }
		bool operator() (int a, int b) {
			return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a + h] < g[b + h];
		}
	};

	static const int SIZE = 100000;
	int n;
	string str;
	vector<int> sa;
	vector<int> lcp;

	SuffixArray() { ; }
	SuffixArray(const string t) :str(t) {
		Init();
	}
	void Init() {
		n = str.size();
		buildSA();
		buildLCP();
	}

	// O(mlogn)

	////?????°????????????
	//int find(const string p) {
	//	int m = p.size();
	//	int left = 0;
	//	int right = n-m;
	//	while (left < right) {
	//		int mid = (left + right) / 2;
	//		if (str.substr(sa[mid],m)<p.substr(0,m)) { left = mid + 1; }
	//		else { right = mid; }
	//	}
	//	return str.substr(sa[left], m)== p.substr(0, m)? sa[left] : -1;
	//}
private:
	//O(nlog^2n)
	void buildSA() {
		sa = vector<int>(n + 1);
		vector<int>g(n + 1);
		vector<int>b(n + 1);
		REP(i, n + 1) { sa[i] = i; g[i] = str[i]; }
		b[0] = 0;
		b[n] = 0;
		SAComp f(0, g);
		sort(sa.begin(), sa.end(), SAComp(0, g));
		for (int h = 1; b[n] != n; h *= 2) {
			SAComp comp(h, g);
			sort(sa.begin(), sa.end(), comp);
			REP(i, n) b[i + 1] = b[i] + comp(sa[i], sa[i + 1]);
			REP(i, n + 1) g[sa[i]] = b[i];
		}
	}
	void buildLCP() {
		lcp = vector<int>(n + 1);
		int h = 0;
		vector<int>b(n + 1);
		REP(i, n + 1) { b[sa[i]] = i; }
		REP(i, n + 1) {
			if (b[i]) {
				for (int j = sa[b[i] - 1]; j + h < n && i + h < n && str[j + h] == str[i + h]; h++) { ; }
				lcp[b[i]] = h;
			}
			else {
				lcp[b[i]] = -1;
			}
			if (h > 0) { h--; }
		}
	}
};

int main() { cin >> T >> P;
vector<int>newsa;
{
	SuffixArray asa(T);
	vector<int>oldsa = asa.sa;
	for (auto s : oldsa) {
		newsa.push_back(s);
	}
}
	
	int r, l;
	{
		int amin = -1;
		int amax = newsa.size();
		while (amin + 1 != amax) {
			int amid = (amin + amax) / 2;
			string ast = T.substr(newsa[amid], P.size());
			if (ast <= P)amin = amid;
			else amax = amid;
		}
		r = amax;
	}
	{
		int amin = -1;
		int amax = newsa.size();
		while (amin + 1 != amax) {
			int amid = (amin + amax) / 2;
			string ast = T.substr(newsa[amid], P.size());
			if (ast < P)amin = amid;
			else amax = amid;
		}
		l = amax;
	}
	vector<int>nums;
	for (int i = l; i < r; ++i) {
		nums.push_back(newsa[i]);
	}
	sort(nums.begin(), nums.end());
	for (auto n : nums) {
		cout << n << endl;
	}
	
	return 0;
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;

int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall


        
    ini(n);
    ini(n1);
    int tmp1 = n;
    int tmp = abs(n-n1);
    if(n >n1){
        tmp1-=(n/n1)*n1;
        tmp = abs(tmp1-n1);
        }
    while(1){
           if(tmp<tmp1){
               tmp1 = tmp;
               int tmp_ = tmp;
               tmp = abs(tmp_-n1);
               continue;
           }
           else break;
       }
           out(tmp1);
    
    


    return 0;
}


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


int main()
{
	int n;
	cin >> n;
	int a[11];
	while (n--)
	{
		bool flag = true;
		int min_a = 0, min_b = 0;
		for (int i = 0; i < 10; i++)
			cin >> a[i];
		for (int j = 0; j < 10; j++)
		{
			if (a[j] > min_a)
			{
				if (min_a >= min_b)
				{
					min_a = a[j];
				}
				else
				{
					min_b = a[j];
				}
				continue;
			}
			else if (a[j] > min_b)
			{
				min_b = a[j];
			}
			else
			{
				flag = false;
				break;
			}
		}
		if (flag==true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
    return 0;
}

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

const int MAX = 110000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    COMinit();
    map<int, int> primeFactorCount;
    ll num = M;
    for (ll i = 2; i * i <= num; i++)
    {
        while (num % i == 0)
        {
            primeFactorCount[i]++;
            num /= i;
        }
    }
    if (num > 1)
    {
        primeFactorCount[num]++;
    }
    //各素数要素をNのうちどこにいくつ入れるかを検討
    //これは間に区切りを入れる通り数になるので二項係数で求められる (2が二つあってNが四なら(空)|(空)|2|2の感じで0,0, 1, 1などで分けられるが、これは5C2で10通りと求められる)
    ll answer = 1;
    for(auto primeFactor: primeFactorCount)
    {
        answer = answer * COM(N - 1 + primeFactor.second, N - 1) % MOD;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 2816
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

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

    int n, k; cin >> n >> k;
    if(k != 1) {
        cout << n - k << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
def main():
    H,W,M = map(int,input().split())
    row = [0 for i in range(H)]
    col = [0 for i in range(W)]
    target  = set()

    for _ in range(M):
        h,w = map(lambda x: int(x)-1,input().split())
        row[h] += 1
        col[w] += 1
        target.add((h,w))
    max_r = max(row)
    max_w = max(col)

    candidate_r = []
    for i,r in enumerate(row):
        if r == max_r:
            candidate_r.append(i)
    candidate_c = []
    for i,c in enumerate(col):
        if c == max_w:
            candidate_c.append(i)

    for idx_r in candidate_r:
        for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
    print(max_r+max_w-1)
    return

if __name__ == '__main__':
    main()

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

#define ll long long
#define pb push_back
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f

// 000 ou 111 -> left == i and right == i -> pinta i
// 100 ou 110 -> left == i -> pinta left
// 001 ou 011 -> right == i -> pinta right

/*
 10010010
 10110010
 */

char inverse(char c){
    return (c == '0' ? '1' : '0');
}

int main(){
    fcin;
    string str;
    cin >> str;
    int ans = 0;

    for(int i = 0; i < str.size(); i++){
        if(str[i] == str[i-1] and str[i] == str[i+1]){
            str[i] = inverse(str[i]);
            ans++;
        } else if(str[i] == str[i-1]){
            str[i-1] = inverse(str[i-1]);
            ans++;
        } else if(str[i] == str[i+1]){
            str[i+1] = inverse(str[i+1]);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

#define rep(i, a, n) for(int i = a; i < (n); ++i)

template<class T>
int Divisor(T Num)
{
    int res = 0;
    for(T i = 1; i * i <= Num; ++i)
    {
        if (Num % i == 0)
        {
            ++res;
            if (i * i != Num) ++res;
        }
    }
    
    return res;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n+1)
    {
        if (i % 2 == 1)
        {
            if (Divisor(i) == 8) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
inline int _ceil(ri a,ri b){
	return (a+(b-1))/b;
}
inline int calc(ri a,ri b){
	if(a<b) swap(a,b);
	return _ceil(a,b+1);
}
int main(){
	ri q,i,a,b,c,d,p,k,l,r,mid,nowa,nowb;
	gi(q);
	while(q--){
		gi(a);gi(b);gi(c);gi(d);
		k=calc(a,b);
		l=0;r=a+b-1;
		p=0;
		while(l<=r){
			mid=l+r>>1;
			nowb=mid/(k+1);
			nowa=mid-nowb;
		//	printf("check %d %d %d %d %lld\n",mid,nowa,nowb,b-nowb,(ll)(a-nowa)*k); 
			if(nowa+1<=a&&nowb<=b&&b-nowb<=(ll)(a-nowa)*k)
				p=mid+1,
				l=mid+1;
			else
				r=mid-1;
		}
	//	printf("mid = %d\n",mid);
		l=c;r=min(d,p);
	//	printf("l = %d r = %d\n",l,r);
		if(l<=r)
			for(i=l;i<=r;++i)
				if(i%(k+1)==0)
					putc('B');
				else
					putc('A');
		l=max(c,p+1);r=d;
	//	printf("l = %d r = %d\n",l,r);
		if(l<=r)
			for(i=l;i<=r;++i)
				if((a+b-i+1)%(k+1)==0)
					putc('A');
				else
					putc('B');
		putc('\n');
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n, d;
    cin >> n >> d;

    int ans = 0;
    int cnt = 0;
    while (true) {
        cnt += 2 * d + 1;
        ans++;
        if (cnt >= n) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3612
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b] <- getIntList
    print $ lcm a b

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> cnt(n);
    rep(i,m){
        int a,b;
        cin >> a >> b ;
        --a;--b;
        cnt[a] ++;
        cnt[b] ++;
    }
    rep(i,n){
        if(cnt[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640
import collections

N, M = map(int, input().split())
WA_CNT = {}
CLEAR = {}
for i in range(M):
    P, S = input().split()
    if P in CLEAR:
        continue
    if S == "AC":
        CLEAR[P] = 1
        continue

    if not P in WA_CNT:
        WA_CNT[P] = 0
    WA_CNT[P] += 1


num = len(CLEAR)
try_num = 0
for i in CLEAR:
    if i in WA_CNT:
        try_num += WA_CNT[i]
print("{} {}".format(num, try_num))

Measured memory_bytes: 22276
#include <algorithm>
#include <iostream>
#include <string>
 
int main()
{
	std::string const NAME_LETTER = "abcdefghijklmnopqrstuvwxyz";
	long long n = 0LL;
 
	std::cin >> n;
 
	std::string dogName;
 
	while (n > 0)
	{
    	--n;
		dogName.push_back(NAME_LETTER.at(n % 26));
		n /= 26;
	}
 
	std::reverse(dogName.begin(), dogName.end());
 
	std::cout << dogName << std::endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	vector<int>b(N);
	int n = N / 2 + 1;
	for (int i = N; i >= 1; i--) {
		if (i >= n)b[i - 1] = a[i - 1];
		else {
			int num = N / i;
			int sum = 0;
			for (int j = 2; j <= num; j++) {
				sum += b[j * i - 1];
			}
			sum %= 2;
			if (sum == a[i - 1])b[i - 1] = 0;
			else b[i - 1] = 1;
		}
	}
	int M = 0;
	rep(i, N)M += b[i];
	cout << M << endl;
	rep(i, N) {
		if (b[i])cout << i + 1 << " ";
	}
}

Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<cctype>
using namespace std;

#define MAX_N 10000

string S[MAX_N];
int pass;
int miss[MAX_N];
int over[MAX_N];
int misscnt, totalcnt;
int n, m;
string a;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> S[i] >> over[i];
	}
	for (int i = 0; i < n; i++) {
		pass = 0;
		while (pass != S[i].size()) {
			cout << "? ";
			cout << S[i] << endl;
			cin >> a;
			totalcnt++;
			if (tolower(a[0]) == tolower(S[i][pass])) { 
				S[i][pass] = '_'; pass++; misscnt++; 
			}
			else {
				miss[i]++;
				if (miss[i] > over[i]) {
					m--; break;
				}
			}
		}
		if (m <= 0) { 
			cout << "! Game Over" << endl; return 0; 
		}
	}
	cout << fixed << setprecision(1) << "! Game Clear " << (double)((int)(1000 * misscnt / totalcnt) / 10.0) << endl;
	return 0;
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> data(3);
  for(int i = 0; i < 3; ++i) cin >> data.at(i);
  sort(data.begin(), data.end());
  
  cout << data.at(0) + data.at(1) << endl;
}

Measured memory_bytes: 256