akhauriyash/Code-Regression huggingface dataset:
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

struct Q{
	int a,b,c,d;
	
	Q(int _a,int _b,int _c,int _d){
		a=_a,b=_b,c=_c,d=_d;
	}
};

vector<Q> queries;

int n,m,q;
int arr[15];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m>>q;
	rep (x,1,n+1) arr[x]=1;
	
	int a,b,c,d;
	while (q--){
		cin>>a>>b>>c>>d;
		queries.push_back(Q(a,b,c,d));
	}
	
	int ans=0;
	
	for (auto &it:queries){
		if (it.c==0) ans+=it.d;
	}
	
	while (true){
		for (int x=n;;x--){
			if (x==0) goto _end;
			if (arr[x]!=m){
				arr[x]++;
				rep(y,x+1,n+1) arr[y]=arr[x];
				break;
			}
		}
		
		int curr=0;
		for (auto &it:queries){
			if (arr[it.b]-arr[it.a]==it.c) curr+=it.d;
		}
		
		ans=max(ans,curr);
	}
	
	_end:;
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3664
//ProblemA

//#define USE_STDIO
//#define USE_LOG
//#define FILE_ERR

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#ifndef debug
#define debug(...)
#endif // !LOG

//include
#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>

using namespace std;

//for
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define forbe(i, begin, end) for(decltype(begin) i = (begin); i != (end); ++i)
#define forbes(i, begin, end, step) for(decltype(begin) i = (begin); i != (end); i += (step))

//int
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;

//pair
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
#define fi first
#define se second

//vector
template <typename Value>
static inline void fillv(Value& x, const Value& val) { x = val; }
template <typename Vector, typename Value>
static inline void fillv(Vector& v, const Value& val) { for (auto& x : v) fillv(x, val); }

static inline void Solve();

int main(int argc, char* argv[]) {
#ifdef REDIRECT_STDIO
	REDIRECT_STDIO;
#endif // REDIRECT_STDIO

	Solve();
	return 0;
}

//ProblemA
void Solve() {
	int a, b;
	cin >> a >> b;

	if (a + b == 15)
		cout << '+' << endl;
	else if (a * b == 15)
		cout << '*' << endl;
	else
		cout << 'x' << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if (op=='?') break;
        
        if (op == '+') cout<<a+b<<endl;
        else if (op == '-') cout<<a-b<<endl;
        else if (op == '*') cout<<a*b<<endl;
        else if (op == '/') cout<<a/b<<endl;
    }
    return 0;
}


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

#define W(A) (((A)+2)%3)
int h(char c){
	if(c=='r') return 0;
	if(c=='s') return 1;
	return 2;
}
int main(void){
	int n, i;
	int k, j;
	int p[3];
	scanf("%d%d%d%d%d", &n, &k, p, p+1, p+2);
	char *t = malloc(n+1);
	scanf("%s", t);
	long point = 0;
	for(j=0; j<k; j++){
		int d = h(t[j]);
		point+=p[W(d)];
		for(i=j+k; i<n; i+=k){
			if(d<0 || t[i]!=t[i-k]){
				d = h(t[i]);
				point+=p[W(d)];
			}else{
				d=-1;
			}
		}
	}
	printf("%ld\n", point);
}



Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int a,b,c;
	cin >> a >> b >> c;
	int max_num = max({a,b,c});
	int res = max_num * 10 + a + b + c - max_num;


	cout << res << endl;



}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()
T = input().rstrip()

ans = 0
for i in range(3):
    if S[i] == T[i]:
        ans += 1

print(ans)

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

int main() {
	int N; cin >> N;
	int color[9];
	for(int i=0; i<9; ++i) color[i]=0;
	int a;
	for(int i=0; i<N; ++i){
	    cin >> a;
	    int b=a/400;
	    if(b>7) ++color[8];
	    else if(!color[b]) ++color[b];
	}
	int m=0;
	for(int i=0; i<8; ++i) m += color[i];
	if(m) cout << m << ' ' << m+color[8] << endl;
	else cout << 1 << ' ' << color[8] << endl;
	return 0;
}


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


int main(){
int n,k;
int l[51];
int i,j,temp;
int x=0;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++){
	scanf("%d",&l[i]);
}
for(i=0;i<n;i++){
	for(j=n-1;j>i;j--){
		if(l[j]<l[j-1]){
			temp=l[j-1];
			l[j-1]=l[j];
			l[j]=temp;
			
		}
		
		
		
		
		
		
		
		
	}
	
	
	
	
}
for(i=n-1;i>n-(k+1);i--){
	
	x+=l[i];
	
	
}
printf("%d\n",x);



	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

import heapq

def main():  
    N,M=map(int, input().split())
    B=[[] for _ in range(M+1)]
    heapq.heapify(B)
    for i in range(N):
        a,b=map(int, input().split())
        if a > M: continue
        B[a].append(-b)
    max=[]
    heapq.heapify(max)
    ans=0
    for i in range(1, M+1):
        for j in B[i]:
            heapq.heappush(max, j)
        if len(max) != 0:
            ans+=heapq.heappop(max)
    print(-ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 64092
from sys import stdin, setrecursionlimit
from bisect import bisect_right


def main():
    input = stdin.buffer.readline
    n, l = map(int, input().split())
    arr = []
    for i in range(n):
        arr.append(l + i)
    arr.sort()
    print(sum(arr) - arr[min(bisect_right(arr, -1), n - 1)])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

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

    int N, M; cin >> N >> M;

    cout << N*(N-1)/2 + M*(M-1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int k,a,b;
  int sum=0;
  scanf("%d",&k);
  scanf("%d %d",&a,&b);
  for(int i=a;i<=b;i++){
    if(i%k==0){
      sum+=1;
    }
  }
  if(sum>=1){
    printf("OK\n");
  }else{
    printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll INF = 1e9 + 10;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int M = 1e3 + 10;
const int N = 1e6 + 10;

int a[N];

void solve() {
    int n;
    scanf("%d", &n);
    multiset<int> m;
    fr(i, n) {
        scanf("%d", &a[i]);
        m.insert(a[i]);
    }

    int ans = 0;
    //cout << m.size() << endl;
    while (m.size()) {
        auto it = m.end();
        it--;
        int cnt = 0;
        int cur = *it;
        int cur2 = cur;
        m.erase(it);
        while (cur) {
            cnt++;
            cur >>= 1;
        }
        int sum = (1 << cnt);
        int second = sum - (cur2);

        auto it2 = m.find(second);
        if (it2 != m.end()) {
            ans++;
            m.erase(it2);
        }
    }
    cout << ans;

}

int main() {
    //freopen("a.in", "r", stdin);
    //ios_base::sync_with_stdio(false);
    solve();

    return 0;

}


Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<climits>

using namespace std;

void quick_sort(long s[], int left, int right){
	long p, l, r, t;
    l = left, r = right;
    p = s[(l+r)/2];
    while(1){
    	while(s[l] < p)
    		l++;
    	while(s[r] > p)
        	r--;
        if(l >= r) break;
        t = s[r];
        s[r] = s[l];
        s[l] = t;
        l++;r--;
    }
    if(left < l-1)
    	quick_sort(s, left, l-1);
    if(right > r+1)
    	quick_sort(s, r+1, right);
}

int comb(long n, long r){
	if(n == 0) return 1;
    else if(r == 0) return 1;
    else if(r == n) return 1;
    else return comb(n-1, r) + comb(n-1, r-1);
}

int main(){
	long long n, t, l;
    long long count = 0;
    cin >> n;
    int a[n];
    long long s[n+2];
    
    for(int i = 0; i < n; i++){
    	cin >> t;
    	a[i] = t;
    }
    
    s[0] = 0;
    for(int i = 1; i < n+1; i++){
    	s[i] = a[i-1] + s[i-1];
    }
    
    sort(s, s+n+1);
    //quick_sort(s, 0, n);

    l = 0;s[n+1] = 1000000000000000LL;
    for(int i = 0; i <= n+1; i++){
    	if(s[i]!=s[l]){
        	count += (i-l)*(i-l-1)/2;
            l = i;
        }
    }
    
    cout << count << endl;
}






Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

struct restaurant{
	int id;
	string name;
	int review;
};

struct restaurant buf[100];

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

	for(int i = 0; i < n; ++i){
		buf[i].id = i+1;
		cin >> buf[i].name >> buf[i].review;
	}

	stable_sort(buf, buf+n, [](const restaurant& x, const restaurant& y){	return x.review > y.review;	});
	stable_sort(buf, buf+n, [](const restaurant& x, const restaurant& y){	return x.name < y.name;		});

	for(int i = 0; i < n; ++i){
		cout << buf[i].id << endl;
	}

	return 0;
}

Measured memory_bytes: 256
l = input()
S1, S2 = [], []

sum = 0
n = len(l)
for i in range(n):
    if l[i] == "\\":
        S1.append(i)
    elif l[i] == "/" and S1:
        j = S1.pop()
        a = i - j
        sum += a

        while S2 and S2[-1][0] > j:
            a += S2.pop()[1]
        S2.append([j, a])

print(sum)
print(len(S2), *(a for j, a in S2))


Measured memory_bytes: 6512
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;

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

double getWidth(vector<int> &v1, vector<int> &v2) {
    vector<int> v;
    int n = v1.size();
    for (int i=0; i<n; ++i) {
        v.push_back(v1[i]);
        if (i < (int)v2.size()) {
            v.push_back(v2[i]);
        }
    }
    int m = v.size();
    double sum = v[0] + v[m-1];
    for (int i=1; i<m; ++i) {
        sum += sqrt(sq(v[i] + v[i-1]) - sq(abs(v[i] - v[i-1])));
    }
    return sum;
}

bool solve(vector<int> v1, vector<int> v2, double len) {
    do {
        sort(v2.begin(), v2.end());
        do {
            if (v1.size() < v2.size()) {
                swap(v1, v2);
            }
            if (getWidth(v1, v2) < len + 1e-6) {
                return true;
            }
        } while (next_permutation(v2.begin(), v2.end()));
    } while (next_permutation(v1.begin(), v1.end()));
    return false;
}

int main() {
    string input;
    int len, r;
    while (getline(cin, input)) {
        stringstream ss(input);
        ss >> len;
        vector<int> cake;
        while (ss >> r) {
            cake.push_back(r);
        }
        sort(cake.begin(), cake.end());
        int siz = cake.size();
        int n = siz / 2 + (siz % 2);
        int m = siz / 2;
        bool ok = solve(vector<int>(cake.begin(), cake.begin() + n),
                        vector<int>(cake.end() - m, cake.end()),
                        len);
        if ( ! ok) {
            ok |= solve(vector<int>(cake.end() - n, cake.end()),
                        vector<int>(cake.begin(), cake.begin() + m),
                        len);
        }
        cout << (ok ? "OK" : "NA") << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std; 
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n, x, y;
    cin >> n;
    vector<int> arr, arr2;
    for (int i=0; i<n; i++){
        cin >> x >> y;
        arr.emplace_back(x+y);
        arr2.emplace_back(x-y);
    }
    sort(arr.begin(), arr.end());
    sort(arr2.begin(), arr2.end());
    cout << max(arr.back()-arr[0], arr2.back()-arr2[0]) << "\n";
}

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

typedef long long ll;

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

    int N;

    cin >> N;

    vector<ll> A(N);

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

    vector<ll> dp1(N);
    vector<ll> dp2(N);

    dp1[1] = A[0] + A[1];
    dp2[1] = - A[0] - A[1];

    for(int i = 2; i < N; i++) {
        ll a = dp1[i - 1] + A[i];
        ll b = dp2[i - 1] + A[i];
        if(a > b) {
            dp1[i] = a;
        } else {
            dp1[i] = b;
        }

        ll c = dp1[i - 1] - 2LL * A[i - 1] - A[i];
        ll d = dp2[i - 1] + 2LL * A[i - 1] - A[i];
        if(c > d) {
            dp2[i] = c;
        } else {
            dp2[i] = d;
        }
    }

    if(dp1[N - 1] > dp2[N - 1]) {
        cout << dp1[N - 1] << endl;
    } else {
        cout << dp2[N - 1] << endl;
    }
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.Math;

public class Main {
    public static void main(String[] args) throws IOException {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        double r = Double.parseDouble(br.readLine());
        
        double area = Math.PI * (r * r);
        double circumference = 2 * (Math.PI * r);
        
        System.out.printf("%6f %6f", area, circumference);
    }
}


Measured memory_bytes: 24720
#include <cstdio>
using namespace std;

int main(){
	int sum, A[9];
	
	while(true){
		scanf("%d", &sum);
		
		if(sum == 0) break;
		
		for(int i = 0; i < 9; i++){
			scanf("%d", &A[i]);
		}
		
		for(int i = 0; i < 9; i++){
			sum -= A[i];
		}
		
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 1028
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


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

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


void solve(long long n, std::vector<long long> a, std::vector<long long> b){
    int ans = MOD;
    for(int i = 0; i < (1 << n); ++i){
        bitset<18> bs(i);
        if(bs.count() % 2 != 0)
            continue;
        vector<int> v(n);
        for(int j = 0; j < n; ++j)
            v[j] = (bs[j] ? b[j] : a[j]);

        vector<vector<int>> w(2);
        for(int j = 0; j < n; ++j){
            bool fl = (j % 2) ^ bs[j];
            w[fl].emplace_back(v[j]);
        }

        sort(w[0].begin(), w[0].end());
        sort(w[1].begin(), w[1].end());

        bool fl = true;


        if(w[0].size() != (n + 1) / 2 || w[1].size() != n / 2)
            continue;

        vector<int> v_b(v);
        sort(v_b.begin(), v_b.end());
        for(int j = 0; j < n; ++j)
            fl &= (v_b[j] == w[j % 2][j / 2]);

        bs = bitset<18>(i);

        /*
        for(int j = 0; j < n; ++j)
            cout << v[j] << " \n"[j == n - 1];
        for(int j = 0; j < n; ++j)
            cout << v_b[j] << " \n"[j == n - 1];
        for(int j = 0; j < n; ++j)
            cout << w[j % 2][j / 2] << " \n"[j == n - 1];
        cout << endl;
        */


        if(!fl)
            continue;

        int cnt = 0;
        for(int j = 0; j < n; ++j){
            int idx = j - 1;
            do{
                idx = distance(v.begin(), min_element(next(v.begin(), idx + 1), v.end()));
            }while(idx % 2 != ((j % 2) ^ bs[idx]));
            while(idx != j){
                ++cnt;
                swap(v[idx], v[idx - 1]);
                if(bs[idx] == bs[idx - 1]){
                    bs.flip(idx);
                    bs.flip(idx - 1);
                }
                --idx;
            }
        }

        for(int j = 0; j < n - 1; ++j)
            if(bs[j] & bs[j + 1]){
                bs.flip(j);
                bs.flip(j + 1);
                swap(v[j], v[j + 1]);
                ++cnt;
            }

        if(v != v_b){
            continue;
        }
        chmin(ans, cnt + int(bs.count() / 2));
    }
    cout << (ans == MOD ? -1 : ans) << endl;
}


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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,mini=200010,cnt=0; cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]<=mini){
            mini=a[i];
            cnt++;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    char c;
    cin>>c;
    cout<<(char)(c+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

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

type light struct {
	ss int
	p  int
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	lights := make([]light, m)
	for i := range lights {
		k := nextInt()
		for j := 0; j < k; j++ {
			s := nextInt()
			lights[i].ss += 1 << uint(s-1)
		}
	}
	for i := range lights {
		lights[i].p = nextInt()
	}

	ans := 0
	for x := 0; x < int(math.Pow(2.0, float64(n))); x++ {
		flg := true
		for _, l := range lights {
			elec := l.ss & x
			cnt := 0
			for i := 0; i < n; i++ {
				cnt += (elec >> uint(i)) & 1
			}
			if cnt%2 != l.p {
				flg = false
			}
		}
		if flg {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>

using namespace std;

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

string a, b, c;

int main(){
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
def check(r):
    if r == r[::-1]:
        return True


def main():
    s = input()
    n = len(s)
    print("Yes" if check(s) and check(s[:(n-1)//2])
          and check(s[((n-1)//2) + 1:]) else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9064
#pragma region Include
#include <bits/stdc++.h>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(digit) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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;
}

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vi A(N);
  vi ans(N);
  cin >> A;
  rep(i, N - 1) { ans[A[i] - 1]++; }
  rep(i, N) { cout << ans[i] << endl; }
  return 0;
}

Measured memory_bytes: 4776
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include <math.h>
#include<vector>
#include<stack>
#include<math.h>
#include<malloc.h>
#define INF 0x3f3f3f3f
#define maxn 2000006
#define ll long long
using namespace std;
struct Node
{
   int   x,y,h;
}s[105];
int n;
bool  judge(int x,int y,int z)
{   int t=0,h,i;
     h=s[z].h+abs(x-s[z].x)+abs(y-s[z].y);
    for( i=0;i<n;i++)
    {
        if(max((h-abs(x-s[i].x)-abs(y-s[i].y)),0)!=s[i].h)
        {    t=1;
            break;
        }

    }
    if(t==0)
    {
       cout<<x<<' '<<y<<' '<<h<<endl;
        return true;
    }
    else
        return false;
}
int main()
{   int  i,j,k,p=0;

     cin>>n;
     for(i=0;i<n;i++)
     {
         cin>>s[i].x>>s[i].y>>s[i].h;
         if(!p&&s[i].h)
            p=i;


     }


         for(j=0;j<=100;j++)

         {
             for(k=0;k<=100;k++)
             {

                 {
                      if(judge(j,k,p))
                        return 0;

                 }
             }
         }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<LL> a(N+1);
    vector<pll> L(N);
    vector<LL> ans(N,INF);
    rep(i,N+1){
        if(i == 0)a[0] = INF;
        else cin >> a[i];
    }
    rep(i,N){           // 上からi番目までを引いたときのx
        if(i == 0){
            L[0].F = 0;
        }
        else L[i].F = L[i-1].F + a[i];
    }
    for(int i = N-1;i>=1;i--){  // 上からi番目までを引いた時のy
        if(i == N-1){
            L[N-1].S = a[N];
        }
        else L[i].S = L[i+1].S + a[i+1];
    }
    rep(i,N){
        if(i == 0)continue;
        ans[i] = abs(L[i].F - L[i].S);
    }
    sort(all(ans));

    cout << ans[0] << endl;
}


Measured memory_bytes: 6528
#include<stdio.h>
#include<math.h>
#define Number 100000
int main()
{
	int n;
	int a[Number];
	int i,j;
	int flag=0;
	int c=0;
	int c1=0;

	scanf("%d",&n);

		for(i=0;i<n;i++)
		{
		   scanf("%d",&a[i]);
		   for(j=2;j<=sqrt(a[i]);j++)
		    {
		    	if(a[i]%j==0)
		    	{
		    		flag=1;
		    		break;
		    	}
		    }
		 if(flag==0)
		 	c++;
		 flag=0;
		}
	printf("%d\n",c);
}


    


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

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
#define birep(i,n) for (int i = 0; i < (1<<(n));i++)
#define isOne(bit,i) (bit & (1 << i))
using ll = long long;
using pint = pair<int, int>;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
int N,cnt;

bool judge(int bit, vector<vector<pint>> shougens){
  rep(i,N){
    if(!isOne(bit,i)){
      continue;
    }
    for(auto xy : shougens.at(i)){
      int x = xy.first;
      int y = xy.second;
      if(y==1 && !isOne(bit,x)) return false;
      if(y==0 && isOne(bit,x)) return false;
    }
  }
  return true;
}

int main(){
  cin >> N;
  vector<vector<pint>> shougens(N);
  rep(i,N){
    int A; cin >> A;
    shougens.at(i).resize(A);
    rep(j,A){
      cin >> shougens.at(i).at(j).first >> shougens.at(i).at(j).second;
      shougens.at(i).at(j).first--;
    }
  }
  cnt = 0;
  birep(i,N){
    if(judge(i,shougens)){
      bitset<15> b(i);
      int res = b.count();
      cnt = max(res,cnt);
    }
  }
  print(cnt);
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m;
int s1,s2,t1,t2;
char a[1005][1005];
bool b[1005][1005];
int dp[1005][1005];
int h[5]={-1,0,1,0},l[5]={0,-1,0,1};
struct edge{
	int x;
	int y;
	edge(){}
	edge(int X,int Y){x=X,y=Y;}
};
bool bfs(int x,int y,int z)
{
	deque <edge> q;//双端队列，不会的去学STL
	q.push_front(edge(x,y));
	while(!q.empty())//在BFS基础模板上修改
	{
		edge u=q.front();
		q.pop_front();
		if(u.x==t1 && u.y==t2)
		{
			printf("%d",dp[u.x][u.y]);
			return true;
		}
		if(b[u.x][u.y])
		{
			continue;
		}
		b[u.x][u.y]=1;
		for(int i=0;i<4;i++)
		{
			if(u.x+h[i]>=1 && u.x+h[i]<=n && u.y+l[i]>=1 && u.y+l[i]<=m && a[u.x+h[i]][u.y+l[i]]!='#')
			{
				dp[u.x+h[i]][u.y+l[i]]=min(dp[u.x+h[i]][u.y+l[i]],dp[u.x][u.y]);
				q.push_front(edge(u.x+h[i],u.y+l[i]));//直到这里都是BFS板子
			}
		}
		for(int i=u.x-2;i<=u.x+2;i++)//特判以起点为中心的5x5区域
		{
			for(int j=u.y-2;j<=u.y+2;j++)
			{
				if(i<=0 || j<=0 || i>n || j>m || a[i][j]=='#' || b[i][j]==1)//判边界，和是否已经访问过
				{
					continue;
				}
				dp[i][j]=min(dp[i][j],dp[u.x][u.y]+1);//更新
				q.push_back(edge(i,j)); //将更新后的值压入栈
			}
		}
	}
	return false;//输出-1
}
int main() 
{
	scanf("%d %d",&n,&m);
	scanf("%d %d\n%d %d",&s1,&s2,&t1,&t2);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			dp[i][j]=0x3f3f3f3f;
		}
	}
	dp[s1][s2]=0;//将起点初始化为0
	if(bfs(s1,s2,0)==false)
	{
		printf("-1");
	}
	return 0;
}

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

int main() {
  ll n, m;
  cin >> n >> m;
  dsu uf(n);
  rep(i,m) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    uf.merge(a,b);
  }
  cout << uf.groups().size() - 1 << endl;
}

Measured memory_bytes: 9012
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

struct Person {
  bool honest;
  vector<pair<ll, bool>> comments;  // hito, honest
};

constexpr ll combi = 1 << 15;
int main() {
  ll N;
  cin >> N;

  vector<Person> people(N);
  for (ll i = 0; i < N; i++) {
    ll A;
    cin >> A;
    for (ll j = 0; j < A; j++) {
      ll x, y;
      cin >> x >> y;
      x--;  // 0-index;
      people[i].comments.emplace_back(x, (y == 1));
    }
  }
  // 順番にすべての組み合わせを試す。
  ll count_max = 0;

  auto resetFunc = [&](vector<Person>& p) {
    for (auto&& x : p) {
      x.honest = false;
    }
  };
  auto flagOnFunc = [&](vector<Person>& p, ll combiNum) {
    ll count = 0;
    ll on = 0;
    while (combiNum > 0) {
      if (combiNum % 2 == 1) {
        p[count].honest = true;
        on++;
      }
      count++;
      combiNum >>= 1;
    }
    return on;
  };
  auto checkFunc = [&](vector<Person>& p) {
    for (const auto& x : p) {
      if (x.honest) {
        for (const auto& y : x.comments) {
          ll other = y.first;
          bool honestly = y.second;
          if (p[other].honest != honestly) {
            return false;
          }
        }
      }
    }
    return true;
  };

  for (ll i = 0; i < (1 << N); i++) {
    resetFunc(people);
    ll count = flagOnFunc(people, i);
    if (checkFunc(people)) {
      count_max = max(count_max, count);
    }
  }

  cout << count_max << endl;
  return 0;
}


Measured memory_bytes: 256
import re

inp = input()
inl = re.split(" ",inp)
inl = list(map(int,inl))

if (abs(inl[0]-inl[1]) <= inl[3] and abs(inl[1]-inl[2]) <= inl[3]) or (abs(inl[0]-inl[2]) <= inl[3]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


const double PI = 3.14159265359;

double a, b, x;
int main() {
	cin >> a >> b >> x;

	double h = 2*x / (a*a);

	double ans;
	if (h <= b) {
		double ta = 2 * (x/a) / b;
		ans = atan(ta / b);
	}
	else {
		double tb = 2 * b - h;
		ans = atan(a / tb);
	}

	printf("%.10lf\n", 90 - ans*180/PI);

	return 0;
}



Measured memory_bytes: 256
/*
 * Created by solzard on 1/31/20.
 *
 * https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_1_B
 */
#include <iostream>
using namespace std;

int gcd(int x, int y) {
  if (y) return gcd(y, x % y);
  return x;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << endl;
}


Measured memory_bytes: 3120
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int s_len = S.size(), t_len = T.size();
  priority_queue<int> pq;
  int match;
  
  rep(i, s_len-t_len+1){
    match = 0;
    rep(j, t_len){
      if(S.at(i+j) == T.at(j)) match++;
      pq.push(match);
    }
  }
    
    cout << t_len - pq.top() << endl;
}

Measured memory_bytes: 4236
#include <iostream>
#define ll long long
using namespace std;

int main(){
  int n; ll t;
  cin >> n >> t;
  ll a[n]; ll sum=t;
  
  cin >> a[0];
  for(int i=1; i<n; i++){
    cin >> a[i];
    if(a[i]-a[i-1]<t){sum = sum + a[i]-a[i-1];}
    else{sum = sum + t;}
  }
  
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define _printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printV(vec) cout<<#vec<<":";_printV(vec)
#define _printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
#define printA(arr) cout<<#arr<<":";_printA(arr,sizeof(arr)/sizeof(arr[0]))
#define LLINF = (1LL<<62)
#define puts(var) cout<<#var<<":"<<var<<" "
typedef long long ll;

struct mypair_t {
  int index;
  int p;
  int y;
  int id;
};

// int1のみ用いてソート
bool cmp(const mypair_t &left, const mypair_t &right){
  return left.y < right.y;
}
bool cmpidx(const mypair_t &left, const mypair_t &right){
  return left.index < right.index;
}
int main()
{
  int N,M;
  cin >> N >> M;
  vector<mypair_t> A(M);
  int cnt[N];
  REP(i,N){
    cnt[i] = 1;
    // cout << "cnti " << cnt[i] << endl;
  }
  REP(m,M){
    cin >> A[m].p >> A[m].y;
    A[m].index = m;
  }

  sort(A.begin(),A.end(),cmp);

  REP(i,M){
    A[i].id = cnt[A[i].p-1];
    cnt[A[i].p-1] += 1;
    // cout << "  " << "p" << A[i].p << " id"<< A[i].id << endl;
  }

  sort(A.begin(),A.end(),cmpidx);


  REP(i,M){
    // string にformatするのはないのか?
    cout << setfill('0') << setw(6) << right << A[i].p;
    cout << setfill('0') << setw(6) << right << A[i].id << endl;
  }

  return 0;
}



Measured memory_bytes: 3456
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class v:
    def __init__(self, f):
        self.f = f
        self.v = None
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def f(S):
    for s, t in zip(S, S[::-1]):
        if s != t:
            return False
    return True

def main():
    S = input().strip()
    FS = S[:len(S)// 2]
    BS = S[len(S) // 2 + 1:]
    
    if f(S) and f(FS) and f(BS):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    vector<int> vec(4);
    for (int i = 0; i < 4; i++){
        char c;
        cin >> c;
        vec[i] = (int)(c-'0');
    }
    for (int i = 0; i < 8; i++) {
        int ans = vec[0];
        for (int j = 0; j < 3; j++) {
            if(i>>j&1) ans += vec[j+1];
            else ans -= vec[j+1];
        }
        if(ans == 7){
            cout << vec[0];
            for (int j = 0; j < 3; j++) {
                if(i>>j&1) cout << '+';
                else cout << '-';
                cout << vec[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


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

int main() {
  int a;
  string b,c;
  cin >> a >> b;
  
  if(a >= b.size()) {
    cout << b << endl;
  } else {
    for(int i = 0; i < a; i++) {
    	c = c + b.at(i);
    }
    cout << c + "..." << endl;
  }
}

Measured memory_bytes: 3632
s = input()
mmyy = (1 <= int(s[:2]) <= 12)
yymm = (1 <= int(s[2:]) <= 12)
if mmyy and yymm:
    print('AMBIGUOUS')
elif mmyy:
    print('MMYY')
elif yymm:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 8956
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    /*string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;*/

    /*int x;
    int happy = 0,temp;
    //bool b = true;
    cin >> x;
    happy += (x/500)*1000;
    x = x%500;
    happy += (x/5)*5;
    cout << happy << endl;
    return 0;*/

    /*int k,n;
    int flag = 0;
    int a[n]={};
    cin >> k >> n;
    rep(i,n) cin >> a[i];
    rep(i,n){
        if()
    }*/

    /*int A,B;
    cin >> A >> B;
    for(int i=1; i<=B; i++){
        if((A*i)%B==0){
            cout << A*i << endl;
            break;
        }
    }
    return 0;*/

    /*int X,Y,Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;*/

    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    float temp=0;
    rep(i, N){
        cin >> A[i];
        temp += A[i];
    }
    temp = temp/(4.0*M);
    sort(A.rbegin(),A.rend());
    int sum=0;
    rep(i,N){
        if(A[i]>=temp) sum++;
    }
    if(sum>=M) cout << "Yes";
    else cout << "No";
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

struct DI {
  int com;
  int stn;
  int dist;
  DI(int c, int s, int d) : com(c), stn(s), dist(d) {}
};

int N, M;
vector<unordered_map<int, vector<int>>> peer;
deque<DI> deq;
unordered_set<int> visited;

int enc(int com, int stn) {
  return com * (N+1) + stn;
}

int bfs() {
  while (!deq.empty()) {
    DI di(deq.front()); deq.pop_front();
    if (di.stn == N) return di.dist;
    int e = enc(di.com, di.stn);
    if (visited.count(e)) continue;
    visited.insert(e);
    for (int q : peer.at(di.stn)[di.com]) {
      deq.emplace_front(di.com, q, di.dist);
    }
    int e2 = enc(0, di.stn);
    if (visited.count(e2)) continue;
    visited.insert(e2);
    for (auto t : peer.at(di.stn)) {
      int com1 = t.first;
      if (di.com == com1) continue;
      deq.emplace_back(com1, di.stn, di.dist + 1);
    }
  }
  return -1;
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  cin >> N >> M;
  peer.resize(N+1);
  for (int i = 0; i < M; i++) {
    int p, q, c; cin >> p >> q >> c;
    peer.at(p)[c].push_back(q);
    peer.at(q)[c].push_back(p);
  }

  for (auto t : peer.at(1)) {
    deq.emplace_back(t.first, 1, 1);
  }
  cout << bfs() << endl;

  return 0;
}



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

int main(){
  int a,b,c,d,e,f;
  int A,B,C,mins,ans,ans2;
  while(1){
    cin>>a>>b>>c>>d>>e>>f;
    if(!a&&!b&&!c&&!d&&!e&&!f)break;
    A=a+d;
    B=b+e;
    C=c+f;
    mins=min(A,min(B,C));
    ans2=0;
    for(int i=0;i<2;i++){
      ans=0;
      ans+=(A-mins)/3;
      ans+=(B-mins)/3;
      ans+=(C-mins)/3;
      A=A-((A-mins)/3)*3;
      B=B-((B-mins)/3)*3;
      C=C-((C-mins)/3)*3;
      ans=max(ans+A/3+B/3+C/3,ans+mins);
      ans2=max(ans2,ans);
      if(mins>=1)mins--;
      else break;
      A=a+d;
      B=b+e;
      C=c+f;
    }
    cout<<ans2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
 
int main(void)
{
    int n, t[100001], x[100001], y[100001];
    int i, dt, dist;
    bool flag = false;
    scanf("%d", &n);
    t[0] = x[0] = y[0] = 0;
    for (i=1; i<n+1; i++)
    {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
 
    for (i=0; i<n; i++)
    {
        dt =  t[i+1] - t[i];
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) {
            flag = true;
            break;
        }
        if (dt%2 != dist%2) {
            flag = true;
            break;
        }
    }
 
    if (flag == true) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int a1,a2,a3,a4,sum,m,s;
    scanf("%d %d %d %d",&a1,&a2,&a3,&a4);
    sum = a1+a2+a3+a4;
    printf("%d\n",sum/60);
    printf("%d\n",sum%60);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;
const int M = 1000000007;


typedef long long int ll;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算、a,b<=300000でないと使えない
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

typedef long long int ll;


int main(){

  int n;
  cin >> n;

  cout << (n+1)/2 << endl;

}


Measured memory_bytes: 4992
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    ll ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int ii = 1; ii <= k; ii++) {
                ans += (ll)gcd(i, gcd(j, ii));
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int tree[100010];
int root(int x){return tree[x] == x ? x : tree[x] = root(tree[x]);}
void unite(int a , int b){tree[root(a)] = root(b);}

int main(){
	int n , m;	cin >> n >> m;
	for(int i = 0; i < n; i++)	tree[i] = i;
	int k;
	vector <vector <int> > l(m);
	for(int i = 0; i < n; i++){
		cin >> k;
		int va;
		for(int j = 0; j < k; j++){
			cin >> va;
			va--;
			l[va].push_back(i);
		}
	}
	for(int i = 0; i < m; i++){
		while(l[i].size() >= 2){
			unite(l[i][0] , l[i][l[i].size() - 1]);
			l[i].pop_back();
		}
	}
	for(int i = 0; i < n - 1; i++)
		if(root(i) != root(i + 1)){
			cout << "NO" << endl;
			return 0;
		}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 4608
def resolve():
    import sys
    n,x=map(int, input().split())
    l=list(map(int, input().split()))
    l.sort()
    cnt=0
    for i in range(n):
        if l[i]<=x:
            x-=l[i]
            cnt+=1
        else:
            print(i)
            sys.exit()
    if cnt==n and x>0:
        cnt-=1
    print(cnt)
resolve()

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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int flag = 1;
	for(int i = 0; i < n; i = i + 2){
		if(s[i] != 'h' || s[i + 1] != 'i'){
			flag = 0;
			break;
		}
	}
	if(n & 1) flag = 0;
	cout << (flag ? "Yes" : "No") << endl;
 	return 0;
}


Measured memory_bytes: 256