akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
long a[100005];
long b[100005];
long ans[100005];

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        scanf("%ld", a+i);
    }
    for(int i = 0; i < n; i++){
        b[i+1] = a[i] - b[i];
        //printf("%ld ", b[i+1]);
    }
    ans[0] = b[n];
    for(int i = 1; i < n; i++){
        ans[i] = a[i-1]*2 - ans[i-1];
    }
    for(int i = 0; i < n; i++){
        printf("%ld ", ans[i]);
    }
    printf("\n");
}


Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
struct edge
{
    int to, cost;
};
int zalgo(string S)
{
    vector<int> A(S.size());
    A[0] = S.size();
    int i = 1, j = 0;
    while (i < S.size())
    {
        while (i + j < S.size() && S[j] == S[i + j]){
            ++j; //共通文字を数える
        }
        A[i] = j;
        if (j == 0)
        {
            ++i;
            continue;
        }
        int k = 1;
        while (i + k < S.size() && k + A[k] < j)
            A[i + k] = A[k], ++k; //上で一致した数がk文字目の一致した数とkを足した数
        //より小さい時A[k+i]を上回る可能性はなくスタート直後の一致文字列の長さと同じになる
        i += k;
        j -= k;
    }
    int ans=0;
    for(int i=0;i<S.size();i++){
        ans=max(ans,min(A[i],i));
    }
    return ans;
}
int n;
string s;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;

    int ans = 0;
    for(int i=0;i<n;i++){
        string temp=s.substr(i);
        ans=max(ans,zalgo(temp));
    }
    cout << ans << "\n";
}


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

int main(){
  int n;
  std::cin >> n;

  std::vector<ll> a(n);
  rep(i,n){
    std::cin >> a[i];
  }

  sort(a.rbegin(),a.rend());

  if(a[a.size()-1]==0){
    std::cout << 0 << '\n';
    return 0;
  }

  ll ans=a[0];
  ll max=pow(10,18);

  for (int i = 1; i < a.size(); i++) {

    if(max/ans>=a[i])ans*=a[i];
    else {
      std::cout << -1 << '\n';
      return 0;
    }

  }
  std::cout << ans << '\n';


  return 0;
}


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

using namespace std;

using ll=long long;

int main(){
    ll N,W;
    cin>>N>>W;
    vector<vector<int>>t(4);
    ll ww;
    int vv;
    cin>>ww>>vv;
    t[0].push_back(vv);
    for(int i=1;i<N;++i){
        int w,v;
        cin>>w>>v;
        t[w-ww].push_back(v);
    }
    sort(t[0].begin(),t[0].end(),greater<int>());
    sort(t[1].begin(),t[1].end(),greater<int>());
    sort(t[2].begin(),t[2].end(),greater<int>());
    sort(t[3].begin(),t[3].end(),greater<int>());
    for(int i=0;i<4;++i){
        int pre=0;
        for(auto& x:t[i]){
            x += pre;
            pre=x;
        }
    }
    t[0].insert(t[0].begin(),0);
    t[1].insert(t[1].begin(),0);
    t[2].insert(t[2].begin(),0);
    t[3].insert(t[3].begin(),0);
    int ans=0;
    for(ll i=0;i<=t[0].size()-1;++i){
        for(ll j=0;j<=t[1].size()-1;++j){
            for(ll k=0;k<=t[2].size()-1;++k){
                for(ll l=0;l<=t[3].size()-1;++l){
                    if(W<ww*(i+j+k+l)+j+2*k+3*l){
                        break;
                    }
                    ans=max(ans,t[0][i]+t[1][j]+t[2][k]+t[3][l]);
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  
  static void Main(string[] args){
    program p = new program();
    p.Sta();
  }
  void Sta(){
    WriteLine(Run());
  }
  
  string Run(){
	string c =ReadLine();
    string s = "abcdefghijklmnopqrstuvwxyz";
    int n = s.IndexOf(c);
    return s.Substring(n+1,1);
  }

}

Measured memory_bytes: 13280
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	A = list(rli())
	for i, n in enumerate(A, 1):
		if n == 0:
			print(i)
			break
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 65104
import std.stdio, std.string, std.conv;

void main() {
    auto input = getStdin!(string[])[0];
    auto num = input.split(" ").to!(int[]);
    int a = num[0];
    int b = num[1];
    int c = num[2];
    int count = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
        	count++;
        }
    }
    count.writeln;
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

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

typedef long long ll;


#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18


int main() {
    ll N,M; cin >> N >> M;
    vector<ll> A(N);
    ll sum = 0;
    map<ll,ll> B;
    REP(i,N){
        cin >> A[i];
        sum += A[i];
        B[sum%M] ++;
    }

    ll ans = B[0]; 
    for(auto n: B){
        ans += n.second * (n.second-1) / 2;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 7956
n=int(input())
p=sorted(list(map(int,input().split())))
s=set()
m = 10**6+1
a=[True for _ in range(m)]
prev = 0
for x in p:
    if prev == x:
        s.discard(x)
        continue
    if a[x]:
        s.add(x)
    i = 2
    y = i*x
    while y<m:
        a[y] = False
        i+=1
        y = i*x
    prev=x

print(len(s))


Measured memory_bytes: 197584
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[112];

int main(){
	scanf("%s",in);
	for(int i=0;in[i];i++)in[i]='x';
		printf("%s\n",in);
}

Measured memory_bytes: 128
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, M = LI()
S = LI()
T = LI()

MOD = 10 ** 9 + 7


def main():
    dp = [[0] * (M + 1) for _ in range(N + 1)]
    for i in range(1, N + 1):
        for j in range(1, M + 1):
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1]
            dp[i][j] %= MOD
            if S[i - 1] == T[j - 1]:
                x = 1 + dp[i - 1][j - 1]
                dp[i][j] = (dp[i][j] + x) % MOD
    
    ans = (dp[-1][-1] + 1) % MOD
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  string cm;
  int sx = 0;
  int gx,gy;
  vector<int> xs;
  vector<int> ys;
  cin >> cm >> gx >> gy;
  int cnt = 0;
  bool virgin = true;
  bool modex = true;
  bool xok[16001];
  bool yok[16001];
  bool okt[16001];

  
  for(int i=0;i<16001;++i){
    xok[i] = false;
    yok[i] = false;
  }
  for(int i=0;i<cm.length();++i){
    if(cm[i]=='T' || i==cm.length()-1){
      if(cm[i] == 'F' && i==cm.length()-1){
	cnt++;
      }
      if(virgin){
	sx = cnt;
	virgin = false;
      }else{
	if(modex){
	  xs.push_back(cnt);
	}else{
	  ys.push_back(cnt);
	}
      }
      cnt = 0;
      modex = !modex;
    }else{
      cnt+=1;
    }
  }
  xs.push_back(0);
  ys.push_back(0);
  cerr<<gx<<","<<gy<<","<<sx<<endl;
  for(int i=0;i<xs.size();++i){
    cerr<<xs[i]<<",";
  }
  cerr<<endl;
  for(int i=0;i<ys.size();++i){
    cerr<<ys[i]<<",";
  }
  cerr<<endl;
  xok[sx+8000] = true;
  yok[8000] = true;
  for(int j=0;j<16001;++j){
    okt[j] = xok[j];
    xok[j] = false;
  }
  
  for(int i=0;i<xs.size();++i){
    for(int j=0;j<16001;++j){
      if(okt[j]){
	//cerr<<j<<","<<xs[i]<<endl;
	xok[j-xs[i]] = true;
	xok[j+xs[i]] = true;
      }
    }
    for(int j=0;j<16001;++j){
      okt[j] = xok[j];
      if(i!=xs.size()-1){
	xok[j] = false;
      }
    }
    //cerr<<"**"<<endl;
  }
  //cerr<<"---"<<endl;
  for(int j=0;j<16001;++j){
    okt[j] = yok[j];
    yok[j] = false;
  }
  for(int i=0;i<ys.size();++i){
    for(int j=0;j<16001;++j){
      if(okt[j]){
	//cerr<<j<<","<<ys[i]<<endl;
	yok[j-ys[i]] = true;
	yok[j+ys[i]] = true;
      }
    }
    for(int j=0;j<16001;++j){
      okt[j] = yok[j];
      if(i!= ys.size()-1){
	yok[j] = false;
      }
    }
    //cerr<<"**"<<endl;
  }
  if(xok[8000+gx] && yok[8000+gy]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include "math.h"
using namespace std;
int a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d) cout<<"Yes"<<endl;
	else if(abs(a-b)<=d&&abs(b-c)<=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

int main() {
  int N=0;
  cin>>N;
  long long ans=0;
  rep(i,N+1){
    if(!(i%3==0||i%5==0)){
      ans+=i;
    }
  }
    cout<<ans;
}


Measured memory_bytes: 3636
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;
typedef vector<ll> vll;


ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n, z, w;
        cin >> n >> z >> w;
        vll a(n);
        rep(i, n)cin >> a[i];
        ll ans = abs(a.back() - w);
        if (n > 1) ans = max(ans, abs(a[a.size() - 2] - a.back()));
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e17;
constexpr const ll MOD = 1000000007;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
typedef pair<ll,ll> P;
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n;
    cin >> a >> b >> n;
    ll k;
    if (n < b-1) k = n;
    else k = b-1;
    PRINT(floor(a*k/b)-a*floor(k/b));
}


Measured memory_bytes: 3804
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,W,h,w;
	scan(H);scan(W);scan(h);scan(w);
	prin((H-h)*(W-w));

	return 0;
}


Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, m, l := scanInt(), scanInt(),scanInt()

	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		for j := 0; j < n; j++ {
			g[i][j] = 1<<32
		}
	}

	for i := 0; i < n; i++ {
		g[i][i] = 0
	}

	for i := 0; i < m; i++ {
		a,b,c := scanInt()-1, scanInt()-1,scanInt()
		g[a][b] = c
		g[b][a] = c
	}

	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				g[i][j] = min(g[i][j], g[i][k]+g[k][j])
			}
		}
	}

	f := make([][]int, n)
	for i := 0; i < n; i++ {
		f[i] = make([]int, n)
		for j := 0; j < n; j++ {
			f[i][j] = 1<<32
		}
	}

	for i := 0; i < n; i++ {
		f[i][i] = 0
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if g[i][j] <= l {
				f[i][j] = 1
			}
		}
	}

	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				f[i][j] = min(f[i][j], f[i][k]+f[k][j])
			}
		}
	}

	q := scanInt()

	for i := 0; i < q; i++ {
		s,t := scanInt()-1, scanInt()-1
		if f[s][t] == 1<<32 {
			fmt.Fprintln(wr, -1)
		} else {
			fmt.Fprintln(wr,f[s][t]-1)
		}
	}

	wr.Flush()

}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] {
			res = a[i]
		}
	}
	return res
}


Measured memory_bytes: 4608
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int, C: "List[int]"):
    pows = [1]
    for i in range(N):
        pows.append(pows[i] * 2 % MOD)

    C.sort(reverse=True)
    ret = 0
    for i, v in enumerate(C):
        if i > 0:
            ret += (pows[i] + pows[i - 1] * i) * (pows[N - i - 1]) * v
        else:
            ret += pows[i] * (pows[N - i - 1]) * v
    ret = ret * pows[N] % MOD
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36852
N = int(input())
A = input().strip()
B = input().strip()
C = input().strip()

cost = 0
for i in range(N):
  s = set()
  s.add(A[i])
  s.add(B[i])
  s.add(C[i])
  cost += len(s) - 1

print(cost)


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
const int mod=1e9+7,inv2=(mod+1)/2;
int n,q;
int a[3005],f[3005][3005],mi=1,ans=0;
int main()
{
	n=read(),q=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++) f[i][j]=a[i]>a[j];
	while(q--)
	{
		mi=mi*2%mod;
		int x=read(),y=read();
		for(int j=1;j<=n;j++)
		{
			if(j==x||j==y) continue;
			f[x][j]=f[y][j]=1ll*inv2*(f[x][j]+f[y][j])%mod;
			f[j][x]=f[j][y]=1ll*inv2*(f[j][x]+f[j][y])%mod;
		}
		f[x][y]=f[y][x]=1ll*inv2*(f[x][y]+f[y][x])%mod;
	}
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++) ans=(ans+f[i][j])%mod;
	ans=1ll*ans*mi%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 38956
n = int(input())
li = [''.join(sorted(input())) for _ in range(n)]

ans = 0
w_dic = {}
for l in li:
  if not w_dic.get(l):
    w_dic[l] = 1
  else:
    ans += w_dic[l]
    w_dic[l] = w_dic[l] + 1

print(int(ans))

Measured memory_bytes: 19404
S = input()
okay_num_As = [1, 0, 0, 1, 1, 1]

S_without_A = "".join([char for char in S if char != "A"])
# print(S_without_A)
if S_without_A != "KIHBR":
    print("NO")
    exit(0)

cur_num_As = 0
cur_idx_bet = 0
for char in S:
    if char == "A":
        cur_num_As += 1
    else:
        if okay_num_As[cur_idx_bet] < cur_num_As:
            print("NO")
            exit(0)
        cur_num_As = 0
        cur_idx_bet += 1


print("YES" if okay_num_As[-1] >= cur_num_As else "NO")
# print("YES")


Measured memory_bytes: 3064
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = n%10;
        String ans = "";
        if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9) {
            ans = "hon";
        }
        else if (r == 0 || r == 1 || r == 6 || r == 8) {
            ans = "pon";
        }
        else {
            ans = "bon";
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35796
#include<bits/stdc++.h>
    #define ll  long long
    #define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define rep(i,a,b)  for(ll i=a;i<b;i++)
    #define per(i,a,b)  for(ll i=b-1;i>=a;i--)
    #define pb push_back
    #define Max(x,y,z) max(x,max(y,z))
    #define f first
    #define s second
    #define lbd lower_bound
    #define sz(x)       (ll)x.size()
    #define pi 3.1415926536
    #define mod 1000000007
    #define MOD 998244353
    #define maxi 100000000000000000
    using namespace std;
    const int N=120;
    /*bool isprime(ll x)
    {
        for(ll i=2;(i*i)<=x;i++)
        {
            if(x%i==0) return 0;
        }
        return 1;
    }*/
    /*ll power(ll x,ll n)
    {
        ll res=1;
        while(n>0){
        if(n%2) res=(res*x)%mod;
        x=(x*x)%mod;
        n=n/2;}
        return res;
    }*/
    void solve()
    {
                ll n,m,l=0,r=0,z,sum1=0,h,a,b,c,d,x=0,y=0;
                    cin>>m>>d;
                    ll ans=0;
                    rep(j,1,m+1){
                    rep(i,10,d+1)
                    {
                        x=i/10;
                        y=i%10;
                        if((x*y)==j && x>=2 && y>=2) ans++;
                    }}
                    cout<<ans;
    }

            int main()
            {
                speed_up
                ll t=1;
                //cin>>t;
                while(t--)
                    solve();
            }


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

int main(){
    int x[3];
    rep(i,3){
        cin >> x[i];
    }
    swap(x[0],x[1]);
    swap(x[0],x[2]);
    rep(i,3){
        cout << x[i] << " ";
    }
}

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

string s;

bool isPalindrome(string& str)
{
    bool res = true;
    int sz = str.size();
    for(int i=0;i<sz;i++){
        if(s[i]!=s[sz-i-1]) res = false;
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);

    cin>>s;

    int n=s.size();

    string str1 = s.substr(0,n/2);
    string str2 = s.substr((n/2)+1,n/2);

    bool res = isPalindrome(s)&&isPalindrome(str1)&&isPalindrome(str2);

    cout<<(res?"Yes":"No");
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 998244353;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

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

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout <<"Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 888
def vax(S, num):
    nums = [999]
    index = [ i for i, x in enumerate(S) if x == str(num) and i <= len(S) - 3]
    for i in index:
        nums.append(abs(753 - int( S[i] + S[i+1] + S[i+2])))
    return min(nums)

S = list(input())
ans = 999
for i in range(10):
    ans = min(vax(S, i), ans)
print(ans)

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


int main(){
  int n, c; cin >> n >> c;
  int d[c][c];
  vector<vector<int>> vamari(3);
  rep(i, c) rep(j, c){
    cin >> d[i][j];
  }
  //vector<vector<int>> v(n, vector<int>(n));
  int v[n][n];
  rep(i, n) rep(j, n){
    cin >> v[i][j];
    vamari[(i + j) % 3].push_back(v[i][j] - 1);
  }

  int ans = 1000000000;
  rep(ch0, c){
    int sum0 = 0;
    rep(i, vamari[0].size()){
      sum0 += d[vamari[0][i]][ch0];
    }
    rep(ch1, c){
      if(ch0 == ch1) continue;
      int sum1 = sum0;
      rep(i, vamari[1].size()){
        sum1 += d[vamari[1][i]][ch1];
      }

      rep(ch2, c){
        if(ch0 == ch2 || ch1 == ch2) continue;
        int sum2 = sum1;
        //cout << ch0 << " " << ch1 << " " << ch2 << endl;
        rep(i, vamari[2].size()){
          sum2 += d[vamari[2][i]][ch2];
        }

        ans = min(ans, sum2);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int k,n;
    cin>>k>>n;
    vector<int> a(n,0);
    rep(i,n) cin>>a.at(i);
    vector<int> dist(n);
    dist[0]=a[0]+k-a[n-1];
    REP(i,1,n){
        dist[i]=a[i]-a[i-1];
    }
    sort(all(dist));
    int ans=0;
    rep(i,n-1) ans+=dist[i];
    cout<<ans<<endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N;
	cin >> N;
	vecl(A);
	ll k = 1E18;
	ll ans = 1;
	fx(N) {
		vecpl(A);
		if (A[x]==0) {
			ce(0);
			return 0;
		}
		k /= A[x];
		ans *= A[x];
	}

	if (k==0) {
		ce(-1)
			return 0;
	}

	ce(ans)

    return 0;
}



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  string s;
  cin >> s;
  int n = s.size();
  int w = 0, b = n - 1;
  ll cnt = 0;
  rep (i, n) {
    if (s[i] == 'W') {
      cnt += i - w;
      w++;
    }
  }
  cout << cnt << endl;
}


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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() > k) {
        s = s.substr(0, k) + "...";
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3616
N, M = map(int, input().split())
man = [[int(x) for x in input().split()] for _ in range(N)]
check = [[int(x) for x in input().split()] for _ in range(M)]

for a, b in man:
    tmp = 1000000000
    ans = 1
    for i, (c, d) in enumerate(check):
        if tmp > (abs(a-c) + abs(b-d)):
            tmp = min(tmp, abs(a-c) + abs(b-d))
            ans = i+1
    print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Int64 B = 1;
        static Int64 G = 1;
        static Int64 R = 1;
        static Int64 Bsig = 0;
        static Int64 Gsig = 0;
        static Int64 Rsig = 0;
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();

            char[] ch = str.ToCharArray();
            if (n < 3200)
            {
                Console.WriteLine("red");
            } else
            {
                Console.WriteLine(str);
            }

        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    int tmp=0,ans=0;
    REP(i,n){
        if(s[i]=='I'){
            tmp++;
            ans=max(ans,tmp);
        }
        else tmp--;
    }
    cout<<ans<<endl;
}

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




int main(){
    int x[5];
    
    for(int i=0;i<5;i++){
        cin>>x[i];
        if(x[i]==0){
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }






int main() {
  cout<<fixed<<setprecision(10);

  string s;cin>>s;
  ll ans = s.size();

  rep(i,26){
    ll cnt = 0;
    ll cntmax = 0;
    rep(j,s.size()){
      if(s[j]-'a'==i){
        cntmax = max(cntmax,cnt);
        cnt = 0;
      }else{
        cnt++;
      }
    }
    cntmax = max(cntmax,cnt);
    ans = min(ans,cntmax);

  }

  cout << ans << endl;



}

















//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100010];
queue<int>que;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
        que.push(a[i]);
    int ans=que.front();
    que.pop();
    int flag;
    while(!que.empty())
    {
        flag=0;
        int num=que.front();
        que.pop();
        int maxx=max(ans,num);
        int minn=min(ans,num);
        while(maxx && minn)
        {
            if(maxx%minn==0)
            {
                ans=minn;
                flag=1;
            }
            else
            {
                if(maxx>minn)
                {
                    maxx=maxx%minn;
                }
                else if(maxx==minn)
                {
                    ans=minn;
                    flag=1;
                }
                else
                {
                    int temp;
                    temp=minn;
                    minn=maxx;
                    maxx=temp;
                }
            }
            if(flag==1) break;

        }
        if(minn==0) ans=maxx;
            else ans=minn;
//        cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


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

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start();
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int x = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int x = vs[1];
			int y = vs[2];
			int[,] g = new int[n + 1, 3];
			for (int i = 1; i <= n; i++) {
				if (i > 1) {
					g[i, 0] = i - 1;
				}
				if (i < n) {
					g[i, 1] = i + 1;
				}
				if (i == x) {
					g[i, 2] = y;
				}
				if (i == y) {
					g[i, 2] = x;
				}
			}

			int[,] distance = new int[n + 1, n + 1];
			Queue<Tuple> queue = new Queue<Tuple>();
			for (int from = 1; from <= n; from++) {
				queue.Clear();
				queue.Enqueue(new Tuple() { n = from, d = 0 });

				while (queue.Count > 0) {
					Tuple tup = queue.Dequeue();
					for (int j = 0; j < 3; j++) {
						if (g[tup.n, j] > 0 && g[tup.n, j] != from) {
							int to = g[tup.n, j];
							if (distance[from, to] == 0 || tup.d + 1 < distance[from, to]) {
								distance[from, to] = tup.d + 1;
								//System.Diagnostics.Debug.WriteLine($"{from} -> {to} : {tup.d + 1}");
								queue.Enqueue(new Tuple() { n = to, d = tup.d + 1 });
							}
						}
					}
				}
				//System.Diagnostics.Debug.WriteLine("--");
			}

			int[] ans = new int[n - 1];
			for (int i = 1; i < n + 1; i++) {
				for (int j = i + 1; j < n + 1; j++) {
					ans[distance[i, j] - 1]++;
				}
			}
			for (int i = 0; i < n - 1; i++) {
				Console.WriteLine(ans[i]);
			}


			//Console.Out.Flush();
			//System.Diagnostics.Debug.WriteLine(sw.Elapsed);
		}
	}

	public class Tuple
	{
		public int n;
		public int d;
	}
}

Measured memory_bytes: 32904
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

struct node {
    i64 counter{0};
    std::vector<int> link;
};

void dfs(std::vector<node>& ns, std::vector<bool>& visit, const std::unordered_map<int,int>& cost, int id) {
    node& n = ns[id];
    visit[id] = true;
    auto it = cost.find(id);
    if (it != cost.end()) n.counter += it->second;
    for (int c : n.link) {
        if (visit[c]) continue;
        ns[c].counter = n.counter;
        dfs(ns, visit, cost, c);
    }
}

int main(int argc, char **argv) {
    int n, q;
    cin >> n >> q;

    std::vector<node> nodes(n+1);
    std::vector<bool> visit(n+1, false);
    nodes.push_back(node());
    std::unordered_map<int, int> ps;

    for (int i=1; i<n; ++i) {
        int a, b;
        cin >> a >> b;
        nodes[a].link.push_back(b);
        nodes[b].link.push_back(a);
    }

    for (int i=0; i<q; ++i) {
        int p, x;
        cin >> p >> x;

        auto it = ps.find(p);
        if (it != ps.end()) {
            it->second += x;
        } else {
            ps.insert(make_pair(p, x));
        }
    }

    dfs(nodes, visit, ps, 1);

    for (int i=1; i < n+1; ++i) {
        cout << nodes[i].counter << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 39828
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    string s;
    cin >> s;
    vi a(24, 0);

    bool flag = true;
    for (char c = 'a'; c <= 'z'; c++)
    {
        int count = 0;
        rep(i, s.size())
        {
            if (c == s[i])
            {
                count++;
            }
        }
        if (!(count % 2 == 0))
        {
            flag = false;
            break;
        }
    }

    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    int a[n][n+1];
    int d[n]={0};
    for(int i=1;i<n;i++){
        for(int j=i+1;j<n+1;j++){
            a[i][j]=min(j-i,abs(x-i)+abs(y-j)+1);
            d[a[i][j]]++;
        }
    }
    for(int k=1;k<n;k++){
        cout<<d[k]<<'\n';
    }
    return 0;
}

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

const int inf=1e9;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,h,k;
	while(cin>>n>>m>>h>>k,n){
		vector<tuple<int,int,int,int> > v[101];
		for(int i=0;i<m;i++){
			int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
			a--;b--;e--;
			v[a].push_back(make_tuple(b,c,d,e));
			v[b].push_back(make_tuple(a,c,d,e));
		}
		int s,t;cin>>s>>t;
		s--;t--;
		int p;cin>>p;
		int a[500],b[500];
		for(int i=0;i<p;i++){
			int l,d;cin>>l>>d;
			int now=0;
			for(int j=0;j<l;j++){
				int tmp;cin>>tmp;
				tmp--;
				now|=(1<<tmp);
			}
			a[i]=d;
			b[i]=now;
		}
		int dp[300][300];
		for(int i=0;i<300;i++)for(int j=0;j<300;j++)dp[i][j]=inf;
		dp[0][0]=0;
		for(int i=0;i<p;i++){
			for(int j=0;j<(1<<k);j++){
				dp[i+1][j|b[i]]=min(dp[i+1][j|b[i]],dp[i][j]+a[i]);
				dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			}
		}
		int ans=inf;
		for(int i=0;i<(1<<k);i++){
			if(dp[p][i]==inf)continue;
			int d[101][25];
			for(int j=0;j<n;j++)for(int k=0;k<=h;k++)d[j][k]=inf;
			d[s][0]=0;
			priority_queue<tuple<int,int,int> > q;
			q.push(make_tuple(0,s,0));
			while(!q.empty()){
				int now=get<1>(q.top());
				int nowcost=-get<0>(q.top());
				int nowh=get<2>(q.top());
				q.pop();
				if(nowcost>d[now][nowh])continue;
				for(int j=0;j<(int)v[now].size();j++){
					int next=get<0>(v[now][j]);
					int next_h=get<2>(v[now][j]);
					int next_cost=get<1>(v[now][j]);
					int cop=get<3>(v[now][j]);
					if(i&(1<<cop))next_cost=0;
					if(nowh+next_h<=h && d[next][nowh+next_h]>d[now][nowh]+next_cost){
						d[next][nowh+next_h]=d[now][nowh]+next_cost;
						q.push(make_tuple(-d[next][nowh+next_h],next,nowh+next_h));
					}
				}
			}
			int res=inf;
			for(int j=0;j<=h;j++)res=min(res,d[t][j]);
			ans=min(res+dp[p][i],ans);
		}
		if(ans==inf)cout<<-1<<endl;
		else cout<<ans<<endl;
	}
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, p[maxn], t;
char s[maxn];
long long ans;

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int j;
	for (int i = 1; i <= n; i = j + 1) {
		t = 0;
		for (j = i; j <= n; ) {
			if(s[j] == 'A') {
				p[++t] = 1;
				++j;
				continue;
			}
			if(s[j] == 'B' && j < n && s[j + 1] == 'C') {
				p[++t] = 2;
				j += 2;
				continue;
			}
			break;
		}
		long long now = 0;
		for (int k = 1; k <= t; ++k) {
			if(p[k] == 1) ++now;
			else ans += now;
		}
	} 
	printf("%lld\n", ans);
	return 0;
}

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

#define MOD 1000000007
#define fastio std::ios_base::sync_with_stdio(false);
#define ll long long
#define matrix vector <vector <ll> >

int main(){

    fastio;
    
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << "Yes";
    else                   cout << "No";

    return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

unordered_map<string, int> mm[19];

int n;
string s;


int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	ll ans = 0;
	cin >> n;
	cin >> s;
	string t = s.substr(n, n);
	reverse(t.begin(), t.end());
	s = s.substr(0, n);
	for (int i = 0; i < (1 << n); ++i) {
		string a, b;
		for (int j = 0; j < n; ++j) {
			if ((i >> j) & 1)
				a += s[j];
			else
				b += s[j];
		}
		reverse(b.begin(), b.end());
		int c = a.size();
		mm[c][a + b] += 1;
	}
	for (int i = 0; i < (1 << n); ++i) {
		string a, b;
		for (int j = 0; j < n; ++j) {
			if ((i >> j) & 1)
				a += t[j];
			else
				b += t[j];
		}
		reverse(b.begin(), b.end());
		int c = a.size();
		ans += mm[c][a + b];
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 69044