akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll N;
    string s;
    cin>>s;
    N=s.size();
    ll ar[N+1]={};
    ar[N]=0;
    for(ll i=N-1;i>=0;i--)
    {
        if(s[i]=='>')
            ar[i]=ar[i+1]+1;
        else
            ar[i]=0;
    }
    ll ans[N+1]={};
    for(ll i=0;i<N+1;i++)
    {
        if(i==0)
            ans[i]=ar[i];
        else
        {
            if(ar[i]==ar[i-1])
                ans[i]=ans[i-1]+1;
            else
            {
                if(ar[i-1]==0)
                    ans[i]=max(ans[i-1]+1,ar[i]);
                else
                    ans[i]=ar[i];
            }
        }
    }
    //oa(ans,N+1);
    ll sum=0;
    for(ll i=0;i<N+1;i++)
        sum+=ans[i];
    cout<<sum<<endl;
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 
/*
Powered by Buggy plugin
*/


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

int main()
{
    int n;
    long sum = 0;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    vector<int> difference(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        difference.at(i) = v.at(i) - c.at(i);
    }
    sort(difference.begin(), difference.end());
    reverse(difference.begin(), difference.end());
    for (int i = 0; i < n; i++)
    {
        if (difference.at(i) <= 0)
        {
            break;
        }
        else
        {
            sum += difference.at(i);
        }
    }
    cout << sum << endl;

    return 0;
}

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

int main() {
  int N, M, C, Sum=0, cnt=0;
  cin >> N >> M >> C;
  vector<int> B(M), A(M);
  rep(i, M) cin >> B.at(i);
  rep(i, N){
    rep(j, M){
      cin >> A.at(j);
      Sum=Sum+A.at(j)*B.at(j);
    }
    if(Sum+C>0) cnt++;
    Sum=0;
  }
  cout << cnt << endl;
}

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

using namespace std;

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



int const MAX_N = 100000;
int par[MAX_N]; // 親
int depth[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        depth[i] = 0;
    }
}

// 木の根を求める
int find(int x){
    if (par[x] == x) {
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を合併
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (depth[x] < depth[y]) {
        par[x] = y;
    }else{
        par[y] = x;
        if (depth[x] == depth[y]) depth[x]++;
    }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}



int main(){
    int n, m;
    cin >> n >> m;
    int x[m], y[m], z[m];
    rep(i, m){
        cin >> x[i] >> y[i] >> z[i];
    }
    init(n);
    rep(i, m){
        unite(x[i]-1, y[i]-1);
    }
    int ans = 0;
    rep(i, n){
        if (find(i) == i) {
            ans++;
        }
    }
cout << ans << endl;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


double N; 
double x[10], y[10];
double dis(double x1, double x2, double y1, double y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}
int main() {
	cin >> N;
	REP(i, N)cin >> x[i] >> y[i];
	vector<int>v;
	double key = 1;
	REP(i, N) {
		v.push_back(i);
		key*=(i + 1);
	}
	sort(v.begin(), v.end());
	double sum = 0;
	do {
		double res = 0;
		REP(i, N-1) {
			res += dis(x[v[i]], x[v[i + 1]], y[v[i]], y[v[i + 1]]);
		}
		sum += res;
	} while (next_permutation(v.begin(), v.end()));
	cout << fixed << setprecision(12) << sum/key << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	fmt.Println(gcd(x, y))
}

func gcd(a, b int)int{
	if a<b{
		tmp := a
		a = b
		b = tmp
	}

	r := a % b
	for r != 0{
		a = b
		b = r
		r = a % b
	}
	return b
}


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

typedef long long ll;

// dp[k]
// k ???????¨??????????
// ???????????????????????° mod 1e9+7 ???????????¨???????????????
ll dp[310 * 310];

const ll M = 1e9+7;

int main() {
	int d;
	vector<int> l;
	int s;
	cin >> d;
	l.resize(d);
	for(int i = 0; i < l.size(); i++)
		cin >> l[i];
	cin >> s;

	dp[0] = 1;
	for(int i = 0; i < l.size(); i++) {
		for(int j = 310*310; j >= 0; j--) {
			if(j - l[i] < 0) continue;
			dp[j] = (dp[j] - dp[j-l[i]] + M) % M;
		}
	}
	ll res = 0;
	for(int i = 0; i <= s; i++) {
		ll x = 1;
		for(int j = 0; j < d; j++) x = x * (s-i) % M;
		res = (res + dp[i] * x) % M;
	}
	cout << res << endl;
}

Measured memory_bytes: 1952
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int x, a, b;

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen(fname".in", "r", stdin);
	// freopen(fname".out", "w", stdout);
	scanf("%d%d%d", &x, &a, &b);
	if(b <= a){
		printf("delicious\n");
	}else if(-a + b <= x){
		printf("safe\n");
	}else{
		printf("dangerous\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    vi l(C);
    rep(i,C) cin >> l[i];

    vector<pair<int,int>> v(N);
    rep(i,N){
        cin >> v[i].se >> v[i].fi;
        v[i].se--;
    }
    sort(all(v));
    reverse(all(v));

    ll ans = 0;
    vi cnt(C,0);
    int m = 0;
    rep(i,N){
        int color = v[i].se;
        int value = v[i].fi;
        if(cnt[color] == l[color])continue;
        cnt[color]++;
        ans += value;
        if(++m == M) break;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4412
#include <iostream>

using namespace std;

long long  XORsum(long long a)
{
    if(a == 0) return 0;

    long long ans;
    switch (a % 4)
    {
    case 0:
        ans = a;
        break;
    
    case 1:
        ans = 1;
        break;

    case 2:
        ans = 1 ^ a;
        break;

    case 3:
        ans = 0;
        break;
    }
    return ans;

}

int main(int argc, char const *argv[])
{
    long long A, B;
    cin >> A >> B;
    A--;
    long long sumA = XORsum(A);
    long long sumB = XORsum(B);

    cout << (sumB ^ sumA) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  VI c(4);
  REP (i, 6) {
    int a; cin >> a;
    a--;
    c[a]++;
  }
  sort(ALL(c));
  cout << (c == VI({1, 1, 2, 2}) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import java.util.*;

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 class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	static int[] intArray(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 = intArray(sc, N);

		boolean ok = true;
		int curr = H[N - 1];
		for (int i = N-2; i >= 0; i--) {
			int x = H[i];
			if (x > curr + 1) {
				ok = false;
				break;
			}
			if (x < curr) {
				curr = x;
			}
		}
		if (ok) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 50548
#include<iostream>
using namespace std;
int main()
{
	char a[5];
	for(int i=0;i<4;i++)
	{
		cin>>a[i];
	}
	a[4]='\0';
	for(int i=0;i<3;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll n; cin >> n;
	vector<ll> dvs;
	for( ll i = 1; i*i <= n; ++i ){
		if( n%i == 0 ){
			dvs.push_back( i );
			if( i*i != n ) dvs.push_back( n/i );
		}
	}
	sort( dvs.begin(), dvs.end() );
	ll ans = 0;
	for( auto d : dvs ){
		if( d > 1 && n/(d-1) == n/d ) ans += (d-1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import math

n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
a = sorted(a)[::-1]
b = sorted(b)[::-1]

cnt = 0
for i in b:
    if i > a[0]:
        h -= i
        cnt += 1
        if h <= 0:
            print(cnt)
            exit()

cnt += math.ceil(h/a[0])
print(cnt)

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

using namespace std;


int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int x, y, z;
    cin >> x >> y >>z;
    int temp;
    temp = z;
    z = y;
    y = x;
    x = temp;
    cout << x << " " << y << " "<<z <<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int dp[4001][4001];

int main(){
    
    string s, t;

    while(cin >> s >> t){
        memset(dp, -1, sizeof(dp));
        dp[0][0] = (s[0] == t[0]);
        for(int i = 1; i < s.size(); i++){
            for(int j = 1; j < t.size(); j++){
                if(s[i] == t[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
                else dp[i][j]  = 0;
            }
        }
        int maxi = 0;
        for(int i = 0; i < s.size(); i++){
            maxi = max(maxi, *max_element(dp[i], dp[i] + t.size()));
        }
        cout << maxi << endl;
    }
}

Measured memory_bytes: 63748
n=int(input())
s=[]
fla=True
s.append(input())
for i in range(1,n):
    s.append(input())
    if fla :
        if s[i][0]==s[i-1][len(s[i-1])-1]:
            for j in range(i):
                if s[j]==s[i]:
                    fla=False
        else:
            fla=False
if fla:
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque


def breadth_first_search(adj_matrix, n):
    distance = [0] + [-1] * (n - 1)
    searching = deque([0])
    while len(searching) > 0:
        start = searching.popleft()
        for end in range(n):
            if adj_matrix[start][end] and distance[end] == -1:
                searching.append(end)
                distance[end] = distance[start] + 1
    return distance


def main():
    n = int(input())
    adj = [[False for _ in range(n)] for _ in range(n)]
    for _ in range(n):
        ukv = input().split()
        id = int(ukv[0])
        dim = int(ukv[1])
        if dim > 0:
            nodes = map(int, ukv[2:])
            for node in nodes:
                adj[id - 1][node - 1] = True
    distance = breadth_first_search(adj, n)
    for i in range(n):
        print("{} {}".format(i + 1, distance[i]))


if __name__ == "__main__":
    main()



Measured memory_bytes: 6076
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        x: i64,
    }
    for i in 0..50_000 {
        if i*108/100 == x {
            println!("{}", i);
            return;
        }
    }
    println!(":(");
}


Measured memory_bytes: 2148
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// lib/union_find.hpp
#ifndef UNION_FIND_HPP
#define UNION_FIND_HPP


/*
usage:

tools::union_find<std::int_fast64_t> uf(10);
uf.unite(1, 3);
uf.is_same(1, 3);
*/

namespace tools {
  template <typename T>
  class union_find {
  private:
    std::vector<T> parents;
    std::vector<T> sizes;

    T root(const T x) {
      return this->parents[x] == x ? x : (this->parents[x] = this->root(this->parents[x]));
    }

  public:
    union_find(const T n) :
      parents(n),
      sizes(n, 1) {
      for (T i = 0; i < n; ++i) {
        parents[i] = i;
      }
    }

    bool is_same(const T x, const T y) {
      return this->root(x) == this->root(y);
    }

    void unite(T x, T y) {
      x = this->root(x);
      y = this->root(y);
      if (x == y) return;

      if (this->sizes[x] < this->sizes[y]) std::swap(x, y);
      this->parents[y] = x;
      this->sizes[x] += this->sizes[y];
    }

    T size(const T x) {
      return this->sizes[this->root(x)];
    }
  };
}

#endif

// main.cpp

class edge {
public:
  i64 from, to;
};

namespace std {
  std::istream& operator>>(std::istream& is, edge& self) {
    is >> self.from >> self.to;
    --self.from;
    --self.to;
    return is;
  }
}

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<edge> edges;
  tools::read(edges, M);

  std::vector<i64> conveniences({0});
  conveniences.reserve(M + 1);
  std::reverse(edges.begin(), edges.end());
  tools::union_find<i64> uf(N);
  for (const edge& edge : edges) {
    if (uf.is_same(edge.from, edge.to)) {
      conveniences.push_back(conveniences.back());
    } else {
      conveniences.push_back(conveniences.back() + uf.size(edge.from) * uf.size(edge.to));
      uf.unite(edge.from, edge.to);
    }
  }

  std::vector<i64> answers;
  answers.reserve(M);
  std::transform(conveniences.begin(), conveniences.end() - 1, std::back_inserter(answers), [&N](const i64& convenience) { return N * (N - 1) / 2 - convenience; });
  std::reverse(answers.begin(), answers.end());

  for (const i64& answer : answers) {
    std::cout << answer << std::endl;
  }
  return 0;
}

Measured memory_bytes: 6016
using System;
using System.Collections;
using System.Linq;


public class ABC077_Rotation
{
	public static void Main()
	{
		string line1 = Console.ReadLine();
        string line2 = Console.ReadLine();
        char[] c = line2.ToCharArray();
        Array.Reverse(c);
        string s = "";
        for(int i = 0 ; i < c.Length ; i++){
            s += c[i].ToString();
        }

        if(line1 == s){
            Console.WriteLine("YES");
        } else {
            Console.WriteLine("NO");
        }
	}
}

Measured memory_bytes: 11092
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n, a, b = map(int, input().split())
    x = list(map(int, input().split()))
    ans = 0
    for i in range(1,n):
        ans += min(b, a*(x[i]-x[i-1]))

    print(ans)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 20068
#include <cstdio>
#include <unordered_map>
using namespace std;
const int N=200010;
int n;
int a[N],f[N];
inline void updmax(int &x,int y){
	x=(x>=y)?x:y;
}
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
}
void solve(){
	int ans=0;
	for(int i=n;i>=1;i--){
		f[a[i]]=f[a[i]+1]+1;
		updmax(ans,f[a[i]]);
	}
	printf("%d\n",n-ans);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[1000][1000];
int main(){
	int h,w;cin>>h>>w;
	rep(i,h)rep(j,w)cin>>a[i][j];
	ll sum=0;
	rep(i,h)rep(j,w){
		sum+=a[i][j]*(i+1)*(j+1)*(ll)(h-i)*(ll)(w-j);
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 5068
n,y = map(int, input().split())


s = [-1,-1,-1]

for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j +1000*(n-i-j) == y:
            s = [i,j,n-i-j]
            break

print(*[x for x in s])

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

import sys
sys.setrecursionlimit(10**6)

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
#	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
#		search(values,hp+dh,vp+dv,item)
	search(values,hp-1,vp,item)
	search(values,hp+1,vp,item)
	search(values,hp,vp-1,item)
	search(values,hp,vp+1,item)

def solve(values):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in valid_items:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line, values = input().strip(), list()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		value = list()
		for _ in range(H):
			value.append(list(x for x in input().strip()))
#			value.append(list(input().strip()))
		print(solve(value))
#		values.append(value)
		line = input().strip()
#	for value in values:
#		print(solve(value))

if __name__=='__main__':
	main()

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double PI = acos(-1);

struct matrix{
    int mat[50][50];
    int sz;
    void identity(){
        memset(mat, 0, sizeof mat);
        for(int i=0;i<sz;++i)
            mat[i][i] = 1;
    }
    matrix operator*(const matrix ot){
        matrix res;
        res.sz = sz;
        for(int i=0;i<sz;++i){
            for(int j=0;j<sz;++j){
                res.mat[i][j] = 0;
                for(int k=0;k<sz;++k){
                    res.mat[i][j] += 1LL * mat[i][k] * ot.mat[k][j] % mod;
                    res.mat[i][j] %= mod;
                }
            }
        }
        return res;
    }
    int sum(){
        int res = 0;
        for(int i=0;i<sz;++i){
            for(int j=0;j<sz;++j){
                res += mat[i][j];
                res %= mod;
            }
        }
        return res;
    }
    void print(){
        cout<<"print:"<<endl;
        for(int i=0;i<sz;++i){
            for(int j=0;j<sz;++j){
                cout<<mat[i][j]<<" ";
            }
            cout<<endl;
        }
    }
};

int n,i,j,k,t;
ll p;
matrix mat;
matrix pp[64];

int main(){
    scanf("%d %lld", &n, &p);
    mat.sz = n;
    for(i=0;i<n;++i){
        for(j=0;j<n;++j){
            scanf("%d", &mat.mat[i][j]);
        }
    }
    pp[0] = mat;
    for(i=1;i<64;++i){
        pp[i] = pp[i-1]*pp[i-1];
    }
    matrix res;
    res.sz = n;
    res.identity();
    for(i=0;p;++i){
        if(p&1){
            res = res * pp[i];
        }
        p>>=1;
    }
    printf("%d\n", res.sum());
    return 0;
}

Measured memory_bytes: 896
from collections import deque

def bfs(u):
    dist = [-1 for _ in range(n)]
    dist[u] = 0
    que = deque([])
    que.append(u)
    
    while que:
        v = que.popleft()
        for nv in G[v]:
            if dist[nv] != -1:
                continue
            dist[nv] = dist[v] + 1
            que.append(nv)

    for d in dist:
        if d == 0:
            continue
        ans[d-1] += 1
    return ans


n, x, y = map(int,input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    G[i].append(i+1)
    G[i+1].append(i)
G[x-1].append(y-1)
G[y-1].append(x-1)

ans = [0]*(n-1)
for i in range(n):
    bfs(i)

for i in ans:
    print(i//2)


Measured memory_bytes: 47964
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a==b&&a!=c){
		printf("Yes\n");
	}
	else if(b==c&&a!=b){
		printf("Yes\n");
	}
	else if(a==c&&b!=c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1604
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      int d = sc.nextInt();

      int n = h * w + 1;
      int[] row = new int[n];
      int[] col = new int[n];

      for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++) {
            int num = sc.nextInt();
            row[num] = i;
            col[num] = j;
        }
          
      int[] prefixSum = new int[n];
      for(int i = d + 1; i < n; i++) {
        prefixSum[i] = prefixSum[i - d] + Math.abs(row[i] - row[i - d]) + Math.abs(col[i] - col[i - d]);
      }

      int q = sc.nextInt();
      for(int i = 0; i < q; i++) {
        int l = sc.nextInt();
        int r = sc.nextInt();
        System.out.println(Math.abs(prefixSum[l] - prefixSum[r]));
      }
  }
}


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

int main(){
    int n;
    cin >> n;
    int x[n], y[n], t[n];
    for(int i = 0; i < n; i++) cin >> t[i] >> x[i] >> y[i];
    int pt = 0, px = 0, py = 0;
    bool f = 1;
    for(int i = 0; i < n; i++){
        int dx = abs(px - x[i]);
        int dy = abs(py - y[i]);
        int dt = t[i] - pt;
        if(dx + dy > dt || ((dx + dy) % 2 != dt % 2)) f = 0;
        px = x[i], py = y[i], pt = t[i];
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int arr[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	double threshold=(1.0/(4*m))*sum;
	//cout<<threshold<<endl;
	int c=0;
	for(int i=0;i<n;i++)
	{
		if(arr[i]>=threshold)
		{
			if(c<m)
			{
				c++;
			}
			else
			break;
			
		}
	}
	if(c==m)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int n;
    scanf("%d", &n);

    int weight[n];
    for(int i=0; i<n; i++){
        scanf("%d", &weight[i]);
    }

    int left=0;
    for(int i=0; i<n; i++){
        left += weight[i];
    }

    int right=0, ans=left, tmpans=0;
    for(int i=0; i<n; i++){
        right += weight[n-1-i];
        left -= weight[n-1-i];
        if(right > left){
            tmpans = right-left;
        } else {
            tmpans = left - right;
        }
        if(tmpans < ans) ans = tmpans;
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
n = int(input())
h_list = list(map(int, input().split()))

ans, cnt = 0, 0
tmp = 0
for h in h_list:
    if h > tmp:
        ans = max(cnt, ans)
        cnt = 0
    else: cnt += 1
    tmp = h
        
print(max(cnt, ans))


Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000001
#define vmax 10000
constexpr ll inf = 1000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main() {
   int n,x=0,ans=0;
   cin>>n;
   string s;
   cin>>s;
   for(int i=0;i<n;i++){
       if(s[i]=='I'){
           x++;
       }else{
           x--;
       }
       ans=max(x,ans);
   }
    cout<<ans<<endl;
    return 0;
}











Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n, i, j, result=0;
    cin >> n;
  char t, c[n];
 
  for(i=0; i<n; i++)
    cin >> c[i];
  i=0;
  j=n-1;
  while(i<j)
  {
    while(c[i]!='W' && i<n)
      i++;
    while(c[j]!='R' && j>=0)
      j--;
    if(i < j)
    {
      result++;
      t = c[i];
      c[i] = c[j];
      c[j] = t;
      i++;
      j--;
    }
  }
  cout << result;
  return(0);
}

Measured memory_bytes: 3808
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

#define MaxN 100005
#define INF 2140000000
 
using namespace std;

FILE *IN,*OUT;

int v[MaxN],a[MaxN],N,ans=0;
int Search(int val)
{
	int lw=1,hi=N,mid;
	while(lw<=hi)
	{
		int mid=(lw+hi)>>1;
		if(v[mid]>val)
			hi=mid-1;
		else if(v[mid]<val)
			lw=mid+1;
		else return mid%2;
	}
}
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>a[i];
		v[i]=a[i];
	}
	sort(v+1,v+1+N);
	for(int i=1;i<=N;i++)
	{
		if((i%2)^Search(a[i]))
			ans++;
	}
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 1024
s = input()
n1, n2 = int(s[:2]), int(s[2:])
YM, MY = False, False
if 0 < n2 < 13: YM = True
if 0 < n1 < 13: MY = True

if YM and MY: print("AMBIGUOUS")
elif YM: print("YYMM")
elif MY: print("MMYY")
else: print("NA")

Measured memory_bytes: 3060
N=int(input())
array=list(map(int,input().split()))
array1=sorted(array)
import itertools
list1=list(itertools.combinations(array1,3))
ans=0
for n in range(len(list1)):
  if list1[n][0]!=list1[n][1] and list1[n][1]!=list1[n][2]:
    if list1[n][0]+list1[n][1]>list1[n][2]:
      ans=ans+1
print(ans)

Measured memory_bytes: 20500
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> s(n);
    FOR(i, 0, n){
        cin >> s[i];
    }

    int q;
    cin >> q;
    vector<int> t(q);
    int cnt=0;
    FOR(i, 0, q){
        cin >> t[i];
        if ( *lower_bound(s.begin(), s.end(), t[i]) == t[i] ) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll tot=0;
  map<ll,ll> mpl,mpr;
  rep(i,n){
    ll l=i+a[i];
    if(mpl.find(l)!=mpl.end())mpl[l]++;
    else mpl[l]=1;
    ll r=i-a[i];
    if(mpr.find(r)!=mpr.end())mpr[r]++;
    else mpr[r]=1;
  }
  for(const auto&[key,value]:mpl){
    tot+=mpr[key]*value;
  }
  cout<<tot<<endl;
  return 0;
  }


Measured memory_bytes: 39000
N  = int (input())
S = input()
s = set()
s.add("")
for c in S:
    new = []
    for c2 in s:
        if len(c2) < 3:
            new.append(c2 + c)
    for temp in new:
        s.add(temp)
ans = 0
for temp in s:
    if len(temp) == 3:
        ans += 1
print(ans)



Measured memory_bytes: 43700
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A, B, T; 
  cin >> A >> B >> T;
  cout << T/A*B << endl;
  return 0;
}


Measured memory_bytes: 256
// #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) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int> & 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 -> Vector 変換 ------------------ //
vector<int> ItoVec(int x) {

	vector<int> xVec;

	while (x > 0) {
		int tmp = x % 10;
		xVec.insert(xVec.begin(), tmp);
		x /= 10;
	}

	return xVec;
}

// ------------------ 最大公約数関数 ------------------ //
int GCD(int x, int y) {
	if (x == 0) return y;
	else GCD(y % x, x);
}


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

int main(void) {

	int N, M;
	cin >> N >> M;
	vector<int> H(N), A(M), B(M);
	vector<int> ans(N, 1);

	rep(i, N) {
		cin >> H[i];
	}
	rep(i, M) {
		cin >> A[i] >> B[i];
	}

	rep(i, M){
		if (H[A[i]-1] < H[B[i]-1]) ans[A[i]-1] = 0;
		else if (H[B[i]-1] < H[A[i]-1]) ans[B[i]-1] = 0;
		else if (H[B[i]-1] == H[A[i]-1]) ans[A[i]-1] = ans[B[i]-1] = 0;
	}

	cout << sumVec(ans) << endl;

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

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

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAXN = 2e5 + 5;

char str[MAXN];
vi pos[300];
int bit[MAXN];

#define lsone(s) (s & (-s))

void add(int b, int val) {
    while (b < MAXN) {
        bit[b] += val;
        b += lsone(b);
    }
}

int ask(int b) {
    int res = 0;
    while (b > 0) {
        res += bit[b];
        b -= lsone(b);
    }
    return res;
}

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    scanf("%s", str + 1);
    int n = strlen(str + 1);
    for (int i = 1; i <= n; i++) {
        pos[str[i]].pb(i);
    }
    int odd = 0;
    for (int i = 0; i < 300; i++)
        if (pos[i].size() & 1)
            odd++;
    if (odd > 1) {
        puts("-1");
        return 0;
    }
    ll ans = 0;
    int who = -1;
    if (odd == 1) {
        for (int i = 0; i < 300; i++)
            if (pos[i].size() & 1)
                who = i;
        /*
        int sz = pos[who].size();
        int cur = pos[who][sz / 2];
        ans += abs(n / 2 + 1 - cur);
        while (cur > n / 2 + 1) {
            swap(str[cur], str[cur - 1]);
            cur--;
        }
        while (cur < n / 2 + 1) {
            swap(str[cur], str[cur + 1]);
            cur++;
        }
        */
    }
    //assert(odd == 0);
    fill(pos, pos + 300, vi());
    for (int i = 1; i <= n; i++) {
        pos[str[i]].pb(i);
    }
    for (int i = 1; i <= n; i++) {
        add(i, +1);
    }
    bool found = false;
    for (int i = 1; i <= n; i++) {
        if (pos[str[i]].size() > 0 && i < pos[str[i]].back()) {
            ans += ask(n) - ask(pos[str[i]].back());
            add(pos[str[i]].back(), -1);
            pos[str[i]].pop_back();
            if (found) ans++;
            //printf("running at pos %d with found = %d\n", i, (int)found);
        } else if (str[i] == who) {
            found = true;
        }
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  string s;
  cin >> s;
  sort(all(s));
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
template<class T> inline void chmin(T& a, T b) { if(a > b) a = b; }
template<class T> inline void chmax(T& a, T b) { if(a < b) a = b; }
const ll mod = 1000000007;

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

	ll a = 1;
	for(int i=0; i<N; i++){
		a *= 9;
		a %= mod;
	}
	ll b = 1;
	for(int i=0; i<N; i++){
		b *= 9;
		b %= mod;
	}
	ll c = 1;
	for(int i=0; i<N; i++){
		c *= 8;
		c %= mod;
	}
	ll d = 1;
	for(int i=0; i<N; i++){
		d *= 10;
		d %= mod;
	}
	ll res = (d + c) % mod;
	res = (mod + res - a) % mod;
	res = (mod + res - b) % mod;
	std::cout << res % mod << std::endl;
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

using namespace std;
#define ll long long
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define INF 100000
int main(){
  ios_base::sync_with_stdio(0);

  for(ll i = 1; i < 10; i++){
    for(ll k = 1; k < 10; k++){
      printf("%dx%d=%d\n",i,k,i*k);
    }
  }

  return 0;

}

Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int main()
{
	LL x,y;int ans=0;
	cin>>x>>y;
	while (x<=y) ans++,x<<=1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t;
    t = 1;
    for(int i=0;i<t;i++)
    {
        int n;
        cin>>n;
        ll arr[n];
        ll prod = 1;
        int x = 0;
        for(int j=0;j<n;j++)
        {
            cin>>arr[j];
            if(arr[j]==0)
            {
                x = 2;
                break;
            }
        }
        for(int j=0;j<n && x==0;j++)
        {
            if(prod>1000000000000000000/arr[j])
            {
                x = 1;
                break;
            }
            else
            {
                prod*=arr[j];
            }
        }
        if(x==2)
        {
            cout<<0;
        }
        else if(x==1)
        {
            cout<<"-1";
        }
        else
        {
            cout<<prod;
        }
    }
    return 0;
}

Measured memory_bytes: 4444
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明

// vector の使い方
// 宣言：
// vector<int> v;
// vector<int> v(N);
// 初期化:
// vector<int> v(10, 5); 要素数10，全ての要素の値5．
// vector<int> v = {1, 2, 3};
// 代入：
// v[0] = 3;
// sort:
// sort(v.begin(), v.end());
//

// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) {
		a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
    double T, X;
    cin >> T >> X;

    cout << T/X << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,vector<vector<int> >&GRAPH,vector<int>&dist,int depth)
{
  dist[V] = depth;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    if(dist[GRAPH[V][i]] == -1)
    {
      DFS(GRAPH[V][i],GRAPH,dist,depth+1);
    }
  }
  return;
}
void solve(void)
{
  int N;
  cin>>N;
  int i = 0;
  while(true)
  {
    int X = pow(2,i);
    if(X > N)
    {
      cout<<(int)(pow(2,i-1))<<endl;;
      break;
    }
    i++;
  }
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	map<ll,ll> mp;
	ll arr[n-1];
	for(int a=0;a<n-1;a++)
	{
		cin>>arr[a];
		mp[arr[a]]++;
	}
	for(int a=1;a<=n;a++)
	cout<<mp[a]<<endl;
	return 0;
}


Measured memory_bytes: 17688