akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int n;
ll d[100005];
map <ll, int> st;
vector <pii> e;
int siz[100005];
vi g[100005];

ll dfs(int u, int p) {
	ll dd = 0;
	rep(i, g[u].size()) if (g[u][i] != p) dd += siz[g[u][i]] + dfs(g[u][i], u);
	return dd;
}

int main() {
	n = read();
	rep(i, n) scanf("%lld", &d[i]);
	rep(i, n) st[d[i]] = i;
	int rt = st.begin() -> second;
	rep(i, n) siz[i] = 1;
	while (!st.empty()) {
		ll mx = st.rbegin() -> second;
		if (mx == rt) break;
		st.erase(d[mx]);
		ll nxd = d[mx] - (n - 2 * siz[mx]);
		if (!st.count(nxd)) {
			puts("-1");
			return 0;
		}
		siz[st[nxd]] += siz[mx];
		e.pb(mp(mx, st[nxd]));
		g[mx].pb(st[nxd]); g[st[nxd]].pb(mx);
	}
	if (dfs(rt, -1) != d[rt]) {
		puts("-1");
		return 0;
	}
	rep(i, e.size()) printf("%d %d\n", e[i].first + 1, e[i].second + 1);
	return 0;
}

Measured memory_bytes: 15224
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int a;
  int b;
  cin>>a>>b;
  if((a+b)%2!=0){
    cout<<(a+b)/2+1<<"\n";
    return(0);
  }
  cout<<(a+b)/2<<"\n";
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//bool cmp(pair<int, int>a, pair<int, int>b){if(a.first==b.first) return a.second > b.second;  else return a.first<b.first;   }
//bool valid(int i, int j){ return 0 <= i&&i < n && 0 <= j&&j < m; }
#define ll long long
#define MEMSET_INF 127
#define MEMSET_HALF_INF 63
#define fi first
#define se second
#define mp make_pair
#define siz 100000

typedef pair<int,int> pii;

vector<int>adj[9];
int use[9][9], c[9], there[9][9];
pii edg[20];


int main(){
      ios_base::sync_with_stdio(0);

      //freopen("milano.in","r",stdin);
     //freopen("output.txt","w",stdout);
    //memset(dist, MEMSET_INF, sizeof dist);
   //memset (dp_memo, -1, sizeof dp_memo);

   map<string,string>mp;
   mp["Sunny"] = "Cloudy";
   mp["Cloudy"] = "Rainy";
   mp["Rainy"] = "Sunny";

   string s; cin>>s; cout<<mp[s];

    return 0;
}


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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    
	int N;
    cin >> N;
    int *count;
    count = (int *)malloc(10000000 * sizeof(int));
    ll ans = 0;
    for(ll i=1;i<=N;++i) {
        for(int j=i;j<=10000000;j+=i) count[j]++;
        ans += i*count[i];
    }
    free(count);
    cout << ans << endl;
}


Measured memory_bytes: 42264
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<=n-1;i++)cin>>arr[i];
    for(int j=0;j<=n-2;j++)cout<<arr[n-1-j]<<" ";
    cout<<arr[0]<<endl;
    return 0;
}

Measured memory_bytes: 3080
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

//関節点および橋の列挙
vector<pair<int, int>> bridge; //橋
vector<int> art; //関節点(articulation)
int ord[101010], low[101010];
bool used[101010];
int k;

vector<int> g[101010];

void lowlink(int v, int p) {
        used[v] = true;
        ord[v] = k ++;
        low[v] = ord[v];
        bool is_art = false;
        int cnt = 0;
        for (auto u : g[v]) {
                if (!used[u]) {
                        cnt ++;
                        lowlink(u, v);
                        low[v] = min(low[v], low[u]);
                        if (p != -1 && ord[v] <= low[u]) is_art = true;
                        if (ord[v] < low[u]) bridge.emplace_back(min(v, u), max(v, u));
                } else if (u != p) {
                        low[v] = min(low[v], ord[u]);
                }
        }
        if (p == -1 && cnt > 1) is_art = true;
        if (is_art) art.push_back(v);
}

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        for (int i = 0; i < m; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        lowlink(0, -1);
        cout << bridge.size() << endl;
        return 0;
}



Measured memory_bytes: 2688
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for(int i = 1; i <= N; i++) {
            int tmp = sc.nextInt();
            map.put(tmp, i);
        }

        for(int k: map.values()) {
            System.out.print(k + " ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 69268
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        while(true){
            int H =sc.nextInt();
            int W =sc.nextInt();
            if(H==0&&W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i%2==0&&j%2==0){
                        System.out.print("#");
                    }
                     if(i%2==1&&j%2==1){
                        System.out.print("#");
                    }
                    if(i%2==1&&j%2==0){
                        System.out.print(".");
                    }
                     if(i%2==0&&j%2==1){
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        } 
        sc.close();
    }
}


Measured memory_bytes: 34684
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n; n--;
    vector<ll> a(5); rep(i,5) cin >> a[i];
    ll ans = -1002003004005006007;

    rep(i,5){
        ans = max(ans,n/a[i]);
    }

    cout << ans + 5 << endl;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(string, a, b, c);
  OUTN((char)toupper(a[0]), (char)toupper(b[0]), (char)toupper(c[0]), "\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
typedef long long ll;

inline ll read()
{
    ll w = 0, t = 1;
    char c = getchar();
    while (c < '0' || c > '9')
    {
        if (c == '-')
            t = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9')
    {
        w = (w << 3) + (w << 1) + (c ^ 48);
        c = getchar();
    }
    return w * t;
}
//a: <
//b: >

const int maxn = 2e5 + 5;

int n, above_zero;
ll a[maxn], b[maxn], k;

int Nada_bsa(int key, ll res)
{
    ll l = 1, r = n, mid, ret = 0;
    while (l <= r)
    {
        mid = (l + r) >> 1;
        if (a[mid] * a[key] < res)
            ret = mid, l = mid + 1;
        else
            r = mid - 1;
    }
    return ret >= key ? (ret - 1) : ret;
}
int Boxer_bsb(int key, ll res)
{
    ll l = 1, r = n, mid, ret = 0;
    while (l <= r)
    {
        mid = (l + r) >> 1;
        if (b[mid] * a[key] < res)
            ret = mid, l = mid + 1;
        else
            r = mid - 1;
    }
    return (ret + key > n) ? (ret - 1) : ret;
}
inline int check(ll res)
{
    ll _cur_k = 0;
    for (int i = 1; i < above_zero; i++) //-
        _cur_k += Boxer_bsb(i, res);
    for (int i = above_zero; i <= n; i++) //+
        _cur_k += Nada_bsa(i, res);
    _cur_k >>= 1;
    return _cur_k >= k;
}

int main()
{
    n = read();
    k = read();
    for (int i = 1; i <= n; i++)
        a[i] = read();
    std::sort(a + 1, a + 1 + n);
    above_zero = n + 1;
    for (int i = 1; i <= n; i++)
        if (a[i] >= 0)
        {
            above_zero = i;
            break;
        }
    for (int i = 1; i <= n; i++)
        b[n - i + 1] = a[i];
    
    ll l = -1e18, r = 1e18, mid, res;
    while (l <= r)
    {
        mid = (l + r) >> 1;
        if (check(mid))
            res = mid - 1, r = mid - 1;
        else
            l = mid + 1;
    }
    printf("%lld", res);
    return 0;
}

Measured memory_bytes: 6256
N = int(input())
X = []
U = []
for i in range(N):
    l = list(map(str, input().split()))
    U.append(l[1])
    if U[i] == 'JPY':
        X.append(int(l[0]))
    else:
        X.append(float(l[0]))

Y = 0.0
for n in range(N):
    if U[n]=='JPY':
        Y += X[n]
    else:
        Y += X[n] * 380000.0

print(Y)

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

    int main (){
        int n;
        cin >> n;
        int ans=1;
        while(n>=ans*2){
            ans*=2;
        }
        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 3580
c11,c12,c13=map(int, input().split(" "))
c21,c22,c23=map(int, input().split(" "))
c31,c32,c33=map(int, input().split(" "))
dif1=c12-c11
dif2=c13-c12

if c22-c21 == dif1 and c32-c31 == dif1 and c23-c22 == dif2 and c33-c32 == dif2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<pair<ll,ll>> r(n);
  rep(i,n){
    cin>>r[i].fi>>r[i].se;
  }

  map<pair<ll,ll>,ll> p;
  rep(i,n){
    rep(j,n){
      if(i==j) continue;
      auto x=mp(r[i].fi-r[j].fi,r[i].se-r[j].se);
      if(p.count(x)) p.at(x)++;
      else p[x]=1;
    }
  }

  ll ans=0;
  for(auto x : p){
    chmax(ans,x.se);
  }

  cout << n-ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
void solve() {
	ll a, b, n;
	cin>>n>>a>>b;
	cout<<n/(a+b)*a+min(n%(a+b),a)<<"\n";
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a = Integer.parseInt(String.valueOf(s.charAt(0)));
    int b = Integer.parseInt(String.valueOf(s.charAt(1)));
    int c = Integer.parseInt(String.valueOf(s.charAt(2)));
    int d = Integer.parseInt(String.valueOf(s.charAt(3)));
    String ans = "";
    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
        for(int k = 0; k < 2; k++) {
          int t = a;
          if(i == 0) {
            t += b;
          } else {
            t -= b;
          }
          if(j == 0) {
            t += c;
          } else {
            t -= c;
          }
          if(k == 0) {
            t += d;
          } else {
            t -= d;
          }
          if(t == 7) {
            ans = String.valueOf(a);
            if(i == 0) {
              ans += "+";
            } else {
              ans += "-";
            }
            ans += String.valueOf(b);
            if(j == 0) {
              ans += "+";
            } else {
              ans += "-";
            }
            ans += String.valueOf(c);
            if(k == 0) {
              ans += "+";
            } else {
              ans += "-";
            }
            ans += String.valueOf(d);
            ans += "=7";
          }
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 39760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<26;i++){
		ll sum=n-4*i;
		if(sum%7==0&&sum>=0){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/tenka1-2018-beginner/submissions/9815887
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main(){
    int N;  cin >> N;
    int k = -1;
    for(int i=1; i<=1e4; i++){
        if(i*(i-1) == 2*N){
            k = i;
            break;
        }
    }
    if(k==-1){
        cout << "No" << endl;
        return 0;
    }
 
    vector<vector<int>> S(k);
    int cnt = 1;
    for(int i=0; i<k; i++) for(int j=i+1; j<k; j++){
        S[i].push_back(cnt);
        S[j].push_back(cnt);
        cnt++;
    }
 
    cout << "Yes" << endl;
    cout << k << endl;
    for(vector<int> s : S){
        cout << k-1 << " ";
        for(int v : s){
            cout << v << " ";
        }cout << endl;
    }
}

Measured memory_bytes: 2304
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let mut a = vec![0i64; n + 2];
    for i in 1..n + 1 {
        a[i] = input();
    }

    let mut s = vec![0; n + 2];
    let mut t = vec![0; n + 2];
    for i in 0..n + 1 {
        s[i + 1] = s[i] + (a[i + 1] - a[i]).abs();

        let m = n + 1 - i;
        t[m - 1] = t[m] + (a[m] - a[m - 1]).abs()
    }

    for i in 1..n + 1 {
        println!("{}", s[i - 1] + (a[i - 1] - a[i + 1]).abs() + t[i + 1]);
    }
}


Measured memory_bytes: 7292
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll get(ll lx, ll ly, ll ux, ll uy, ll a, ll b)
{
	vector<ll>x, y;
	x.push_back(lx), x.push_back(ux + 1), x.push_back(0), x.push_back(a);
	y.push_back(ly), y.push_back(uy + 1), y.push_back(0), y.push_back(b);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	ll r = 0;
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (0 <= x[i] && x[i] < a && 0 <= y[j] && y[j] < b)continue;
			if (lx <= x[i] && x[i] <= ux&&ly <= y[j] && y[j] <= uy)r += (x[i + 1] - x[i])*(y[j + 1] - y[j]);
		}
	}
	//printf("%lld %lld %lld %lld   %lld %lld   %lld\n", lx, ly, ux, uy, a, b, r);
	return r % mod;
}
ll calc(ll a, ll b, ll c, ll d)
{
	if (c == 1)return 0LL;
	//printf("-----%lld %lld %lld %lld\n", a, b, c, d);
	vector<ll>v;
	for (ll i = 0; i <= d + 1; i++)for (int j = -1; j <= 2;j++)v.push_back(c*i / a + j + d);
	for (ll i = 0; i <= d + 1; i++)for (int j = -1; j <= 2;j++)v.push_back(c*i / b + j + d);
	for (ll i = 0; i <= d + 1; i++)for (int j = -1; j <= 2;j++)v.push_back(c*(a - i) / a + j + d);
	for (ll i = 0; i <= d + 1; i++)for (int j = -1; j <= 2;j++)v.push_back(c*(b - i) / b + j + d);
	v.push_back(c);
	v.push_back(c + d);
	for (int i = 0; i < v.size(); i++)v[i] = max(d + 1, min(c + d, v[i]));
	sort(v.begin(), v.end());
	ll r = 0;
	for (int i = 0; i < v.size() - 1; i++)
	{
		ll x = (v[i] - d)*a / c;
		ll y = (v[i] - d)*b / c;
		//printf("%lld %lld %lld\n", v[i], x, y);
		ll t = 0;
		if (0 <= v[i] && v[i] < c)t = get(x - d, y - d, x + d, y + d, a, b) % mod;
		else t = (2 * d + 1)*(2 * d + 1);
		//printf("%lld  %lld %lld\n", v[i], v[i + 1] - v[i], t);
		r += t*(v[i + 1] - v[i]);
		r %= mod;
	}
	return r;
}
int main()
{
	ll a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	ll ans = (2 * d + 1)*(2 * d + 1)*(2 * d + 1);
	ans = (ans + (a - 1 + b - 1 + c - 1)*(2 * d + 1) % mod*(2 * d + 1)) % mod;
	//printf("%lld\n", ans);
	ll s = calc(a, b, c, d) + calc(b, c, a, d) + calc(c, a, b, d);
	for (ll i = -d; i <= d; i++)
	{
		if (0 <= i&&i < c)s += get(-d, -d, d, d, a, b);
		else s += (2 * d + 1)*(2 * d + 1);
	}
	s %= mod;
	printf("%lld\n", (ans + mod - s) % mod);
}

Measured memory_bytes: 16700
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r){int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int a, b, c, n, m, x, y, z, w, h, res = 0, sum = 0, mx = -INF, mn = INF;
str s, t;
bool flag = true;

signed main(){
    incant();
    cin >> n;
    int cnt[100001] = {};
    rep(i, n){
        cin >> a;
        if(cnt[a] == 0){
            res++;
        }
        cnt[a]++;
    }
    each(i, cnt){
        if(i){
            i--;
        }
        sum += i;
    }
    if(sum % 2){
        print(res - 1);
    }else{
        print(res);
    }
}


Measured memory_bytes: 1024
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vi arr(n);
	for(int &i:arr)cin>>i;
	sort(arr.begin(),arr.end());
	if(n&1)cout<<0;
	else 
	cout<<arr[n/2]-arr[(n/2)-1];
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3700
#!/usr/bin/env python3
# -*- coding: utf-8-*-
if __name__ == '__main__':
    N = int(input())
    s = input()
    a = 0
    for i in s:
        if i == "R":
            a += 1
        else:
            a -= 1
    if a > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

int yesno(bool f, string yes, string no) {
	if (f)cout << yes << endl;
	else cout << no << endl;
	return 0;
}

int printint(int n) {
	cout << n << endl;
	return 0;
}

int prints(string s) {
	cout << s << endl;
	return 0;
}

long long m, a, r, c, h;

int main() {

	string s;
	int n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		if (s[0] == 'M')m++;
		else if (s[0] == 'A')a++;
		else if (s[0] == 'R')r++;
		else if (s[0] == 'C')c++;
		else if (s[0] == 'H')h++;
	}
	ans += m*a*r;
	ans += m*a*c;
	ans += m*a*h;
	ans += m*r*c;
	ans += m*r*h;
	ans += m*c*h;
	ans += a*r*c;
	ans += a*r*h;
	ans += a*c*h;
	ans += r*c*h;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

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

const int MAXN = 3e3+3; //AREGLAAAAAAAAR!!!!

int a[MAXN];

int main(){
	int n;
	ri(n);
	ll ans =0;
	FOR(i,0,n){
		ri(a[i]);
		ans+=(a[i]-1);
	}
	
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 2回目で0か2しかない場合と1がある場合
# 1がある時は2は0に変換して良い

def lucas(B, r):
    # nCr が奇数ならTrueを返す
    R = bin(r)[2:]
    for x, y in zip(B[::-1], R[::-1]):
        if x == '0' and y == '1':
            return 0
    return 1

N = ir()
A = np.array(list(map(int, sr())))
A = np.abs(np.diff(A))
N -= 1
bl = False
if 1 not in set(A):
    bl = True
    A //= 2

# それぞれの値が答えに何回貢献しているか
result = 0
A = A.tolist()
B = bin(N-1)[2:]
for i, a in enumerate(A):
    result += a * lucas(B, i)
result %= 2

print(result * 2 if bl else result)


Measured memory_bytes: 35880
/*   _ _ _                     
    | | | | ___  ___           
    | | | || . ||  _|          
    |_____||_  ||_|  _____     
             |_|    |_____|  */
// Time : 19/10/15
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
int main(){
#ifdef Wqr_
    freopen("in.txt","r",stdin);
#endif
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    string in;
    ll k, ans = 0;
    cin >> in;
    cin >> k;
    ll len = in.length();
    //kase1
    set<char> sett;
    for(auto i : in){
        sett.insert(i);
    }
    if(sett.size() == 1){
        ll ans = (len * k) / 2;
        cout << ans << endl;
        return 0;
    }
    //kase2
    for(int i = 1; i < len; ++i){
        if (in[i] == in[i - 1]) {
            ++ans;
            ++i;
        }
    }
    ans *= k;
    if(in.front() == in.back()){
        ll a = 1, b = 1;
        for (int i = 1; i < len; ++i) {
            if (in[i] == in[i - 1]) ++a;
            else break;
        }
        for (int i = len - 2; i >= 0; i--) {
            if (in[i] == in[i + 1]) ++b;
            else break;
        }
        // cout << a << " " << b << endl;
        ll tmp = -a / 2 + -b / 2 + (a + b) / 2;
        ans += tmp * (k - 1);
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {
	FastScanner in;
	PrintWriter out;

	int[] p;

	int get(int x) {
		return p[x] == x ? x : (p[x] = get(p[x]));
	}

	void unite(int x, int y) {
		p[get(x)] = get(y);
	}

	void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		p = new int[n + m];
		for (int i = 0; i < p.length; i++) {
			p[i] = i;
		}
		for (int i = 0; i < n; i++) {
			int cnt = in.nextInt();
			for (int j = 0; j < cnt; j++) {
				int id = in.nextInt() - 1;
				unite(i, n + id);
			}
		}
		for (int i = 1; i < n; i++) {
			if (get(i) != get(0)) {
				out.println("NO");
				return;
			}
		}
		out.println("YES");
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 31232
#include <stdio.h>
#include <math.h>

int main() {
	long long int n;
	int t;
	char s[15] = {'0'}, al[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	scanf("%lld", &n);
	for (int i = 2; i < 20; i++) {
		if (n <= (long long int)(pow(26, i) - 26) / 25) {
			t = i - 1;
			break;
		}
	}
	if (t >= 2) n = n - (long long int)(pow(26, t) - 26) / 25;
	n--;
	for (int i = 0; i < t; i++) {
		int r = n / (long long int)pow(26, t - 1 - i);
		n = n - (long long int)pow(26, t - 1 - i) * r;
		s[i]=al[r];
	}
	for (int i = 0; i < t; i++)printf("%c", s[i]);
	return 0;
}

Measured memory_bytes: 2496
#include<bits/stdc++.h>
using namespace std;
int main(){string s;while(cin>>s&&s!="#"){int a=1,b=(s[s.size()-4]=='o')?0:90,i;
for(i=s.size()-5;i>0;i--){if(s[i]=='o')a*=2,b=2*b-90;if(s[i]=='e')a*=2,b=2*b+90;}
while(!(a%2|b%2))a/=2,b/=2;cout<<b;if(a-1&&b)cout<<"/"<<a;cout<<endl;}return 0;}

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

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int distance, time, speed;
    std::cin >> distance >> time >> speed;

    if (time * speed >= distance) {
        std::cout << "Yes";
    }
    else {
        std::cout << "No";
    }

    return 0;
}



Measured memory_bytes: 3632
// Copyright 2020 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<string> S(N);
  for (auto& e : S)cin >> e;
  map<string, int> m;
  int M = 0;
  for (auto& e : S)
    M = max(M,++m[e]);
  auto iter = m.begin();
  auto last = m.end();
  for (; iter != last; ++iter) {
    if (iter->second != M)continue;
    cout << iter->first << "\n";
  }
}


Measured memory_bytes: 25472
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    if (c > d) {
        for (int i = a - 1; i < c - 1; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No";
                return 0;
            }
        }
        bool flag = false;
        for (int i = b - 1; i < d; i++) {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                flag = true;
                break;
            }
        }
        if (flag) {
            cout << "Yes";
        } else {
            cout << "No";
        }


    } else {
        for (int i = a - 1; i < c - 1; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No";
                return 0;
            }
        }
        for (int i = b - 1; i < d - 1; i++) {
            if (s[i] == '#' && s[i + 1] == '#') {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }   
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
int main(){
   string s,t;
   cin>>s>>t;
   int ans=0;
   rep(i,s.size()){
      if(s[i]!=t[i])ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3860
n = int(input())
T = [int(i) for i in input().split()]
m = int(input())
px = [[int(i) for i in input().split()] for i in range(m)]

for i in range(m):
    T2 = T.copy()
    T2.pop(px[i][0] - 1)
    T2.append(px[i][1])
    print(sum(T2))

Measured memory_bytes: 3060
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long x, y;
    scan(x, y);
    // x = 10;
    // y = 20;
    () {
        long ans = long.max;
        foreach (b0; 0 .. 2)
            foreach (b1; 0 .. 2)
            {
                long X = x;
                long Y = y;
                if (b0)
                    X = -X;
                if (b1)
                    Y = -Y;
                // writefln("%d %d %d %d", b0, b1, X, Y);
                if (X <= Y)
                    ans = ans.min(Y - X + b0 + b1);
            }
        return ans;
    }().writeln();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,n,a[1003]={0},ans=0,k;
	cin>>n>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	for(int i=0;i<=n;i++)
        for(int j=0;j<=n-i-1;j++)
            if(a[j]>a[j+1])swap(a[j], a[j+1]);
	for(i=1;i<=k;i++)ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3600
# 優先度付キューのimport
import heapq

n, m = map(int, input().split())

a = [int(i) * -1 for i in input().split()]

heapq.heapify(a)

for i in range(m):
    minPrice = heapq.heappop(a)
    # 負の切捨てが面倒なので正の値にしてからまた負に戻す
    minPrice = -(abs(minPrice) // 2)
    heapq.heappush(a, minPrice)

print(-sum(a))

Measured memory_bytes: 20400
import java.awt.*;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(),W=sc.nextInt();
        int w[]=new int[n+1];int v[]=new int[n+1];
        for (int i=1;i<=n;i++){
            w[i]=sc.nextInt();
            v[i]=sc.nextInt();
        }
        long dp[][]=new long[n+1][W+1];
        for (int i=1;i<n+1;i++){
            for (int j=1;j<W+1;j++){
                if (j>=w[i]) {
                    dp[i][j] = Math.max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j]);
                }else dp[i][j]=dp[i-1][j];
            }
        }
        System.out.println(dp[n][W]);
    }
}

Measured memory_bytes: 127700
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/math>
using namespace atcoder; 

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

  int t; cin >> t;
  while (t--) {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << '\n';
  }
  
  return 0;
}

Measured memory_bytes: 3584
/*input
6 3
2 3
4 5
5 6
*/

#include <bits/stdc++.h>
#define pb(x) push_back(x);
#define in(y) insert(y);
#define tt(t) while(t--)
#define int long long int
#define itr ::iterator it;
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define si set<int>                      
#define msi map<string, int>
#define lines printsf("\n")
#define ff(n) for(int i=0;i<n;i++)
#define fors(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
bool mat[2000][2000];
int  dp [2000][2000];
int n,m;
int solve(int i,int j){
//	if(i==0 and j==0) return 0;
	if(i<=0 and j<=0) return 1;
	//if(i==0 or j==0) return 1;
	
	if(dp[i][j]!=-1) return dp[i][j];
	int ans = 0;
	ans = (((mat[i][j-1]==1?solve(i,j-1):0)%MOD)+((mat[i-1][j]==1?solve(i-1,j):0)%MOD))%MOD;
	return dp[i][j]=ans;
}
signed main(){
	cin>>n>>m;
	fors(i,0,n){
		fors(j,0,m){
			char x;
			cin>>x;
			mat[i][j]=(x=='.'?1:0);
		}
	}
	fors(i,0,1010){
		fors(j,0,1010){
			dp[i][j]=-1;
		}
	}
	cout<<solve(n-1,m-1);
	

}



Measured memory_bytes: 20352
A=[list(map(int,input().split())) for _ in range(3)]
b=[i for i in [int(input()) for _ in range(int(input()))] for j in A if i in j]
A=[[1 if A[i][j] in b else 0 for j in range(len(A[i]))] for i in range(len(A))]
print('NYoe s'[any([all(i) for i in A]) or any([all(i) for i in list(zip(*A))]) or all([A[0][0],A[1][1],A[2][2]]) or all([A[0][2],A[1][1],A[2][0]])::2])

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

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

    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    int max_distance = 0;

    rep(i, N) {
        int distance;
        if (i == N - 1) {
            distance = K - A.at(i) +  A.at(0);
        } else {
            distance = A.at(i+1) - A.at(i);
        }
        max_distance = max(max_distance, distance);
    }

    cout << K - max_distance << endl;
}


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

vector<int>to[200005],ans;
void dfs(int v,int p=-1){
    for(int u:to[v]){
        if(u==p)continue;
        ans[u]+=ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    ans.resize(n);
    rep(i,n-1){
        int a,b; cin>>a>>b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i,q){
        int p,x; cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    dfs(0);
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 23552
#include <stdio.h>
#include <string.h>

int main(){
  char a[1024],b[]="Hoshino",*c;
  int i,n;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    fgets(a,sizeof(a),stdin);
    while((c=strstr(a,b))!=NULL) c[6]='a';
    printf("%s",a);
  }
  return 0;
}

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

int ctoi(char in){
  return (int)(in - '0');
}

int main(){
  ll n;
  cin >> n;
  vector<vector<ll>> c(10);
  for(ll i=0; i<10; i++) c[i].assign(10,0);
  
  for(ll i=1; i<=n; i++){
  	string str = to_string(i);
    c[ctoi(str[0])][ctoi(str[str.size()-1])] += 1;
  }
  
  ll ans = 0;
  for(ll i=1; i<=9; i++){
    for(ll j=1; j<=9; j++){
      ans += c[i][j] * c[j][i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(3);
    string s,s1,s2;
    cin >> s;
    if(s[0] == 'A') cout << "T"<< endl;
    if(s[0] == 'T') cout << "A"<< endl;
    if(s[0] == 'C') cout << "G"<< endl;
    if(s[0] == 'G') cout << "C"<< endl;
    return 0;
} 

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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int>b(n);
  for(int i=0;i<n;i++){
    b[i]=a[i];
  }
  sort(b.begin(),b.end());
  int num=b[n/2];
  for(int i=0;i<n;i++){
    if(a[i]<num) cout<<num<<endl;
    else cout<<b[n/2-1]<<endl;
  }
}
    
    
    
    
    

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

#define vi vector<int>
#define vpii vector<pair<int, int>>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int, int>
#define int long long int
#define inf INT_MAX
#define _inf INT_MIN
#define whilet int t;cin>>t;while(t--)
const int N = 100005;

int min_cost(vi v) {
	int n = v.size();
	vi dp(n);

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

		int a = inf, b = inf;
		if (i - 1 >= 0) a = abs(v[i - 1] - v[i] ) + dp[i - 1];
		if (i - 2 >= 0) b = abs(v[i - 2] - v[i] ) + dp[i - 2];

		dp[i] = min(a, b);
	}

	return dp[n - 1];
}


void solve() {
	int n;
	cin >> n;
	vi v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	cout << min_cost(v) << endl;

}

void init() {
	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("../input.txt", "r", stdin);
	freopen("../output.txt", "w", stdout);
#endif
}


int32_t main()
{
	//init();
	// whilet solve();
	solve();
}

Measured memory_bytes: 5612
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int n,a;
	cin >> n;
	if (n % 2 == 0)
	{
		cout << "0.5";
		return;
	}
	else
	{
		 a = (n + 1) / 2;
	}
	cout << (double)a / (double)n;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
function main(input) {
  var A = input[0];
  var B = input[1];
  var mapA = {};
  var mapB = {};
  for(var i=0;i<A.length;i++){
    if(!mapA[A[i]]){
      mapA[A[i]] = {};
    }else{
      if(mapA[A[i]][B[i]] === undefined){
        console.log('No');
        return;
      }
    }
    if(!mapB[B[i]]){
      mapB[B[i]] = {};
    }else{
      if(mapB[B[i]][A[i]] === undefined){
        console.log('No');
        return;
      }
    }
    mapA[A[i]][B[i]] = true;
    mapB[B[i]][A[i]] = true;
  }
  console.log("Yes");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = double(w * h) / 2.0;
  bool ans2 = !(w % 2 || x != w / 2 || h % 2 || y != h / 2);
  printf("%.6f %d\n", ans, ans2);
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
int main(){
    ll a,b,c;
    int flag = 0;
    
    scanf("%lld %lld %lld",&a,&b,&c);
    for(int i = 1; i <= 1000000; i++){
        if((a*i)%b == c){
            flag = 1;
            break;
        }
    }
    if(flag == 1) printf("YES\n");
    else printf("NO\n");
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int kuriage(int n){
    return (n+9)/10*10;
}
int main(){
    int a[5],i,j,tmp,ans=1000;
    for(i=0;i<5;i++) cin >> a[i];
    for(i=0;i<5;i++){
        tmp=0;
        for(j=0;j<5;j++){
            if(j!=i)tmp+=kuriage(a[j]);
            else tmp+=a[j];
        }
        ans=min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define task "LIS"

const long long maxn=1e6+5;
const long long w=1e8;

using namespace std;

int a,b;
string s;
bool c=true;

inline void init(){
    cin>>a>>b;
    cin.ignore();
    cin>>s;
}

inline void solve(){
    for(int i=0;i<s.length();i++){
        if(i==a){
            if(s[i]!='-'){
                c=false;
            }
        }
        else{
            if(s[i]<'0'||s[i]>'9'){
                c=false;
            }
        }
    }
    if(c) cout<<"Yes";
    else cout<<"No";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen(task".INP","r",stdin);
    //freopen(task".OUT","w",stdout);
    init();
    solve();
    return 0;
}


Measured memory_bytes: 384
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    min_s = 10 ** 12

    for i in range(1, int(math.sqrt(N))+1):
        if N % i == 0:
            if min_s > i+(N/i):
                min_s = i + (N/i)

    print(int(min_s - 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <iostream>
#include <list>

using namespace std;

int main() {
    
    int n;
    cin>>n;
    list <int> llist;
    list <int> :: iterator lt;
    list<int>::reverse_iterator rlt;
    if(n%2 == 0)
    {
         for(int i=1; i<=n; i++)
         {
               int t;
               cin>>t;
               if(i%2==0)
                    llist.push_back(t);
               else
                    llist.push_front(t);
         }
    }
    else
    {
         for(int i=1; i<=n; i++)
         {
               int t;
               cin>>t;
               if(i%2==0)
                    llist.push_front(t);
               else
                    llist.push_back(t);
         }
    }
    
    int ans[n];
     int i = 1;
    for(lt = llist.begin(); lt!= llist.end(); lt++,i++)
    {
         ans[n-i] = *lt;
//         cout<<*lt<<" ";
    }
//    cout<<"\n";
    for(int i=0;i<n;i++)
    cout<<ans[i]<<" ";
    
    return 0;
}

Measured memory_bytes: 9344
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 200005;
std::vector<int> G[maxn];
int a[maxn];

void dfs(int u, int fa) {
	for(int v : G[u])
		if(v != fa) {
			a[v] += a[u];
			dfs(v, u);
		}
}

int main() {
	int n = input(), q = input();
	for(int i = 1; i < n; i ++) {
		int u = input(), v = input();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	while(q --) {
		int u = input(), x = input();
		a[u] += x;
	}
	dfs(1, 0);
	for(int i = 1; i <= n; i ++)
		printf("%d ", a[i]);
	puts("");
}


Measured memory_bytes: 23424