akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#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>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int M=in();
    vector<vector<int>> vec(N,vector<int>(M,0));
    REP(i,N){
        int K;
        cin>>K;
        REP(j,K){
            int a;
            cin>>a;
            --a;
            vec[i][a]=1;
        }
    }
    int ans=0;
    REP(i,M){
        bool flg=true;
        REP(j,N){
            if(vec[j][i]==0){
                flg=false;
                break;
            }
        }
        if(flg)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MN 55
int n,m,a[MN],b[MN],u[MN],v[MN],ok[MN],f[2][1<<21|1];
int fa[MN],dep[MN],ans;
vector<int>edge[MN];
void DFS(int x){
	for(int i=0;i<edge[x].size();++i)
		if(fa[x]!=edge[x][i]){
			fa[edge[x][i]]=x;
			dep[edge[x][i]]=dep[x]+1;
			DFS(edge[x][i]);
		}
}
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<n;++i){
		scanf("%lld%lld",&a[i],&b[i]);
		edge[a[i]].push_back(b[i]);
		edge[b[i]].push_back(a[i]);
	}
	scanf("%lld",&m);
	DFS(1);
	for(int i=1;i<=m;++i){
		scanf("%lld%lld",&u[i],&v[i]);
		if(dep[u[i]]<dep[v[i]])swap(u[i],v[i]);
		while(dep[u[i]]>dep[v[i]]) {
			ok[i]|=(1ll<<u[i]);
		//	cerr<<"shit "<<u[i]<<endl;
			u[i]=fa[u[i]];
		}
		while(u[i]!=v[i]){
			ok[i]|=(1ll<<u[i]),ok[i]|=(1ll<<v[i]);
		//	cerr<<"shit "<<u[i]<<" "<<v[i]<<endl;
			u[i]=fa[u[i]],v[i]=fa[v[i]];
		}
		ok[i]|=(1ll<<u[i]);
	}
	int ans=1;
	for(int i=1;i<n;++i)ans<<=1;
	f[0][0]=1;
	for(int i=1;i<n;++i){
		int qwq=0;
		for(int j=1;j<=m;++j)
			if((ok[j]&(1ll<<a[i]))&&(ok[j]&(1ll<<b[i]))) qwq|=(1ll<<j-1);
		for(int j=0;j<(1<<m);++j){
			f[i&1][j]+=f[!(i&1)][j];
			f[i&1][j|qwq]+=f[!(i&1)][j];
			f[!(i&1)][j]=0;
		}
	}
	printf("%lld\n",f[(n-1)&1][(1<<m)-1]);
	return 0;
}


Measured memory_bytes: 20736
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const int inf2 = 1145141919;
const ld pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//??£??\???????????¨???
	ll to, cost;
};
struct S {//???????????±?????\???????????°
	int from, to, cost;
};
bool operator<(S a, S b) { return a.cost < b.cost; }
bool operator>(S a, S b) { return a.cost > b.cost; }
struct H {
	int x, y;
};
ll gcm(ll i, ll j) {//?????§??¬?´???°
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad?????§?¨???????2??????????????¢
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
struct A {
	int cost, time;
	//????????????i????????????????????´??°????????????
};
int n, a[10000], d = 0, e = 1;
A dp[2][5002][2];
signed main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++)
		cin >> a[i];
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 5001; j++)
			for (int z = 0; z < 2; z++)
				dp[i][j][z] = A{ inf2,-1 };
	dp[1][0][0] = A{ 0,0 }, dp[0][1][1] = A{ 0,0 };
	for (int i = 0; i <= n / 2; i++) {
		for (int j = 0; j <= n / 2; j++) {
			if (i + j == 0) continue;
			if (dp[e][j][0].time != i + 1) dp[e][j][0] = A{ inf2,i + 1 };
			if (dp[e][j][1].time != i + 1) dp[e][j][1] = A{ inf2,i + 1 };
			if (dp[d][j + 1][0].time != i) dp[d][j + 1][0] = A{ inf2,i };
			if (dp[d][j + 1][1].time != i) dp[d][j + 1][1] = A{ inf2,i };
			if (dp[d][j][0].time == i) {
				dp[e][j][0].cost = dp[d][j][0].cost;
				dp[d][j + 1][1].cost = min(dp[d][j + 1][1].cost, dp[d][j][0].cost + a[i + j - 1]);
			}
			if (dp[d][j][1].time == i) {
				dp[e][j][0].cost = min(dp[e][j][0].cost, dp[d][j][1].cost + a[i + j - 1]);
				dp[d][j + 1][1].cost = min(dp[d][j + 1][1].cost, dp[d][j][1].cost);
			}
		}
		swap(d, e);
	}
	int ans = inf2;
	if (dp[d][n / 2][0].time == n / 2 + 1) ans = dp[d][n / 2][0].cost;
	if (dp[d][n / 2][1].time == n / 2 + 1) ans = min(ans, dp[d][n / 2][1].cost);
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 3272
def mitsui2019d_lucky_pin():
    import itertools
    n = int(input())
    s = input()
    cnt = 0
    for t in itertools.product(range(0, 10), repeat=2):
        si = ''.join(map(str,t))
        for i in range(n - 2):
            if si[0] != s[i]: continue
            for j in range(i + 1, n - 1):
                if si[1] != s[j]: continue
                ss = set(list(s[j+1:]))
                cnt += len(ss)
                break
            break
    print(cnt)


mitsui2019d_lucky_pin()

Measured memory_bytes: 9452
import sys

input = sys.stdin.readline


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

    sum_A = sum(A)
    center = sum_A / 2
    total = 0
    near_center = 0
    for a in A:
        total += a
        if abs(total - center) < abs(near_center - center):
            near_center = total

    ans = abs((sum_A - near_center) - near_center)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)        (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define yes           out("Yes");
#define no            out("No");

int main() {
    in(n);
    vector<ll> d(100000);
    ll ans = 0;

    rep(i, n) {
        in(a);
        d[a]++;
        ans += a;
    }

    in(q);

    rep(i, q) {
        in(b);
        in(c);
        ans += c * d[b];
        ans -= b * d[b];
        d[c] += d[b];
        d[b] = 0;
        out(ans);
    }
}

Measured memory_bytes: 4004
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

int n;
int v[MAXN], cnt[2][MAXN];

int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    ri(n);
    FOR(i,0,n) {ri(v[i]); cnt[i&1][v[i]]++;}

    int mxi0 = 1;
    int mxi1 = 1;
    int mxi2 = 0; 
    int mxi3 = 0;
    FOR(i,2,MAXN) {
        if(cnt[0][i] > cnt[0][mxi0]) mxi2 = mxi0, mxi0 = i;
        else if(cnt[0][i] > cnt[0][mxi2]) mxi2 = i;

        if(cnt[1][i] > cnt[1][mxi1]) mxi3 = mxi1, mxi1 = i;
        else if(cnt[1][i] > cnt[1][mxi3]) mxi3 = i;
    }

    if(mxi0 != mxi1){
        printf("%d\n", n - cnt[0][mxi0] - cnt[1][mxi1]);
    }
    else if(cnt[0][mxi0] + cnt[1][mxi3] > cnt[0][mxi2] + cnt[1][mxi1]){
        printf("%d\n", n - cnt[0][mxi0] - cnt[1][mxi3]);
    }
    else{
        printf("%d\n", n - cnt[0][mxi2] - cnt[1][mxi1]);
    }

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    ll n, m;
    cin >> n >> m;
    int sqrt_m = sqrt(m);
    set<int, greater<int>> st;
    for (ll i = 1; i <= sqrt_m; ++i) {
        if(m % i == 0) {
            st.insert(i);
            st.insert(m/i);
        }
    }
    int ans = 1;
    for (auto &x: st) {
        int candidate = m/x;
        if (candidate >= n) {
            ans = x;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
vector<int>g[100010];
int vis[100010],sum1,sum2,n;
typedef struct node
{
    int color,num;
};
void bfs()
{
    sum1=1;
    sum2=1;
    node p1,p2;
    p1.num=1;
    p1.color=-1;
    p2.num=n;
    p2.color=1;
    vis[1]=1;
    vis[n]=1;
    queue<node>p;
    p.push(p1);
    p.push(p2);
    while(!p.empty())
    {
        node now=p.front();
        node ne;
        p.pop();
        for(int i=0;i<g[now.num].size();i++)
        {
            if(vis[g[now.num][i]]==0)
            {
                vis[g[now.num][i]]=1;
                if(now.color==-1)
                sum1++;
                else
                sum2++;
                ne.num=g[now.num][i];
                ne.color=now.color;
                p.push(ne);
            }
        }
    }
}
int main()
{
    scanf("%d",&n);
    ff(i,1,n-1)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bfs();
    if(sum1>sum2)
    printf("Fennec");
    else
    printf("Snuke");
    return 0;
}


Measured memory_bytes: 6400
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#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)
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);

int main() {
    int a, b, c;
    unordered_map<int, int> mp;
    cin >> a >> b >> c;
    mp[a]++, mp[b]++, mp[c]++;
    each(m, mp) {
        if (m.second == 1) {
            cout << m.first << endl;
            return 0;
        }
    }
    return 0;
}

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

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

		a[i] = a[i] + max(b[i-1], c[i-1]);
		b[i] = b[i] + max(a[i-1], c[i-1]);
		c[i] = c[i] + max(a[i-1], b[i-1]);
    }

    cout << max(a[n-1], max(b[n-1], c[n-1]));

    return 0;
}


Measured memory_bytes: 4696
#include<iostream>
using namespace std;
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h != 0 && w != 0) {
			for (int j = 0; j < h; j++) {
				for (int i = 0; i < w; i++) {
					cout << '#';
				}
				cout << endl;
			}
			cout << endl;
		}
		if (h == 0 && w == 0) { break; }
	}
	return 0;
}

Measured memory_bytes: 3068
#include <cstdio>

int main(){
    char s[3][11];
    for(int i = 0; i < 3; i++){
        scanf(" %s",&s[i]);
    }

    int count[3];
    for(int i = 0; i < 3; i++){
        count[i] = 0;
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0;; j++){
            if(s[i][j] == '\0'){
                count[i] = j;
                break;
            }
        }
    }

    if(s[0][count[0] - 1] == s[1][0] && s[1][count[1] - 1] == s[2][0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N 110

using namespace std;

const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int h,w,n,f,now;
int a[N*N],ans[N][N];

int main(){
	int i,j,tx,ty,x,y;
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) a[i]+=a[i-1];
	for(i=1,x=1,y=0;i<=h*w;i++){
		for(;;f=(f+1)%4){
			tx=x+dx[f]; ty=y+dy[f];
			if(tx>=1 && tx<=h && ty>=1 && ty<=w && ans[tx][ty]==0) break;
		}
		x=tx; y=ty;
		if(i>a[now]) now++;
		ans[x][y]=now;
		//printf("%d %d %d %d\n",i,x,y,now);
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++) printf("%d ",ans[i][j]);
		puts("");
	}
	return 0;
}

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

using namespace std;
using ll = long long;

ll euc_gcd (ll a, ll b){
  if(a>b) return euc_gcd(b, a);

  ll r;
  while(r = a % b){
    a = b;
    b = r;
  }
  return b;
}
  

int main(){
  ll a, b, tmp;

  cin >> a >> b;
  cin.ignore();

  if(b > a){
    tmp = b;
    b = a;
    a = tmp;
  }

  // ここまでで a > b

  ll gcd = euc_gcd(a, b);

  ll gcm = a * b / gcd;
  cout << gcm << endl;
                 return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let h = read_vec::<i64>();
    let mut h2 = vec![0];
    for i in 0..n {
        h2.push(h[i]);
    }
    let h = h2;

    let mut dp = vec![vec![std::i64::MAX; n + 1]; n + 1];
    dp[0][0] = 0;
    for i in 1..n + 1 {
        for j in 0..i {
            for ki in 0..i + 1 {
                if dp[j][ki] == std::i64::MAX {
                    continue;
                }
                dp[i][ki + 1] = min(dp[i][ki + 1], dp[j][ki] + max(h[i] - h[j], 0));
            }
        }
    }
    let mut ans = std::i64::MAX;
    for i in 0..n + 1 {
        ans = min(ans, dp[i][n - k]);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin>>n;
  	long int arr[n];
  	for(int i=0;i<n;i++)cin>>arr[i];
  	long int cnt=0;
  	for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
        for(int k=j+1;k<n;k++)
        {
			if(arr[i]!=arr[j]&&arr[i]!=arr[k]&&arr[j]!=arr[k])
            {
              	if(arr[i]+arr[j]>arr[k]&&arr[i]+arr[k]>arr[j]&&arr[j]+arr[k]>arr[i])
                  cnt++;
            }
        }
  cout<<cnt;
}

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

int main(){
    long n,m;
    cin>>n>>m;
    vector<pair<long,long>> BC(n+m);
    long a;
    For(i,n){
        cin>>a;
        BC[i]=make_pair(a,1);
    }
    for(long i=n;i<n+m;i++){
        long b,c;
        cin>>b>>c;
        BC[i]=make_pair(c,b);
    }
    sort(BC.begin(),BC.end());
    long ans=0;
    For(i,n){
        ans+=BC[BC.size()-1].first;
        BC[BC.size()-1].second --;
        if(BC[BC.size()-1].second==0){
            BC.pop_back();
        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3456
#include<iostream>
#include<functional>
#include<algorithm>

using namespace std;

int main(){
  int i,j, x, N, first, last;
  long long count = 0, sum[10][10] = { 0 };

  scanf("%d", &N);

  for (i = 1; i <= N; i++){
	  if (i % 10 == 0) continue;
	  first = i;
	  while (first >= 10)first /= 10;
	  last = i % 10;
	  sum[first][last]++;
  }


  for (i = 0; i < 10; i++){
	  for (j = 0; j < 10; j++){
		  count += sum[i][j] * sum[j][i];
	  }
  }
  printf("%lld\n", count);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;

signed main() {
    int H, A;
    cin >> H >> A;
    cout << H / A + (H % A != 0) << endl;
}



Measured memory_bytes: 256
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let n = readl!(usize);
    let mut a = Vec::with_capacity(n);
    for _ in 0..n {
        let x = readl!(usize);
        a.push(x);
    }
    let a = a;
    let mut num = 1;
    let mut ans = 0;
    for (i, e) in a.iter().enumerate() {
        // debug!(num);
        if *e%num == 0 {
            // debug!(*e/num-1);
            // debug!(i);
            ans += *e/num-1;
            if(num == 1 || *e == num){
                num += 1;
            }
        } else {
            // debug!(*e/num);
            ans += *e/num;
        }
    }
    // debug!(num);
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int n,m;

int main(){
  cin>>n>>m;
  Q vec(m);
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    vec[i].first=b,vec[i].second=a;
  }
  sort(vec.begin(),vec.end());

  int cnt=0,tmp=0;
  rep(i,m){
    int b=vec[i].first,a=vec[i].second;
    if(tmp>=a && tmp<b && i) continue;
    else{
      tmp=b-1;
      cnt++;
    }
  }

  cout<<cnt<<endl;
}

Measured memory_bytes: 1792
void main() {
    int[][] c = new int[][](3, 3);
    foreach (i; 0 .. 3) {
        int[] tmp = readln.split.to!(int[]);
        foreach (j, x; tmp) {
            c[i][j] = x;
        }
    }
    bool ok = true;
    foreach (i; 1 .. 3) {
        int[] diff = new int[3];
        foreach (j; 0 .. 3) {
            diff[j] = c[i][j] - c[i-1][j];
        }
        if (!diff.all!(x => x == diff[0])) {
            ok = false;
        }
    }
    writeln(ok ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

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

   sort(a.begin(), a.end());
   int s = 0, cnt = 0;
   for (int i = 0; i < n; i++) {
      if (cnt == 0) {
         s += a[i];
         cnt = 1;
         continue;
      }
      if (a[i] <= s * 2) {
         s += a[i];
         cnt++;
      } else {
         cnt = 0;
         i--;
      }
   }
   cout << cnt << endl;

   return 0;
}


Measured memory_bytes: 1024
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	s := readString()
	b := []byte(s)
	if len(b) == 2 {
		b = append(b, '_')
	}
	for i := 0; i+2 < len(b); i++ {
		x := b[i]
		y := b[i+1]
		z := b[i+2]
		if x == y {
			println(i+1, i+2)
			return
		}
		if y == z {
			println(i+2, i+3)
			return
		}
		if z == x {
			println(i+1, i+3)
			return
		}
	}
	println(-1, -1)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    cin>>ch;
    int ascii = ch;
    if(ascii>=65 && ascii<=90)
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"a"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll N; cin >> N;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll Max = A[N-1],r = -1,id;
    for(int i = 0; i < N-1; i++) {
        if(r < min(A[i], Max-A[i])){
            r = min(A[i], Max-A[i]);
            id = i;
        }        
    }
    cout << Max << " " << A[id] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now,int n,vvel &way) {
	vel dist1 = dis(now,way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}
int fid(int le,int st,int goal,vvel &way) {
	vel dist = dis(st, way);
	while (dist[goal] > le) {
		rep(j, way[goal].size()) {
			if (dist[goal] > dist[way[goal][j]]) {
				goal = way[goal][j];
				break;
			}
		}
	}
	return goal;
}
int RE() {
	vel v(3,2);
	return v.at(4);
}
signed main() {
	int n; cin >> n;
	vvel way(n);
	rep(i, n-1) {
		int a, b; cin >> a >> b; a--; b--;
		way[a].push_back(b);
		way[b].push_back(a);
	}
	int u = most_far(0,n,way).second;
	pin pi = most_far(u, n, way);
	int v = pi.second;
	int cho = pi.first;
	int kind = (cho / 2) + 1;
	cout << kind << " ";
	int mid1 = fid(cho/2, u, v, way);
	vel dist1 = dis(mid1,way);
	if (cho % 2 == 0) {
		vel ans(kind, 1);
		rep(i, n) {
			int waysz = way[i].size();
			mmax(ans[dist1[i]], waysz - 1);
		}
		ans[0]++;
		int rret = 1;
		for (int i = 0; i < kind-1; i++) {
			rret *= ans[i];
		}
		rep(j, way[mid1].size()) {
			int mid2 = way[mid1][j];
			vel dist2 = dis(mid2, way);
			ans=vel(kind, 1);
			rep(i, n) {
				int waysz = way[i].size();
				mmax(ans[min(dist1[i], dist2[i])], waysz - 1);
			}
			int ret = 1;
			for (int i = 0; i < kind - 1; i++) {
				ret *= ans[i];
			}
			mmin(rret, ret*2);
		}
		cout << rret << endl;
	}
	else {
		int mid2 = fid(kind, u,v, way);
		vel dist2 = dis(mid2, way);
		vel ans(kind, 1);
		rep(i, n) {
			int waysz = way[i].size();
			mmax(ans[min(dist1[i],dist2[i])], waysz - 1);
		}
		int ret = 1;
		for (int i = 0; i < kind-1; i++) {
			ret *= ans[i];
		}
		cout << ret*2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int main(void) {
    int n, i, a[100003], sum, ksum;
    vector<int> po, ne;

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

    sort(a, a + n);

    sum = 0;
    for (i = 0; i < n; i++) {
        if (i == 0) {
            sum += -a[i];
            ne.push_back(a[i]);
        }
        else if (i == n - 1) {
            sum += a[i];
            po.push_back(a[i]);
        }
        else {
            sum += abs(a[i]);
            if (a[i] >= 0) po.push_back(a[i]);
            else ne.push_back(a[i]);
        }
    }

    cout << sum << endl;

    ksum = ne[0];
    for (i = 0; i < po.size() - 1; i++) {
        cout << ksum << ' ' << po[i] << endl;
        ksum -= po[i];
    }

    cout << po[po.size() - 1] << ' ' << ksum << endl;

    ksum = po[po.size() - 1] - ksum;

    for (i = 1; i < ne.size(); i++) {
        cout << ksum << ' ' << ne[i] << endl;
        ksum += -ne[i];
    }

    return 0;
}

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


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

	string name;
	cin >> name;

	int count = 0;
	
	for(int times = 0; times < N; times++) {
		string origin;
		cin >> origin;

		vector<string> cans;
		for(int span = 1; span < origin.size(); span++) {
			for(int head = 0; head < origin.size(); head++) {
				string res;
				
				for(int i = 0; i < name.size() && head + span * i < origin.size(); i++) {
					res += origin[head + span * i];
				}

				cans.push_back(res);
			}
		}

		count += find(cans.begin(), cans.end(), name) != cans.end();
	}

	cout << count << endl;
}

Measured memory_bytes: 1636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, k;
ll a[100100];
ll sum[100100];
vector<ll> ans;

int main(){
	while (cin >> n >> k&&n + k){
		fill(a, a + 100100, 0);
		fill(sum, sum + 100100, 0);
		ll MAX = -1000000000;
		REP(i, n)cin >> a[i];
		REP(i, n){
			if (i == 0)sum[i] = a[i];
			else sum[i] = sum[i - 1] + a[i];
		}
		ans.push_back(sum[k-1]);
		REP(i, n - k){
			ans.push_back(sum[i + k] - sum[i]);
		}
		REP(i, ans.size()){
			MAX = max(MAX, ans[i]);
		}
		cout << MAX << endl;
		ans.clear();
	}
}

Measured memory_bytes: 3292
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
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 ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll x=0;
    rep(i,n){
        cin>>a[i];
        x^=a[i];
    }
    rep(i,n){
        ll y=x^a[i];
        cout<<y<<"\n";
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll A, B, N;
	cin >> A >> B >> N;
	ll n = min( N, B-1);
	ll f = A*n/B;
	ll s = n/B;
	cout << f - A*s;
		

}


Measured memory_bytes: 3620
module Sort_Module
    implicit none
    public
    contains
    recursive subroutine mergesort(a, p, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r
        integer(8) q
        if (p < r) then
            q = (p+r)/2
            call mergesort(a, p, q, b)
            call mergesort(a, q+1, r, b)
            call merge(a, p, q, r, b)
        end if
    end subroutine mergesort
    subroutine merge(a, p, q, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r, q, i, j, k
        integer(8) t
        k = p;   i = p;   j = q+1
        do
            if (.not. (k <= r)) exit
            if (j > r) then
                t = a(i);   i = i+1
            else if (i > q) then
                t = a(j);   j = j+1
            else if (a(i) <= a(j)) then
                t = a(i);   i = i+1
            else
                t = a(j);   j = j+1
            end if
            b(k) = t;   k = k+1
        end do
        do i = p, r
            a(i) = b(i)  
        end do
    end subroutine merge
    subroutine sort(a)
      integer(8) a(:),b(ubound(a,1)-size(a)+1:ubound(a,1)),n,k
      n = ubound(a,1)
      k = ubound(a,1)-size(a)+1
      call mergesort(a,k,n,b)
    end subroutine sort
    function POSL(a,v) result(r)!find first i:a(i)>=v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) >= v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function POSU(a,v) result(r)!find first i:a(i)>v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) > v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function NUM(a,v) result(n)
        implicit none
        integer(8) :: a(:),v,n
        n = POSU(a,v) - POSL(a,v)
    end function
end module Sort_Module
  

program atcoder
    use Sort_Module
    implicit none
    integer(8) :: ans,a,b,c(1:4),i,d(1:4)
    logical ok
    c=0
    do i=1,3
        read*,a,b
        c(a)=c(a)+1
        c(b)=c(b)+1
    enddo
    call sort(c)
    d(1)=1
    d(2)=1
    d(3)=2
    d(4)=2
    ok = .true.
    do i=1,4
        if(d(i) /= c(i))then
            ok = .false.
        endif 
    enddo
    if( ok )then
        write(*,'(a)')"YES"
    else 
        write(*,'(a)')"NO"
    endif
    stop 
contains
end program atcoder

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int a,b;
	cin>>a>>b;
	if(a+b>9)cout<<"error"<<endl;
	else cout<<a+b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    double n,k;
    cin >> n >>k;
    double ans = 0;
    for(int i = 1;i<=n;i++) {
        int x = i;
        int cnt = 0;
        while(x < k) {
            x *= 2;
            cnt++;
        }
        double a = 1/n;
        ans += a*pow(0.5,cnt);
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
}

Measured memory_bytes: 4140
#!/usr/bin/env pypy3

import collections
import itertools


INF = 10 ** 8
UNDEF = -1


def floyd_warshall(num_vs, edges):
    n = num_vs
    dist = [[INF for _ in range(n)] for _ in range(n)]
    for u in range(n):
        dist[u][u] = 0
    for (u, v), c in edges.items():
        dist[u][v] = c
    for t, u, v in itertools.product(range(n), repeat=3):
        nl = dist[u][t] + dist[t][v]
        if nl < dist[u][v]:
            dist[u][v] = nl
    return dist


def main():
    n, m = (int(x) for x in input().split())
    edges = dict()
    used = dict()
    for _ in range(m):
        a, b, c = (int(x) for x in input().split())
        a -= 1
        b -= 1
        edges[(a, b)] = c
        edges[(b, a)] = c
        used[(a, b)] = False
    dist = floyd_warshall(n, edges)
    ans = 0
    for (u, v), c in edges.items():
        if u < v:
            if dist[u][v] != c:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

class Mod{
    static final int MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String K = sc.next();
        int N = K.length();
        int D = sc.nextInt();
        int[] digit = new int[N];
        for(int n=0; n<N; n++) digit[n] = K.charAt(n)-'0';

        long[][] just = new long[N][D];
        long[][] less = new long[N][D];

        for(int firstDig=0; firstDig<digit[0]; firstDig++) less[0][firstDig%D]++;
        just[0][digit[0]%D]++;

        for(int n=1; n<N; n++){
            for(int d=0; d<D;d++)for(int dig=0; dig<10; dig++) less[n][d] = Mod.add(less[n][d], less[n-1][(100*D+d-dig)%D]);
            for(int d=0; d<D;d++)for(int dig=0; dig<digit[n]; dig++) less[n][d] = Mod.add(less[n][d], just[n-1][(100*D+d-dig)%D]);
            for(int d=0; d<D;d++) just[n][d] = just[n-1][(100*D+d-digit[n])%D];
        }

        System.out.println(Mod.add(just[N-1][0]-1,less[N-1][0]));


    }
}

Measured memory_bytes: 64088
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

s = input()
S = s[0]
N = len(s)
cnt = 0
for i in range(N-1):
    if S[i]=='0':
        if s[i+1] == '0':
            #S += '1'
            cnt += 1
        S += '1'

    else:
        if s[i+1] == '1':
            #S += '0'
            cnt += 1
        S += '0'

print(cnt)

Measured memory_bytes: 3188
#include <stdio.h>
int main(void)
{
	int N;
	scanf("%d",&N);
	int A[100],i,j,tmp,k=0;
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	for(j=N-1;j>0;j--){
		for(i=0;i<j;i++){
			if(A[i]>A[i+1]){
				tmp=A[i];
				A[i]=A[i+1];
				A[i+1]=tmp;
				k++;
			}
		}
	}
	for(i=0;i<N;i++){
		if(i>=1) printf(" ");
		printf("%d",A[i]);
	}
	putchar('\n');
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>

int main(){
        int n,x;
        int i;
        char p;
        int ans = 0;

        scanf("%d",&n);

        for(i = 0; i < n; i++){
                scanf("%c",&p);
                scanf("%c",&p);
                scanf("%d",&x);

                if(p == '('){
                        ans += x;
                }else{
                        ans -= x;
                        if(ans < 0) break;
                }
        }

        if(ans == 0){
                printf("YES\n");
        }else{
                printf("NO\n");
        }

        return 0;
}

Measured memory_bytes: 1012
from bisect import bisect_left,bisect_right

n=int(input())
a=list(map(int,input().split()))
a.sort()

maxi=a[-1]
tmp=maxi/2
idx=bisect_left(a,tmp)

if a[idx]-tmp > tmp-a[idx-1] :
  idx += -1

if idx==n-1:
  idx += -1
  
print(maxi,a[idx])

Measured memory_bytes: 14428