akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long ans;
  string s;
  int i,j,k;
  long five[5] = {};
  for(i=0;i<n;i++){
    s = "";
    cin >> s;
    if(s[0]=='M')five[0]++;
    else if(s[0]=='A')five[1]++;
    else if(s[0]=='R')five[2]++;
    else if(s[0]=='C')five[3]++;
    else if(s[0]=='H')five[4]++;
  }
  for(i=0;i<3;i++){
    for(j=i+1;j<4;j++){
      for(k=j+1;k<5;k++){
        ans += five[i]*five[j]*five[k];
      }
    }
  }
  cout << ans;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int N,K, S;
vi v;

void solve(){
    rep(i, K){
        v.push_back(S);
    }

    if(N > K){
        rep(i, N-K){
            if(S==1) v.push_back(S+1);
            else v.push_back(S - 1);
        }
    }

    rep(i, N){
        cout << v[i];

        if(i==N-1) cout << endl;
        else cout << " ";
    }
}

int main(){
    cin >> N >> K >> S;

    solve();
}


Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <functional>
using namespace std;

int main(){
    int a;
    cin >> a;
    cout << a+ pow(a,2)+pow(a,3) << endl;
}

Measured memory_bytes: 4196
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char **argv)
{
        string s;
        cin >> s;
        int64_t n = s.size(), m = 1 << (n - 1);
        int64_t sum = 0;
        for (int64_t i = 0; i < m; i++) {
                int64_t num = 0;
                for (int64_t j = 0; j < n; j++) {
                        num = num * 10 + s[j] - '0';
                        if (i & (1 << j)) {
                                sum += num;
                                num = 0;
                        }
                }
                sum += num;
        }
        cout << sum << endl;
        return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: u64
    }
    let mut pvec = vec![];
    let mut sum = 0;
    for i in 1..((n as f64).sqrt() as u64 + 2) {
        if n%i==0 {
            pvec.push(i);
            pvec.push(n/i);
        }
    }
    // println!("{:?}", pvec);
    for i in pvec {
        // println!("{}", i);
        if n/i - 1 > i {
            sum += n/i - 1;
        }
    }
    println!("{}", sum);
    
}

Measured memory_bytes: 4476
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    P = list(map(int, input().split()))
    selectionSort(N, P)


def selectionSort(N, P):
    change_count = 0
    for i in range(0, N):
        minj = i

        # print(P[i:N])
        # print(min(P[i:N]))

        for j in range(i, N):
            if P[j] < P[minj]:
                minj = j

        if i != minj:
            tmp = P[i]
            P[i] = P[minj]
            P[minj] = tmp
            change_count += 1

        # print(' '.join(map(str, P)))

    print(' '.join(map(str, P)))
    print(change_count)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
fun main() {
    val list = readLine()!!.split(" ").map { it.toInt() }
    if ((2 * list[0] - list[1]) % 2 != 0 || 4 * list[0] < list[1] || 2 * list[0] > list[1]) {
        println("No")
        return
    } else {
        val b = (2 * list[0] - list[1]) / 2
        if (list[0] - b < 0) {
            println("No")
            return
        }
    }

    println("Yes")

}

Measured memory_bytes: 36444
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct SegmentTree {
  using T = lint;
  static T op(const T& a, const T& b) { return min(a, b); }
  static constexpr T e() { return 1e18; }
  using U = lint;
  static void ap(const U& f, T& a) { a = min(a, f); }
  static void cp(const U& g, U& f) { f = min(f, g); }
  static constexpr U id() { return 1e18; }

  const int n;
  V<T> t;
  V<U> u;
  SegmentTree(int _n) : n(_n), t(2 * n, e()), u(n, id()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
  void push() { for (int i = 1; i < n; ++i) push(i); }
  void apply(const U& f, int i) {
    ap(f, t[i]);
    if (i < n) cp(f, u[i]);
  }
  void push(int i) {
    if (u[i] == id()) return;
    apply(u[i], 2 * i);
    apply(u[i], 2 * i + 1);
    u[i] = id();
  }
  void push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = (l + n) >> hl, ar = (r - 1 + n) >> hr;
      if (al < n) push(al);
      if (ar != al) push(ar);
    }
  }
  T acc(int l, int r) {
    push(l, r);
    T resl = e(), resr = e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = op(resl, t[l++]);
      if (r & 1) resr = op(t[--r], resr);
    }
    return op(resl, resr);
  }
  T get(int i) { return acc(i, i + 1); }
  void act(int l, int r, const U& f) {
    push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) apply(f, i++);
      if (j & 1) apply(f, --j);
    }
    l = (l + n) >> __builtin_ctz(l + n);
    while (l >>= 1) t[l] = op(t[2 * l], t[2 * l + 1]);
    r = (r + n) >> __builtin_ctz(r + n);
    while (r >>= 1) t[r] = op(t[2 * r], t[2 * r + 1]);
  }
  void set(int i, const T& a) {
    push(i, i + 1);
    t[i += n] = a;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> l(m), r(m), c(m);
  for (int i = 0; i < m; ++i) {
    cin >> l[i] >> r[i] >> c[i], --l[i];
  }
  V<> idx(m);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return l[i] < l[j]; });
  SegmentTree st(n);
  st.set(0, 0);
  for (int i : idx) {
    st.act(l[i], r[i], st.acc(l[i], r[i]) + c[i]);
  }
  if (st.get(n - 1) < 1e18) {
    cout << st.get(n - 1) << '\n';
  } else {
    cout << -1 << '\n';
  }
}

Measured memory_bytes: 4096
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // strcmp(), strncpy(), memcpy()

#define MAX_L 1000
const char NUL = '\0';

int
main(int argc, char** argv)
{
	char str[MAX_L + 1];
	char p[MAX_L + 1];
	char output[MAX_L + 1];
	char cmd[7 + 1]; /* max "replace" */
	int q, a, b;
	int l;
	int i;
	char t;

	scanf("%s\n", str);
	scanf("%d\n", &q);
	while (q--)
	{
		scanf("%s", cmd);
		if (strcmp(cmd, "replace") == 0)
		{
			scanf("%d %d %s\n", &a, &b, p);
			memcpy(&str[a], p, b + 1 - a);
		}

		else if (strcmp(cmd, "reverse") == 0)
		{
			scanf("%d %d\n", &a, &b);
			l = (b + 1 - a) / 2;
			for (i = 0; i < l; ++i)
			{
				t = str[a + i]; /* swap(str[a + i], str[b - i]) */
				str[a + i] = str[b - i];
				str[b - i] = t;
			}
		}

		else if (strcmp(cmd, "print") == 0)
		{
			scanf("%d %d\n", &a, &b);

			l = b + 1 - a;
			strncpy(output, &str[a], l);
			output[l] = NUL;
			printf("%s\n", output);
		}
	}

	return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << #x << " = " << x << endl;
typedef long long ll;


const int MAXN = 100005;

pair <int, int> a[MAXN];

int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first;
        a[i].second = i%2;
    }

    sort(a, a+n);

    int ans = 0;
    for (int i = 0; i < n; i++)
        if (i%2 != a[i].second) ans++;

    cout << ans / 2;

    return 0;
}



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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

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


Measured memory_bytes: 512
N = int(input())
T, A = map(int, input().split(' '))
H = map(int, input().split(' '))

ans = -1
abs_val = 1e9

for i, v in enumerate(H):
  if abs_val > abs((T - v * 0.006) - A):
    abs_val = abs((T - v * 0.006) - A)
    ans = i
print(ans + 1)

Measured memory_bytes: 3064
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <utility>
 
#define DEBUG(X) std::cout << #X << " : " << X << std::endl
#define Mp(X, Y) std::make_pair(X, Y)

typedef long long ll;

long long nextInt()
{
    long long num = 0;
    char c;
    bool flag = false;	
    while ((c = std::getchar()) == ' ' || c == '\r' || c == '\t' || c == '\n');
    if (c == '-')
        flag = true;
    else
        num = c - 48; 
    while (std::isdigit(c = std::getchar()))
        num = num * 10 + c - 48;
    return (flag ? -1 : 1) * num;
}

int main(int argc, char **argv)
{
	int n = nextInt(), m = nextInt();
	if (n * m % 2 == 0)
		std::cout << "No\n";
	else
		std::cout << "Yes\n";
#ifdef __EDWARD_EDIT
	std::cin.get();
	std::cin.get();
#endif
	return 0;
}

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

int main() {
	int in;
	vector <int> a;
	while (cin >> in) {
		if (in == 0) {
			cout << a.back();
			a.pop_back();
			/*if (a.size() == 0)
				break;
			else*/
				cout << endl;
		}
		else
			a.push_back(in);
	}
	return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int n;
int danger[100009];
int a[100009];
set<int> s;
set<pii> sdb;
vi ans;
void kesz()
{
    for(int x: ans) cout<<x<<" ";
    cout<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        danger[a[i]]++;
        s.insert(i);
    }
    if(n==2)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(int i=1; i<=n; i++)
    {
        sdb.insert({-danger[i], i});
    }
    int tabu=0;
    while(s.size()>3)
    {
        auto sdbit=sdb.begin();
        if(-sdbit->F == (int)(s.size())-1)
        {
            int x=sdbit->S;
            ans.push_back(x);
            s.erase(x);
            auto it=s.begin();
            if(*it == a[x])
            {
                it++;
                ans.push_back(*it);
                it--;
                ans.push_back(*it);
                it++;
                it++;
            }
            while(it!=s.end())
            {
                ans.push_back(*it);
                it++;
            }
            kesz();
            return 0;
        }
        auto it=s.begin();
        int kivesz=*it;
        if(*it == tabu)
        {
            it++;
            kivesz=*it;
        }
        s.erase(kivesz);
        ans.push_back(kivesz);
        tabu=a[kivesz];
        sdb.erase({-danger[kivesz], kivesz});
        sdb.erase({-danger[tabu], tabu});
        danger[tabu]--;
        sdb.insert({-danger[tabu], tabu});
    }
    vi rm;
    for(int z: s) rm.push_back(z);
    int ll=0;
    if(ans.size()>0) ll=ans.back();
    if(a[ll]!=rm[0] && a[rm[0]]!=rm[1] && a[rm[1]]!=rm[2])
    {
        ans.push_back(rm[0]);
        ans.push_back(rm[1]);
        ans.push_back(rm[2]);
    }
    else if(a[ll]!=rm[0] && a[rm[0]]!=rm[2] && a[rm[2]]!=rm[1])
    {
        ans.push_back(rm[0]);
        ans.push_back(rm[2]);
        ans.push_back(rm[1]);
    }
    else if(a[ll]!=rm[1] && a[rm[1]]!=rm[0] && a[rm[0]]!=rm[2])
    {
        ans.push_back(rm[1]);
        ans.push_back(rm[0]);
        ans.push_back(rm[2]);
    }
    else if(a[ll]!=rm[1] && a[rm[1]]!=rm[2] && a[rm[2]]!=rm[0])
    {
        ans.push_back(rm[1]);
        ans.push_back(rm[2]);
        ans.push_back(rm[0]);
    }
    else if(a[ll]!=rm[2] && a[rm[2]]!=rm[0] && a[rm[0]]!=rm[1])
    {
        ans.push_back(rm[2]);
        ans.push_back(rm[0]);
        ans.push_back(rm[1]);
    }
    else
    {
        ans.push_back(rm[2]);
        ans.push_back(rm[1]);
        ans.push_back(rm[0]);
    }
    kesz();

    return 0;
}


Measured memory_bytes: 11452
def abc():
    n = int(input())
    s = input().rstrip()
    max_dup = 0
    for i in range(1, n+1):
        s1 = set(s[0:i])
        s2 = set(s[i:])
        max_dup = max(max_dup, len(s1 & s2))
    print(max_dup)


abc()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,long double> P;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
ll n;
vector<P> v;
long double rui[N];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=0;i<n;i++){
	ll t,a; cin>>t>>a; 
	long double s=(100-a*10)/100.0;
	v.push_back(make_pair(t,s));
    }
    sort(v.begin(),v.end());
    rui[0]=1;
    for(int i=0;i<v.size();i++){
	rui[i+1]=rui[i]*v[i].second;
    }
    ll q; cin>>q;
    while(q--){
	ll l,r;
	cin>>l>>r;
	ll L,R,mid;
	L=-1,R=n;
	while(L<R-1){
	    mid=(L+R)>>1;
	    if(v[mid].first<l)L=mid;
	    else R=mid;
	}
	long double vl=rui[L+1];
	
	L=-1,R=n;
	while(L<R-1){
	    mid=(L+R)>>1;
	    if(v[mid].first<=r)L=mid;
	    else R=mid;
	}
	long double vr=rui[L+1];
	long double ans=vr/vl;
	ans*=1e9;
	cout<<fixed<<setprecision(9)<<ans<<endl;
    }
}





Measured memory_bytes: 7816
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

dp = [[0]*3 for i in range(N+1)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if j==k: continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + src[i][k])
print(max(dp[-1]))

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

int main() {
	int N;
	cin >> N;
	vector<int>B(N + 1,0);
	for (int i = 1; i <= N - 1; i++)  cin >> B[i];
	B[0] = 100001;
	B[N] = 100001;
	int sum = 0;
	for (int i = 1; i <= N; i++) sum += min(B[i - 1], B[i]);
	cout << sum << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> C;
typedef pair<C,C> pp;
typedef vector<C> VP;
typedef vector<pp> VPP;
#define eq(a,b) (fabs(a-b)<eps)
#define veq(a,b) (eq(a.real(),b.real())&&eq(a.imag(),b.imag()))
const C O{0,0};

void In(C& p){
	double x,y;
	cin>>x>>y;
	p=C(x,y);
}

void Out(C p){
	cout<<(int)p.real()<<' '<<(int)p.imag()<<endl;
}

double Dot(C p,C q){
	return p.real()*q.real()+p.imag()*q.imag();
}

double Det(C p,C q){
	return p.real()*q.imag()-q.real()*p.imag();
}

bool is_Convex(VP p){
	p.push_back(p[0]);
	p.push_back(p[1]);
	int n=p.size();
	for(int i=1;i<n-1;i++) if(Det(p[i]-p[i-1],p[i+1]-p[i-1])<0) return 0;
	return 1;
}

int n;
VP a;

int main(){
	cin>>n;
	a=VP(n);
	for(auto &i:a) In(i);
	cout<<is_Convex(a)<<endl;
}


Measured memory_bytes: 3212
"""
python3 main.py < input.txt
"""
import math
a=float(input())
b=float(input())
c=float(input())
d=float(input())
e=float(input())
l=[a, b, c, d, e]
l.sort(key=lambda x: (x+9)%10)
t=0
for x in l[1:]:
    t += math.ceil(x/10)*10
print(int(t+l[0]))

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

using namespace std;
typedef long long ll;

int parent[1000000];

int find(int v){
    if(parent[v] == v)return v;
    return parent[v] = find(parent[v]);
}

void merge(int u, int v){
    int a = find(u);
    int b = find(v);
    if(a != b){
        parent[b] = a;
    }
}

int main(){
    
    int n, m;
    cin >> n >> m;
    
    for(int i = 0; i <= n; i++){
        parent[i] = i;
    }
    
    while(m--){
        
        int u, v;
        cin >> u >> v;
        
        merge(u, v);
        
    }
    
    vector<int> table(n+1, 0);
    for(int i = 1; i <= n; i++){
        table[find(i)]++;
    }
    
    int answer = 0;
    for(int i = 1; i <= n; i++){
        answer = max(answer, table[i]);
    }
    
    cout << answer << endl;
    
    return 0;
    
}

Measured memory_bytes: 4948
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    vector<vector<int> > d(n, vector<int>(2));
    for (int i = 0; i < n; i++)
        cin >> d[i][0] >> d[i][1];
    for (int i = 0; i + 2 < n; i++) {
        if (d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] && d[i+2][0] == d[i+2][1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n); for (int i=0; i<(n); i++)//第一引数の変数をカウンタ変数としてn回回す
using veci = vector<int>;
using vecl = vector<long long>;
using vecd = vector<double>;
using vecs = vector<string>;
int a[2][55];
int b[55];
int main(){//n個の要素を持つ配列を用意し、その添え字の部分と入力を対応させて当該部分の数を1増やす
  int n, m;
  cin >> n >> m;
  rep(i, m){
    cin >> a[0][i] >> a[1][i];
  }
  rep(i, m){
    b[a[0][i]] +=1;
    b[a[1][i]] +=1;
  }
  for (int i=1; i<=n; i++){
    cout << b[i] << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2700
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

int n ;
cin >> n ;
int Free = 0 ;
int rate[8] ;
for(int i=0;i<8;i++) rate[i] = 0;

for(int i=0;i<n;i++)
{
    int a ;
    cin >> a  ;
    if(a<400){
        rate[0]=1;
    }else if(a>=400 && a<800){
        rate[1]=1;
    }else if(a>=800 && a<1200){
        rate[2]=1;
    }else if(a>=1200 && a<1600){
        rate[3]=1;
    }else if(a>=1600 && a<2000){
        rate[4]=1;
    }else if(a>=2000 && a<2400){
        rate[5]=1;
    }else if(a>=2400 && a<2800){
        rate[6]=1;
    }else if(a>=2800 && a<3200){
        rate[7]=1;
    }else{
        ++Free;
    }
}
//cout << rate[5] << rate[6] << endl ;
sort(rate,rate+8) ;
int SUM = 0;
for(int i=0;i<8;i++) SUM+=rate[i];

if(SUM==0 && Free>0)
 cout << 1 <<  " " << Free << endl ;
else
  cout << SUM <<  " " << Free+SUM << endl ;

return 0 ;
}  





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, Q; cin >> N >> Q;
    string s; cin >> s;

    s = '0' + s + '0';
    vector<int> cum(N+2, 0);
    for(int i=1; i<=N; i++){
        if(s[i] == 'C' && s[i-1] == 'A') cum[i] = cum[i-1]+1;
        else cum[i] = cum[i-1];
    }

    vector<int> l(Q), r(Q);
    for(int i=0; i<Q; i++) cin >> l[i] >> r[i];

    for(int i=0; i<Q; i++){
        if(s[l[i]-1] == 'A' && s[l[i]] == 'C') cout << cum[r[i]]-cum[l[i]-1]-1 << endl;
        else cout << cum[r[i]]-cum[l[i]-1] << endl;
    }
}

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

int main()
{
    int n,k,q;
    cin>>n>>k>>q;
    int c=q;
    int arr[n+5];
    for(int i=1;i<=n;i++)
    {
        arr[i]=k;
    }
    while(q--)
    {
        int p;
        cin>>p;
        arr[p]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(arr[i]>c)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    int v;
    char s[3];
    scanf("%s",s);
    v = 700;
    
    if (s[0] == 'o')
    {
        v = v + 100;
    }
    
    
    if (s[1] == 'o')
    {
        v = v + 100;
    }
    
    
    if (s[2] == 'o')
    {
        v  = v  + 100;
    }
    
    printf ("%d\n",v);
    
    
    
    
    return 0;
}


Measured memory_bytes: 128
//define DEBUG for debug
//#define DEBUG

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair 
#define pb push_back
#define MAX 100000+100
#define MOD 1000000007
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef DEBUG
	freopen("i.txt","r",stdin);
	freopen("o.txt","w",stdout);
#endif
	int n;
	string a;
	cin >> n >> a;
	for(char i : a){
		int x = i-'A';
		x+=n;
		x%=26;
		cout << (char)(x+'A');
	}
	return 0;
}

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

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


 
int main() {
 int N, M;
   cin >> N >> M;
   if(N == M){
     cout << "Yes" << endl;
   }else{
     cout << "No" << endl;
   }
   

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

sum = 0
for i in range(len(A)):
    sum += A[i]

av = sum/len(A)
ans = 0
dis = 10000000

for i in range(len(A)):
    if abs(A[i]-av) < dis:
        dis = abs(A[i]-av)
        ans = i
print(ans)


Measured memory_bytes: 3316
using System;
using static System.Console;

namespace abc178
{
    class Program
    {
        static void Main()
        {
            var abcd = ReadLine().Split(' ');
            var a = long.Parse(abcd[0]);
            var b = long.Parse(abcd[1]);
            var c = long.Parse(abcd[2]);
            var d = long.Parse(abcd[3]);
            var max = Math.Max(a * c, a * d);
            max = Math.Max(max, b * c);
            max = Math.Max(max, b * d);
            WriteLine(max);
        }
    }
}


Measured memory_bytes: 27548
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <vector>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

const int inf = 1e9 + 5;
const ll INF = 1e18 + 5;
const int maxn = 2e5 + 5;

ll n, a[maxn], w[maxn], s;
ll dp[maxn];

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(NULL);
	cin >> n >> s;
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	for (ll i = 1; i <= n; i++){
		int w, cost;
		cin >> w >> cost;
		for (int j = s - w; j >= 0; j--) {
			if (dp[j] != -1)
				dp[j + w] = max(dp[j + w], dp[j] + cost);
		}
	}
	ll ans = -1;
	for (int i = 0; i <= s; i++)
		ans = max(ans, dp[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
/**
 * ３つの整数を読み込み、それらを値が小さい順に並べて出力するプログラム
 * @author 前島佑介
 *@version 2014/12/1
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


// 2-C ３つの整数を読み込み、それらを値が小さい順に並べて出力するプログラム
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		//入力値1つ目
		int intNum1 = 0;

		//入力値2つ目
		int intNum2 = 0;

		//入力値2つ目
		int intNum3 = 0;

		try{
			//キーボードからの入力準備
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			//キーボードからの入力をString型で受け取る
			String strLine = br.readLine();

			//文字列の分割:入力値を" "で分ける
			//分けた文字列はstrLineAry[0]とstrLineAry[1]に分けられる
			String[] strLineAry = strLine.split(" ");

			//入力値の１つ目の値
			intNum1 = Integer.parseInt(strLineAry[0]);

			//２つ目の値
			intNum2 = Integer.parseInt(strLineAry[1]);

			//３つ目の値
			intNum3 = Integer.parseInt(strLineAry[2]);

			//入れ替えする為の場所
			int intChange = 0;

			//intNum1よりintNum2のほうが小さいなら
			//intNum1とintNum2を入れ替える
			if(intNum1 > intNum2) {
				intChange = intNum1;
				intNum1 = intNum2;
				intNum2 = intChange;
			}

			//intNum2よりintNum3のほうが小さいなら
			//intNum1とintNum2を入れ替える
			if(intNum2 > intNum3) {
				intChange = intNum2;
				intNum2 = intNum3;
				intNum3 = intChange;
			}

			//intNum1よりintNum2のほうが小さいなら
			//intNum1とintNum2を入れ替える
			if(intNum1 > intNum2) {
				intChange = intNum1;
				intNum1 = intNum2;
				intNum2 = intChange;
			}

			//結果を出力
			System.out.println(intNum1 + " " + intNum2 + " " + intNum3);

			//例外処理
			}catch(IOException e) {

				//例外時の出力
				System.out.println(e);

			}catch(NumberFormatException e) {

				//数値以外の入力値で出力
				System.out.println("数値で入力して下さい");
			}
	}
}

Measured memory_bytes: 16896
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
typedef long long ll;
int main()
{
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  ll cnt = 0;
  vector<ll> sum(n+1);
  sum[0] = 0;
  rep(i,n) sum[i+1] = sum[i] + a[i];

  ll tmp = 0;
  rep1(i,n) {
    ll buf = sum[i] + cnt;
    if(i % 2 == 1) {
      if(buf <= 0) {
	cnt += -buf + 1;
	tmp += -buf + 1;
      }
    }
    else {
      if(buf >= 0) {
	cnt += -buf - 1;
	tmp += buf + 1;
      }      
    }
  }
  ll res = tmp;
  tmp = 0;
  cnt = 0;
  rep1(i,n) {
    ll buf = sum[i] + cnt;
    if(i % 2 == 0) {
      if(buf <= 0) {
	cnt += -buf + 1;
	tmp += -buf + 1;
      }
    }
    else {
      if(buf >= 0) {
	cnt += -buf - 1;
	tmp += buf + 1;
      }      
    }
  }

  cout << min(res, tmp) << "\n";
  
  return 0;
}


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  string s;
  cin >> s;

  bool ans = true;
  if(s[0] != 'A') ans = false;

  for(int i=2;i<s.size() - 1;i++) {
    if(s[i] == 'C') break;
    
    if(i == s.size() - 2) ans = false;
  }

  int count = 0;
  REP(i, s.size()) {
    if(isupper(s[i])) count++;
  }
  // cout << count << endl;
  if(count != 2) ans = false;

  if(ans) cout << "AC" << endl;
  else cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M){
    if(N>M)cout<<NO<<endl;
    else cout<<YES<<endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

#n = int(input())
#a = [int(i) for i in input().split()]
n,k = [int(i) for i in input().split()]

_max = (n-1)*(n-2)//2

#if n==2:
#    print(-1)
#    exit()
    

if k > _max:
    print(-1)
    exit()

print(n-1 + _max - k)
for i in range(n-1):
    print(1, i+2)

l=2
r=3
for i in range( _max - k):
    print(l,r)
    r += 1
    if r > n:
        l += 1
        r = l+1
    






Measured memory_bytes: 3608
// 解答不能.
// betrue12氏.
// https://atcoder.jp/contests/abc152/submissions/9635499
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back

vector<pair<int, int>> edges[50];

int mask[50];
bool dfs(int i, int p, int target, int ei, int b){
    bool ok = (i == target);
    for(auto& e : edges[i]) if(e.first != p) ok |= dfs(e.first, i, target, e.second, b);
    if(ok && ei >= 0) mask[ei] |= 1<<b;
    return ok;
}

int main(){
    int N, M;
    scanf("%d", &N);
    rep(i, N - 1){
        int a, b;
        scanf("%d %d", &a, &b);
        edges[a - 1].pb({b - 1, i});
        edges[b - 1].pb({a - 1, i});
    }
    scanf("%d", &M);
    rep(i, M){
        int a, b;
        scanf("%d %d", &a, &b);
        dfs(a - 1, -1, b - 1, -1, i);
    }
    LL ans = 0;
    rep(b, 1 << M){
        LL res = 1;
        rep(i, N - 1) if(!(b & mask[i])) res *= 2;
        if(__builtin_popcount(b) % 2)    res *= -1;
        ans += res;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int n;
string s;

char next(char a, char b, int i) {
	if (s[i] == 'o') {
		if (a == 'S' && b == 'W') return 'W';
		if (a == 'S' && b == 'S') return 'S';
		if (a == 'W' && b == 'S') return 'W';
		if (a == 'W' && b == 'W') return 'S';
	}
	else {
		if (a == 'S' && b == 'W') return 'S';
		if (a == 'S' && b == 'S') return 'W';
		if (a == 'W' && b == 'S') return 'S';
		if (a == 'W' && b == 'W') return 'W';
	}
}

int main() {
	cin >> n;
	cin >> s;
	rep(i, 4) {
		string ans;
		if (i == 0) {
			ans = "SW";
		}
		if (i == 1) {
			ans = "SS";
		}
		if (i == 2) {
			ans = "WS";
		}
		if (i == 3) {
			ans = "WW";
		}

		FOR(j, 1, n - 1) {
			ans.push_back(next(ans[j - 1], ans[j], j));
		}
		if (next(ans[n - 2], ans[n - 1], n - 1) == ans[0] &&
			next(ans[n - 1], ans[0], 0) == ans[1]) {
			cout << ans << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long n,rem;
int main()
{
	scanf("%lld",&n);
	rem=n%11;
	if(rem==0)
	{
		printf("%lld\n",2*(n/11));
	}else
	{
		if(rem<=6)
		{
			printf("%lld\n",2*(n/11)+1);
		}else
		{
			printf("%lld\n",2*(n/11)+2);
		}
	}
}

Measured memory_bytes: 3776
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int>P;//<beginNum,endNum>
int f(P p){return p.second-p.first+1;}
int main()
{
	int a[100000],n,k,i,b,l,x;
	while(scanf("%d%d",&n,&k),n)
	{
		for(i=0;i<k;++i)scanf("%d",&a[i]);
		vector<P>v;
		sort(a,a+k);
		for(i=!a[0],b=l=a[i];i+1<k;++i)
		{
			if(a[i]+1==a[i+1])++l;
			else v.push_back(P(b,l)),b=l=a[i+1];
		}
		v.push_back(P(b,l));
		if(!a[0])
		{
			P p,q,r,s;
			for(i=0;i+1<v.size();++i)
			{
				r=v[i],s=v[i+1];
				if(r.second+2==s.first && f(p)+f(q)<f(r)+f(s))p=r,q=s;
			}
			v.push_back(P(p.first,q.second));
		}
		for(x=i=0;i<v.size();++i)x=max(x,f(v[i]));
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 0
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
S = list(input())

l = len(S)
ans = []

for i in range(1<<l-1):
	anss = []
	i = list("{:b}".format(i).zfill(l-1))
	SS = S.copy()
	anss.append(SS.pop(0))
	while SS != []:
		if i.pop(0) == "1":
			anss.append("+")
		anss.append(SS.pop(0))

	ans.append(eval("".join(anss)))


print(sum(ans))


Measured memory_bytes: 13760
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, D: "List[List[int]]"):
    f = False
    c = 0
    for i in range(N):
        if D[i][0] == D[i][1]:
            c += 1
            if c == 3:
                f = True
                break
        else:
            c = 0
    if f:
        print("Yes")
    else:
        print("No")

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int dataSet;
		for (int i = 0; (dataSet = Integer.parseInt(br.readLine())) != 0; i++) {
			System.out.println("Case " + (i + 1) + ": " + dataSet);
		}
		br.close();
	}
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n;
  cin >> n;
  if (n <= 999)
  {
    cout << "ABC" << endl;
  }
  else
  {
    cout << "ABD" << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, k = map(int,input().split())
C = [list(input().split()) for i in range(n)]
D = [[0] * (2*k) for i in range(2*k)]

E = []
for i in range(n):
    x = int(C[i][0]) % (2*k)
    y = int(C[i][1]) % (2*k)
    if C[i][2] == "W":
        x = (x+k) % (2*k)
    E.append([x, y])
    x = (x+k) % (2*k)
    y = (y+k) % (2*k)
    E.append([x, y])

for i in range(2*n):
    xx = 0
    yy = 0
    x = E[i][0]
    y = E[i][1]

    D[x][y] += 1
    if x+k > 2*k:
        xx = 1
    if y+k > 2*k:
        yy = 1
    if xx == 1 and yy == 1:
        D[0][0] += 1
        D[x-k][0] -= 1
        D[0][y-k] -= 1
        D[x-k][y-k] += 1

        D[x][0] += 1
        D[x][y-k] -= 1

        D[0][y] += 1
        D[x-k][y] -= 1

    elif xx == 1:
        D[0][y] += 1
        D[x-k][y] -= 1
        if y != k:
            D[x][y+k] -= 1
            D[0][y+k] -= 1
            D[x-k][y+k] += 1
    elif yy == 1:
        D[x][0] += 1
        D[x][y-k] -= 1
        if x != k:
            D[x+k][y] -= 1
            D[x+k][0] -= 1
            D[x+k][y-k] += 1
    else:
        if x != k:
            D[x+k][y] -= 1
        if y != k:
            D[x][y+k] -= 1
        if x != k and y != k:
            D[x+k][y+k] += 1
    # print(D)
    
for i in range(1, 2*k):
    D[0][i] += D[0][i-1]
    D[i][0] += D[i-1][0]

for i in range(1, 2*k):
    for j in range(1, 2*k):
        D[i][j] += D[i-1][j] + D[i][j-1] - D[i-1][j-1]

print(max([max(D[i]) for i in range(2*k)]))

Measured memory_bytes: 124200
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 10000000000;
/****** define constant end ********/


/****** define variable start ******/
ll n;
/******* define variable end *******/
ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
ll solve(){
    cin >> n;
    vector< vector<ll> > pair_num(10, vector<ll>(10));
    REP(i, 10){
        REP(j, 10){
            pair_num[i][j] = 0;
        }
    }
    for(ll i = 1; i <= n; ++i){
        ll first_keta = i / pow(10,GetDigit(i)-1);
        ll end_keta = i % 10;
        if(end_keta != 0){
            pair_num[first_keta][end_keta]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= n; ++i){
        ll first_keta = i / pow(10,GetDigit(i)-1);
        ll end_keta = i % 10;
        if(end_keta != 0){
            ans += pair_num[end_keta][first_keta];
        }
    }
    cout << ans << endl;
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d", &a,&b,&c,&d);
  if(a+b == c+d) printf("Balanced");
  else if (a+b > c+d){
    printf("Left");
  }
  else{
    printf("Right");
  }
}

Measured memory_bytes: 256
<?php
// C
fscanf(STDIN, '%d %d', $D, $G);
for ($i = 1; $i <= $D; $i++) {
    fscanf(STDIN, '%d %d', $p, $c);
    for ($j = 0; $j <= $p; $j++) {
        $score[$i][$j] = 100 * $i * $j;
        if ($j === $p) $score[$i][$j] += $c;
    }
}
$ans = dp(1, $G);
echo $ans;

function dp($n, $goal)
{
    global $score, $memo, $D;

    if (isset($memo[$n][$goal])) return $memo[$n][$goal];
    if ($goal <= 0) return 0;

    $num = 10000;
    foreach ($score[$n] as $i => $v) {
        if ($n !== $D) {
            $nnum = dp($n + 1, $goal - $v);
        } else {
            if ($v < $goal) continue;
            $nnum = 0;
        }
        if ($nnum >= 10000) continue;
        $num = min($num, $i + $nnum);
    }
    $memo[$n][$goal] = $num;
    return $memo[$n][$goal];
}

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

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

#define frep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) frep(i, 0, (n))
#define rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define all(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100010;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	int n; cin >> n;
	if(n == 1){
		cout << "Yes" << END;
		cout << 2 << END;
		cout << 1 << " " << 1 << END;
		cout << 1 << " " << 1 << END;
		return;
	}
	int ans = 0;
	frep(i, 1, n+1){
		if(i * (i-1) == 2 * n){
			ans = i;
		}
	}
	if(ans >= 1){
		int r = (2 * n) / ans;
		int a[ans][r], s = r;
		int cnt = 0, now = 1;
		while(r > 0){
			rep(i, r){
				a[cnt][cnt + i] = now + i;
				a[i + cnt + 1][cnt] = now + i;
			}
			now += r;
			r -= 1;
			cnt += 1;
		}
		cout << "Yes" << END;
		cout << ans << END;
		rep(i, ans){
			cout << s << " ";
			rep(j, s){
				cout << a[i][j] << " ";
			}
			cout << END;
		}
	}else{
		cout << "No" << END;
	}
}

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


Measured memory_bytes: 2176
import sys
from heapq import*
r=sys.stdin.readline
def g(s,g):
 F=[1e7]*-~n;F[s]=0
 H=[(0,s)]
 while H:
  c,u=heappop(H)
  if u==g:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:
    F[v]=t
    heappush(H,(t,v))
 return-1
for e in iter(r,'0 0\n'):
 n,k=map(int,e.split())
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r()
  if'0'==f[0]:print(g(*map(int,f[2:].split())))
  else:
   c,d,e=map(int,f[2:].split())
   E[c]+=[(e,d)];E[d]+=[(e,c)]


Measured memory_bytes: 6280
# -*- coding:utf-8 -*-

def main():
    while True:
        try:
            A=input().split()
            B=input().split()

            Hit=0
            Blow=0

            for b in B:
                if b in A:
                    index=B.index(b)
                    if b==A[index]:
                        Hit+=1

                    else:
                        Blow+=1
            print(Hit,Blow)

        except:
            break
            
    
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 7400
A, B, C = list(map(int, input().split()))
h = [A, B, C]
maxvalue = -1
for i in h:
    if i > maxvalue:
        maxvalue = i
minvalue = 10
for i in h:
    if i < minvalue:
        minvalue = i
print(maxvalue*10+A+B+C-maxvalue-minvalue+minvalue)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n), memo(n,0);
    vector<vector<ll>> child(n);
    
    rep(i,n-1) {
        cin>>a[i];
        a[i]--;
        child[a[i]].push_back(i+1);
    }
    // function<ll(ll)> solve = [&] (ll num) {
    //     ll res = 0;
    //     if (child[num].size()==0) {
    //         return 1LL;
    //     }
    //     for(auto x:child[num]) {
    //         res += solve(x);
    //     }
    //     return memo[num] = res;
    // };
    // solve(0);
    rep(i,n) {
        cout << child[i].size() << endl;
    }
    return 0;
}


Measured memory_bytes: 17136
# include <iostream>
# include <string.h>

using namespace std;

int main()
{
	string day;

	cin >> day;

	int count= 0;

	for (int  i = 0; i < 3; i++)
	{
		if (day[i] == 'R')
		{
			count++;
		}
	}
	if (count != 2)
		cout << count;
	else if (count == 2)
	{
		if (day[1] == 'S')
			cout << 1;
		else
			cout << count;
	}

	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int s[100], sm = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s[i];
    sm += s[i];
  }
  sort(s, s+n);
  for(int i=0;sm % 10 == 0 && i < n; i++){
    if(s[i] % 10 == 0) continue;
    sm -= s[i];
  }
  cout << (sm % 10 == 0? 0 : sm) << endl;
}

Measured memory_bytes: 256
import math
x1,y1,x2,y2 = map(float, input().split())
a1 = (x2-x1)**2
a2 = (x1-x2)**2
b1 = (y2-y1)**2
b2 = (y1-y2)**2
if x1<x2:
    if y1<y2:
        print(math.sqrt(a1+b1))
    else:
        print(math.sqrt(a1+b2))
else:
    if y1<y2:
        print(math.sqrt(a2+b1))
    else:
        print(math.sqrt(a2+b2))


Measured memory_bytes: 5656
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int N, A[4] = {};
    scanf("%d", &N);
    for (int i = 1; i <= 3; i++) {
        scanf("%d", &A[i]);
    }
    vector<int> V;
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        V.push_back(tmp);
    }
    int ans = (int)1e9;
    for (int S = 0; S < (int)pow(4, N); S++) {
        int sum[4] = {};
        int cnt[4] = {};
        int tmpans = 0;
        int tmpS = S;
        for (int j = 0; j < N; j++) {
             int cur = tmpS % 4;
             if (cur) {
                cnt[cur]++;
                sum[cur] += V[j];
             }
             tmpS /= 4;
        }
        bool OK = true;
        for (int j = 1; j <= 3; j++) {
            if (!cnt[j]) OK = false;
            tmpans += (cnt[j] - 1) * 10;
            tmpans += abs(sum[j] - A[j]);
        }
        if (OK) ans = min(tmpans, ans);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256