akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int MASK = 0x03, P = 10;

int main(){
	long long n, res, pow;
	while(cin >> n, n != -1){
		res = 0;
		pow = 1;
		while(n != 0){
			int digit = n & MASK;
			res += digit * pow;
			n >>= 2;
			pow *= P;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < d.length; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        System.out.println(d[n / 2] - d[n / 2 - 1]);
        sc.close();
    }
}

Measured memory_bytes: 52696
import java.util.*;
import java.lang.*;

public class Main {
    public static int helper(int N, int A, int B) {
        int sum = 0;
        for (int i = 1; i < N + 1; i++) {
            int digsum = sumDigit(i);
            if (digsum >= A && digsum <= B) {
                sum = sum + i;
            }
        }
        return sum;
    }

    public static int sumDigit(int num) {
        int digSum = 0;
        int pow = 0;
        while (Math.pow(10,pow) < num) {
            pow++;
        }
        for (int i = 0; i <= pow; i++) {
            int digits = num / (int) Math.pow(10,i);
            digSum = digSum + (digits % 10);
        }
        return digSum;
    }

    public static void main(String[] args) {
        Scanner dataScanner = new Scanner(System.in);
        String[] data = dataScanner.nextLine().split(" ");
        int intLim = Integer.parseInt(data[0]);
        int digLLim = Integer.parseInt(data[1]);
        int digULim = Integer.parseInt(data[2]);
        int sum = helper(intLim, digLLim, digULim);
      	System.out.println(sum);
    }
}


Measured memory_bytes: 21716
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

long long int cnt[100];

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

	memset(cnt, 0, sizeof(cnt));

	int n;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		stringstream ss;
		ss << i;
		string s = ss.str();
		//cout << s << '\n';
		string t = s.substr(0, 1) + s.substr(s.length() - 1);
		//cout << s << ' ' << t << '\n';
		cnt[stoi(t)]++;
	}

	long long int res = 0;

	for (int i = 0; i < 100; i++)
	{
		int j = (i % 10) * 10 + (i / 10);
		res += (cnt[i])*(cnt[j]);
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return int(gcd(b, c))

def lcm(a, b):
    return int(a * b / gcd(a,b))

A, B, C, D = [int(x) for x in input().split()] 

l = lcm(C, D)

A = A-1
x = (B-A)
y = (B//C - A//C)
z = (B//D - A//D)
a = (B//l - A//l)
print(x+a - (y+z))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <climits>
using namespace std;

int N, Q;
struct Year {
  string name;
  int base, wy;
  Year() {}
  Year(string name, int base, int wy)
    : name(name), base(base), wy(wy) {}
  bool operator < (const Year &y) const {
    if(wy != y.wy) return wy < y.wy;
    if(base != y.base) return base < y.base;
    return name < y.name;
  }
};

vector<Year> v;
int main() {
  while(cin >> N >> Q && (N || Q)) {
    v.clear();
    for(int i = 0; i < N; ++i) {
      Year y;
      cin >> y.name >> y.base >> y.wy;
      y.wy = y.wy - y.base + 1;
      v.push_back(y);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < Q; ++i) {
      int q;
      cin >> q;
      int p  = distance(v.begin(),lower_bound(v.begin(), v.end(), Year("",INT_MAX,q)));
      if(p == 0 || !(q < v[p-1].wy+v[p-1].base)) cout << "Unknown" << endl;
      else cout << v[p-1].name << " " << q-v[p-1].wy+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 984
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int min = Integer.MAX_VALUE;
        long ans = 0;
        for(int i = 0; i < N; i++) {
            int a = sc.nextInt();
            X -= a;
            min = Math.min(a, min);
        }
        ans += N;
        while(X>=min) {
            X-=min;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;
    const ll N = 1<<n;

    vl cost(m), key(m);
    rep(i, m) {
        ll b;
        cin >> cost[i] >> b;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            key[i] |= 1<<c;
        }
    }

    vvl dp(m+1, vl(N,INF));  // dp[i+1][S] : 鍵iまで(iは0-index)で開いた宝箱の集合がSとなるときの費用の最小値
    dp[0][0] = 0;
    rep(i, m) {
        rep(s, N) {
            chmin(dp[i+1][s], dp[i][s]);
            chmin(dp[i+1][s | key[i]], dp[i][s] + cost[i]);
        }
    }
        
    if(dp[m][N-1] == INF) {
        out(-1);
    }
    else {
        out(dp[m][N-1]);
    }

    re0;
}

Measured memory_bytes: 32384
#pragma warning(disable:4996)

#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
	string s;
	cin >> s;

	ll absMin = 9999999999;
	for (int i = 0; i <= s.size() - 3; i++)
	{
		ll var = abs(stoll(s.substr(i, 3)) - 753);
		if (absMin > var)
		{
			absMin = var;
		}
	}

	cout << absMin << "\n";
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = v.size();
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}

Measured memory_bytes: 256
x,y = map(int, input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
elif x in C and y in C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9112
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 2005

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

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, tot;
int l[N], r[N];
char A[N], B[N], C[N];
bool flag;
Pair a[N];

int MOD(int x) { return x < 0 ? x + n : x > n ? x - n : x; }

int main() {
	scanf("%s%s", A + 1, B + 1);
	n = strlen(A + 1);

	if (string(A + 1) == string(B + 1)) return puts("0"), 0;
	for (int i = 1; i <= n; ++i) if (B[i] == '1') flag = true;
	if (!flag) return puts("-1"), 0;

	for (int i = n; i; --i)
		if (B[i] == '1') {
			l[0] = i;
			break;
		}
	for (int i = 1; i <= n; ++i)
		if (B[i] == '1') l[i] = i;
		else l[i] = l[i - 1];

	for (int i = 1; i <= n; ++i)
		if (B[i] == '1') {
			r[n + 1] = i;
			break;
		}
	for (int i = n; i; --i)
		if (B[i] == '1') r[i] = i;
		else r[i] = r[i + 1];

	int Ans = inf;
	for (int i = 0, ans = 0, MIN = inf; i < n; ++i, tot = 0, ans = 0, MIN = inf) {
		for (int j = 1; j <= n; ++j) C[MOD(j + i)] = A[j];
		for (int j = 1; j <= n; ++j) if (B[j] != C[j]) ++ans;

		for (int j = 1; j <= n; ++j)
			if (B[j] == '0' && C[j] == '1')
				a[++tot] = MP(max(0, MOD(j - l[j]) - i), MOD(r[j] - j));
		sort(a + 1, a + tot + 1);
		for (int i = tot, MAX = 0; ~i; chkmax(MAX, a[i--].se))
			chkmin(MIN, (a[i].fi + MAX) * 2);
		chkmin(Ans, ans + MIN + i), tot = 0;

		for (int j = 1; j <= n; ++j)
			if (B[j] == '0' && C[j] == '1')
				a[++tot] = MP(MOD(j - l[j]), max(0, MOD(r[j] - j) - (n - i)));
		sort(a + 1, a + tot + 1), MIN = inf;
		for (int i = tot, MAX = 0; ~i; chkmax(MAX, a[i--].se))
			chkmin(MIN, (a[i].fi + MAX) * 2);
		chkmin(Ans, ans + MIN + n - i);
	}

	printf("%d\n", Ans);
	return 0;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=0;
  arep(i,a,b+1)if(c%i==0)ans++;
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
const int N = 555;
int n, mod, f[N], g[N], dp[N][N];
vector<pair<int, int>> a;

int main() {
  scanf("%d%d", &n, &mod);
  for (int i = 0; i < n << 1; i++) {
    for (int j = 0; j < n << 1; j++) if (i * i + j * j < n * n) f[i] = j + 1;
    for (int j = 0; j < n << 1; j++) if (i * i + j * j <= (n << 1) * (n << 1)) g[i] = j + 1;
  }
  for (int i = 0; i < n; i++) {
    a.emplace_back(f[i], i);
  }
  for (int i = n; i < n << 1; i++) {
    a.emplace_back(g[i], i);
  }
  sort(a.begin(), a.end(), [&](pair<int, int> &a, pair<int, int> &b){return a.first == b.first ? a.second > b.second : a.first < b.first;});
  int ans = 0;
  for (int k = 0; k <= n; k++) {
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 0; i < n << 1; i++) {
      for (int j = 0; j <= i; j++) if (dp[i][j]) {
        dp[i + 1][j] = (dp[i + 1][j] + (ll) dp[i][j] * max(0, a[i].first - (i - j))) % mod;
        if (a[i].second < n) {
          dp[i + 1][j + 1] = (dp[i + 1][j + 1] + (ll) dp[i][j] * max(0, g[a[i].second] - (k + n + j))) % mod;
        }
      }
    }
    if (k & 1) {
      ans = (ans + mod - dp[n << 1][n - k]) % mod;
    } else {
      ans = (ans + dp[n << 1][n - k]) % mod;
    }
  }
  printf("%d\n", ans);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int h,w;
  scanf("%d%d",&h,&w);
  int a,b;
  REP(i,h)REP(j,w){
    string s;
    cin>>s;
    if(s=="snuke"){
      a=i;b=j;
    }
  }
  printf("%c%d\n",b+'A',a+1);
  return 0;
}


Measured memory_bytes: 764
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    ll ss[100010] = {}, tt[100010] = {};
    rep(i,0,S.size()){
        if(S[i] == 'A'){
            ss[i+1] = 2;
        }else{
            ss[i+1] = 1;
        }
    }
    rep(i,0,T.size()){
        if(T[i] == 'A'){
            tt[i+1] = 2;
        }else{
            tt[i+1] = 1;
        }
    }
    rep(i,0,S.size()+1) ss[i+1] += ss[i];
    rep(i,0,T.size()+1) tt[i+1] += tt[i];
    ll q;
    cin >> q;
    while(q--){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        if((ss[b+1] - ss[a]) % 3 == (tt[d+1] - tt[c]) % 3){
            print("YES");
        }else{
            print("NO");
        }
    }
    

}

Measured memory_bytes: 2512
def main():
    from math import gcd
    a, b, c, d = (int(i) for i in input().split())
    L = c*d//gcd(c, d)
    ans = b - (b//c + b//d - b//L)
    ans -= (a-1) - ((a-1)//c + (a-1)//d - (a-1)//L)
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
	int t, n;
	for (int i = 0; i < 4; i++) {
		cin >> t >> n;
		switch (t) {
		case 1: cout << 6000 * n << endl; break;
		case 2: cout << 4000 * n << endl; break;
		case 3: cout << 3000 * n << endl; break;
		case 4: cout << 2000 * n << endl; break;
		}
	}
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	ll N;
	cin >> N;

	vector<ll> count(N,0);
	vector<ll> A;
	ll temp = 0;
	for(int i=0; i<N; i++){
			cin >> temp;
			A.emplace_back(temp - 1);
			count[temp - 1]++;
	}

	ll no_ban = 0;
	REP(i,N){
		no_ban += count[i] * (count[i] - 1) / 2;
	}

	REP(i,N){
		ll ans = no_ban;
		ans -= count[A[i]] * (count[A[i]] - 1) / 2;
		ans += (count[A[i]] - 1) * (count[A[i]] - 2) / 2;
		cout << ans << "\n";
	}

	return 0;
}

Measured memory_bytes: 5872
#include<stdio.h>
#define N 100000

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[N];
int count = 0;


int depth(int id){
  if(T[id].parent == -1){
    return count;
  }

  else{
    count++;
    return depth(T[id].parent);
  }
}


void degree(int id){
  if(id != -1){
    if(count != 0){
      printf(", ");
    }
    printf("%d",id);
    count++;
    degree(T[id].right);
  }
}



int main(){
  int i,j,n,left,right,node,child,m;


  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i=0 ; i<n ; i++){
    scanf("%d%d",&node,&m);
    for(j=0 ; j<m ; j++){
      scanf("%d",&child);
      T[child].parent = node;
      if(j != 0)T[left].right = child;
      else T[node].left = child;
      left = child;
    }
  }

  for(i=0;i<n;i++){
    count = 0;
   
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
    if(T[i].parent == -1) printf("root, [");
    else if(T[i].left == -1) printf("leaf, [");
    else  printf("internal node, [");
    count = 0;
    degree(T[i].left);
    printf("]\n");
  }
  return 0;
}

Measured memory_bytes: 1784
package main

import "fmt"

type po struct {
	t int
	x int
	y int
}

func main() {
	var N int

	fmt.Scan(&N)

	list := make([]po, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&list[i].t, &list[i].x, &list[i].y)
	}

	for i, now := range list {
		var pre po
		if i == 0 {
			pre = po{
				t: 0,
				x: 0,
				y: 0,
			}
		} else {
			pre = list[i-1]
		}

		dis := abs(now.x-pre.x) + abs(now.y-pre.y)
		time := now.t - pre.t
		if time < dis {
			fmt.Println("No")
			return
		}

		if (time-dis)%2 == 1 {
			fmt.Println("No")
			return
		}

	}
	fmt.Println("Yes")
}

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


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();

        if (k >= n) {
            System.out.println(1);
        } else {
            System.out.println((n - k + k - 2) / (k - 1) + 1);
        }
    }
}


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

using namespace std;
using ll = long long;

int main() {
  int a, b;
  cin >> a >> b;
  if ((b - 1) % (a - 1) == 0) {
    cout << (b - 1) / (a - 1) << endl;
  } else {
    cout << (b - 1) / (a - 1) + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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() { 
    int n; cin >> n;
    vector<pll> works;
    rep(i, n){
        ll a, b; cin >> a >> b;
        works.emplace_back(b, a);
    }
    sort(all(works));
    bool fg = true; ll time = 0;
    rep(i, n){
        time += works[i].second;
        if(time > works[i].first) fg = false;
    }
    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
} 


Measured memory_bytes: 6256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int):
    if N & 1:
        print(N << 1)
    else:
        print(N)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n, m;
  scan(n, m);
  vi a(n);
  scan(a);
  priority_queue<int> pq;
  rep (i, n) {
    pq.push(a[i]);
  }
  rep (i, m) {
    int t = pq.top();
    pq.pop();
    pq.push(t / 2);
  }
  ll sum = 0;
  rep (i, n) {
    int t = pq.top();
    sum += t;
    pq.pop();
  }
  print(sum);

  return 0;
}


Measured memory_bytes: 1276
from collections import defaultdict
import sys
input=sys.stdin.readline
r,c,k=map(int,input().split())
l=[0]*((r+1)*(c+1))
for i in range(k):
  a1,a2,a3=map(int,input().split())
  l[a1*(c+1)+a2]=a3
dp0=[[0 for i in range(c+1)] for j in range(r+1)]
dp1=[[0 for i in range(c+1)] for j in range(r+1)]
dp2=[[0 for i in range(c+1)] for j in range(r+1)]
dp3=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
  for j in range(c):
    x=l[i*(c+1)+j+1]
    y=l[(i+1)*(c+1)+j]
    dp3[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp2[i+1][j]+y,dp3[i+1][j])
    dp2[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp1[i+1][j]+y,dp2[i+1][j])
    dp1[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp0[i+1][j]+y,dp1[i+1][j])
    dp0[i+1][j+1]=max(dp2[i][j+1]+x,dp3[i][j+1],dp0[i+1][j])
z=l[r*(c+1)+c]
print(max(dp2[r][c]+z,dp3[r][c]))

Measured memory_bytes: 458264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
#define ll long long

using namespace std;

int main() {
    int n;
    cin >> n;
    int s = 0;
    vector<int> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a[i];
        s = s ^ a[i];
    }
    for (int i=0; i<n-1; ++i) {
        cout << (s ^ a[i]) << " ";
    }
    cout << (s ^ a[n-1]) << endl;
}




Measured memory_bytes: 4052
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	m := nextInt()

	if n == m {
		fmt.Printf("Yes")
	} else {
		fmt.Printf("No")
	}
}


Measured memory_bytes: 640
from numpy import median
from copy import deepcopy

n = int(input())
x = list(map(int,input().split()))

sx = sorted(x)
newl = deepcopy(sx)
del newl[0]
maxm = median(newl)
newl = deepcopy(sx)
del newl[-1]
minm = median(newl)

med = median(x)

for i in x:
    if i > med:
        print(int(minm))
    else:
        print(int(maxm))


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

using namespace std;
const int Maxn = 1e5 + 5;
set <int> vec[Maxn];
int cnt = 0;
int vis[Maxn], a[1010][1010], mp1[Maxn], mp2[Maxn];
int dfs(int x, int y){
    if (x == y) return 1;
    int ans = 0;
    vis[x] = 1;
    for (int i = 1; i <= cnt; i++)
        if (a[x][i] && !vis[i]){
            ans += dfs(i, y);
        }
    vis[x] = 0;
    return ans;
}
int main()
{
    //freopen("004.in", "r", stdin);
    int n, m;
    scanf("%d%d", &n, &m);
    //cout << n << " " << m << endl;
    for (int i = 1; i <= m; i++){
        int x, y;
        scanf("%d%d", &x, &y);
        //cout << x << " " << y << endl;
        vec[y].insert(x);
        vec[x].insert(y);
    }
    queue <int> q;
    for (int i = 1; i <= n; i++){
        if (vec[i].size() == 1) q.push(i);
    }
    //cout << q.size() << endl;
    while(!q.empty()){
        int x = q.front(), y = *vec[x].begin();
        //cout << x << endl;
        q.pop();
        vec[y].erase(x);
        vec[x].clear();
        if (vec[y].size() == 1){
            q.push(y);
        }
    }
    for (int i = 1; i <= n; i++){
        if (vec[i].size() == 2){
            set <int>::iterator it;
            it = vec[i].begin();
            int x = *it;
            it++;
            int y = *it;
            if (vec[x].find(y) == vec[x].end()){
                vec[x].insert(y);
                vec[y].insert(x);
                vec[x].erase(i);
                vec[y].erase(i);
                vec[i].clear();
            }
        }
    }
    for (int i = 1; i <= n; i++){
        if (!vec[i].empty()) mp1[i] = ++cnt, mp2[cnt] = i;
    }
    //cout << cnt << endl;
    for (int i = 1; i <= cnt; i++){
        int x = mp2[i];
        multiset <int>::iterator it;
        for (it = vec[x].begin(); it != vec[x].end(); it++){
            int y = *it;
            a[i][mp1[y]] = 1;
            //a[mp1[y]][i] = 1;
        }
    }
    int ans = 0;
    //cout << cnt << endl;
    for (int i = 1; i <= cnt; i++)
        for (int j = i + 1; j <= cnt; j++)
            if (a[i][j]){
            a[i][j] = a[j][i] = 0;
            ans += dfs(i, j);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> A(2,vector<int>(N));
  for(int i=0;i<2;i++){
    for(int j=0;j<N;j++){
      cin>>A.at(i).at(j);
    }
  }
  /*
  for(int y=0;y<2;y++){
    for(int x=0;x<N;x++){
      cout<<A.at(y).at(x)<<" ";
    }
    cout<<endl;
  }
  */
  int sum1=0;
  int tmp=0;
  int max_n=0;
  for(int x=0;x<N;x++){
    //cout<<"x:"<<x<<endl;
    //cout<<A.at(0).at(x)<<endl;
    sum1+=A.at(0).at(x);
    tmp=sum1;
    for(int y=x;y<N;y++){
      //cout<<A.at(1).at(y)<<endl;
      tmp+=A.at(1).at(y);
    }
    //cout<<tmp<<endl;
    max_n=max(max_n,tmp);
  }
  cout<<max_n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
using namespace std;
int main(){
	int x,y,z;
	cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	cout<<x<<' '<<y<<' '<<z;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(int i=p;i<n;i++)
#define fr1(i,p,n) for(int i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (int)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        ll xx=0;
        fr(i,0,n)
        {
            cin>>a[i];
            xx^=a[i];
        }
        fr(i,0,n)
        {
            ll ans=xx^a[i];
            cout<<ans<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 5168
M = int(input())

if 400<= M <=599:
    print("8")
elif 600<= M <=799:
    print("7")
elif 800<= M <=999:
    print("6")
elif 1000<= M <=1199:
    print("5")
elif 1200<= M <=1399:
    print("4")
elif 1400<= M <=1599:
    print("3")
elif 1600<= M <=1799:
    print("2")
elif 1800<= M <=1999:
    print("1")


Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
	
	private static boolean[][] graph = new boolean[20][20];
	private static boolean[] vis = new boolean[20];
	private static int ans = 0;
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int i , j , n , m;
		n = scan.nextInt();
		m = scan.nextInt();
		for (i = 0;i < m;i ++) {
			int from = scan.nextInt() , to = scan.nextInt();
			graph[from][to] = graph[to][from] = true;
		}
		dfs(1 , n , 0);
		System.out.println(ans);
		
	}	
	
	private static void dfs(int current , int n , int tot) {
			
		vis[current] = true;
		tot ++;
		
		if (tot == n) {
			ans ++;
		} else {
			for (int i = 1;i <= n;i ++) {
				if (!vis[i] && graph[current][i]) {
					dfs(i , n , tot);
				}
			}
		}
		
		vis[current] = false;
		
	}
	
}





Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vvl board(n, vl(2*n));
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, n) {
            board[i][j] = s[j] - 'a';
            board[i][j+n] = board[i][j];
        }
    }
    
    ll ans = 0;
    rep(a, n) {
        bool ok = true;
        rep(i, n) {
            exrep(j, a, a+n-1) {
                if(i == j-a) {
                    continue;
                }
                if(board[i][j] != board[j-a][i+a]) {
                    ok = false;
                }
            }
        }
        if(ok) {
            ans++;
        }
    }

    ans *= n;
    out(ans);
    re0;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
P = list(map(int, input().split()))
S = []
E = []
temp = 0
for i in range(N):
    P[i] = (P[i] + 1) / 2
    temp += P[i]
    S.append(temp)
E.append(S[K-1])
for i in range(K, N):
    E.append(S[i] - S[i-K])
print(max(E))

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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; }

int main() {
  ll N, K;
  cin >> N >> K;
  map<ll, ll> mp;
  rep(i, 0, N) {
    ll a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  for(auto &p : mp) {
    K -= p.second;
    if(K <= 0) {
      cout << p.first << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4224
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=105;
int a[MAXN],b[MAXN];
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]+=a[i-1];
	}
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=n-1;i>=1;i--)
		b[i]+=b[i+1];
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=max(a[i]+b[i],ans);
	printf("%d\n",ans);
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;

    ll res = 0;
    for (int i=1; i<=N; ++i) {
        ll num = N / i;
        res += num * (i + i*num) / 2;
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int n = sz(s);
    vi ans(n);
    rep(t, 2) {
        int cnt = 0;
        rep(i, n) {
            if (s[i]=='R') ++cnt;
            else if (i-1>=0&&s[i-1]=='R') {
                ans[i-1] += (cnt+1)/2;
                ans[i] += cnt/2;
                cnt = 0;
            }
        }
        reverse(all(ans));
        reverse(all(s));
        rep(i, n) {
            if (s[i]=='R') s[i] = 'L';
            else s[i] = 'R';
        }
    }
    rep(i, n) printf("%d%c", ans[i], (i<n-1?' ':'\n'));
    return 0;
}


Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,ans{};
    cin>>n;
    if(n==1) return puts("1"),0;
    vector<int> a(3*n);
    for(auto&i:a) cin>>i,--i;
    auto dp=vector(n,vector(n,INT_MIN));
    auto dp2=vector(n,INT_MIN);
    int dp3{};
    fr(i,n) sort(a.begin()+max(0,3*i-1),a.begin()+3*i+2);
    dp[a[0]][a[1]]=dp2[a[0]]=dp2[a[1]]=0;
    struct ud{
        int i,j,k;
    };
    vector<ud> q;
    Fr(i,n-1){
        int x=a[3*i-1],y=a[3*i],z=a[3*i+1];
        if(x==z){
            ++ans;
            continue;
        }
        fr(j,n){
            q.push_back(ud{j,x,dp2[j]});
            q.push_back(ud{j,y,dp2[j]});
            q.push_back(ud{j,z,dp2[j]});
            q.push_back(ud{x,y,max(dp3,dp[z][z]+1)});
            q.push_back(ud{x,z,max(dp3,dp[y][y]+1)});
            q.push_back(ud{y,z,max(dp3,dp[x][x]+1)});
        }
        if(x==y or y==z){
            if(y==z) swap(x,z);
            fr(j,n) if(j!=x){
                q.push_back(ud{j,z,dp[min(j,x)][max(j,x)]+1});
            }
            q.push_back(ud{x,x,dp[z][z]+1});
        }
        for(auto[X,Y,D]:q){
            if(X>Y) swap(X,Y);
            chmax(dp[X][Y],D);
            chmax(dp2[X],D);
            chmax(dp2[Y],D);
            chmax(dp3,D);
        }
        q.clear();
    }
    cout<<max(dp3,dp[a[3*n-1]][a[3*n-1]]+1)+ans<<'\n';
}

Measured memory_bytes: 19528
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

signed main() {
  int N, Q;
  cin >> N >> Q;
  
  Graph G(N);
  int A, B;
  for( int i = 0; i < N-1; i++ ){
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }

  vector<int> ten(N, 0);
  int P, X;
  for( int i = 0; i < Q; i++ ){
    cin >> P >> X;
    ten.at(P-1) += X;
  }
  
  
  //頂点1を根にDFS
  vector<bool> seen(N, false);
  vector<int> dist(N, 0);
  stack<int> sta;
  
  dist.at(0) = ten.at(0);
  seen.at(0) = true;
  sta.push(0);
  
  while( !sta.empty() ){
    int v = sta.top();
    sta.pop();
    
    for( int nv : G.at(v) ){
      if( seen.at(nv) ) continue;
      dist.at(nv) = dist.at(v) + ten.at(nv);
      seen.at(nv) = true;
      sta.push(nv);
    }
  } 
  
  for( int i = 0; i < N; i++ ) cout << dist.at(i) << " ";
  cout << endl;
  
    
}
  

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


ll n,x;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    map <ll,ll> mp;
    ll res=0;
    for (ll i=1; i<=n; i++){
        cin>>x;
        res+=mp[i-x];
        mp[x+i]++;
    }
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 26192
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int h, w, c;
int ans = 0;
int pc = 0;
vector< vector<int> > cp;
int flag = 0;

void change(vector< vector<int> > &p, int color, int y, int x, int tmp) {
	p[y][x] = color;

	if(x+1 < w) if(tmp == p[y][x+1])
		change(p, color, y, x+1, tmp);

	if(y+1 < h) if(tmp == p[y+1][x])
		change(p, color, y+1, x, tmp);

	if(x-1 >= 0) if(tmp == p[y][x-1])
		change(p, color, y, x-1, tmp);

	if(y-1 >= 0) if(tmp == p[y-1][x])
		change(p, color, y-1, x, tmp);


}

void pcount(vector< vector<int> > &p, int color, int y, int x) {
	p[y][x] = -1;
	pc++;

	if(ans < pc) ans = pc;

	if(x+1 < w) if(color == p[y][x+1])
		pcount(p, color, y, x+1);

	if(y+1 < h) if(color == p[y+1][x])
		pcount(p, color, y+1, x);

	if(x-1 >= 0) if(color == p[y][x-1])
		pcount(p, color, y, x-1);

	if(y-1 >= 0) if(color == p[y-1][x])
		pcount(p, color, y-1, x);

}

void solve(vector< vector<int> > p, int color, int count) {
	if( p[0][0] != color ) change(p, color, 0, 0, p[0][0]);

	if( count < 5 ) {
		if( count < 4  ) {
			for(int i = 1; i <= 6 ; i++) {
				if( p[0][0] == i ) continue;
				solve(p, i, count+1);
			}
		} else {
			solve(p, c, count+1);
		}
	}else {
		cp = p;
		pc = 0;
		pcount(p, p[0][0], 0, 0);
		flag = 1;
	}

}

int main(void) {
	vector< vector<int> > p;
	int i, j;

	while(1) {
		p.clear();
		ans = 0;
		scanf("%d %d %d", &h, &w, &c);

		if(h == 0 && w == 0 && c == 0) break;

		for(i = 0; i < h; i++) {
			vector<int> v_tmp;
			int tmp;
			for(j = 0; j < w; j++) {
				scanf("%d", &tmp);
				v_tmp.push_back(tmp);
			}
			p.push_back(v_tmp);
		}

		for(i = 1; i <= 6; i++) {
			if( p[0][0] == i ) continue;
			solve(p, i, 1);
		}
/*		
for(int aa=1;aa<=6;aa++){
for(i=0;i<p.size();i++){
for(j=0;j<p[0].size();j++){
cout<<p[i][j]<<" ";
}cout<<endl;
}	cout<<endl;
cout<<"change to "<<(p[0][0])%6+1 <<endl;
change(p,(p[0][0])%6+1,0,0,p[0][0]);
}
*/
		printf("%d\n", ans);

	}

	return 0;

}

Measured memory_bytes: 1224
while True:
  a,b,c = list(input().split())
  a = int(a)
  c = int(c)
  if b == "?":
    break
  if b == "+":
    print(a+c)
  elif b == "-":
    print(a-c)
  elif b == "*":
    print(a*c)
  elif b == "/":
    print(a//c)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int N, L;
    cin >> N >> L;
    vector<string> s(N);
    // vector<vector<char>> s(N, vector<char>(L));

    rep(i, N) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i, N) cout << s[i];
    cout << endl;

    return 0;
}

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

typedef long long ll;

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

    string s; cin >> s;
    int n = s.size();
    reverse(s.begin(),s.end());
    bool ok = true;
    for(int i=0;i<n;){
        if(s[i]=='m'){
            if(s.substr(i,5)!="maerd"){
                ok = false;
                break;
            }else{
                i += 5;
            }
        }
        else if(s[i]=='e'){
            if(s.substr(i,5)!="esare"){
                ok = false;
                break;
            }else{
                i += 5;
            }
        }
        else if(s[i]=='r'){
            if(s.substr(i,7)!="remaerd" && s.substr(i,6)!="resare"){
                ok = false;
                break;
            }
            else if(s.substr(i,7)=="remaerd") i += 7;
            else if(s.substr(i,6)=="resare") i += 6;
        }
        else{
            ok = false;
            break;
        }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin >> S;
    string ans;
    if(S=="Sunny") ans="Cloudy";
    else if(S=="Cloudy") ans="Rainy";
    else ans="Sunny";
    cout << ans << endl;



}


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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
const int N=1e5+5;



int32_t main() {
    faster;

    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    int A[a],B[b],C[c];
    for(int i=0;i<a;i++) cin>>A[i];
    sort(A,A+a,greater<int>());
    for(int i=0;i<b;i++) cin>>B[i];
    sort(B,B+b,greater<int>());
    for(int i=0;i<c;i++) cin>>C[i];
    sort(C,C+c,greater<int>());

    int ans=0;
    multiset<pii> ms;
    for(int i=0;i<x;i++) ms.insert({A[i],1});
    for(int i=0;i<y;i++) ms.insert({B[i],2});

    for(auto k:ms) ans+=k.first;
    int k1=0,k2=0;
    for(int i=0;i<c;i++){
        auto tmp=ms.begin();
        if((*tmp).first<C[i]){
            if((*tmp).second==3) break;
            if((*tmp).second==1) x--;
            else y--;

            if(x<0){
                while(!ms.empty()&&(*ms.begin()).second==1) continue;
                x=0;
            }
            if(y<0){
                while(!ms.empty()&&(*ms.begin()).second==2) continue;
                y=0;
            }

            if(ms.empty()) break;
            else tmp=ms.begin();

            ans+=C[i];
            ans-=(*tmp).first;
            ms.insert({C[i],3});
            ms.erase(tmp);
        }else break;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 13824
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        final int[] x = new int[N];
        final int[] y = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        final double[][] costs = new double[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                costs[i][j] = Math.sqrt(Math.pow(x[i]-x[j], 2) + Math.pow(y[i]-y[j], 2));
            }
        }

        List<List<Integer>> perms = new ArrayList<>();
        List<Integer> candidate = IntStream.range(0, N).boxed().collect(Collectors.toList());
        perm(candidate, new ArrayList<>(), perms);

        double total = 0;

        for (int i = 0; i < perms.size(); i++) {
            double sum = 0;
            final List<Integer> perm = perms.get(i);
            for (int j = 0; j < perm.size() -1; j++) {
                total += costs[perm.get(j)][perm.get(j+1)];
            }
            total += sum;
        }

        System.out.println(total / perms.size());
    }

    private static void perm(List<Integer> candidate, List<Integer> perm, List<List<Integer>> perms) {
        if (candidate.size() == 0) {
            perms.add(perm);
        }
        for (int i = 0; i < candidate.size(); i++) {
            List<Integer> c = new ArrayList<>(candidate);
            List<Integer> p = new ArrayList<>(perm);
            p.add(c.get(i));
            c.remove(i);
            perm(c, p, perms);
        }
    }
}


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

int main(){
  int r,g,b,n,ans = 0;
  cin >> r >> g >> b >> n;
  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=n/g;j++){
      if((n-r*i-g*j)%b == 0&&(n-r*i-g*j)>=0)
      ans++;
    }
  }
  cout << ans << endl;
}



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

bool solve() {
    string s;
    cin >>  s;
    map<char,int> m;
    for ( int i = 0; i < 3; i++ ) {
        m[s[i]]++;
    }
    
    return m.size() != 1;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256