akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int n, a[100005], ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a, a+n);

    int cur = a[0], cnt = 1;
    for(int i=1; i<=n; i++) {
        if(a[i]!=cur) {
            if(cnt&1) ans++;
            cur = a[i];
            cnt = 1;
        } else cnt++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
(let ((n (read))
      (a (read))
      (b (read))
      (str (read-line))
      (kokunai 0)
      (kaigai 0))
  (loop :as c :across str
        :do
          (case c
            (#\a (if (< (+ kokunai kaigai) (+ a b))
                     (progn
                        (format t "Yes~%")
                        (incf kokunai))
                     (format t "No~%")))
            (#\b (if (and (< (+ kokunai kaigai) (+ a b))
                          (< kaigai b))
                     (progn
                        (format t "Yes~%")
                        (incf kaigai))
                     (format t "No~%")))
            (#\c (format t "No~%")))))

Measured memory_bytes: 16100
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;

int main(){
	int A,B;
	cin>>A>>B;
	if(A+B>=24){
		p(A+B-24);
	}else p(A+B);


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    int n,m;
    cin >> n >> m;
    int ans = 0;
    UnionFind z(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        z.merge(a-1, b-1);
    }
    vector<int> aa(n+1);
    for (int i = 0; i < n; i++) {
        aa.at(z.size(i))++;
    }
    for (int i = 1; i < n+1; i++) {
        ans += aa.at(i) / i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5020
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cins(s);
	string t(s.size(), 'x');
	cout << t << endl;
}

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



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <random>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>
#include <unordered_set>
#include <unordered_map>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

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

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const long double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll M = 1000000007;
const ll LLINF = 1000000000000000000;
const double EPS = 1e-8;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin >> s;
    int n = s.size();
    FOR(i, 1, n) {
        if (s[i] == s[i - 1]) {
            cout << i << ' ' << i + 1 << "\n";
            return 0;
        }
    }
    FOR(i, 2, n) {
        if (s[i] == s[i - 2]) {
            cout << i - 1 << ' ' << i + 1 << "\n";
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << "\n";

    return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main(int argc, char *argv[]) {
  /*
  cin>>x;
  cout<<x<<endl;
  */
  int i,j,n,m,l,c=0;
  cin>>n;
  cin>>m;
  c++;
  for(i=1;i<n;i++){
    cin>>l;
    if(m>l)
      continue;
    else{
      c++;
      m=l;
    }
  }
  cout<<c<<endl;
}


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

int main(){
    int N;
    cin >> N;
    
    for (int i = 1; i <= 50000; i++) {
        if (i*108/100 == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int a1, b1, a2, b2, a3, b3;
	cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3;
	vector<int> v = { a1, b1, a2, b2, a3, b3 };
	map<int, int> mp = { {1,0},{2,0},{3,0},{4,0} };
	for (const auto& item : v) mp[item]++;
	for (const auto& item : mp) {
		if (item.second == 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 3560
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n = 0, a, z;
	char s[200000], c;
	while((c=getchar())!='\n'){
		s[n++] = c;
		if(c=='Z') z = n;
	}
	REP(i, 0, n){
		if(s[i]=='A'){
			printf("%d\n", z-i);
			break;
		}
	}
	return 0;
}



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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());

  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    if(k>0){
      k--;
      continue;
    }
    ans += (long long)h[i];
  }
  cout << ans << endl;
  

  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a,ll b){
  if(a>b){
    return a;
  }
  else{
return b;
  }
}

int main(){
  int N;
  cin>>N;
  
  vector<int>x(N);
  vector<int>y(N);
  vector<ll>h(N);
  ll memX=0;
  ll memY=0;
  ll memH=0;
  
  for(int i=0;i<N;i++){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]!=0){
      memX=x[i];
      memY=y[i];
      memH=h[i];
  }
  }
  
  bool chk=false;
  
  for(int X=0;X<=100;X++){
for(int Y=0;Y<=100;Y++){
  ll H=abs(X-memX)+abs(Y-memY)+memH;
  
  bool flag=true;
  
  for(int i=0;i<N;i++){
    if(h[i]!=max(H-abs(X-x[i])-abs(Y-y[i]),0)){
flag=false;
      break;
    }
    
  }
  if(flag){
cout<<X<<" "<<Y<<" "<<H<<endl;
    chk=true;
    break;
  }
}
    if(chk){
      break;
    }

   }

}
  
     

Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
	var mem = input[0].split(" ").map(Number);
	var arr = input[1].split("");
	var p = mem[1]+mem[2];
	var n = 0;
	var m = 0;
	for(var i=0;i<arr.length;i++){
		if(arr[i]=="a"){
			m++;
			console.log(m<=p?"Yes":"No");
		}else if(arr[i]=="b"){
			n++;
			m++;
			console.log(m<=p&&n<=mem[2]?"Yes":"No")
			if(!(m<=p&&n<=mem[2])) m--;
		}else{
			console.log("No")
		}
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 16108
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<int> h(n);
    for (auto &v : h)
        cin >> v;
    vector<vector<int> > G(n);
    while (m--) {
        int u, v; cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans = 0;
    for (int u = 0 ; u < n ; u++) {
        bool f = 1;
        for (auto &v : G[u]) {
            if (h[v] >= h[u])
                f = 0;
        }
        if (f)
            ans++;
    }
    cout << ans << '\n';

}

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


int main(){
    int N, K;
    cin >> N >> K;
    vector<float> p(N);
    for(int i=0; i<N; i++) cin >> p.at(i);
    for(int i=0; i<N; i++) p.at(i) = (p.at(i) + 1) / 2;
    vector<double> q(N);
    q.at(0) = p.at(0);
    for(int i=1; i<N; i++) q.at(i) = q.at(i-1) + p.at(i);
    vector<double> r(N - K + 1);
    r.at(0) = q.at(K-1);
    for(int i=1; i<N-K+1; i++){
        r.at(i) = q.at(i+K-1) - q.at(i-1);
    }
    double max = 0;
    for(int i=0; i<N-K+1; i++){
        if(max < r.at(i)) max = r.at(i);
    }
    cout << fixed << setprecision(12);
    cout << max << endl;
}


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

const int M = 1000000007;

class unionfind {
    public:
    int n;
    vector<int> par;
    unionfind(int m) {
        n = m;
        par.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int find(int x) { return par[x] == x ? x : (par[x] = find(par[x])); }
    int isunion(int x, int y) { return find(x) == find(y); }
    int tounion(int x, int y) {
        int p = find(x), q = find(y);
        if (p == q) return 0;
        par[q] = p;
        return 1;
    }
};

int main() {
    while (1) {
        int n, m;
        cin >> n >> m;
        if (!n) return 0;

        vector<int> h(n);
        map<int, int> mp;
        for (int i = 0; i < n; ++i) {
            cin >> h[i];
            mp[h[i]] = 1;
        }
        int cc = 0;
        for (auto& i : mp)
            i.second = cc++;

        vector<vector<int>> lis(n);
        for (int i = 0; i < n; ++i) {
            h[i] = mp[h[i]];
            lis[h[i]].push_back(i);
        }
        vector<vector<pair<int, pair<int, int>>>> edge(n);
        for (int i = 0; i < m; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            --a;
            --b;
            edge[min(h[a], h[b])].push_back(make_pair(c, make_pair(a, b)));
        }
        for (int i = 0; i < n; ++i)
            sort(edge[i].begin(), edge[i].end());

        int lastsep = n;
        unionfind puf(n);
        for (int i = n - 1; i >= 0; --i) {
            for (auto j : edge[i])
                puf.tounion(j.second.first, j.second.second);

            for (int j = 0; j < n; ++j) {
                if (h[j] >= i) {
                    for (int k = 0; k < n; ++k) {
                        if (h[k] >= i && !puf.isunion(j, k)) {
                            lastsep = i;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        if (lastsep == 0) {
            cout << "0\n";
            continue;
        }
        vector<pair<int, pair<int, int>>> fedge;
        for (int i = lastsep - 1; i < n; ++i)
            for (auto j : edge[i])
                fedge.push_back(j);

        sort(fedge.begin(), fedge.end());
        unionfind uf(n);
        long long sum = 0;
        for (auto i : fedge)
            if (uf.tounion(i.second.first, i.second.second))
                sum += i.first;

        for (int i = lastsep - 2; i >= 0; --i)
            for (auto j : edge[i])
                if (uf.tounion(j.second.first, j.second.second))
                    sum += j.first;

        cout << sum << "\n";
    }
}

Measured memory_bytes: 3668
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

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

using namespace std;

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;

    cout << std::max(0LL, C - (A - B)) << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define MEM(a, x) memset(a, x, sizeof a)

typedef pair<int, int> ii;

int main() {
	int h, w;
	char buf;
	bool grid[1005][1005];
	vector<ii> st;

	cin >> h >> w;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> buf;
			grid[i][j] = (buf == '#') ? true : false;
			if(grid[i][j])
				st.pb({i,j});
		}
	}

	queue<ii> q;
	int u, d, ans;

	for(auto& it : st) {
		int idx = it.first * w + it.second;
		q.push({idx, 0});
	}

	while(!q.empty()) {
		u = q.front().first; d = q.front().second;
		q.pop();

		int i = u / w, j = u % w;

		if(!grid[i][j] || d == 0) {
			grid[i][j] = true;
			ans = d;
			//cout << i << ' ' << j << ' ' << d << endl;

			if(i < h - 1 && !grid[i+1][j]) q.push({(i+1) * w + j, d + 1});
			if(i > 0 && !grid[i-1][j]) q.push({(i-1) * w + j, d + 1});
			if(j < w - 1 && !grid[i][j+1]) q.push({i * w + j + 1, d + 1});
			if(j > 0 && !grid[i][j-1]) q.push({i * w + j - 1, d + 1});
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
long long int t,i,s=0,s1=0;
cin>>t;
int v[1000];
int c[1000];
for(i=0;i<t;i++)
{
    cin>>v[i];
}
for(i=0;i<t;i++)
{
    cin>>c[i];
}
for(i=0;i<t;i++)
{
    if(v[i]>=c[i])
    {
        s=s+v[i];
       s1=s1+c[i];
    }
}
cout<<s-s1<<endl;

}

Measured memory_bytes: 3624
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	long long a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0) {
		cout << a - b << endl;
	} else {
		cout << b - a << endl;
	}
}





Measured memory_bytes: 384
import java.util.*
import javax.print.attribute.IntegerSyntax
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val x = readInt()
    println(if (x >= 30) "Yes" else "No")
}


Measured memory_bytes: 34528
v = int(input())

p1 = [2,4,5,7,9]
p2 = [0,1,6,8]
p3 = [3]
if v%10 in p1:
    print("hon")
elif v%10 in p2:
    print("pon")
elif v%10 in p3:
    print("bon")

Measured memory_bytes: 61684
#include <bits/stdc++.h>
using namespace std;
int main()
{
        long long n,q;
        cin >> n;
        long long arr[1000001];
        for(int i = 0; i< 1000001;i++)
        {
                arr[i] = 0;
        }
        
        long long num = 0;
        for(int i = 0;i<n;i++)
        {
                long long x;
                cin >> x;
                arr[x]++;
                num += x;
        }
  		cin >> q;
        for(int i = 0;i<q;i++)
        {
                long long b,c;
                cin >> b>>c;
                arr[c] = arr[b]+arr[c];
                num += (c-b) * arr[b];
                arr[b] = 0;
          		cout << num << endl;
        }
        
}

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 9;

inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}
int n, ans;
char s[101], t[101];
bool fail;

int main () {
	boost ();
	cin >> n;
	cin >> s + 1 >> t + 1;
	for (int i = 1;i <= n;i ++) 
		if (s[i] != t[i]) fail = 1;
	if (!fail) return cout << n, 0;
	ans = n + n;
	for (int i = 1;i <= n;i ++) {
		int cur = 1, pos = i, len = n;
		while (t[cur] == s[pos]) {
			pos ++, cur ++;
			len --;
		}
		ans = min (ans, n + len);
	}
	cout << ans;
	return 0;
}

        

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
map<int, int> mp;
void prime_factorize(ll n, vector<ll> &ret)
{
	if (n <= 1)	return;
	ll last = sqrt(n);
	for (ll i = 2; i <= last; i++) {
		if (n % i == 0) {
			prime_factorize(i, ret);
			prime_factorize(n / i, ret);
			return;
		}
	}
	ret.push_back(n);
	return;
}
int getDig(ll i)
{
	int dig = 0;
	while (i != 0) {
		i /= ll(10);
		dig++;
	}
	return dig;
}
ll getGCD(ll a, ll b)
{
	// Greatest Common Divisor
	if (a == b)	return a;
	ll _min = min(a, b);
	ll _max = max(a, b);
	if (_max % _min == 0)	return _min;
	return getGCD(_min, _max%_min);
}
ll getLCM(ll a, ll b)
{
	// Least Common Multiple
	return a*b / getGCD(a, b);
}
vector<ll> divisor(ll n)
{
	vector<ll> ret;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n)	ret.push_back(n / i);
		}
	}
	return ret;
}
int main()
{
	ll a, b;
	cin >> a >> b;
	ll gcd = getGCD(a, b);
	vector<ll> fac = divisor(gcd);
	sort(fac.begin(), fac.end());
	int s = fac.size();
	vector<ll> disjoints(1, 1);
	if (s == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll ans = 1;
	for (int i = 1; i < s; ++i) {
		bool ok = true;
		rep(j, disjoints.size()) {
			//if (disjoints[j] == fac[i])	continue;
			gcd = getGCD(disjoints[j], fac[i]);
			if (gcd != 1) {
				ok = false;
				break;
			}
		}
		if (ok) {
			disjoints.push_back(fac[i]);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3680
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] d = new int[n];
            Map<Integer, Integer> d_cnt = new HashMap<>();
            for (int i = 0; i < n; i++) {
                d[i] = Integer.parseInt(in.next());
                if (!d_cnt.containsKey(d[i])) {
                    d_cnt.put(d[i], 1);
                } else {
                    Integer tmp = d_cnt.get(d[i]);
                    d_cnt.put(d[i], ++tmp);
                }
            }
            int m = Integer.parseInt(in.next());
            int[] t = new int[m];
            Map<Integer, Integer> t_cnt = new HashMap<>();
            for (int i = 0; i < m; i++) {
                t[i] = Integer.parseInt(in.next());
                if (!t_cnt.containsKey(t[i])) {
                    t_cnt.put(t[i], 1);
                } else {
                    Integer tmp = t_cnt.get(t[i]);
                    t_cnt.put(t[i], ++tmp);
                }
            }
            boolean ok = true;

            for (int i = 0; i < m; i++) {
                if (!d_cnt.containsKey(t[i])) {
                    ok = false;
                } else if (t_cnt.get(t[i]) > d_cnt.get(t[i])) {
                    ok = false;
                }
            }
            out.println(ok ? "YES" : "NO");

        }

    }
}



Measured memory_bytes: 85424
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    ans = pow(N // K, 3)
    if K % 2 == 0:
        ans += pow((N + K // 2) // K, 3)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <iostream>

using namespace std;

int main(void)
{
    long long N, i, l[1001], r[1001], ans=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> l[i] >> r[i];

        ans += (r[i]-l[i]+1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

int a,b,c,x,y,z;

scanf("%d%d%d",&a,&b,&c);

if(a>b){

x=a;

a=b;

b=x;

}

if(b>c){

y=b;

b=c;

c=y;

}

if(a>b){

z=a;

a=b;

b=z;

}

printf("%d %d %d\n",a,b,c);

return 0;

}
  

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<set>
using namespace std;

int s, d;

class DisjointSet{
public:
    vector<int> p;

    DisjointSet(){}
    DisjointSet(int size){
        p.resize(size, 0);
        for(int i = 0; i < size; i++) makeSet(i);
    }
    void makeSet(int x){
        p[x] = x;
    }
    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }
    void unite(int x, int y){
        link(findSet(x), findSet(y));
    }
    void link(int x, int y){
        if(x == y)  return;
        if(x < s)   p[y] = x;
        else        p[x] = y;
    }
    int findSet(int x){
        if(x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
    bool isHotSpring(int x){
        return findSet(x) < s;
    }
};

int main(){
    while(cin >> s >> d, s+d){
        DisjointSet uf(s+d);
        set<pair<int, pair<int,int>>> path;
        for(int i = 0; i < s; i++){
            for(int j = 0; j < d; j++){
                int x;  cin >> x;
                if(x != 0)  path.insert({x, {i, s+j}});
            }
        }
        for(int i = 0; i < d-1; i++){
            for(int j = 0; j < d-1-i; j++){
                int x;  cin >> x;
                if(x != 0)  path.insert({x, {s+i, s+i+j+1}});
            }
        }
        int ans = 0;
        bool update = true;
        while(update){
            update = false;
            for(auto it = path.begin(); it != path.end(); it++){
                auto p = *it;
                int cost = p.first, i = p.second.first, j = p.second.second;
                if(!uf.same(i, j) && (uf.isHotSpring(i)+uf.isHotSpring(j) == 1)){
                    ans += cost;
                    uf.unite(i, j);
                    path.erase(it);
                    update = true;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
while True:
    a,op,b = input().split()
    if op == '?':
        break
    a = int(a)
    b = int(b)
    
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(a//b)
    


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int n;
    cin >> n;
    ll ans = 0;
    FOR(i, 1, n + 1) {
        bool add = i % 5 != 0 && i % 3 != 0;
        ans += add * i;
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void answer(int a, int b) {
	cout << a << " " << b;
}

int main(void) {


	ll x;
	cin >> x;

	/*

	{
		auto v = pow(10,9);

		int valP = 0;
		int valM = 0;
		for (int i = 1; i < 2000; ++i) {
			auto a = pow(i, 5) - pow(i - 1, 5);
			if (a >= v) {
				valP = i;
				break;
			}
		}
		for (int i = 1; i < 2000; ++i) {
			auto a = pow(-i, 5) - pow(-i - 1, 5);
			if (a >= v) {
				valM = -i;
				break;
			}
		}
		cout << valP << " " << valM;
		return 0;
	}
	→120,-119のため、答えは-119<=A|B<=120
	*/

	
	map<ll, int> ans;
	for (int i = -120; i <= 120; ++i) {
		ll val = 1;
		for (int j{}; j < 5; ++j) val *= i;

		if (ans.count(val + x)) {
			cout << ans[val + x]<< " " <<  i;
			break;
		}

		if (ans.count(-val + x)) {
			cout << ans[-val + x]<< " " <<  -i;
			break;
		}

		ans[val] = i;
	}
	//auto output = resultCount;
	//cout << output;

	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int n, a;
    cin >> n >> a;
    cout << n*n - a << endl;
    return 0;
}



Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    C = []
    for _ in range(3):
        C.append([int(x) for x in input().split()])


    is_yes = True
    for j in range(2):
        tmp = 0
        for i in range(3):
            if i == 0:
                tmp = C[j + 1][i] - C[j][i]
            else:
                if tmp != C[j + 1][i] - C[j][i]:
                    is_yes = False
                    break

    for i in range(2):
        tmp = 0
        for j in range(3):
            if j == 0:
                tmp = C[j][i + 1] - C[j][i]
            else:
                if tmp != C[j][i + 1] - C[j][i]:
                    is_yes = False
                    break

    if is_yes:
        print("Yes")
    else:
        print("No")




if __name__ == '__main__':
    main()




Measured memory_bytes: 3064
n = int(input())
s = input()

rcnt = s.count('R')
gcnt = s.count('G')
bcnt = s.count('B')

sub = 0
for i in range(n):
    for j in range(i+1, n):
        k = j + (j - i)
        if n <= k: break

        alp = set()
        alp.add(s[i])
        alp.add(s[j])
        alp.add(s[k])

        if len(alp) == 3: sub += 1

ans = rcnt * gcnt * bcnt - sub
print(ans)

Measured memory_bytes: 68344
n, q = list(map(int, input().split(' ')))
input_ = [input().split(' ') for i in range(n)]
process = [{'name':input_[i][0], 'time':int(input_[i][1])} for i in range(n)]

time_table = 0
queue = [process[i] for i in range(n)]
while queue:
    tmp_pro = queue.pop(0)
    if tmp_pro['time'] > q:
        time_table += q
        tmp_pro['time'] -= q
        queue.append(tmp_pro)
    else:
        time_table += tmp_pro['time']
        print(tmp_pro['name'] + ' ' + str(time_table))


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

#define LL long long
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int n,a[100],i,t=100,ans=1e9;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>n;
	REP(i,n)
		cin >>a[i];
	while (t--!=1)
	{
		int s=0;
		REP(i,n)
		{
			s+=(a[i]-t)*(a[i]-t);
		}
		ans=min(ans,s);
	}
	cout <<ans;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    while (1) {
        string S; cin >> S;
        if (S == "#") break;

        int ans = 1<<19;
        loop (2, i) {
            int p[2] = { 1, 3 };
            int l = i, cnt = 0;
            for (char c : S) {
                int v = (c - '1') % 3 + 1;
                int f = (l * 2) - 1;
                if (f * (v - p[l^1]) >= 0) {
                    p[l] = v;
                    l ^= 1;
                } else {
                    p[l^1] = v;
                    cnt++;
                }
            }
            ans = min(ans, cnt);
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

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

  int N; cin>>N;
  vector<int> A(N); for (auto& a : A) cin>>a;
  vector<int> order(N);
  iota(order.begin(), order.end(), 0);
  sort(order.begin(), order.end(), [&](int l, int r) {return A[l] < A[r];});
  for (auto o : order) {
	cout << o+1 << endl;
  }

  return 0;
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

// 素数判定
bool isprime(ll  n){
	if (n < 2) return false;
	else if (n == 2) return true;
	else if (n % 2 == 0) return false;
	else
		for (int i = 3; i*i <= n; i++)
			if (n%i == 0) return false;

	return true;
}
// 桁数
int func(int n){
	int ret = 0;
	while (n > 0){
		n /= 10;
		ret++;
	}
	return ret;
}

signed main(){

	int N;
	cin >> N;
	if (isprime(N)){
		cout << func(N) << endl;
		return 0;
	}
	for (int i = sqrt(N);; i--){
		if (N%i == 0){ cout << func(N/i) << endl; return 0; }
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;cin >> x;
    for(ll i=-1000;i<=1000;i++){
      for(ll j=-1000;j<=1000;j++){
        if(i*i*i*i*i-j*j*j*j*j==x){
          cout << i << " " << j << endl;
          return 0;
        }
      }
    }
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int a[3];
  rep(i,3)cin>>a[i];
  sort(a,a+3);
  int ans=(a[1]-a[0])/2;
  if((a[1]-a[0])%2==1){
    ans+=1;
    a[2]++;
    }
  cout<<ans+a[2]-a[1]<<endl;
  
  return 0;
  }

Measured memory_bytes: 256
// E - Multiplication 4
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
int vpop(vector<int>& v){int x=v.back();v.pop_back();return x;}

int main(){
	int N, K; cin>>N>>K;
	vector<int> P, M;
	rep(i, N){
		int a; cin>>a;
		if(a < 0) M.push_back(a);
		else P.push_back(a);
	}

	sort(P.begin(), P.end());
	sort(M.rbegin(), M.rend());

	vector<int> p, m;
	while(int(p.size() + m.size()) < K){
		if(P.size() > 0 && M.size() <= 0) p.push_back(vpop(P));
		else if(P.size() <= 0 && M.size() > 0) m.push_back(vpop(M));
		else if(P.back() < -M.back()) m.push_back(vpop(M));
		else p.push_back(vpop(P));
	}

	if(m.size()%2){
		ll pM = p.size() * M.size(), mP = m.size() * P.size();
		if(pM > 0 && mP > 0){
			if(abs((ll)p.back() * P.back()) < abs((ll)m.back() * M.back())){ p.pop_back(); m.push_back(vpop(M)); }
			else{ m.pop_back(); p.push_back(vpop(P)); }
		}
		else if (pM > 0){ p.pop_back(); m.push_back(vpop(M)); }
		else if (mP > 0){ m.pop_back(); p.push_back(vpop(P)); }
		else{
			while(m.size() > 0) p.push_back(vpop(m));
			while(P.size() > 0) p.push_back(vpop(P));
			while(M.size() > 0) p.push_back(vpop(M));
			sort(p.begin(), p.end(), [](int x, int y){ return abs(x) < abs(y); });
			while((int)p.size() > K) p.pop_back();
		}
	}

	ll ans = 1;
	int mod = 1'000'000'007;
	for(int a:p) ans = ans * a % mod;
	for(int a:m) ans = ans * a % mod;
	cout<< (ans+mod)%mod <<endl;
}


Measured memory_bytes: 5768
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int A = sc.nextInt();
 
        int[] X=new int[N];
 
        int sum=0;
        for (int i = 0; i < N; i++) {
            X[i]=sc.nextInt();
            sum+=X[i];
        }
 
        long[][][] dp=new long[N+1][N+1][sum+1];
 
        dp[0][0][0]=1;
 
        for (int j = 1; j < N+1; j++) {
            for (int k = 0; k < N+1; k++) {
                    for (int s = 0; s <sum+1; s++) {
 
                    if(s<X[j - 1]) {
                        dp[j][k][s]=dp[j-1][k][s];
                    }else if(k>=1 && s>=X[j - 1]) {
                        dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-X[j - 1]];
                    }else {
                        dp[j][k][s]=0;
                    }
 
                }
            }
        }
 
        long ans=0;
        for (int k = 1; k < N+1 && k * A < sum + 1; k++) {
            ans+=dp[N][k][k*A];
        }
 
        System.out.println(ans);
    }
}

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

#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)

const double EPS = 1e-8;
const double INF = 1e12;

struct P {
  complex<double> p;
  int h;
  P(complex<double> p,int h) : p(p),h(h) {;}
};

namespace std {
  bool operator<(const P &a, const P &b) {
    return real(a.p) != real(b.p) ? real(a.p) < real(b.p) : imag(a.p) < imag(b.p);
  }
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

double cross(const P &a, const P &b) {
  return imag(conj(a.p)*b.p);
}

//inner product
double dot(const P &a, const P &b) {
  return real(conj(a.p)*b.p);
}

int ccw(P a, P b, P c) {
  b.p -= a.p;
  c.p -= a.p;
  if( cross(b, c) > 0 ) return +1; // counter clockwise
  if( cross(b, c) < 0 ) return -1; // clockwise
  if( dot(b, c) < 0 ) return +2;   // c--a--b on line
  if( norm(b.p) < norm(c.p) ) return -2; // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0]) * ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0]) * ccw(t[0],t[1],s[1]) <= 0;
}

// a1,a2ツづーツ端ツ点ツづつキツづゥツ静シツ閉ェツづ1,b2ツづーツ端ツ点ツづつキツづゥツ静シツ閉ェツづ個古ーツ点ツ計ツ算
P intersection_ls(P a1, P a2, P b1, P b2) {
  P b = P(b2.p-b1.p,b1.h);
  double d1 = abs(cross(b, P(a1.p-b1.p,b1.h)));
  double d2 = abs(cross(b, P(a2.p-b1.p,b1.h)));
  double t = d1 / (d1 + d2);
  return P(a1.p + (a2.p-a1.p) * t,b1.h);
}

int main() {
  int num,n,i;
  cin>>num;
  while(num--) {
    vector<L> in;
    double xa,ya,xb,yb,sx,sy,o,l;
    cin>>sx>>sy>>xb>>yb;
    in.push_back(L(P(complex<double>(0,0),0),P(complex<double>(xb-sx,yb-sy),0)));
    cin>>n;
    for(int i=0; i<n; ++i) {
      cin>>xa>>ya>>xb>>yb>>o>>l;
      int h = (o == 1) ? l : (l == 1) ? 0 : 1;
      in.push_back(L(P(complex<double>(xa-sx,ya-sy),h),
		     P(complex<double>(xb-sx,yb-sy),h)));
    }

    vector<P> cr;
    for(int i=1; i<=n; ++i) {
      if(intersectSS(in[0],in[i])) {
	cr.push_back(intersection_ls(in[0][0],in[0][1],in[i][0],in[i][1]));
      }
    }

    sort(cr.begin(), cr.end());
    int ans = 0;
    if(!cr.empty()) {
      for(int i=0; i<cr.size()-1; ++i) {
	if(cr[i].h != cr[i+1].h) {
	  ans++;
	}
      }
    }

    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	char c ;
	cin >> c ;
	cout << (char)(c+1);
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3564
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

struct edge{
  int u, v, cost;
  bool operator< (edge const& other){
	    return cost < other.cost; 
	 }	
};

const int N = 4e5 + 11;
int p[N], sz[N];
int n, m, k;
vector<edge> ret;
int weight , cnt;

int get(int x){
  if (x == p[x]) return x;
  return p[x] = get(p[x]);	
}

void unite(int x, int y){
  x = get(x), y = get(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[y] += sz[x];
  p[y] = x;	
}

void solve(){
  	cin >> n >> m >> k;
  	vector<edge> g;
  	for(int i = 0; i < N; i++){
	    p[i] = i;
	    sz[i] = 0;	
	}
	int now = 1;
	int color[n];
	for(int i = 0; i < n; i++){
	   	cin >> color[i];
	   	if (color[i] == 0) {
		  color[i] = now + 100000;
		  now++;	
		}
	}
  	for(int i = 0; i < m; i++){
	  int x, y, val;
	  cin >> x >> y >> val;
	  x--, y--;
	  g.push_back({x, y, val});
	}
    sort(all(g));
	cnt = 0;
	weight = 0;
	for(auto it : g){
	  if (get(color[it.u]) != get(color[it.v])){
		   unite(color[it.u], color[it.v]);
		   weight += it.cost;
		   cnt++;  
		}	
	 if (cnt == k - 1) {
	   cout << weight << endl;
	   exit(0);	 
	 }
	}
   cout << -1 << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 12020