akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
set<int>s[100001];
map<pair<int,int>,int>m;
queue<pair<int,int> >q;
#define mp make_pair
#define IT set<int>::iterator
int fa[100001];
int find(int x){return (fa[x]==x)?fa[x]:find(fa[x]);}
signed main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<=2*n-2;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		s[u].insert(v);
		s[v].insert(u);
		m[mp(u,v)]++,m[mp(v,u)]++;
		if(m[mp(u,v)]==2)
			q.push(mp(u,v));
	}
	while(!q.empty())
	{
		int u=q.front().first;
		int v=q.front().second;
		q.pop();
		u=find(u),v=find(v);
		if(u!=v)
		{
			if(s[v].size()>s[u].size())swap(u,v);
			s[u].erase(v);
			s[v].erase(u);
			for(IT it=s[v].begin();it!=s[v].end();++it)
			{
				int to=(*it);
				m[mp(to,v)]=m[mp(v,to)]=0;
				s[to].erase(v);
				s[to].insert(u);
				s[u].insert(to);
				m[mp(u,to)]++,m[mp(to,u)]++;
				if(m[mp(u,to)]==2)
					q.push(mp(u,to));
				if(m[mp(to,u)]==2)
					q.push(mp(to,u));
			}
			fa[v]=u;
			s[v].clear();
		}
	}
	for(int i=2;i<=n;i++)
		if(find(i)!=find(i-1))
		{
			printf("NO");
			return 0;
		}
		printf("YES");
    return 0;
}


Measured memory_bytes: 57856
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>

using namespace std;
typedef long long ll;
#define MP make_pair

ll powll(ll powllnum,ll powlljou){
    if(powlljou==1){
        return powllnum;
    }else if(powlljou==0){
        return 1;
    }else if(powlljou%2==0){
        ll powlltmp=powll(powllnum,powlljou/2);
        return powlltmp*powlltmp;
    }else{
        ll powlltmp=powll(powllnum,powlljou-1);
        return powlltmp*powllnum;
    }
}
int main(void) {
    ll n,k,num=0;
    cin>>n>>k;

    for (ll i = 0; i < 1000000000; i++) {
        num++;
        if(powll(k,i)>n)break;
    }

    cout<<max((long long)1,num-1)<<"\n";

    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<map>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sort(begin(s[i]), end(s[i]));
        ans += mp[s[i]];
        mp[s[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18176
#include<stdio.h>

int main(void){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=1.0*a/b;
	printf("%d %d %.5lf\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int max(int a,int b){return a>b?a:b;}
int main(void){
    int n,m,i,j,data[10]={0,2,5,5,4,5,6,3,7,6},len;
    int ans[5000];
    scanf("%d%d",&n,&m);
    int dp[n+1],a[m],b[m];
    for(i=0;i<m;i++)scanf("%d",&a[i]);
    for(i=0;i<m-1;i++)for(j=0;j<m-i-1;j++)if(a[j]<a[j+1]){int t=a[j];a[j]=a[j+1];a[j+1]=t;}
    for(i=0;i<m;i++)b[i]=data[a[i]];
    dp[0]=0;
    for(i=1;i<=n;i++){
        dp[i]=-2100000000;
        for(j=0;j<m;j++)if(i-b[j]>=0)dp[i]=max(dp[i],dp[i-b[j]]+1);
    }
    len=dp[n];
    for(i=0;i<len;i++)for(j=0;j<m;j++){
      if(n>=b[j]&&dp[n-b[j]]==dp[n]-1){
        ans[i]=a[j];
        n-=b[j];
        break;
      }
    }
    for(i=0;i<len;i++)printf("%d",ans[i]);
}

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

int main(){
	int tc, arr[105];
	cin >> tc;
	int flag, cnt;
	flag = cnt = 0;
	for(int t = 0 ; t < tc ; t++){
		cin >> arr[t];
		if(arr[t] %2 == 0){	
			if(arr[t] %3 == 0 || arr[t]%5 == 0){
				flag = 1;
				cnt++;
			}	
			else{
				flag = 0;
			}
		}
		else if(arr[t] %2 == 1){
			cnt++;
		}
	}	
	if(cnt == tc){
		cout << "APPROVED\n";
	}
	else{
		cout << "DENIED\n";
	}
	return 0;
}

Measured memory_bytes: 256
import math

A, B, K = map(int, input().split())

tmp = min(A, B)
l = []
for i in range(1, tmp):
    if A % i == 0 and B % i == 0:
        l.append(i)
if A % tmp == 0 and B % tmp == 0:
    l.append(tmp)

print(l[-K])


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
sort(a,a+n);int ans=0;int c=1;
for(int i=0;i<n;i++){
  if(a[i]==a[i+1]){
    c++;
  }
  else{
    if(c%2) {
      ans++;
    }
    c=1;
  }
}
cout << ans<<endl;
}

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

struct node{
	int num;
	set<node *> as;
	int df;
	int ds;
};

int main(){
	int n, in1, in2;
	int fanc(vector<bool> &c, vector<node> &vn, int n);
	
	cin >> n;
	vector<node> vn(n);
	rep(i, n) vn.at(i).num = i;
	vn.at(0).df = 0;
	vn.at(n-1).ds = 0;
	rep(i, n-1){
		cin >> in1 >> in2;
		in1--;
		in2--;
		vn.at(in1).as.insert(&(vn.at(in2)));
		vn.at(in2).as.insert(&(vn.at(in1)));
	}
	
	queue<tuple<int, int, int>> q;//zahyo, count, mae
	vector<bool> cf(n, false);
	cf.at(0) = true;
	q.push(make_tuple(0, 0, 0));
	int fc = -1, sc = 0;
	while(!q.empty()){
		auto t = q.front(); q.pop();
		for(node *an : vn.at(get<0>(t)).as){
			if(cf.at(an->num) == false){
				q.push(make_tuple(an->num, get<1>(t)+1, get<0>(t)));
				vn.at(an->num).df = get<1>(t)+1;
				cf.at(an->num) =true;
			}
		}
	}
	
	vector<bool> cs(n, false);
	cs.at(n-1) = true;
	q.push(make_tuple(n-1, 0, 0));
	while(!q.empty()){
		auto t = q.front(); q.pop();
		for(node *an : vn.at(get<0>(t)).as){
			if(cs.at(an->num) == false){
				q.push(make_tuple(an->num, get<1>(t)+1, get<0>(t)));
				vn.at(an->num).ds = get<1>(t)+1;
				cs.at(an->num) =true;
				if(vn.at(an->num).df <= vn.at(an->num).ds){
					cerr << "f" << an->num+1 << endl;
					fc++;
				}else{
					cerr << "s" << an->num+1 << endl;
					sc++;
				}
			}
		}
	}
	
	cerr << fc << " " << sc << endl;
	
	if(fc <= sc) cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
	
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;
        vector<double> v(n);
        double sum = 0;
        for(i = 0; i < n ;i++){
            cin >> v[i];
            sum += (1 / v[i]);
        }
        cout <<fixed << setprecision(12) << (1 / sum);
    }
    return 0;
}

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

const int MAXN = 1e6+10;
ll M = 1e9+7;

ll powm(ll p, ll b) {
  if (p<=0) return 1;
  ll ans = powm(p/2, b);
  ans = ans*ans%M;
  if (p%2) ans = ans*b%M;
  return ans;
}
ll fact[MAXN], inv[MAXN];

ll choose(int t, int d) {
  return fact[t+d]*inv[t]%M*inv[d]%M;
}

int main(){
  int n;
  cin.tie(0); ios_base::sync_with_stdio(0);
  fact[0] = inv[0] = 1;
  for(int i=1;i<MAXN;i++) {
    fact[i]= fact[i-1]*i%M;
    inv[i] = powm(M-2, fact[i]);
  }
  cin >> n;
  if (n==1) cout << 0<<endl;
  else {
    ll ans = 0;
    for(int i=2;i<=n;i++) { // i is number of 0/9 digs
      //cerr << i << " " << powm(i,2)-2 << " " << powm(n-i, 8) << " " << choose(i, n-i) <<endl;
      ll ways = (powm(i,2)-2+M)*powm( n-i, 8)%M*choose(i, n-i)%M;
      ans = (ans+ways)%M;
    }
    ans = (ans%M+M)%M;
    cout << ans <<endl;
  }
}


Measured memory_bytes: 19172
#include <stdio.h>
#include <string.h>
int main(){
	char a[105],b[105],c[105];
	char l,m,n;
	scanf("%s %s %s" ,&a,&b,&c);
	for(int i = 0; i < strlen(a); i++){
		l = a[i];
	}
	for(int j = 0; j < strlen(b); j++){
		m = b[j];
	}
	for(int k = 0; k < strlen(c); k++){
		n = c[k];
	}
	if(l == b [0] && m == c[0]){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,j,h,w,m;
  cin >> h >> w >> m;
  map<P,bool> mp;
  vector<int> a(300010,0),b(300010,0);
  for(i=0;i<m;i++){
    int x,y;
    cin >> x >> y;
    x--,y--;
    mp[make_pair(x,y)]=true;
    a[x]++,b[y]++;
  }
  int mx1=0,mx2=0;
  for(i=0;i<h;i++){
    mx1=max(mx1,a[i]);
  }
  for(i=0;i<w;i++){
    mx2=max(mx2,b[i]);
  }
  vector<int> c,d;
  for(i=0;i<h;i++){
    if(mx1==a[i]){
      c.push_back(i);
    }
  }
  for(i=0;i<w;i++){
    if(mx2==b[i]){
      d.push_back(i);
    }
  }
  int res=-1;
  for(i=0;i<c.size();i++){
    for(j=0;j<d.size();j++){
      if(mp[make_pair(c[i],d[j])]==false){
        res=0;
        break;
      }
    }
    if(res==0){
      break;
    }
  }
  cout << mx1+mx2+res << endl;
}

Measured memory_bytes: 28560
/**
 * Author: AcFunction
 * Date:   2019-09-04 21:48:14
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double 

#define fi first
#define se second
#define MP make_pair
#define pii pair <int, int>
#define pil pair <int, ll> 
#define pli pair <ll, int>
#define pll pair <ll, ll>  

#define All(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

#define ms0(x) memset(x, 0, sizeof(x))
#define ms1(x) memset(x, -1, sizeof(x))

#define oiu cerr << "Yes!" << endl; 
#define O(x) cerr << #x << ": " << x << endl;  

template <typename T> void printarr(T a[], int b, int e) {
  if(b > e) return ; 
  for(int i = b; i < e; i++) cout << a[i] << " "; 
  cout << a[e] << " " << endl; 
} 

template <typename T> int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0; 
}

template <typename T> int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0; 
}

const int N = 200200; 

ll n, a[N], b[N]; 

priority_queue <pli> Q; 

int main() {
  scanf("%lld", &n); ll ans = 0; 
  for(int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]); 
  }
  for(int i = 1; i <= n; i++) {
    scanf("%lld", &b[i]); 
    Q.push({b[i], i}); 
    if(b[i] < a[i]) {
      puts("-1"); 
      return 0; 
    }
  }
  while(!Q.empty()) {
    pli tmp = Q.top(); Q.pop(); 
    if(tmp.fi == a[tmp.se]) continue ; 
    if(tmp.fi < a[tmp.se]) {
      puts("-1"); 
      return 0; 
    }
    int id = tmp.se; 
    int id1 = id + 1; 
    int id2 = id - 1; 
    if(id1 > n) id1 -= n; 
    if(id2 < 1) id2 += n; 
    if(b[id] < b[id1] + b[id2] + a[id]) {
      puts("-1");
      return 0; 
    }
    ll t = b[id1] + b[id2]; 
    ll x = b[id] - a[id]; 
    ans += x / t; b[id] -= x / t * t; 
    if(a[id] != b[id])
      Q.push({b[id], id}); 
  }
  for(int i = 1; i <= n; i++) {
    if(a[i] != b[i]) {
      puts("-1"); 
      return 0; 
    }
  }
  printf("%lld\n", ans);
  return 0; 
}


Measured memory_bytes: 8816
#include <stdio.h>
int main(){

  int normal,totalw,rule1,rulex,ruley,x,y;

  scanf("%d",&rulex);

  scanf("%d",&normal);
  
  scanf("%d",&rule1);

  scanf("%d",&ruley);

  scanf("%d",&totalw);

  x = rulex * totalw;
  
  if(totalw < rule1){

    y = normal;
    
  }else if(totalw > rule1){

    y =  normal + (totalw - rule1) * ruley;  

  }
  
  if(x < y){

    printf("%d\n",x);
    
  }else if(x > y){

    printf("%d\n",y);

  }else if(x == y){

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

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a > b)cout << "a > b" << endl;
  if(a == b)cout << "a == b" << endl;
  if(a < b)cout << "a < b" << endl;
}


Measured memory_bytes: 3112
m = list(map(int,input().split(" ")))
W = m[0]
H = m[1]
x = m[2]
y = m[3]

xyplus = x + y
#重心に来る時は複数、線上と内部は1こ
# if w % 2 == 0 and h % 2 == 0:

ans_area = W * H / 2
if x == W / 2 and y == H / 2:
    ans_sp = 1
else:
    ans_sp = 0
print(str(ans_area) + " " + str(ans_sp))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));


int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    for(int i = 0; i < H; i++)for(int j = 0; j < W; j++) cin >> A[i][j];
    vector<vector<int>> Ae(H + 1, vector<int>(W + 1));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) Ae[i][j] = A[i][j];
    }
    for(int i = 0; i < H; i++){
        int sum = 0;
        for(int j = 0; j < W; j++){
            sum += A[i][j];
        }
        Ae[i][W] = sum;
    }
    for(int i = 0; i < W; i++){
        int sum = 0;
        for(int j = 0; j <  H; j++){
            sum+= A[j][i];
        }
        Ae[H][i] = sum;
    }
    int sum = 0;
    for(int i = 0; i < H; i++){
        sum += Ae[i][W];
    }
    Ae[H][W] = sum;
    for(int i = 0; i < H + 1; i++){
        for(int j = 0; j < W + 1; j++){
            cout << Ae[i][j];
            if(j != W) cout << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3180
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
like = [0] * M

for i in range(N):
    for j in range(A[i][0]):
        like[A[i][j+1]-1] += 1
        
cnt = 0
for i in range(M):
    if like[i] == N:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

void solve() {
    lli n;
    cin >> n;
    lli ans = 0;
    for (int i = 0; i < n; ++i) {
        lli x;
        cin >> x;
        if (i == 0) ans = x;
        else ans = gcd(ans, x);
    }
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
import math
n=int(input())
T,A=map(int,input().split())
for i in range(n-1):
    t,a=map(int,input().split())
    x=T//t if T%t==0 else T//t+1
    y=A//a if A%a==0 else A//a+1
    c=max(x,y)
    T=t*c
    A=a*c

print(A+T)

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

int main() {
  int n;
  cin>>n;
  map<string,ll> m;
  for(int i=0;i<n;i++) {
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    m[s]+=1;
  }
  ll ans=0;
  for(auto itr=m.begin();itr !=m.end();itr++){
    ll v=itr->second;
    ans+=v*(v-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11136
using System;
using System.Linq;

class AizuOnlineJudge {
    static void Main() {
        Console.ReadLine();

        Console.WriteLine((Console.ReadLine().Split().Select(ulong.Parse).Aggregate(0ul, (p, c) => ((p >> 32) < c ? ++p : p) & uint.MaxValue | (c << 32)) & uint.MaxValue) - 1);
    }
}



Measured memory_bytes: 23024
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 21;

bool check(long long n, long long k)
{
	while (n % k == 0)
		n /= k;
	return n % k == 1;
}

int divs(long long n, bool ch = false)
{
	int ret = n > 1;

	for (long long i=2; i*i<=n; i++) if (n % i == 0)
	{
		long long j = n / i;
		if (ch)
		{
			if (check(n, i))
				ret++;
			if (j != i and check(n, j))
				ret++;
		}
		
		else
		{
			ret += j == i ? 1 : 2;
		}
	}
	
	return ret;
}

void solve()
{
	long long n;
	scanf ("%lld", &n);
	printf("%d\n", divs(n, true) + divs(n-1));
}
 
int main()
{
	int t;
t=1;////	scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll ui, vi, wi;
    vector<ll> U, V, W;
    vector<vector<array<ll,2>>> g(N, vector<array<ll,2>>());
    for(int i=0;i<N-1;i++){
        cin >> ui >> vi >> wi;
        g[ui-1].push_back(array<ll,2>{vi-1, wi});
        g[vi-1].push_back(array<ll,2>{ui-1, wi});
    }
    vector<ll> color(N,-1);
    color[0] = 0;
    queue<ll> q;
    q.push(0);
    while(!q.empty()){
        auto v = q.front(); q.pop();
        for(auto nv : g[v]){
            if(color[nv[0]]!=-1) continue;
            q.push(nv[0]);
            if(nv[1]%2==0) color[nv[0]] = color[v];
            else           color[nv[0]] = (color[v]+1)%2;
        }
    }

    for(int i=0;i<N;i++){
        cout<<color[i]<<endl;
    }

    return 0;
}

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

int dx[13]={1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,};
int dy[13]={1, 1, 1, 0, 0, 0,-1,-1,-1, 1, 1, 1, 0,};
int dz[13]={1, 0,-1, 1, 0,-1, 1, 0,-1, 1, 0,-1, 1,};

int main(){			
	while(1){
		int n,m,p;
		cin >> n >> m >> p;
		if(n==0) break;
		
		vector<vector<vector<int> > > field(n+2, vector<vector<int> >(n+2, vector<int>(n+2, -1)) );
		bool end=false;
		for(int i=1; i<=p; i++){
			//put a stone
			int x,y;
			cin >> x >> y;
			int z = 1;
			while(field[x][y][z] != -1) z++;
			field[x][y][z] = i%2;
			
			//check
			if(end) continue;
			for(int j=0; j<13; j++){
				int count=-1;
				int cx=x, cy=y, cz=z;
				while(field[cx][cy][cz] == i%2){
					cx-=dx[j]; cy-=dy[j]; cz-=dz[j];
				}
				do{
					cx+=dx[j]; cy+=dy[j]; cz+=dz[j];
					count++;
				}while(field[cx][cy][cz] == i%2);
				
				if(count >= m){
					cout << (i%2==0 ? "White " :"Black ") << i << endl;
					end = true;
					break;
				}
			}
		}
		if(!end){
			cout << "Draw" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3132
N, M = map(int, input().split())

tree = [0]*(N-1)

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        tree[b-2] += 1
    elif b == 1:
        tree[a-2] += 1
    else:
        tree[a-2] += 1
        tree[b-2] += 1

if all(tree[i] % 2 == 0 for i in range(N-1)):
    print('YES')
else:
    print('NO')

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a==b&&a==c)
        cout<<1<<endl;
    else if(a!=b&&a!=c&&b!=c)
        cout<<3<<endl;
    else
        cout<<2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    int sum = 0;
    for (int i = 0; i < a; i++) {
        if (s[i] >= '0' && s[i] <= '9') sum++;
    }
    if (s[a] == '-') sum++;
    for (int i = a+1; i < a+b+1; i++) {
        if (s[i] >= '0' && s[i] <= '9') sum++;
    }

    if (sum == a+b+1) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1; i<=n; i++){
        if(i%3ll!=0&&i%5ll!=0) ans+=i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define N 101234
#define ll long long
int n,i,h[N],a,b;
bool chk(ll o){
	int c=a-b;
	ll d=0;
	for(i=1;i<=n;i++){
		ll x=h[i]-o*b;	
		if(h[i]/b+3<o)x=0;
		d+=max((x+c-1)/c,0ll);
	}
	return d<=o;
}
int main(){
	int i,j,k=0;
	scanf("%d%d%d",&n,&a,&b);
	for(i=1;i<=n;i++)scanf("%d",h+i);
	ll l=1,r=0,o,ans;
	for(i=1;i<=n;i++)r+=h[i]/a+1;
	for(;l<=r;){
		o=(l+r)/2;
		if(chk(o)){
			ans=o;
			r=o-1;
		}else l=o+1;
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define ps(x) cout<<x;
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
int a,b,c,d,n,m,k,h,w,sum,mi,ma;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int main(void){
    cin>>n>>k;
    int maxe=n*(n-1)/2-(n-1);
    if(maxe<k){p(-1);return 0;}
    d(maxe);
    p(n-1+maxe-k);
    rep(i,2,n+1){
        ps(1);ps(" ");p(i);
    }
    c=maxe-k;
    rep(i,2,n)rep(j,i+1,n+1){
        if(c==0)break;
        c--;
        ps(i);ps(" ");p(j);
    }
    return 0;
}


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

using namespace std;

int dp[51][1000][1000];

int main(){
  int n,t[50];
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];

  for(int i=0;i<=n;i++)
    for(int j=0;j<900;j++)
      for(int k=0;k<900;k++)
	dp[i][j][k]=1e9;

  dp[0][0][0]=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<1000;j++)
      for(int k=0;k<1000;k++){
	if(j+t[i]<1000)dp[i+1][j+t[i]][k]=min(dp[i+1][j+t[i]][k],dp[i][j][k]);
	if(k+t[i]<1000)dp[i+1][j][k+t[i]]=min(dp[i+1][j][k+t[i]],dp[i][j][k]);
	dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]+t[i]);
      }
  
  int ans=1e9;
  for(int i=0;i<1000;i++)
    for(int j=0;j<1000;j++)
      if(dp[n][i][j]!=1e9)ans=min(ans,max(dp[n][i][j],max(i,j)));
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 201912
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int N;
        N = int.Parse(arr[0]);
        if (new List<int> { 2, 4, 5, 7, 9 }.Contains(N % 10))
            Console.WriteLine("hon");
        else if (new List<int> { 0, 1, 4, 6, 8 }.Contains(N % 10))
            Console.WriteLine("pon");
        else
            Console.WriteLine("bon");
        return;
    }
}


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

int main(){
  
  int N, i, j, k;
  cin>>N;
  map<int, int> data;
  for(i=1; i<=100; i++){
    for(j=1; j<=100; j++){
      for(k=1; k<=100; k++){
        
        data[i*i+j*j+k*k+i*j+j*k+k*i]++;
      }
    }
  }
  
  for(i=1; i<=N; i++){
    cout<<data[i]<<endl;
  }
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m,a[100000],x=1,M;

signed main() {
    cin >> n >> m;
    rep(i,n) {
        cin >> a[i];
        M = max(M, a[i]);
        x = a[i]*x/__gcd(a[i],x);
        if (x > 3000000000) x = 0;
    }
    if (x%2) {
        cout << 0 << endl;
        return 0;
    }
    x /= 2;
    bool f=true;
    rep(i,n) {
        if ((double)x/a[i] - (int)(x/a[i]) != 0.5) f=false;
    }
    if (f) cout << (m/x+1)/2 << endl;
    else cout << 0 << endl;


}






Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
//const int MAX=;
//const long double INF=;


int main(){
	ll N, X;
	cin>>N>>X;
	
	ll ans=N;
	ll a=X, b=N-X;
	while(true){
		if(a>b){
			if(a%b==0){
				ans+=2*a-b;
				break;
			}
			else{
				ans+=2*(a/b)*b;
				a=a%b;
			}
		}
		else if(a==b){
			ans+=a;
			break;
		}
		else{
			if(b%a==0){
				ans+=2*b-a;
				break;
			}
			else{
				ans+=2*(b/a)*a;
				b=b%a;
			}
		}
	}
	cout<<ans<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int len=s.length();
  
  int min=1000,x;
  string tmp;
  rep(i,len-2){
    tmp = s.substr(i,3);
    x = stoi(tmp);
    if( abs(x-753) < min ) min = abs(x-753);
  }
  
  cout << min << endl;
    
  return 0;

}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  while(n!=0)
  {
    int now=1000;
    now-=n;
    int ans=0;
    while(now>=500)
    {
      now-=500;
      ans++;
    }
    while(now>=100)
    {
      now-=100;
      ans++;
    }
    while(now>=50)
    {
      now-=50;
      ans++;
    }
    while(now>=10)
    {
      now-=10;
      ans++;
    }
    while(now>=5)
    {
      now-=5;
      ans++;
    }
    while(now>=1)
    {
      now--;
      ans++;
    }
    cout<<ans<<endl;
    cin>>n;
  }
}


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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

int rec(int x, int y, int c){
    if(c == 0){
        return x==0;
    }
    if(x < y*y) return 0;
    int res = 0;
    for(int i=y;i*i<=x;i++){
        res += rec(x-i*i, i, c-1);
    }
    return res;
}

int solve(){
    int n;
    cin >> n;
    if(n == 0) return 1;
    cout << rec(n, 0, 4) << endl;
    return 0;
}

int main(){
    // solve();
    while(solve()==0);
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,tmp=INF,sum=0; cin>>n;
    rep(i,n){
        int a,b; cin>>a>>b;
        if(a>b)chmin(tmp,b);
        sum+=a;
    }
    if(tmp==INF)cout<<0<<endl;
    else cout<<sum-tmp<<endl;
}

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

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

int main() {
    ll A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
p = list(map(int,input().split()))	
ans="NO"
tank=0
check=[(i+1) for i in range(n)]
if(p==check):
    ans="YES"
    
for i in range(n-1):
    for j in range(n-i-1):
        j+=i+1
        tank=p[i]
        p[i]=p[j]
        p[j]=tank
        if(p==check):
            ans="YES"
        tank=p[i]
        p[i]=p[j]
        p[j]=tank
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, y;
    cin >> n >> y;
    rep(i, n + 1)
    {
        rep(j, n + 1)
        {
            int k = n - i - j;
            if (k < 0)
            {
                continue;
            }
            if (i * 10000 + j * 5000 + k * 1000 == y)
            {
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    char s[4];
    scanf("%s",s);
    if(s[0]=='S'){
        if(s[1]=='U')
            printf("7");
        else
           printf("1"); 
    }
    else if(s[0]=='M')
        printf("6");
    else if(s[0]=='T'){
        if(s[1]=='U')
            printf("5");
        else
            printf("3");
    }
    else if(s[0]=='W')
        printf("4");
    else
        printf("2");
    return 0;
}


Measured memory_bytes: 128
rh = {'I'=>1, 'V'=>5, 'X'=>10, 'L'=>50, 'C'=>100, 'D'=>500, 'M'=>1000 }

while gets
	roman = $_.chomp.upcase
	nums = pn = []
	1.upto(roman.size-1) do |i|
		pn << (rh[roman[i]] > rh[roman[i-1]] ? -1 : 1)
	end
	pn << 1
	0.upto(roman.size-1) {|i| nums[i] = rh[roman[i]] * pn[i]}
	puts nums.inject {|x,y| x+y}
end

Measured memory_bytes: 6104
#include<bits/stdc++.h>
#define MOD 1000000007
#define F first
#define S second

typedef long long ll;
using namespace std;

int a[5];

int main()
{
    cin >> a[0] >> a[1] >> a[2];
    cout << (*max_element(a, a + 3) - *min_element(a, a + 3));
    return 0;
}


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

// DAME:

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    // bは vector aの中央値
    if(n%2!=0){
        int index = 0;
        index = n/2;
        for(int i=0; i<n; i++){
            ans += abs(a[i]-a[index]);
        }
    }else{
        int center = a[n/2];
        for(int i=0; i<n; i++){
            ans += abs(a[i]-center);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  
 long long  int sum=0;
  
  for(long long int i=0;i<S.size();i++){
    if(S[i]=='1'){
      sum++;
    }
  }
  
  long long int sum2=S.size()-sum;
  
  cout<<S.size()-abs(sum-sum2)<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    // Your code here!
    int N[10] = {0,0,0,0,0,0,0,0,0,0},P;
    for(int i = 0; i < 4; i++)
    {
        scanf("%d",&P);
        N[P]++;
    }
    if(N[1]==1 && N[9]== 1 && N[7]==1 && N[4]==1)
        printf("YES\n");
    else
        printf("NO\n");
}


Measured memory_bytes: 128
# https://atcoder.jp/contests/abc082/tasks/arc087_a
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


from collections import Counter
N = a_int()
A = ints()
# Counterして成り立たない数字を取り除いた数が答え

cnt = Counter(A)
ans = 0
for k, v in cnt.items():
    if k < v:
        ans += v - k
    if k > v:
        ans += v
print(ans)


Measured memory_bytes: 101104
#include <iostream>
using namespace std;
int main(void){
  string O,E;
  cin>>O;
  cin>>E;
  int N=O.length();
  int M=E.length();
  int countO=0,countE=0;
  for(int i=1;i<=N+M;i++){
      if(i%2!=0){
          cout<<O[countO];
          countO+=1;
      }
      else{
          cout<<E[countE];
          countE+=1;
      }
  }
  cout<<endl;
}


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

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

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

    int A,B,T; cin >> A >> B >> T;

    cout << (T/A)*B << endl;

    return 0;

}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	x, y := getInt(), getInt()

	if asub(x, y) <= 1 {
		out("Brown")
	} else {
		out("Alice")
	}
}


Measured memory_bytes: 640
open System

[<EntryPoint>]
let main argv =

    let scoreCount = stdin.ReadLine() |> int

    let scores:(int*string*int) array = Array.create scoreCount (0,"", 0)

    for i = 0 to scoreCount - 1 do
        let inputs = stdin.ReadLine().Split(' ')

        scores.[i] <- (i+1, inputs.[0], int(inputs.[1]))

    for (i,s,p) in scores |> Array.sortBy(fun (i,s,p) -> s, -p) do
        printfn "%d" i

    0 // return an integer exit code


Measured memory_bytes: 15020
#include <iostream>

int N;

bool solve(){
    int opened = 0;
    for(int i=0;i<N;i++){
        char c;
        int n;
        std::cin >> c >> n;

        if(c == '('){
            opened += n;
        }else{
            if(n > opened){return false;}
            opened -= n;
        }
    }

    return opened == 0;
}

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

    std::cout << (solve() ? "YES" : "NO") << std::endl;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
    double D, S, T;
    scanf("%lf %lf %lf", &D, &T, &S);
    //printf("%d %d %d", D, T, S);
    
    if(D/S<=T)
        printf("Yes");
    else
        printf("No");

    return 0;
}


Measured memory_bytes: 1748
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int L[10010];
    rep(i, N) cin >> L[i];
    sort(L, L + N, greater<int>());
    int sum = 0;
    rep(i, N - 1) sum += L[i + 1];
    if (L[0] < sum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

a=[s]
ans=0
for i in range(1,1000000):
  if a[i-1]%2==0:
    ax=(int(a[i-1]/2))
  else:
    ax=(int(a[i-1]*3+1))
  a.append(ax)
  if a.count(ax)>=2:
    ans=i+1
    break
print(ans)

Measured memory_bytes: 3064
#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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k, c;
    string s;
    cin, n, k, c, s;
    vector<int> L, R;
    int pos = 0;
    while (pos < n) {
        while (pos < n && s[pos] == 'x') pos++;
        if (L.size() < k && pos < n) {
            L.push_back(pos);
        }
        pos += c + 1;
    }
    pos = n - 1;
    while (pos >= 0) {
        while (pos >= 0 && s[pos] == 'x') pos--;
        if (R.size() < k && pos >= 0) {
            R.push_back(pos);
        }
        pos -= (c + 1);
    }
    reverse(R.begin(), R.end());
    int t = L.size();
    REP(i, 0, t) {
        if (L[i] == R[i]) {
            print(L[i] + 1);
        }
    }

    return 0;
}


Measured memory_bytes: 3468
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
ans = 10 ** 10
for i in A:
    a = 0
    while i % 2 == 0:
        a += 1
        i //= 2
    ans = min(ans, a)
print(ans)

Measured memory_bytes: 3060
N = int(input())
a = list(map(int, input().split()))

if a == sorted(a):
  print('YES')
  raise SystemExit

for i in range(N):
  for j in range(i + 1, N):
    b = a[:]
    b[i], b[j] = b[j], b[i]
    if b == sorted(a):
      print('YES')
      raise SystemExit

print('NO')


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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  ll d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    if (d >= sqrt(a * a + b * b)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
	int N, L; cin >> N >> L;
	vector<string> a(N);

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

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

	for(int i = 0; i < a.size(); i++) {
		cout << a[i];
	}

	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  using D = double;
  D a,b;
  cin>>a>>b;
  cout<<1/(1/a+1/b)<<endl;
  return 0;
}


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map
#define mtv(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out( 
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cout << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    stringstream ss; ss << H;
    cout << args[idx] << "- " << ss.str() << ", ";
    debug_out(args, idx + 1, LINE_NUM, T...);
}

void doit(){
	ll n, i;
	cin >> n;
	vector<string>v;
	string s;
	rep(i,0,n){
		cin >> s;
		sort(all(s));
		v.pb(s);
	}
	sort(all(v));
	ll ans = 0;
	s = v[0];
	ll cur = 1;
	rep(i,1,n){
		if(v[i] == s){
			cur++;
		}
		else {
			ans += ((cur * (cur-1))/2);
			cur = 1;
			s = v[i];
		}
	}
	ans += ((cur * (cur-1))/2);
	cout << ans << nl;
}

int main(){ 
#ifndef ONLINE_JUDGE
 //   freopen("input1.txt","r",stdin);
  //  freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



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

#define boost ios::sync_with_stdio(); cin.tie(); cout.tie();
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define vt vector 
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

template<class T> bool umin(T& a, const T& b) {
	return b<a?a=b, 1:0;
}
template<class T> bool umax(T& a, const T& b) { 
	return a<b?a=b, 1:0;
} 

const int INF = 1e9 + 10;
const int mod = 1e9 + 7;
const ll LLINF = 1e18 + 10;
const int mxn = 1000 + 10;
int tab[mxn];
void solve() 
{
	int n;
	cin >> n;
	for(int i =0;i < n;i++){
		cin >> tab[i];
	}
	ll ans =0;
	for(int x =0;x < n;x++){
		for(int y = x+1; y < n; y++){
			for(int z =y+1;z < n; z++){
				if(x != z && z != y && x != y){
					int pom[3];
					pom[0] = tab[x];
					pom[1] = tab[y];
					pom[2] = tab[z];
					sort(pom,pom+3);
					if((pom[0] + pom[1] > pom[2]) && (tab[x] != tab[y] && tab[y] != tab[z] && tab[x] != tab[z])){
						//cout << pom[0] << " " << pom[1] << " " << pom[2] << "\n";			
						ans++;
					}
				}
			}
		}
	}
	cout << ans;
}
int main()
{
    boost
    //int t; read(t); while(t--)
    solve();
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    constexpr int W = 5;
    for(;;){
        int H;
        cin >> H;
        if(H == 0)  return 0;
        vector<vector<int>> Stone(H, vector<int>(W));
        for(int i = H - 1; i >= 0; --i){
            for(int j = 0; j < W; ++j){
                cin >> Stone[i][j];
            }
        }
        int ans = 0;
        bool update = true;
        while(update){
            update = false;
            for(int i = 0; i < H; ++i){
                for(int j = 0; j < W;){
                    int len = 1;
                    for(int k = j + 1; k < W; ++k){
                        if(Stone[i][k] == Stone[i][j])  ++len;
                        else    break;
                    }
                    if(Stone[i][j] == 0){
                        j += len;
                        continue;
                    }
                    if(len >= 3){
                        update = true;
                        ans += Stone[i][j] * len;
                        for(int k = 0; k < len; ++k)    Stone[i][j + k] = 0;
                    }
                    j += len;
                }
            }
            if(update){
                vector<int> idx(W, 0);
                for(int i = 0; i < H; ++i){
                    for(int j = 0; j < W; ++j){
                        if(Stone[i][j]){
                            if(idx[j] == i) ++idx[j];
                            else{
                                Stone[idx[j]++][j] = Stone[i][j];
                                Stone[i][j] = 0;
                            }
                        }
                    }
                }
            }
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 3144
fun main(args: Array<String>) {
    val line= readLine()

    var reftOK = true
    var rightOK = true
    for(i in 1..line!!.length){
        val p = line.substring(i-1,i)
        if((i.mod(2)) == 0 && p == "R"){
            //println("R:false")
            reftOK = false
        }else if( i.mod(2) == 1 && p == "L"){
            //println("L:false")
            rightOK = false
        }else{
            //println("OK")
        }
    }

    if(rightOK && reftOK){
        println("Yes")
    }else{
        println("No")
    }
}

Measured memory_bytes: 33680