akhauriyash/Code-Regression huggingface dataset:
while True:
    ins = input().split()
    
    a = int(ins[0])
    b = int(ins[2])
    op = ins[1]

    if op == "?":
        break
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "/":
        print(a//b)
    else:
        print(a*b)

Measured memory_bytes: 7648
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    priority_queue<int> q1, q2, q3;
    int ans = 0;
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    rep(i, A) {int p; cin >> p; q1.push(p);}
    rep(i, B) {int p; cin >> p; q2.push(p);}
    rep(i, C) {int p; cin >> p; q3.push(p);}
    rep(i, X) {int p = q1.top(); q1.pop(); q3.push(p);}
    rep(i, Y) {int p = q2.top(); q2.pop(); q3.push(p);}
    rep(i, X + Y) {int p = q3.top(); q3.pop(); ans += p;}
    cout << ans << endl;

    return 0;
}


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

const int N = 2005;
const int MOD = 1e9+7;

int dp[N];

void solve() {
    int n;
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 3; j <= i; j++) {
            dp[i] += dp[i-j];
            if (dp[i] >= MOD) dp[i] -= MOD;
        }
    }
    cout << dp[n] << endl;
}

int main(){

    solve();
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	int N, L;
	CIN2(N, L);
	vector<string> v(N);
	REP(i, N) {
		CIN(v[i]);
	}
	sort(ALL(v));
	REP(i, N) {
		cout << v[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

signed main() {
    Fast();

    int a, b;
    cin >> a >> b;
    if(a + b >= 10) cout << "error";
    else cout << a + b;
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi te(n);
	rep(i,n)cin>>te[i];
	vvi in(m,vi(3));
	rep(i,m)rep(j,3)cin>>in[i][j];
	vvi dp(n,vi(m));
	loop(i,1,n)rep(j,m)if(in[j][0]<=te[i]&&te[i]<=in[j][1]){
		int mi=0;
		rep(k,m)if(in[k][0]<=te[i-1]&&te[i-1]<=in[k][1])
			mi=max(mi,dp[i-1][k]+abs(in[j][2]-in[k][2]));
		dp[i][j]=max(dp[i][j],mi);
	}
	int out=0;
	rep(i,m)out=max(out,dp[n-1][i]);
	cout<<out<<endl;
}
 
 

Measured memory_bytes: 1352
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 100005;

char C[MAXN];
int cnt[MAXN], l, sol, br;

int main() {
	scanf("%s", C);
	l = strlen(C);
	cnt[0] = ('p' == C[0]);
	for (int i = 1; i < l; ++i) {
		cnt[i] = cnt[i-1] + ('p' == C[0]);
	}

	for (int i = 0; i < l; ++i) {
		if (C[i] == 'p') {
			if (br > 0) br--;
			else {
				br++;
				sol--;
			}
		} else {
			if (cnt[i] < br) {
				br--;
				sol++;
			} else {
				br++;
			}
		}
	}

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


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	ll n;
	cin >> n;
	ll a[n],b[n],a_sum = 0,b_sum = 0,ans = 0,c_sum = 0;
	priority_queue<ll, vector<ll> > pq;
	bool flag = false;
	
	rep(i,0,n){
		cin >> a[i]; //zyunbi
		a_sum += a[i];
	}
	
	rep(i,0,n){
		cin >> b[i]; //siken
		b_sum += b[i];
		if(b[i] > a[i]){
			c_sum += b[i] - a[i];
			ans++;
			flag = true;
		}
		else{
			pq.push(a[i] - b[i]);
		}
	}
	
	while(pq.size() > 0 && flag){
		ans++;
		if(pq.top() >= c_sum){
			break;
		}
		
		c_sum -= pq.top();
		pq.pop();
	}
	
	
	if(b_sum > a_sum) cout << -1 << endl;
	else cout << ans << endl;
	return 0;

}

Measured memory_bytes: 2680
N = int(input())

def make_yakusu(x):
  all_yakusu=[]
  for i in range(1,int(x**0.5)+1):
    if x % i == 0:
      kumi_yakusu=[int(i), int(x / i)]
      all_yakusu.append(kumi_yakusu)
  return(all_yakusu)

tp = make_yakusu(N)
idouryou_list = []
for i in range(len(tp)):
  xn = tp[i][0]
  yn = tp[i][1]
  idouryou_list.append(int(xn) + int(yn) -2)
print(min(idouryou_list))


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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}

const int N = 1e5+100;

vector<int> g[N];
int a[N];
long long dp[N];

void dfs(int u, int p) {
//    debug(), dbg(u), dbg(p);
    if(g[u].size() == 1) {
        dp[u] = a[u];
        return;
    }
    long long sum = 0;
    vector<long long> all;
    for(int v : g[u]) {
        if(v == p) continue;
        dfs(v, u);
        sum += dp[v];
        all.push_back(dp[v]);
    }
    sort(all.begin(), all.end());
    long long pairs = 0;
    if(all.size() >= 2) {
        long long mx = all.back();
        long long other = sum-mx;
        if(other >= mx) pairs = sum/2;
        else pairs = other;
    }
    long long req_pair = sum-a[u];
//    debug(), dbg(u), dbg(req_pair), dbg(pairs), dbg(sum);
    if(req_pair >= 0 && req_pair <= pairs) {
        dp[u] = sum - 2*req_pair;
    }
    else {
        cout << "NO" << endl;
        exit(0);
    }
}

int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if(n == 2) {
        if(a[1] == a[2]) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
        return 0;
    }
    int root = -1;
    for(int i = 1; i <= n; i++) {
        if(g[i].size() > 1) {
            root = i;
            break;
        }
    }
    dfs(root, -1);
//    for(int i = 1; i <= n; i++) {
//        debug(), dbg(i), dbg(dp[i]);
//    }
    if(dp[root] == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}





Measured memory_bytes: 19544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c;
inline void cmp(ll x,ll y){
	if(x>y)printf("Left\n");
	else if(x<y)printf("Right\n");
	else printf("Balanced\n");
	return;
}
int main(){
	scanf("%lld%lld",&a,&b);
	a+=b;
	scanf("%lld%lld",&c,&b);
	c+=b;
	cmp(a,c);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,m,ans,a[200002],head[200002],cnt;
struct edge{
	int to,next;
}e[400002];
inline void add(re int x,re int y){
	e[++cnt]=(edge){y,head[x]};
	head[x]=cnt;
}
signed main(){
	n=read();m=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	for(re int i=1,x,y;i<=m;++i){
		x=read();y=read();
		add(x,y);
		add(y,x);
	}
	for(re int i=1;i<=n;++i){
		bool ia=1;
		for(re int j=head[i];j;j=e[j].next)if(a[i]<=a[e[j].to]){
			ia=0;
			break;
		}
		if(ia)++ans;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 6104
import java.util.*;

public class Main {
    public static void main(String[] args) {

        solve_152_A();
        
        return;
    }

    private static void solve_152_A() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        if(N==M) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23764
class Solver():
    def __init__(self, N, W, items):
        self.N = N
        self.W = W
        self.items = items

    def solve(self):
        dp = [[0 for _ in range(self.W+1)] for _ in range(self.N+1)]
        for i in range(self.N):
            for w in range(self.W+1):
                if w - self.items[i][0] >= 0:
                    dp[i+1][w] = max(dp[i+1][w], dp[i][w - self.items[i][0]] + self.items[i][1])

                dp[i + 1][w] = max(dp[i + 1][w], dp[i][w])
        return dp[self.N][self.W]


def main():
    N, W = [int(i) for i in input().split()]
    items = [[int(i) for i in input().split()] for _ in range(N)]
    solver = Solver(N, W, items)
    print(solver.solve())


if __name__ == "__main__":
    main()

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

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

  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; j++) {
      int rest = y - i * 10000 - j * 5000;
      int c = n - i - j;
      if (c >= 0 && rest / 1000 == c && rest % 1000 == 0) {
        cout << i << " " << j << " " << rest / 1000 << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a,b;
  cin >> a >> b;
  if((a-b)%2 == 0) cout << (a+b)/2;
  else cout << "IMPOSSIBLE";
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,a,b=map(int,input().split())
    l=min(a,b)
    if n>a+b:
        r=0
    else:
        r=a+b-n
    print(l,r)
    
resolve()

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

int main() {
  int n;
  cin >> n;
  set<string>st;
  rep(i,n){
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19208
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<ll>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int K, S;
	cin >> K >> S;
	
	int ans = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (0 <= z && z <= K) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 2005;

ll dp[N][N];
int n;
vector <pair <ll, ll>> a;

ll go(int l, int r, int idx) {
  if(idx == n) return 0;
  if(dp[l][r] != -1) return dp[l][r];
  ll p = a[idx].first, q = a[idx].second;
  ll LL = p * abs(q - l) + go(l + 1, r, idx + 1);
  ll RR = p * abs(q - r) + go(l, r - 1, idx + 1);
  ll res = max(LL, RR);
  return dp[l][r] = res;
}

int main() {
  cin >> n;
  a.resize(n);
  for(ll i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.rbegin(), a.rend());
  memset(dp, -1, sizeof dp);
  cout << go(0, n - 1, 0) << '\n';
}

Measured memory_bytes: 35176
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
   
  for(int i = 0; i < 26; i++){
    if(s.find('a' + i) == s.npos){
      cout << (char)('a' + i) << endl;
      return 0;
    }
  }
  
  cout << "None" << endl;
 
  return 0;
}

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

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

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int S = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    int[] A = new int[M];
    int[] B = new int[M];
    int[] E = new int[M];
    for (int i = 0; i < M; i++) {
      int u = scanner.nextInt() - 1;
      int v = scanner.nextInt() - 1;
      A[i] = scanner.nextInt();
      B[i] = scanner.nextInt();
      nodes[u].edges.add(i);
      nodes[v].edges.add(i);
      E[i] = u ^ v;
    }
    int[] C = new int[N];
    int[] D = new int[N];
    for (int i = 0; i < N; i++) {
      C[i] = scanner.nextInt();
      D[i] = scanner.nextInt();
    }

    long INF = 10_000_000_000_000L;
    int G = 2500;
    long[][] dp = new long[N][G + 1];
    for (int i = 0; i < N; i++) Arrays.fill(dp[i], INF);
    for (int i = 0; i <= S && i <= G; i++) dp[0][i] = 0;
    for (int k = 0; k < N * 2; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j <= G; j++) {
          if (j >= C[i]) dp[i][j] = Math.min(dp[i][j], dp[i][j - C[i]] + D[i]);
          for (int e : nodes[i].edges) if (j + A[e] <= G) dp[i][j] = Math.min(dp[i][j], dp[E[e] ^ i][j + A[e]] + B[e]);
        }
      }
    }
    for (int i = 1; i < N; i++) {
      long min = INF;
      for (int j = 0; j <= 2500; j++) {
        min = Math.min(min, dp[i][j]);
      }
      System.out.println(min);
    }
  }

  private static class Node {
    private final List<Integer> edges = new ArrayList<>();
  }
}


Measured memory_bytes: 57912
#include <stdio.h>

int a[200000];
int b[200000];

int main(void)
{
	int n, m, i, j;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {
		scanf("%d", b + i);
	}
	for (i = j = 0; i < n && j < m; i++) {
		j += a[i] == b[j];
	}
	puts(j == m ? "1" : "0");
	return 0;
}



Measured memory_bytes: 3268
let inputs = require('fs').readFileSync('/dev/stdin', 'UTF-8').split('\n');
const num = inputs[0];
const nums = inputs[1].split(' ').map(Number);
const min = nums.reduce((a,b) => Math.min(a,b));
const max = nums.reduce((a,b) => Math.max(a,b));
const sum = nums.reduce((a,b) => a+b);
console.log(min + ' ' + max+ ' ' + sum);


Measured memory_bytes: 18180
#include<bits/stdc++.h>
#define ll long long
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
using namespace std;

ll a[200005];
ll boom[200005];
//dp[]
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    ll n;cin>>n;ll sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        boom[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        sum+=boom[i]*(boom[i]-1)/2;
    }
    for(int i=1;i<=n;i++)
    {
        ll t=boom[a[i]];
        ll tt=sum-t*(t-1)/2+(t-1)*(t-2)/2;
        cout<<tt<<endl;
    }
}


Measured memory_bytes: 4736
#include<stdio.h>
#include<stdlib.h>
#define df 0


int main(){
  int i,a,b,flag=1;
  char S[5],p,q;
  scanf("%s",S);
  p=S[0];
  for(i=1;i<4;i++){
    if(S[i]==p){
      a=i;
      b=a%3+1;
      break;
    }
  }
  if(i==4)flag=0;
  else if(S[a]==S[b] || S[b]!=S[6-a-b])flag=0;

  printf("%s",flag?"Yes":"No");
  return 0;
}


/// confirm df==1 ///

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

using namespace std;

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    int i,m;
    i=x-a;
    m=x-b;
    if(i<0) i*=-1;
    if(m<0) m*=-1;
    
    if(i<m) cout<<"A"<<endl;
    else cout<<"B"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
void chmax(t &a, u b)
{
    if (a < b)
        a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
    if (b < a)
        a = b;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ans += i;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += xs[i] * xs[j];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
s = gets.chomp.split('')
t = gets.chomp.split('')
# p s #["k", "y", "o", "t", "o"]
# p t #["t", "o", "k", "y", "o"]

# p s.count  #5

array = []
for i in 1..s.count
    # p s.rotate(i)
    #["y", "o", "t", "o", "k"]
    #["o", "t", "o", "k", "y"]
    #["t", "o", "k", "y", "o"]
    #["o", "k", "y", "o", "t"]
    #["k", "y", "o", "t", "o"]
    array.push(s.rotate(i))
end
if array.include?(t)
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1916
#include <stdio.h>
int main(){
	int x,y,z,z1;
	scanf("%d %d",&x,&y);
	getchar();
	z=100*(10-x);
	z1=y+z;
	if (x>=10)
	{
		printf("%d",y);
	}
	else
	{
		printf("%d",z1);
	}
	return 0;
}

Measured memory_bytes: 1668
fun main(args:Array<String>){
  var s = readLine()!!.toInt()
  var a = s/100
  var b = s%100
  if(0<b && b<13){
    if(0<a && a<13){
      println("AMBIGUOUS")
    }else{
      println("YYMM")
    }
  }else{
    if(0<a && a<13){
      println("MMYY")
    }else{
      println("NA")
    }
  }
}

Measured memory_bytes: 31904
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    forn (i, 0, n)
        cin >> a[i];
    int cur = 1;
    forn (i, 0, n) {
        if (a[i] == cur) {
            cur++;
        }
    }
    if (cur == 1)
        cout << -1;
    else
        cout << n - cur + 1;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  string s,t;
  cin>>s>>t;
  if(s<t)cout<<'<'<<endl;
  else if(s>t)cout<<'>'<<endl;
  else cout<<'='<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		int max = 0;
		int current = H[N-1];
		int cnt = 0;
		for (int i = N-2; i >= 0; i--) {
			if (H[i] >= current) {
				current = H[i];
				cnt += 1;
				max = Math.max(max, cnt);
				// System.out.println("Y" + cnt);
			} else {
				current = H[i];
				cnt = 0;
				// System.out.println("X");
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 50860
import java.util.*;
class Main{
	public static void main(String[] args){
	  Scanner scan = new Scanner(System.in);
	  int N  = scan.nextInt();
      int A = 0;
      long count = 0;
      int max = 0;
      for(int i = 0; i < N; i++){
          A = scan.nextInt();
          if(i == 0)    max = A;
          else{
             if(max <= A) max = A;
          	 count += max - A;
          }
      }
      System.out.println(count);
	}
}

Measured memory_bytes: 58800
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    root = [[] for _ in range(N + 1)]
    for a, b in AB:
        root[a].append(b)
        root[b].append(a)

    que = deque()
    que.append(1)
    front = [-1] * (N + 1)
    front[1] = 1
    while que:
        point = que.popleft()
        for i in root[point]:
            if front[i] > 0:
                continue
            front[i] = point
            que.append(i)

    if min(front[1:]) < 0:
        print('No')
    else:
        print('Yes')
        for i in range(2, N + 1):
            print(front[i])

if __name__ == '__main__':
    main()


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;

    int ans=LLONG_MAX;

    for(int i=-1;i<=1;i+=2){
        for(int j=-1;j<=1;j+=2){
            int aa=a*i;
            int bb=b*j;
            if(aa>bb)continue;
            chmin(ans,bb-aa+(i==-1)+(j==-1));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

k = [i for i in range(1, n + 1) if i % 2 == 1]

res = 0

for i in k:
    cnt = 0
    for j in range(1, i + 1):
        if i % j == 0:
            cnt += 1
            
    if cnt == 8:
        res += 1

print(res)

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 2010
int bad[N], bad2[N];
vector<int> g[N];
int n;
int p[N], a[N];

void dfs_init(int u){
	for(auto v: g[u]){
		dfs_init(v);
		bad[u] += bad[v];
	}
	if(bad[u]==1 && a[u]==u) bad[u] = 0;
}

int search(int u){

	for(auto v: g[u]){
		if(bad2[v]) return search(v);
	}
	{
		int u2 = u;
		while(u2>=0){
			bad2[u2]--;
			u2 = p[u2];
		}
	}
	return u;
}

int search2(int u){
	if(g[u].empty()) return u;
	int mn = 0;
	for(auto v: g[u]){
		if(!bad[v]) continue;
		int w = search2(v);
		if(a[w]<a[mn]) mn = w;
	}
	if(mn==0) return u;
	return mn;
}

void rot(int u, int x){
	if(u<0) return;
	rot(p[u], a[u]);
	a[u] = x;
}

void update_bad(int u){
	bad[u] = 0;
	for(auto v: g[u]){
		update_bad(v);
		bad[u] += bad[v];
	}
	if(bad[u]||u!=a[u]) bad[u]++;
}

int main(){
	cin>>n;
	p[0] = -1;
	rep(i, n-1) cin>>p[i+1];
	rep(i, n) cin>>a[i];
	rep(i, n-1) g[p[i+1]].pb(i+1);
	fill(bad, bad+n, 1);
	dfs_init(0);
	vector<int> res;
	memcpy(bad2, bad, sizeof(bad));
	int cnt = 0;
	while(bad[0]){
		if(bad2[0]==1) memcpy(bad2, bad, sizeof(bad));
		/*if(cnt>20) break;
		rep(i, n) cerr<<a[i]<<" "; cerr<<endl;
		rep(i, n) cerr<<bad[i]<<" "; cerr<<endl;
		rep(i, n) cerr<<bad2[i]<<" "; cerr<<endl;
		cerr<<endl;*/
		int v = a[0];
		if(bad2[v]){
			v = search(v);
		}
		v = search2(v);
		rot(v, a[0]);
		update_bad(0);
		/*if(bad[v]==1&&v==a[v]){
			int u2 = v;
			while(u2>=0){
				bad[u2]--;
				u2 = p[u2];
			}
		}*/
		res.pb(v);
		cnt++;
		if(cnt>=30000) return -1;
	}
	cout<<res.size()<<endl;
	rep(i, res.size()) cout<<res[i]<<endl;
	//rep(i, n) cerr<<a[i]<<" ";
	return 0;
}


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

int main() {
	int a, b, x, c;
	c = 0;
	cin >> a >> b;
	int d[4], f[4], g[4];
	int z;

	for (x = a; x <= b; x++) {
		z = x;
		d[0] = z % 10;
		z /= 10;
		d[1] = z % 10;
		z /= 10;
		d[2] = z % 10;
		z /= 10;
		d[3] = z % 10;
		z /= 10;
		d[4] = z % 10;
		z /= 10;
		if (d[0] == d[4]&&d[1]==d[3]) {
			c = c + 1;
		}
	}
	cout << c << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int cnt=0;
  while(b<=a){
    b*=2;
    cnt++;
  }
  while(c<=b){
    c*=2;
    cnt++;
  }
  if(cnt<=k)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 3608
let () =
  let a, b, c = Scanf.scanf "%d %d %d" (fun a b c -> (a, b, c)) in
  let rec f tmp =
    let x = tmp mod b in
    match x with 0 -> "NO" | y when y = c -> "YES" | _ -> f (tmp + a)
  in
  f a |> print_endline

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


ll modpow(ll a, ll n, ll mod){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2, mod);
    return res * res % mod;
  }
  return a * modpow(a, n-1, mod) % mod;
}


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

  const ll mod = 1e9+7;

  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,61) {
    int cnt = 0;
    rep(j,n) {
      if((a[j]>>i) & 1) cnt++;
    }
    ll tmp = modpow(2,i,mod) * cnt % mod * (n-cnt) % mod;
    ans += tmp;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n,m;
vector<int> g[1005];

vector<int> bfs(int s){
  vector<int> d(n,INF),prev(n,-1);
  queue<int> q;
  d[s] = 0;
  q.push(s);
  while(!q.empty()){
    int now = q.front();q.pop();
    for(auto to:g[now]){
      if(d[to] != INF) continue;
      d[to] = d[now]+1;
      prev[to] = now;
      q.push(to);
    }
  }
  
  pair<int,int> shortest(INF,-1);
  rep(i,n){
    for(auto to:g[i]){
      if(to == s) shortest = min(shortest, make_pair(d[i],i));
    }
  }
  if(shortest.first == INF) return vector<int>(n+1);
  
  vector<int> ret;
  int p = shortest.second;
  while(p != -1){
    ret.push_back(p);
    p = prev[p];
  }
  return ret;
}

int main(){
  cin >> n >> m;
  rep(i,m){
    int a,b; cin >> a >> b;
    a--,b--;
    g[a].push_back(b);
  }
  vector<int> ans(n+1);
  
  rep(i,n){
    auto tmp = bfs(i);
    if(ans.size() > tmp.size()) ans = tmp;
  }
  
  if(ans.size() == n+1){
    cout << -1 << endl;
    return 0;
  }
  
  cout << ans.size() << endl;
  for(auto e:ans) cout << e+1 << endl;
  
  return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		Map<String,Boolean> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String Ni = sc.next();
			if (map.containsKey(Ni)) {
				map.remove(Ni);
			} else {
				map.put(Ni, Boolean.TRUE);
			}
		}
		
		System.out.println(map.size());
	}
}

Measured memory_bytes: 51892
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    int n;
    cin>>n;
    int ans =0;
    if(n%1000!=0)
    {
        ans +=(1000-(n%1000));
    }
    cout<<ans<<"\n";
    return 0;
}

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

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

inline double sq(double x) { return x*x; }

template <typename Weight>
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight): src(src), dst(dst), weight(weight) {}
    bool operator<(const Edge<Weight>& other) const { return weight < other.weight; }
};
template <typename Weight> using Vertex = vector<Edge<Weight>>;
template <typename Weight> using Graph = vector<Vertex<Weight>>;

struct UnionFind {
    vector<int> data;
    explicit UnionFind(int size): data(size, -1) {}
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
};

template <typename Weight>
double kruskal(const Graph<Weight>& g) {
    UnionFind uf(g.size());

    vector<Edge<Weight>> edges;
    for (auto& v : g) edges.insert(edges.end(), v.begin(), v.end());
    sort(edges.begin(), edges.end());

    Weight total = 0;
    for (auto& e : edges) {
        if (uf.merge(e.src, e.dst)) {
            total += e.weight;
        }
    }
    return total;
}

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

    int N, M;
    while (cin>>N>>M) {
        vector<pair<int, int>> piles(N), fances(M);
        REP(i, N) cin >> piles[i].first >> piles[i].second;
        REP(i, M) {
            cin >> fances[i].first >> fances[i].second;
            --fances[i].first; --fances[i].second;
        }

        Graph<double> g(N);
        double total = 0;
        REP(i, M) {
            auto& p1 = piles[fances[i].first];
            auto& p2 = piles[fances[i].second];
            double length = sqrt(sq(p1.first - p2.first) + sq(p1.second - p2.second));
            g[fances[i].first].emplace_back(fances[i].first, fances[i].second, -length);
            total += length;
        }

        double w = -kruskal(g);
        cout << setprecision(10) << total - w << '\n';
    }
}

Measured memory_bytes: 5176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);

int modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;sc(n)
    vector<int> x(n);
    REP(i, n) sc(x[i])
    int mod = 1e9 + 7;
    ll ans = 0, seg, sum = 0;

    REP(i, n - 1){
        seg = (x[i + 1] - x[i] + mod) % mod;
        sum = (sum + modpow(i + 1, mod - 2, mod)) %mod;
        ans = (ans + seg * sum % mod) %mod;
    }

    ll acc = 1;
    for (int i = 1; i < n; i++){
        acc *= i;
        acc %= mod;
    }

    cout << (ans * acc)%mod << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

int A[50][50];
int B[50][50];
int N, M;

signed main()
{
	init();
	solve();
}

void init()
{
	cin >> N >> M;
	rep(i, N) rep(j, N) {
		CIN(char, t);
		A[i][j] = t == '#';
	}
	rep(i, M) rep(j, M) {
		CIN(char, t);
		B[i][j] = t == '#';
	}
}

bool ch(int r, int c)
{
	rep(i, M) rep(j, M) {
		if (r+i >= N || c + j >= N) return false;
		if (B[i][j] != A[r+i][c+j]) return false;
	}
	return true;
}

void solve()
{
	rep(i, N) rep(j, N) {
		if (ch(i, j)) {
			PRINT(true);
			return;
		}
	}
	PRINT(false);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char s[4];
	scanf("%s",s);
	if((s[0]=='A'&&s[1]=='A'&&s[2]=='A')||(s[0]=='B'&&s[1]=='B'&&s[2]=='B')){
		printf("No");
	}else{
		printf("Yes");
	}
	return 0;
}


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

int partition(int A[],int p,int r){
   int x=A[r];
   int i=p-1;
   for(int j=p;j<=r-1;j++){
      if(A[j]<=x){
          i=i+1;
          int a;
          a=A[i];
          A[i]=A[j];
          A[j]=a;
      }
   }
   int b;
   b=A[i+1];
   A[i+1]=A[r];
   A[r]=b;
   return i+1;
}

int main(){
   int n;
   cin >> n;
   int A[100000];
   for(int i=0;i<n;i++)
      cin >> A[i];
   int p=partition(A,0,n-1);
   for(int i=0;i<n;i++){
      if(i==p)
         cout << '[' << A[i] << ']';
      else
         cout << A[i];
      if(i<n-1)
         cout << ' ';
      else
         cout << endl;
   }
   return 0;
}

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

int main(){
    string s;
    cin >> s;
    int x = (int)'a';
    int y = (int)'z';
    int count[26] = {};
    for(int i = 0; i < s.size(); i++){
        int p = (int)s[i];
        count[p-x] += 1;
    }
    for(int i = 0; i < 26; i++){
        if(count[i] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    } 
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input=lambda: sys.stdin.readline().rstrip()
x=int(input())
A=[int(i) for i in range(5000)]
Ans=[]
for a in A:
  for b in A:
    if a**5+b**5==x and not Ans:
      Ans=[a,-b]
    if a**5-b**5==x and not Ans:
      Ans=[a,b]
print(*Ans)

Measured memory_bytes: 68104
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

struct edge {
  int to, cost;
};

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}


signed main()
{
  int n; cin >> n;
  vec<int> a(n);
  rep(i, 0, n) {
    cin >> a[i];
  }

  deque<int> dq;
  rep(i, 0, n) {
    if ((n-i) % 2 == 1) {
      dq.push_front(a[i]);
    } else {
      dq.push_back(a[i]);
    }
  }

  rep(i, 0, n) {
    cout << dq[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  map<int,int> m;
  cin >> n >>k;
  int temp;
  for(int i=1;i<=n;i++){
    cin >> temp;
    m[i]=temp;
  }
  int ans=1;
  vector<int> path;
  map<int,int> m2;
  for(int i=0;i<=n;i++){
    if(m2.find(ans)==m2.end()){
      m2[ans]=i;
      path.push_back(ans);
      if(k==i){cout << ans << endl;
        break;
      }
      ans=m[ans];
      
    }else{
      int roop_init=m2[ans];
      int roop=i-roop_init;
      long long  index;
      index=(k-roop_init)%roop+roop_init;
      cout << path[index] << endl;
      break;
    }
  }
  return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    for(int i=1; i<=1000000; i++){
        int a = i*8/100;
        int b = i*10/100;
        if(a == A && b == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256