akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
	int N,S;
	while(cin>>N,N){
		int sum=0,min_=INT_MAX,max_=INT_MIN;
		for(int i=0;i<N;i++){
			cin>>S;
			min_ = min(min_,S);
			max_ = max(max_,S);
			sum += S;
		}
		printf("%d\n",(sum-min_-max_)/(N-2));
	}
	return 0;
}

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

int main(){
	int N; cin>>N;
	vector<ll> L(N);
	for(int i=0;i<N;i++)cin>>L[i];
	sort(L.begin(),L.end());
	reverse(L.begin(),L.end());
	ll ans=0;
	for(int i=0;i<N-2;i++){
		for(int j=i+1;j<N-1;j++){
			for(int k=j+1;k<N;k++){
				if(L[i]==L[j] || L[i]==L[k] || L[j]==L[k])continue;
				if(L[i]<L[j]+L[k] and L[j]<L[i]+L[k] and L[k]<L[i]+L[j])ans++;
			}
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 3620
h,w=map(int,input().split())
a=[]
data=[0]*w
for i in range(h):
  a_=input()
  if a_!='.'*w:
    a.append(a_)
    for j in range(w):
      if a_[j]=='.':
        data[j]+=1
n=len(a)
for i in range(n):
  ans=[]
  for j in range(w):
    if data[j]!=n:
      ans.append(a[i][j])
  print(*ans,sep='')

Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int p[200005];
map<int,int>mp;
map<int,int>::iterator it;

int u_find(int a){
	if(p[a]==0) return a;
	return p[a] = u_find(p[a]);
}
void merge(int a,int b){
	a = u_find(a);
	b = u_find(b);
	if(a==b) return;
	p[a] = b;
}

int main(){
	int n,m;
	cin>>n>>m;
	while(m--){
		int a,b;
		cin>>a>>b;
		merge(a,b);
	}
	vector<int>ret;
	for(int i=1; i<=n; i++){
		int root = u_find(i);
		it = mp.find(root);
		if(it!=mp.end()) it->second+=1;
		else mp.insert(make_pair(root,1));
	}
	int team = 0;
	for(it = mp.begin(); it!=mp.end(); it++) team = max(team,it->second);
	cout<<team;
}

Measured memory_bytes: 12944
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <iomanip>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double a;
    cin, a;
    a /= 3;
    cout << fixed << setprecision(15) << a * a * a << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    D = int(input())
    fuman = list(map(int, input().split()))
    manzoku = [[0]*26 for _ in range(D)]
    for i in range(D): manzoku[i] = list(map(int, input().split()))
    # できるだけ点数が下がらないように、満足度の高いものを選んでいく
    # d日目にテストiを受けた時、score += manzoku[d][i]-sigma[i以外25個](fuman[k]*それを受けてない日数)
    # >テストiをd日目に受ける
    # manzoku[d][i]-sigma[i以外25個](fuman[k]*それを受けてない日数)が一番大きいもの(i)を受けるそれだけ
    timepass = [0]*26
    # 初日のみ指定
    x,t = 0,0
    for j in range(26):
        tmp = manzoku[i][j]
        if tmp>x:
            tprev = t
            x = tmp
            t = j
    print(tprev+1)
    for i in range(1,D):
        # greedy
        x1 = 0
        t1 = 0
        for j in range(26):
            tmp = manzoku[i][j]
            for k in range(26):
                if not j==k: tmp -= fuman[k]*timepass[k]
            if tmp>x1:
                x1 = tmp
                t1 = j

        # update timepass
        for j in range(26):
            if not j==t1: timepass[j] += 1
            else: timepass[j] = 0
        print(t1+1)



main()


Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    int h, a;
    cin >> h >> a;
    cout << (h+a-1)/a << endl;

}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        boolean[] arg = null;
        int length=0;
        int i=0;
        int state=0;
        int a_kun=0,b_kun=0;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0")){
            		break;
            	}
                if(state==0){
                    length=Integer.parseInt(line);
                    arg=new boolean[length];
                    a_kun=0;
                    b_kun=0;
                    state=1;
                    i=0;
                }else{
                    String[] tokens = line.split(" ");
                    int a= Integer.parseInt(tokens[0]);
                    int b = Integer.parseInt(tokens[1]);
                    if(a==b){
                    	a_kun+=a;
                    	b_kun+=b;
                    }else if(a>b){
                    	a_kun+=(a+b);
                    }else{
                    	b_kun+=(a+b);
                    }
                    i++;
                    if(i==length){
                    	System.out.println(a_kun+" "+b_kun);
                        state=0;
                    }
                }
            }
        }
    }

}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<pair<int, int>> v(m);
    for(auto& x : a)
        cin >> x;
    for(auto& x : v)
        cin >> x.fi >> x.se;
    sort(a.begin(), a.end());
    sort(v.begin(), v.end(), [](auto& x, auto& y) {
        return x.se > y.se;
    });
    int i = 0;
    for(auto& c : v) {
        int j = i + c.fi;
        for(; i < j; ++i) {
            if(i > n || c.se <= a[i])
                goto out;
            a[i] = c.se;
        }
    }
    out :
    ll sum = 0;
    for(auto x : a)
        sum += x;
    cout << sum << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  char c;
  int s[30]={};
  while(c=getchar(),c!=EOF){
    if(c>='a'&&c<='z') ++s[c-'a'];
    else if(c>='A'&&c<='Z') ++s[c-'A'];
  }
  for (char i = 'a'; i <= 'z' ; ++i) cout<<i<<" : "<<s[i-'a']<<endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
/*ライブラリゾーン！！！！！！！！！！！！！！！*/
int k, t, a[105],big;
signed main(){
	cin >> k >> t;
	for (int i = 0; i < t; i++)cin >> a[i];
	sort(a, a + t);
	cout << Max(0, a[t - 1] - 1 - (k - a[t - 1])) << endl;
end:;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

int main() {
	int n, m, X, Y;
	int x[105] = {};
	int y[105] = {};
	

	cin >> n >> m >> X >> Y;

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

	for (int i = 0; i < m; i++)
	{
		cin >> y[i];
	}

	for (int i = X + 1; i <= Y; i++)
	{
		int cntX = 0;
		int cntY = 0;

		for (int j = 0; j < n; j++)
		{
			if (x[j] < i) {
				cntX++;
			}
		}

		for (int k = 0; k < m; k++)
		{
			if (i <= y[k]) {
				cntY++;
			}
		}

		if (n == cntX && m == cntY) {
			cout << "No War" << endl;
			return 0;
		}
		
	}

	cout << "War" << endl;
}

Measured memory_bytes: 256
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
#pragma endregion
#pragma endregion
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

int main() {
	lint n; cin >> n;
	vector<lint> x(n + 5), y(n + 5), z(n + 5);
	for (int i = 0; i < n; i++)
		cin >> x[i];
	y[0] = x[0];
	for (int i = 1; i < n; i++) {
		y[i] = gcd(y[i - 1], x[i]);
	}
	z[n - 1] = x[n - 1];
	for (int i = n - 1; i >= 0; i--) {
		z[i] = gcd(z[i + 1], x[i]);
	}
	lint ans = 0;
	for (int i = 1; i < n - 1; i++) {
		ans = max(ans, gcd(y[i - 1], z[i + 1]));
	}
	ans = max(ans, z[1]);
	ans = max(ans, y[n - 2]);
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<cstdio>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int s[510][510];
int main() {
	int n, m, q; cin >> n >> m >> q;
	int l, r;
	for (int i = 0; i < m; ++i) {
		cin >> l >> r;
		++s[l][r];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
		}
	}
	for (int i = 0; i < q; ++i) {
		cin >> l >> r;
		cout << s[r][r] - s[r][l - 1] - s[l - 1][r] + s[l - 1][l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
com=0
for i in range(1,n+1):
    if(c[i]<=1):
        continue
    com+=combinations_count(c[i],2)
for k in range(1,n+1):
    ans=com
    ans-=c[a[k-1]]-1
    print(ans)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<vector<pair<int, int>>> prefectures(N);
  
  for (int i = 0; i < M; i++) {
    int p, y;
    cin >> p >> y;

    prefectures.at(p - 1).push_back(make_pair(y, i));
  }
  
  vector<string> ids(M);
  
  for (int j = 0; j < N; j++) {
    vector<pair<int, int>> prefecture = prefectures.at(j);
    sort(prefecture.begin(), prefecture.end());
    
	for (int k = 0; k < prefecture.size(); k++) {
      pair<int, int> city = prefecture.at(k);
      char id[100];
      sprintf(id, "%06d%06d", j + 1, k + 1);
      ids.at(city.second) = id;
    }
  }
  
  for (int i = 0; i < M; i++) {
    cout << ids.at(i) << endl;
  }
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

struct UnionFind{
	vector<int> par,rank;
	UnionFind(int n) :par(n + 1),rank(n + 1,1){
		for(int i = 1;i <= n;i++) par [i] = i;
	}
	int find(int x){
		return par [x] == x ? x : par [x] = find(par [x]);
	}
	bool connect(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return false;
		if(rank [x] < rank [y]) swap(x,y);
		rank [x] += rank [x] == rank [y];
		par [y] = x;
		return true;
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
};

ll N,M,Q;
set<int> st;

int main()
{
	scanf("%lld%lld%lld",&N,&M,&Q);
	FOR(i,0,Q){
		int x;
		scanf("%d",&x);
		st.insert(x);
	}
	int repeat;
	if(M % 7 == 0){
		repeat = M / 7;
	}
	else{
		repeat = M;
	}

	UnionFind uf(repeat * 7 * 2);
	vector<string> S(repeat,string(7,'x')),T(repeat,string(7,'x'));
	FOR(i,0,repeat) FOR(j,0,7) if(st.count((i * 7 + j) % M) == 0){
		S [i] [j] = 'o';
		T [i] [j] = 'o';
		if(i && S [i - 1] [j] == 'o'){
			uf.connect((i - 1) * 7 + j,i * 7 + j);
			uf.connect((i - 1) * 7 + j + (repeat * 7),i * 7 + j + (repeat * 7));
		}
		if(j && S [i] [j - 1] == 'o'){
			uf.connect(i * 7 + (j - 1),i * 7 + j);
			uf.connect(i * 7 + (j - 1) + (repeat * 7),i * 7 + j + (repeat * 7));
		}
	}

	ll ans = 0;
	FOR(i,0,repeat) FOR(j,0,7) if(S [i] [j] == 'o' && uf.find((i * 7 + j)) == i * 7 + j){
		ans += N / repeat;
	}
	FOR(i,0,7) if(S.front() [i] == 'o' && S.back() [i] == 'o'){
		if(uf.connect((repeat - 1) * 7 + i,i + (repeat * 7))){
			ans -= N / repeat - 1;
		}
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 22784
#include<iostream>
#include<cstdio>
using namespace std;
int a[4][4];
bool b[4][4];
bool vis[110];
int main(void){
	int i,j,n,x;
	for(i=1;i<=3;i++){
		for(j=1;j<=3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		vis[x]=true;
	}
	for(i=1;i<=3;i++){
		for(j=1;j<=3;j++)
		if(vis[a[i][j]])
		b[i][j]=true;
	}
	int flag=0;
	for(i=1;i<=3;i++){
		int p=1;
		for(j=1;j<=3;j++){
			if(!b[i][j])
			p=0;
		}
		if(p)
		flag=1;
	}
	for(j=1;j<=3;j++){
		int p=1;
		for(i=1;i<=3;i++){
			if(!b[i][j])
			p=0;
		}
		if(p)
		flag=1;
	}
	int p=1;
	for(i=1;i<=3;i++){
		if(!b[i][i])
		p=0;
	}
	if(p)
	flag=1;
	p=1;
	for(i=1;i<=3;i++){
		if(!b[i][4-i])
		p=0;
	}
	if(p)
	flag=1;
	if(flag)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
#ifdef LOCAL
#include "../../../DBG/dbg.h"
#endif
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

#define INF LLONG_MAX - 1000

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec[i];
  sort(vec.begin(), vec.end());
  ll ans = INF;
  for (int i = -10; i < 110; ++i) {
    ll tmp = 0;
    for (int j = 0; j < n; ++j) {
      tmp += pow(vec[j]-i, 2);
    }
    chmin(ans, tmp);
  }
  cout << ans << '\n';
}


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


using namespace std;
constexpr long long int mod = 1000000007, MOD = 998244353;
constexpr double PI = 3.14159265358979323846;

int main() {
	int A, B, C,D,E;
	cin >> A>>B>>C>>D>>E;
	cout << max(0,(C-A)*60+(D-B)-E);
}

Measured memory_bytes: 3520
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

// @formatter:on


class CRepsept {
public:
  
  void solveOne(istream& cin, ostream& cout) {
    int k;
    cin >> k;
    set<int> st;
    int x = 7 % k;
    int i = 1;
    while (x != 0) {
      x = (10 * x + 7) % k;
      i++;
      if (st.count(x)) {
        cout << -1 << '\n';
        return;
      }
      st.insert(x);
    }
    cout << i << '\n';
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int t = 1;
    for (int tc = 1; tc <= t; ++tc) {
      //	cout << "Case #" << tc << ": ";
      solveOne(cin, cout);
    }
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	CRepsept solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 50400
s = input()

while True:
  if s[-5:] == "dream":
    s = s[:-5]
    continue
  elif s[-7:] == "dreamer":
    s = s[:-7]
    continue
  elif s[-5:] == "erase":
    s = s[:-5]
    continue
  elif s[-6:] == "eraser":
    s = s[:-6]
    continue
  elif s == "":
    print("YES")
    break
  else:
    print("NO")
    break

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

int main(void)
{
  char day[4];
  char week[7][4] = {"SAT","FRI","THU","WED","TUE","MON","SUN",};
  int i;
  int answer;

  scanf("%s",day);

  for(i=0;i<7;i++){
    if(strcmp(week[i],day)==0)answer=i+1;
  }

  printf("%d",answer);

  return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include <string>
using namespace std;
int main()
{
	string s;
  	cin >> s;
  	int count = 0;
  	for (int i = 0; i < 3; i++) {
      if (s[i] == '1') {
        count++;
      }
    }
  	cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LINE_SIZE 17 //1000000+' '+1000000+\n+\0

int main() {
    int num1, num2;
    int sum;
    while (~scanf("%d %d", &num1, &num2)) {
        sum = num1 + num2;
        int digit = 1;
        while ((sum = sum / 10) != 0) {
            digit++;
        }
        printf("%d\n", digit);
    }
    return 0;
}




Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a) (a)>0 ?(a):-(a)
#define llong long long

int main(){
	int N; scanf("%d",&N);
	llong ans=1;
	rep(i,0,N){
		llong a; scanf("%lld",&a);
		if( a==0 ){
			printf("0");
			return 0;
		}
		if( ans > 1000000000000000000/a ){
			rep(j,i+1,N){
				llong b; scanf("%lld",&b);
				if( b==0 ){
					printf("0");
					return 0;
				}
			}
			printf("-1");
			return 0;
		}
		ans *= a;
	}
	printf("%lld",ans);
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    ll m = std::min({A, B, C, D, E});

    ll ans = 5 + ((N + m - 1) / m - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int T[2];
	ll A[2], B[2];
	cin >> T[0] >> T[1];
	cin >> A[0] >> A[1];
	cin >> B[0] >> B[1];

	ll xa, xb;
	xa = A[0]*T[0]+A[1]*T[1];
	xb = B[0]*T[0]+B[1]*T[1];
	if(xa == xb){
		cout << "infinity" << endl;
		return 0;
	}

	if(xa > xb){
		swap(A[0], B[0]);
		swap(A[1], B[1]);
		swap(xa, xb);
	}

	ll x = xb - xa;
	ll y = A[0]*T[0] - B[0]*T[0];
	if(y < 0) {
		cout << 0 << endl;
		return 0;
	}

	debug(x, y, y % x);

	ll ans = 0;
	if(y % x == 0){
		ans = 2 * (y / x - 1) + 2;
	} else {
		ans = 2 * (y / x) + 1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
r=[]

t=['W']*n

for i in range(m):
    a,b=list(map(int,input().split()))
    if h[a-1]>=h[b-1]:
        t[b-1]='L'
    if h[a-1]<=h[b-1]:
        t[a-1]='L'
print(t.count('W'))

Measured memory_bytes: 20064
#include <iostream>
#include <vector>
using namespace std;
bool visited[9];
int N,M,k;
vector<int> G[9];
int dfs(int s){
	int res = 0;
	visited[s] = true;
	++k;
	for(auto& nb:G[s]){
		if(!visited[nb]) {
			res += dfs(nb);
		}
	}
	if(k == N) res = 1;
	visited[s] = false;
	--k;
	return res;
}
int main(){
	cin >> N >> M;
	int a,b;
	while(M--){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	cout << dfs(1) << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int h, w, k;
    cin >> h >> w >> k;

    char a[h][w];
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> a[i][j];
        }
    }

    ll ans = 0;
    
    int duh = 0, duh2 = 0;
    while (duh < (1<<h)) {
        duh2 = 0;
        while (duh2 < (1<<w)) {
            int cnt = 0;
            for (int i=0; i<h; i++) {
                for (int j=0; j<w; j++) {
                    if ((1<<i)&duh || (1<<j)&duh2) continue;
                    if (a[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) ans++;
            duh2++;
        }
        duh++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<deque>
#define maxn 200010
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
deque<int>d;
int n,tag,K;
char s[maxn];
int a[maxn];
int main()
{
    n=read();K=read();
    scanf("%s",s+1);
    for(int i=1;i<=n;i++) a[i]=s[i]-'A';
    if(K>2*n)  K=2*n+(K-2*n)%2;
    for(int i=1;i<=n;i++)  d.push_back(a[i]);
    while(K--)
    {
        if(!(d.front()^tag))
        {
            d.pop_front();
            d.push_front(tag^1);
        }
        else{
            d.pop_front();
            tag^=1;
            d.push_back(tag);            
        }
    }
    while(d.size())
    {
        int now=(d.front()^tag);d.pop_front();
        printf("%c",(char)(now+'A'));
    }
    puts("");
    return 0;
}

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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular
using namespace modular;

namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 2007

int N, M;
int fa[MAX_N];
ll X, Y;

struct edge{
    int u, v;
    ll w;
    bool operator<(const edge &rhs) const {
        return w < rhs.w;
    }
}e[MAX_N];

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

ll MST(int id = 0) {
    Rep(i, N) fa[i] = i;
    ll ans = 0;
    if (id) {
        ans += e[id].w;
        fa[e[id].u] = e[id].v;
    }
    Rep(i, M) if (i != id) {
        int u = find(e[i].u), v = find(e[i].v);
        if (u == v) continue;
        ans += e[i].w;
        fa[u] = v;
    }
    return ans;
}

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N), read(M), read(X);
    Rep(i, M) read(e[i].u), read(e[i].v), read(e[i].w);
    std::sort(e + 1, e + M + 1);
    Y = MST();
    if (Y > X) return puts("0"), 0;
    int c0 = 0, c1 = 0;
    Rep(i, M) {
        ll tmp = MST(i);
        if (tmp == X) c0++;
        if (tmp > X) c1++;
    }
    if (X == Y) printf("%d\n", mul(add(qpow(2, c0), MOD - 2), qpow(2, c1)));
    else printf("%d\n", mul(add(mul(2, qpow(2, c0)), MOD - 2), qpow(2, c1)));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void){
  long long int N, K;
  scanf("%lld %lld", &N, &K);
  long long int A = llabs((N % K) - K);
  if(A < N % K){
    printf("%lld", A);
  }else{
    printf("%lld", N % K);
  }
  
  return 0;
}

Measured memory_bytes: 128
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}
/// 最小公倍数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }
int main(){
   int N, X;
   cin >> N >> X;
   vector<int> x(N);
   vector<int> y(N);
   for(int i = 0; i < N; i++){
       cin >> x[i];
   }
   for(int i = 0; i < N; i++){
       y[i] = abs(X - x[i]);
   }
   int ans;
   if(N == 1){
       cout << y[0] << endl;
       return 0;
   }
    ans = gcd(y[0],y[1]);
    for(int i = 2; i < N; i++){
        ans = gcd(ans,y[i]);
 
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
while (a = gets.split(" "))[1] != "?"
  p case a[1]
    when "+"; a[0].to_i + a[2].to_i
    when "-"; a[0].to_i - a[2].to_i
    when "*"; a[0].to_i * a[2].to_i
    when "/"; a[0].to_i / a[2].to_i
    end
end

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,k;
    cin>>n>>k;
    vector<double> p(n);
    cin>>p;
    double ans = 0;
    vector<double> s(n+1);
    rep(i,n){
        p[i] = (1+p[i])/2;
    }
    REP(i,1,n+1){
        s[i] = s[i-1] + p[i-1];
        if(i-k>=0){
            s[i] -= p[i-k-1];
        }
    }
    //dbg(s);
    REP(i,1,n+1){
        chmax(ans,s[i]);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

int solve(){
    int n;
    cin>>n;
	int a[n];
	rep(i,0,n){
		cin>>a[i];
	}
	int cnt=0;
	rep(i,0,n){
		rep(j,i+1,n){
			rep(k,j+1,n){
				if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k])continue;
				if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]){
					cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
        cout << (x - a) % b << endl;
    }

Measured memory_bytes: 256
n = input()


if len(n) == 1:
    print(int(n))
    exit()
flag = 0
for i in range(len(n)):
    if int(n[i]) != 9:
        flag = 1
if flag == 0:
    print(9 * len(n))
    exit()

flag = 0
for i in range(1, len(n)):
    if int(n[i]) != 9:
        flag = 1

if flag == 0:
    print(int(n[0]) + 9 * (len(n)-1))
    exit()

print(int(n[0]) - 1 + 9 * (len(n) - 1))

Measured memory_bytes: 3064
main(){float d,e,f,g,h,i,m,n,p;for(;~scanf("%f%f%f%f%f%f%f%f",&d,&e,&f,&g,&h,&i,&m,&n);puts(p*(f-d)*(n-e)>p*(m-d)*(g-e)&p*(d-h)*(n-i)>p*(m-h)*(e-i)?"YES":"NO"))p=(h-f)*(n-g)-(m-f)*(i-g);}

Measured memory_bytes: 0
import re

def main():
    s = input()
    cnt = solve(s)
    print(' '.join(str(c) for c in cnt))

def solve(s):
    pat = re.compile('(R+)(L+)')
    cnt = [0 for _ in s]

    for m in pat.finditer(s):
        pos1 = m.start() + len(m.group(1)) - 1
        pos2 = pos1 + 1

        if len(m.group(0)) % 2 == 0:
            cnt[pos1] = len(m.group(0)) // 2
            cnt[pos2] = cnt[pos1]
        else:
            if pos1 % 2 == m.start() % 2:
                cnt[pos1] = len(m.group(0)) // 2 + 1
                cnt[pos2] = len(m.group(0)) // 2
            else:
                cnt[pos1] = len(m.group(0)) // 2
                cnt[pos2] = len(m.group(0)) // 2 + 1

    return cnt

main()


Measured memory_bytes: 10740
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = input()
def_S = S

while(1):
    S = S[-1] + S[0:-1]
    if S == T:
        print("Yes")
        os.sys.exit()
    if def_S == S:
        print("No")
        os.sys.exit()


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

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

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

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

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




int main(){
    int R;
    cin>>R;
    cout << (double)2*(double)R*PI << endl;
    return 0;
}


Measured memory_bytes: 3788
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m]
    }
    let mut uf = UnionFind::new(n);
    for (a, b) in ab {
        uf.unite(a, b);
    }
    let mut ans = 0;
    for i in 0..n {
        if let Some(r) = uf.rank(i) {
            ans = max(ans, r);
        }
    }
    println!("{}", ans);
}

struct UnionFind {
    par: Vec<usize>,
    rank: Vec<usize>,
}
impl UnionFind {
    fn new(size: usize) -> Self {
        UnionFind {
            par: (0..size).collect(),
            rank: vec![1; size],
        }
    }
    fn unite(&mut self, x: usize, y: usize) {
        let rx = self.root(x);
        let ry = self.root(y);
        if rx == ry {
            return;
        }
        if self.rank[x] > self.rank[y] {
            self.par[ry] = rx;
            self.rank[rx] += self.rank[ry];
        } else {
            self.par[rx] = ry;
            self.rank[ry] += self.rank[rx];
        }
    }
    fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }
    fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            self.par[x] = self.root(self.par[x]);
            self.par[x]
        }
    }
    fn rank(&mut self, x: usize) -> Option<usize> {
        if x == self.root(x) {
            Some(self.rank[x])
        } else {
            None
        }
    }
}


Measured memory_bytes: 10764
import java.util.*;
	import java.lang.Math;
    public class Main
	{
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a==b)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
    }

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

typedef long long ll;
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(ll i = ll(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<ll>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// vector型の「data」に xが存在するかを、True or Falseで返す
// vector_finder(data, x)
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

// ここから開始だよ！
ll N;
std::vector<ll> v;

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
	
	cin >> N;
	ll max = 0;
	rep(i, N) {
		ll tmp;
		cin >> tmp;
		v.push_back(tmp);
		if (max < tmp) {
			max = tmp;
		}
	}
	
	ll ans = 0;
	bool isUse = false;
	rep(i, v.size()){
		if (v[i] == max && isUse == false) {
			ans = ans + (v[i] / 2);
			isUse = true;
		} else {
			ans += v[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<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(){
  int n;
  cin >> n;
  vector<ll> L(n);
  rep(i,n) cin >> L[i];
  ll ans = 0;
  sort(all(L));
  rep(b,n) rep(a,b){
    int ab= L[a]+L[b];
    int r = lower_bound(all(L),ab) - L.begin();
    int l = b+1;//L[b]<=L[c]よりbの右側
    ans += max(0,r-l);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	ll n, k;
	cin >> n >> k;
	if (!cin) return false;

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

	ll sol = 0;
	
	for (int i = 0; i < n; ++i) {
		ll menores = 0;
		ll menoresdesp = 0;
		for (int j = 0; j < i; ++j) {
			if (v[j] < v[i]) ++menores;
		}


		for (int j = i + 1; j < n; ++j) {
			if (v[j] < v[i]) {
				++menores; ++menoresdesp;
			}
		}

		ll avov = (k * (k - 1) / 2) % MOD;

		sol = (sol + ((k * menoresdesp) % MOD + (menores * avov) % MOD) % MOD) % MOD;
	}

	cout << sol << '\n';

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

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

bool is_integer( double x ){
  return std::floor(x)==x;
}

int main(void) {
  double A,B;
  cin >> A >> B;
  double ans = (A+B)/2;
  if(is_integer(ans)) {
    cout << (int)ans << endl;
  } else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

from collections import deque
inf = 10 ** 6
mark = [-1 for _ in range(n)]
que = deque()
mark[0] = 0
que.append(0)

while que:
    cur = que.popleft()
    for to in edges[cur]:
        if mark[to] == -1:
            mark[to] = cur
            que.append(to)

if any(mark[i] == -1 for i in range(n)):
    print('No')

else:
    print('Yes')
    for i in range(1, n):
        print(mark[i] + 1)

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

int main() {
	string s;
	cin >> s;
	for (int i = 0;i + 1 < s.size();i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0;i + 2 < s.size();i++) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}


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

long long sum[200001];

void solve(long long N, vector<long long> A){
  long long res = 0, t = 0, sum = 0, xorsum = 0;
  for (long long s = 0; s < N; s++) {
	 	while (t < N && sum == xorsum) {
			sum += A[t];
			xorsum ^= A[t];
			if (sum == xorsum) {
				t++;
			} else {
				sum -= A[t];
				xorsum ^= A[t];
				break;
			}
		}
		res += t-s;
		sum -= A[s];
		xorsum ^= A[s];
	}
	printf("%lld\n", res);
}

int main(){
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	cout<<(1000-(n%1000))%1000<<endl;
	return 0;
}


Measured memory_bytes: 3636