akhauriyash/Code-Regression huggingface dataset:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n = inp()
    a = inpl()
    a.sort()
    ans = []
    cnt = 0
    if a[0] >= 0:
        x = a[0]
        for i in range(n-2):
            ans.append((x,a[i+1]))
            x -= a[i+1]
        ans.append((a[n-1],x))
        cnt = a[n-1]-x        
    elif a[n-1] <= 0:
        x = a[n-1]
        for i in range(n-1):
            ans.append((x,a[i]))
            x -= a[i]
        cnt = x
    else:
        for i in range(n):
            if a[i] >= 0:
                x = a[i-1]
                index = i
                break
        for i in range(index+1,n):
            ans.append((x,a[i]))
            x -= a[i]
        a[index-1] = x
        x = a[index]
        for i in range(index):
            ans.append((x,a[i]))
            x -= a[i]
        cnt = x        
    print(cnt)
    for i in range(n-1):
        print(*ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 66428
require 'prime'

a,b = gets.split.map(&:to_i)

a_f = a.prime_division
b_f = b.prime_division

arr = []
delete_f = true
a_f.each do |aa|
  while delete_f do
    b_f.delete_if do |bb|
      if aa[0] == bb[0]
        arr << aa[0]
        delete_f = false
        true
      elsif aa[0] < bb[0]
        false
      else
        true
      end
    end
    delete_f = false
  end
  delete_f = true
end

puts arr.size + 1

Measured memory_bytes: 3964
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int idx = -1;
		int minCost = (int) 1e9;
		
		for(int i=0;i<N;i++){
			if(Ts[i] > T) continue;
			if(Cs[i] < minCost){
				idx = i;
				minCost = Cs[i];
			}
		}
		
		if(idx == -1){
			Console.WriteLine("TLE");
		} else {
			Console.WriteLine(minCost);
		}
		
	}
	int N,T;
	int[] Cs, Ts;
	public Sol(){
		var d = ria();
		N = d[0]; T = d[1];
		Cs = new int[N];
		Ts = new int[N];
		for(int i=0;i<N;i++){
			d = ria();
			Cs[i] = d[0]; Ts[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
#include <list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

int main(){
    ll n;cin>>n;
    ll ans = n-1;
    for (ll i=2;i*i<=n;i++){
        if (n % i == 0){
            ll j = n / i;
            ans = min(ans, i-1+j-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


vector<int> a(2);

void inp(){
  cin >>a.at(0) >>a.at(1);
  sort(all(a));
}

int main() {
  inp();
  while (a.at(0)+a.at(1) > 0){
    cout <<a.at(0) <<" " <<a.at(1) <<endl;
    inp();
  }
}



Measured memory_bytes: 3124
n, k = list(map(int,input().split()))
r, s, p = list(map(int,input().split()))
t = list(input())
i = 0
sum = 0
while i < n:
  if i < k:
    if t[i] == 'r':
      sum = sum + p
    elif t[i] == 's':
      sum = sum + r
    else:
      sum = sum + s
  else:
    if t[i] != t[i-k]:
      if t[i] == 'r':
        sum = sum + p
      elif t[i] == 's':
        sum = sum + r
      else:
        sum = sum + s 
    else:
      t[i] = 'U'
  i = i + 1

print(sum) 
    

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	float ans;
	cin >> n;
	if (n % 2 == 0){
		ans = 0.5; 
	}
	else{
		ans = float(n /2 +1) / float(n);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  vector<pair<double, P> > lst;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    double xd = x;
    double yd = y;
    if (x == 0 && y == 0) continue;

    double theta = atan2(yd, xd);
    // cout << theta << endl;
    lst.emplace_back(pair<double, P>(theta, P(x, y)));
  }

  sort(lst.begin(), lst.end());

  ll ans = 0.0;
  for (size_t i = 0; i < lst.size(); i++) {
    for (size_t j = 0; j < lst.size(); j++) {
      ll tmpx = 0, tmpy = 0;
      for (size_t k = i; k <= i + j; k++) {
        tmpx += lst[k % lst.size()].second.first;
        tmpy += lst[k % lst.size()].second.second;
      } // k
      ans = max(ans, tmpx * tmpx + tmpy * tmpy);
    }  // j
  } // i

  printf("%.15f\n", sqrt((double)ans));

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    vector<int> t(n);
    rep(i,n)cin >> t[i];
    int m;cin >> m;
    vector<int> p(m),x(m);
    rep(i,m){
        cin >> p[i] >> x[i];
        p[i]--;
    }
    int ret = 0;
    rep(i,n)ret += t[i];
    rep(i,m){
        int tmp = ret;
        tmp -= t[p[i]];
        tmp += x[i];
        cout << tmp << endl;
    }
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

char s[maxn];

void solve(){
    int n;
    cin>>n>>s;
    int ans = 1;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]) ++ans;
    }
    cout<<ans<<'\n';
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
    //printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int L[N],R[N];
    for(int i=0;i<M;i++) cin >> L[i] >> R[i];
    int count[N];
    for(int i=0;i<N;i++) count[i] = 0;
    for(int i=0;i<M;i++){
        count[L[i]-1]++;
        count[R[i]]--;
    }
    for(int i=1;i<N;i++){
        count[i] = count[i]+count[i-1];
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        if(count[i]==M) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

# make lcm
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

x = lcm_list(A)
y = 0
for a in A:
    y += x / a
if y == 0:
    print("NG!")
else:
    print(x / y)

Measured memory_bytes: 5588
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>
#include <queue>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
typedef std::pair <std::string, ll> P1;
typedef std::pair <ll, std::string> P2;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    string s;
    cin >> s;
    s += '*';

    rep(i, 4){
        if(s[i] == s[i+1]){
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}

Measured memory_bytes: 256
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
N, M = mi()
x = li2(M)

#dp = dp2(0, 2, N)
dp = [[0, []] for i1 in range(N+1)]


for i in range(M):
    dp[x[i][1]][0] = max(dp[x[i][1]][0], dp[x[i][0]][0] + 1)
    dp[x[i][0]][1].append(x[i][1])
    if dp[x[i][1]][1] != []:
        for a in dp[x[i][1]][1]:
            dp[a][0] = max(dp[x[i][1]][0] + 1, dp[a][0])

print(dp)
print(max([row[0] for row in dp])) 
'''
###トポロジカルソート
from collections import deque
N, M = mi()
x = li2(M)

h = [0]*N
adj = [[] for i in range(N)]
for i in range(M):
    x[i][0] -= 1
    x[i][1] -= 1
    h[x[i][1]] += 1
    adj[x[i][0]].append(x[i][1])

zeros = deque([])
#ans = []
for i in range(N):
    if h[i] == 0:
        zeros.append(i)
        #ans.append(i)

dp = [0]*N

while(zeros != deque()):
    a = zeros.popleft()
    if(adj[a]):
        for b in adj[a]:
            h[b] -= 1
            if h[b] == 0:
                zeros.append(b)
                dp[b] = max(dp[a] + 1, dp[b])
                #ans.append(b)
'''
dp = [0]*N
for a in ans:
    if adj[a]:
        for b in adj[a]:
            dp[b] = max(dp[a] + 1, dp[b])

print(dp[ans[-1]])
'''
print(max(dp))

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

typedef long long ll;
typedef long double ld;

typedef pair<ld,ll> P;
#define fr first
#define sc second

int main(){
	static ll n,l;
	static ll t[500010],v[500010];
	scanf("%lld%lld",&n,&l);
	for(int i = 0 ; i < n ; i ++){
		scanf("%lld%lld",&t[i],&v[i]);
	}
	
	int k = 0;
	vector<P> vec;
	ll ret = 0;
	for(int i = 0 ; i < n ; i ++){
		ll V = v[i];
		if(i>0){
			while(V > 0){
				ll x = min(V,vec[k].sc);
				ret -= vec[k].fr*x;
				vec[k].sc -= x;
				V -= x;
				if(vec[k].sc == 0)k ++;
			}
		}
		P q = P((ld)t[i],(ld)v[i]);
		ret += t[i]*v[i];
		while(vec.size() > k){
			P p = vec[vec.size()-1];
			if(p.fr < q.fr)break;
			else {
				vec.pop_back();
				q.fr = (q.fr*q.sc+p.fr*p.sc)/(q.sc+p.sc);
				q.sc += p.sc;
			}
		}
		vec.push_back(q);
		/*if(i>0){
			while(v[i] > 0){
				ll x = min(v[i],vec[k].sc);
				ret -= vec[k].fr*x;
				vec[k].sc -= x;
				v[i] -= x;
				if(vec[k].sc == 0)k ++;
			}
		}*/
		/*for(int i = 0 ; i < vec.size() ; i ++){
			cout << vec[i].fr << " " << vec[i].sc << endl;
		}
		cout << k << " " << ret << endl;*/
		printf("%.12f\n",(double)((ld)ret/(ld)l));
	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  int N=in();
  vector<ll> A(N);
  REP(i,N) A[i]=in();
  
  int num=0,mh=0;
  for(int i=0;i<N;i++){
    if(A[i]>=mh){
      num++;
      mh = A[i];
    }
  }
  cout << num << endl;
  
  return 0;
}

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

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H-h)*(W-w) << endl;
  return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n') // ['1', '2' , ...]
const output = (x: any) => console.log(x)
// debug(input)
const [N, ...S] = input
// debug(N)
// debug(S)

const set = new Set<string>()

S.map(s => {
    set.add(s)
})

output(set.size - 1)

Measured memory_bytes: 68644
/*input
9
.........
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cnt=0;
	REP(i,SZ(s)) if(s[i]=='.') cnt++;
	int ans=0;
	int cur=0;
	REP(i,SZ(s)){
		if(s[i]=='.') cur--;
		else cur++;
		ans=min(ans,cur);
	}
	cout<<ans+cnt<<'\n';
	return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,a,b;
    ll ans;
    scanf("%lld%lld%lld",&n,&a,&b);
    if((b-a)%2==0){
        ans = (b-a)/2;
    }
    else{
        if(n-b>=a-1){
            ans = a + (b-a)/2;
        }
        else{
            ans = n-b+1 + (b-a)/2;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <vector>
#include <string>
using namespace std;

class HeapTree :public std::vector<int>
{
public:
	void InputSet() {
		std::vector<int> & a = *this;
		int n;
		cin >> n;
		a.resize(n,0);
		for(int i=0;i<n;++i) {
			cin >> a.at(i);
		}
	}
	bool has_parent(int i) {
		return i>0;
	}
	int parent_id(int i)
	{
		return (i+1)/2 - 1;
	}
	int left_id(int i)
	{
		return 2*(i+1)-1;
	}
	int right_id(int i){
		return 2*(i+1)+1-1;
	}
	bool has_left(int i) {
		return left_id(i) < (int)size();
	}
	bool has_right(int i) {
		return right_id(i) < (int)size();
	}
	//node id: key = k, parent key = pk, left key = lk, right key = rk, 
	void print(int i) {
		cout << "node " << i+1;
		cout << ": key = " << at(i) << ", ";
		if (has_parent(i))
			cout << "parent key = " << at(parent_id(i)) << ", ";
		if (has_left(i))
			cout << "left key = " << at(left_id(i)) << ", ";
		if (has_right(i))
			cout << "right key = " << at(right_id(i)) << ", ";
		cout << std::endl;
	}
	void Print() {
		for (unsigned int i=0;i<size();++i){
			print(i);
		}
	}
};


int main(){
	HeapTree A;
	A.InputSet();
	A.Print();
}

Measured memory_bytes: 1200
k = int(input())
cnt = [0] * (k + 1)

for i in range(k, 0, -1):
    cnt[i] = (k // i) ** 3
    for j in range(i * 2, k + 1, i):
        cnt[i] -= cnt[j]

print(sum((i* cnt[i] for i in range(1, k + 1))))


Measured memory_bytes: 8972
/**
 *    author:  tourist
 *    created: 14.07.2019 15:46:31
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  if (cnt[0] == n) {
    cout << "Yes" << '\n';
    return 0;
  }
  if (n % 3 != 0) {
    cout << "No" << '\n';
    return 0;
  }
  vector<int> all;
  for (auto& p : cnt) {
    for (int i = 0; i < p.second / (n / 3); i++) {
      all.push_back(p.first);
    }
  }
  if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  ll N,C;
  ll size = 100000;
  Vector s(size),t(size),c(size);
  Vector sm(2*size+2,0),tt(2*size+2,0);
  cin >> N >> C;
  rep(i,N)cin >> s[i] >> t[i] >> c[i];
  repl(i,1,C){
    rep(j,2*size+2)tt[j] = 0;
    rep(j,N)if(c[j] == i)tt[s[j]*2 - 1]++,tt[t[j]*2]--;
    repl(j,1,2*size+1)tt[j]+=tt[j-1];
    rep(j,2*size+2)if(tt[j] > 0)sm[j]++;
  }
  ll mx = 0;
  rep(i,2*size+2)maxch(mx,sm[i]);
  cout << mx << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int d[10];
    d[0] = 0 + abs(b - a) + abs(c - b), d[1] = 0 + abs(c - a) + abs(b - c);
    d[2] = 0 + abs(a - b) + abs(c - a), d[3] = 0 + abs(c - b) + abs(a - c);
	d[4] = 0 + abs(a - c) + abs(b - a), d[5] = abs(b - c) + abs(a - b);
	sort(d, d + 6);
	cout << d[0] << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, a);
    IN(ll, b);
    IN(ll, c);
    OUT(a + b + c - max({a, b, c}));
}

Measured memory_bytes: 3392
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
string x;
int cnt[5];
int main()
{
    cin>>x;
    for(int i=0;i<x.size();i++)
    {
        cnt[x[i]-'a']++;
    }
    sort(cnt,cnt+3);
    
    printf("%s\n",cnt[2]-cnt[0]<=1?"YES":"NO");
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

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;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int m, n;

signed main() {
	cin >> m >> n;
	cout << mod_pow(m, n, mod) << endl;
}


Measured memory_bytes: 3108
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self,n):
        fact=[1]*(n+1); invfact=[1]*(n+1)
        for i in range(1,n+1): fact[i]=i*fact[i-1]%MOD
        invfact[n]=pow(fact[n],MOD-2,MOD)
        for i in range(n-1,-1,-1): invfact[i]=invfact[i+1]*(i+1)%MOD
        self.__fact=fact; self.__invfact=invfact

    def inv(self,n):
        assert(n>0)
        return self.__fact[n-1]*self.__invfact[n]%MOD

    def fact(self,n):
        return self.__fact[n]

    def invfact(self,n):
        return self.__invfact[n]

    def comb(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[k]*self.__invfact[n-k]%MOD

    def perm(self,n,k):
        if(k<0 or n<k): return 0
        return self.__fact[n]*self.__invfact[n-k]%MOD

def resolve():
    n=int(input())
    mf=modfact(n)
    S=input()

    A=[None]*(2*n)
    for i,s in enumerate(S,1):
        A[i-1]=(s=='W')^(i&1)
    B=A[:]
    for i in range(2*n-1):
        B[i+1]+=B[i]

    # A が 0 であるものに対して、自分より左に何個 1 があるかを考える
    if(A[0]==0):
        print(0)
        return
    if(sum(A)!=n):
        print(0)
        return

    now=0
    ans=1
    for i in range(2*n):
        if(A[i]==0):
            ans*=B[i-1]-now
            ans%=MOD
            now+=1

    print(ans*mf.fact(n)%MOD)
resolve()

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


int main(){
    //cout<<"hello"<<endl;
    int N;cin>>N;
    int ans=0;
    int nums[110];
    for(int i=0;i<N;i++){
        nums[i]=i+1;    //1以上N以下
    }


    int maxNumDividableByTwo=1;
    int maxNumDividableByTwo_times=0;
    for(int i=0;i<N;i++){
        int numDividableByTwo_times=0;
        int numsForWhile=nums[i];
        while(numsForWhile%2==0){//無限ループ注意
        //無限ループに陥っているプログラムを終了しないとコンパイルに通らない
            numsForWhile/=2;
            numDividableByTwo_times++;
        }
        if(numDividableByTwo_times>maxNumDividableByTwo_times){
            maxNumDividableByTwo=nums[i];
            maxNumDividableByTwo_times=numDividableByTwo_times;
        }
    }



    ans=maxNumDividableByTwo;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int a[10];

int solve(ll p, int i, int n)
{
    if (i == n) {
        return p%2 == 0;
    }
    
    int a1 = solve((p*(a[i]-1))%2, i+1, n);
    int a2 = solve((p*(a[i]))%2, i+1, n);
    int a3 = solve((p*(a[i]+1))%2, i+1, n);
    return a1+a2+a3;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif
    
    int n;
    cin >> n;
    for0(i,n) {
        cin >> a[i];
    }
    int ans = solve(1, 0, n);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,int> P;

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    vector<int> cnt(1000010);
    for(int i = 0;i < N;i++) {
        int cnt2 = vec.at(i);
        for(int j = 2;j * j <= vec.at(i);j++) {
            int cnt3 = 0;
            while(cnt2 % j == 0) {
                cnt3++;
                cnt2 /= j;
            }
            cnt.at(j) = max(cnt.at(j),cnt3);
        }
        cnt.at(cnt2) = max(cnt.at(cnt2),1);
    }
    ll G = 1;
    for(int i = 2;i < 1000010;i++) {
        G *= RepeatSquaring(i,cnt.at(i),MOD);
        G %= MOD;
    }
    ll ret = 0;
    for(int i = 0;i < N;i++) {
        ret += (G * modinv(vec.at(i),MOD));
        ret %= MOD;
    }
    cout << ret << endl;
}

Measured memory_bytes: 4224
#include <stdio.h>
int main(){
  int a, b;
  scanf("%d%d", &a, &b);
  if (a < b) {
   printf("a < b\n");
  } else if (a > b) {
   printf("a > b\n");
  } else {
   printf("a == b\n");
  } 

 return 0;
}




Measured memory_bytes: 2120
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
const long long MOD = 1e9 + 7, INF = 1e18;
int main() {
	int k;
	vector<int>a(3);
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a.begin(),a.end());
	cout << a[0] + a[1] + a[2] * pow(2,k) << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define EPS 1e-9
#define rank asadf
using namespace std;

const int MAXN = 1e3 + 111;
const int MOD = 1e9 + 7;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};

int h, w, ch, cw, dh, dw;

string s[MAXN];

bool was[MAXN][MAXN], used[MAXN * MAXN];

int cmp[MAXN][MAXN], d[MAXN * MAXN];

set<pair<int, int> > st;

vector<vector<int> > v;

bool good(int x, int y) {
    return x >= 0 && x < h && y >= 0 && y < w;
}

void dfs(int x, int y, int clr) {
    cmp[x][y] = clr;
    was[x][y] = true;
    for (int k = 0; k < 4; ++k) {
        int nx = x + dx[k];
        int ny = y + dy[k];
        if (good(nx, ny) && !was[nx][ny] && s[nx][ny] == '.') {
            dfs(nx, ny, clr);
        }
    }
}

void solve(int s, int f) {
    for (int i = 0; i < h * w; ++i) {
        if (i != s) {
            d[i] = 1e9;
            st.insert({1e9, i});
        }
        else {
            d[i] = 0;
            st.insert({0, i});
        }
    }
    used[s] = true;
    for (int i = 0; i < h * w; ++i) {
        auto cur = *st.begin();
        st.erase(st.begin());
        int w = cur.first;
        int id = cur.second;
        used[id] = true;
        for (auto to : v[id]) {
            if (!used[to]) { 
                st.erase(st.find({d[to], to}));
                d[to] = min(d[to], w + 1);
                st.insert({d[to], to});
            }
        }
    }
    cout << (d[f] == 1e9 ? -1 : d[f]);
}

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w;
    cin >> ch >> cw;
    cin >> dh >> dw;
    --ch, --cw;
    --dh, --dw;
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    int cnt = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '.' && !was[i][j]) {
                dfs(i, j, cnt++);
            }
        }
    }
    cerr << cnt << "\n";
    v.resize(h * w);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            for (int x = i - 2; x <= i + 2; ++x) {
                for (int y = j - 2; y <= j + 2; ++y) {
                    if (good(x, y) && s[i][j] == '.' && s[x][y] == '.' && cmp[i][j] != cmp[x][y]) {
                        v[cmp[i][j]].push_back(cmp[x][y]);
                        v[cmp[x][y]].push_back(cmp[i][j]);
                    }
                }
            }
        }
    }
    if (s[ch][cw] != '.' || s[dh][dw] != '.') {
        cout << -1;
        return 0;
    }
    solve(cmp[ch][cw], cmp[dh][dw]);
    return 0;
}

Measured memory_bytes: 106824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{

    internal class Solution
    {
        public int N, W;
        public int[] Vs, Ws;

        public void Run()
        {
            var line1 = Input.ReadIntArray();
            N = line1[0];
            W = line1[1];
            Vs = new int[N];
            Ws = new int[N];

            for (int i = 0; i < N; i++)
            {
                var line = Input.ReadIntArray();
                Vs[i] = line[0];
                Ws[i] = line[1];
            }

            int[,] dp = new int[N + 1, W + 1];
            for(int i = 0; i <= N; i++)
            for (int j = 0; j <= W; j++)
                dp[i, j] = int.MinValue;

            for (int i = 0; i <= N; i++)
            {
                for (int j = 0; j <= W; j++)
                {
                    if (i == 0)
                    {
                        // 初期化
                        dp[i, j] = 0;
                    }
                    else
                    {
                        int v = Vs[i - 1];
                        int w = Ws[i - 1];
                        if (j < w)
                            dp[i, j] = dp[i - 1, j];
                        else
                            dp[i, j] = Math.Max(dp[i - 1, j], dp[i - 1, j - w] + v);
                    }
                   
                }
            }

            Console.WriteLine(dp[N, W]);
        }

       
    }

    
    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}


Measured memory_bytes: 13508
#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<double> p(n);
	for(int i=0;i<n;i++)
		cin >> p[i];

	vector<vector<long double> > dp(n,vector<long double>(n+1,0));
	
	dp[0][0]=(1-p[0]);
	dp[0][1]=p[0];

	for(int i=1;i<n;i++)
	{
		for(int j=0;j<n+1;j++)
		{
			dp[i][j]=dp[i-1][j]*(1-p[i])+(j!=0 ? dp[i-1][j-1]*p[i] : 0);
		}
	}
	
	int ub=n/2+1;
	long double ans=0;
	for(int i=ub;i<=n;i++)
	{
		ans+=dp[n-1][i];
	}
	
	cout << setprecision(9) << fixed << ans << endl;

}




Measured memory_bytes: 141056
N = int(input())
a = []
for i in range(N):
    ta, tb = map(int, input().split())
    a.append([ta, tb])
a = sorted(a, key=lambda x:(x[1], x[0]), reverse=True)
deadline = a[0][1]
for i in range(N - 1):
    deadline -= a[i][0]
    deadline = min(deadline, a[i + 1][1])
    if deadline < 0:
        print('No')
        exit()
deadline -= a[N - 1][0]
if deadline < 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 52300
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();

// 双方向の関係性をグループにまとめられるやつ
// https://atcoder.jp/contests/abc177/tasks/abc177_d
class UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
public:
    vector<ll> datas;
    UnionFind(ll N) : datas(N, -1) {
    }
    bool isRoot(ll x) const {
        return datas[x] < 0;
    }
    ll root(ll x) {
        if (isRoot(x)) return x;
        // Rootの情報を更新する
        datas[x] = root(datas[x]);
        return datas[x];
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (datas[x] > datas[y]) swap(x, y);
        datas[x] += datas[y];
        datas[y] = x;
        return true;
    }

    ll size(ll x) {
        return -datas[root(x)];
    }

    void Dump() {
#ifdef SOURCE_TEST
        REP(i, datas.size()) {
            if (isRoot(i)) {
                PS("Root:");
                PS(size(i));
            } else {
                cout << datas[i] << ":";
            }

            PR(i);
        }
#endif
    }
};

int main() {
    ll N, M;
    cin >> N >> M;

    UnionFind unionFriends(N);

    REP(i, M) {
        ll a, b;
        cin >> a >> b;

        unionFriends.unite(a - 1, b - 1);
    }

    ll m = 0;

    unionFriends.Dump();
    REP(i, N) {
        m = max(m, unionFriends.size(i));
    }

    PR(m);

    return 0;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
template <class T>
void print(T x){cout << x << '\n';}



void solve(long long X, long long A, long long B){
  print((X-A)%B);
}

int main(){
  long long X;
  scanf("%lld",&X);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(X, A, B);
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    N = int(input())
    S = input()
    t = S[:]
    while True:
        change = False
        for i in range(1, len(t)):
            if (t[i - 1], t[i]) == ("(", ")"):
                t = t[:i - 1] + t[i + 1:]
                change = True
                break
        if not change:
            break

    a = "(" * t.count(")")
    b = ")" * t.count("(")
    print(a + S + b)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

struct Edge {
    int id, to;
};
using ve  = vector<Edge>;
using vve = vector<ve>;

int num_color = 0;
vve edges;
vl ans;

void dfs(int v, int pre_color=-1, int parent=-1) {
    int now_color = 0;
    for (auto e : edges[v]) {
        if (e.to == parent) continue;
        if (now_color == pre_color) now_color++;
        ans[e.id] = now_color;
        dfs(e.to, now_color, v);
        now_color++;
    }
}

int main() {
    int N;
    cin >> N;
    edges.resize(N);
    ans.resize(N-1);
    rep(i,N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        Edge e1{i, b};
        Edge e2{i, a};
        edges[a].push_back(e1);
        edges[b].push_back(e2);
    }
    rep(i,N) num_color = max(num_color, (int)edges[i].size());
    dfs(0);
    cout << num_color << endl;
    rep(i,N-1) {
        cout << ans[i]+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 11220
#include <cstdio>
#include <cstring>
#include <cmath>
#define mod 256
int n;
int l[258];
int r[16][16][16][258];
int cnt[258];
int main(void){
	for(int s=0;s<=15;s++){
		for(int a=0;a<=15;a++){
			for(int c=0;c<=15;c++){
				r[s][a][c][0]=s;
				for(int q=1;q<=256;q++){
					r[s][a][c][q]=(a*r[s][a][c][q-1]+c)%mod;
				}
			}
		}
	}
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=1;i<=n;i++){
			scanf("%d",&l[i]);
		}
		double res=0.0;
		int rs=-1,ra,rc;
		for(int s=0;s<=15;s++){
			for(int a=0;a<=15;a++){
				for(int c=0;c<=15;c++){
					memset(cnt,0,sizeof(cnt));
					for(int q=1;q<=n;q++){
						cnt[(r[s][a][c][q]+l[q])%mod]++;
					}
					double val=0.0;
					for(int i=0;i<=255;i++){
						if(cnt[i]==0)continue;
						val-=(double)cnt[i]*log((double)cnt[i]);
					}
					if(val<res || rs==-1){
						rs=s;
						ra=a;
						rc=c;
						res=val;
					}
				}
			}
		}
		printf("%d %d %d\n",rs,ra,rc);
	}
	return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
    int n;
    cin>>n;
    int s=0;
    for(int i=1;i<=n;i++){
        if((i%3!=0) && (i%5 !=0) && (i%15!=0)){
            // cout<<i<<" ";
         s+=i;   
        }
    }
    cout<<s<<'\n';
}

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    long long N;
    cin >> N;
    long long sum = 0;
    for(long long i = 1; i <= N; i++){
        if((i % 3) * (i % 5) == 0){
            
        } else {
            sum += i;
        }
    }
    cout << sum;
}

Measured memory_bytes: 3608
// ABC060 B - Choose Integers
#include <stdio.h>

int main(void) {
    int A, B, C;
    int mod[100] = { 0 };
    scanf("%d %d %d", &A, &B, &C);
    int a = A;
    while(1) {
        int m = a % B;
        // printf("%d, ", a);
        if (m == C) {
            printf("YES\n");
            return 0;
        }
        if (mod[m] == 1) {
            printf("NO\n");
            return 0;
        } else {
            mod[m] = 1;
        }
        a += A;
    }

}

Measured memory_bytes: 128
//abc149_e.cpp
//Sun Jan  5 11:36:25 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n,m;
	cin >> n >> m;

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

	sort(a,a+n,greater<ll>());

	ll d[300001];
	fill(d,d+300001,0);
	for (int i=0;i<n;i++){
		d[a[i]]++;
	}
	for (int i=300000;i>0;i--){
		d[i-1] += d[i];
	}

	ll left = 0;
	ll right = 300000;
	while (abs(right-left)>1){
		ll mid = (left+right)/2;
		ll temp = 0;
		for (int i=0;i<n;i++){
			temp += d[max(0ll,mid-a[i])];
		}
		if (temp>m){
			left = mid;
		}else {
			right = mid;
		}
	}

	ll sum[n+1];
	sum[0] = 0;
	for (int i=1;i<n+1;i++){
		sum[i] = sum[i-1]+a[i-1];
	}

	ll ans = 0;
	ll hsnum = 0;
	for (int i=0;i<n;i++){
		ll x = d[max(0ll,right-a[i])];
		ans += sum[x]+x*a[i];
		hsnum += x;
	}

	ans += left*(m-hsnum);

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 4096
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-15 10:45:30

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
const int MAXN = 2e5 + 7;

int cnt[MAXN];
int main(int argc, char const *argv[])
{
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	for(int i = 1; i < n; ++i){
		if(s[i-1] == 'A' && s[i] == 'C')	cnt[i+1] = cnt[i] + 1;
		else	cnt[i+1] = cnt[i];
		// cout << i+1 << ' ' << cnt[i+1] << endl;
	}
	int l, r;
	while(q--){
		cin >> l >> r;
		cout << (cnt[r]-cnt[l]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node{
  int key;
  struct Node* prev;
  struct Node* next;
};
typedef struct Node* NodePointer;
NodePointer head;
void init()
{
  head = (NodePointer)malloc(sizeof(struct Node));
  head->prev = head;
  head->next = head;
}

NodePointer search(int m)
{
  NodePointer x = head->next;
  while(x!=head && x->key != m) x = x->next;
  return x;
}

void insert(int m)
{
  NodePointer x;
  x=(NodePointer)malloc(sizeof(struct Node));
  x->key = m;
  x->next = head->next;
  head->next->prev = x;
  head->next = x;
  x->prev = head;
}

void delete(int m)
{
  NodePointer x = search(m);
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}

void deleteFirst(){
  NodePointer x = head->next;
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}

void deleteLast(){
  NodePointer x = head->prev;
  if(x == head) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
}

int main()
{
  int n,i,m;
  NodePointer j;
  char c[20];
  
  init();
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%s",c);
    if(!strcmp(c,"insert")){
      scanf("%d",&m);
      insert(m);
    }
    else if(!strcmp(c,"delete")){
      scanf("%d",&m);
      delete(m);
    }
    else if(!strcmp(c,"deleteFirst")){
      deleteFirst();
    }
    else if(!strcmp(c,"deleteLast")){
      deleteLast();
    }
  }
  for(j = head->next; j!=head;){
    printf("%d",j->key);
    if((j=j->next) != head) printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 34976