akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    ll ans=0;
    for(int i=1;i<=n-1;i++){
        ans+=i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	int l;
	scanf("%d", &l);
	REP(i,l)
	{
		int a,b,c;
		scanf("%d %d %d", &a, &b, &c);
		a *= a;
		b *= b;
		c *= c;
		if (a == b+c || b == a+c || c == a+b)
		{
			printf("YES\n");
		}
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 3140
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int ctoi(char c1, char c2) {
  return (c1 - '0') * 10 + (c2 - '0');
}

int totime(int h, int m, int s) {
  return h * 3600 + m * 60 + s;
}

int solve(int n) {
  int imos[100000] = {};
  for (int i = 0; i < n; i++) {
    std::string b, e;
    cin >> b >> e;
    int begin_i = totime(ctoi(b[0], b[1]), ctoi(b[3], b[4]), ctoi(b[6], b[7]));
    int end_i   = totime(ctoi(e[0], e[1]), ctoi(e[3], e[4]), ctoi(e[6], e[7]));
    imos[begin_i]++;
    imos[end_i]--;
  }
  int cum    = imos[0];
  int result = 0;
  for (int i = 1; i < 100000; i++) {
    cum += imos[i];
    result = std::max(result, cum);
  }
  return result;
}

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

  int n;
  while (1) {
    cin >> n;
    if (n == 0) {
      break;
    }
    cout << solve(n) << endl;
  }

  return 0;
}



Measured memory_bytes: 3504
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

void solve() {
    int n;
    cin >> n;
    int ara[n];
    for(int i = 0; i < n; ++i){
        cin >> ara[i];
    }
    sort(ara, ara + n);
    ll a(0), b(0);
    ll len = n - 1;
    char c(1);
    while(len){
        if(ara[len] == ara[len - 1]){
            if(c){
                a = ara[len];
                c = 0;
            }
            else{
                b = ara[len];
                break;
            }
            len--;
        }
        len--;
    }
    cout << a * b << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4020
import collections

n = int(input())

sets = None
s_lst = []
dic = {}
for i in range(n):
  s = input()
  s_lst.append(s)
  if i == 0:
    sets = set(s)
  else:
    sets &= set(s)

for s in s_lst:
  c = collections.Counter(s)
  for k in sets:
    if not k in dic:
      dic[k] = c[k]
    else:
      dic[k] = min(dic[k], c[k])

res = ''
for key in sorted(list(sets)):
  res += key * dic[key]
print(res)

Measured memory_bytes: 9412
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 200002
struct edge{int to,nxxt;}e[N];
int n,k,head[N],cnt=1,dep[2002],a[N][2];
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void df5(int te,int la)
{
	for(int i=head[te];i;i=e[i].nxxt)
	{
		int j=e[i].to;if(j==la)continue;
		dep[j]=dep[te]+1;df5(j,te);
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		ins(x,y);ins(y,x);a[i][0]=x,a[i][1]=y;
	}
	if(k%2==0)
	{
		int ans=n;
		for(int i=1;i<=n;i++)
		{
			dep[i]=0;df5(i,i);
			int tsu=0;
			for(int j=1;j<=n;j++)if(dep[j]>k/2)tsu++;
			ans=min(ans,tsu);
		}
		printf("%d\n",ans);return 0;
	}
	else
	{
		int ans=n;
		for(int i=1;i<n;i++)
		{
			int x=a[i][0],y=a[i][1],tsu=0;
			memset(dep,-1,sizeof(dep));dep[x]=0;df5(x,y);
			for(int j=1;j<=n;j++)if(dep[j]>k/2)tsu++;
			memset(dep,-1,sizeof(dep));dep[y]=0;df5(y,x);
			for(int j=1;j<=n;j++)if(dep[j]>k/2)tsu++;
			ans=min(ans,tsu);
		}
		printf("%d\n",ans);
	}
}


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

#define ll long long

using namespace std;

const int N = (int)1e5 + 7;

int mod;
int n;
vector < int > gr[N];
int dp[N], dp1[N];
int sz[N];
int ans[N];

int add(int a, int b) {
	return (a + b) % mod;
}

int mul(int a, int b) {
	return (a * 1LL * b) % mod;
}

void dfs(int v, int pr) {
	sz[v] = 1;
	int &res = dp[v];
	res = 1;
	for (int to : gr[v]) {
		if (to == pr) continue;
		dfs(to, v);
		sz[v] += sz[to];
		res = mul(res, dp[to] + 1);
	}
}

int binpow(int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res = mul(res, a);
		a = mul(a, a);
		n >>= 1;
	}
	return res;
}

int ey;

void dfs1(int v, int pr, int cur) {
	cur = add(cur, 1);
	ans[v] = mul(cur, dp[v]);
	vector < int > res;
	int asd = 1;
	res.push_back(1);
	for (int to : gr[v]) {
		if (to == pr) continue;
		asd = mul(asd, dp[to] + 1);
		res.push_back(asd);
	}
	res.pop_back();
	asd = 1;
	reverse(gr[v].begin(), gr[v].end());
	for (int to : gr[v]) {
		if (to == pr) continue;
		dfs1(to, v, mul(cur, mul(res.back(), asd)));
		res.pop_back();
		asd = mul(asd, dp[to] + 1);
	}
}

main() {
	scanf("%d %d", &n, &mod);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		gr[v].push_back(u);
		gr[u].push_back(v);
	}
	dfs(1, 1);
	dfs1(1, 1, 0);
	for (int i = 1; i <= n; i++) {
		printf("%d\n", ans[i]);
	}
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
   	ll n, x;
   	cin >> n;
   	ll flag = 0;
   	rep(i, n){
   		cin >> x;
   		if(x%2 == 0 && x%3 != 0 && x%5 != 0){
   			flag = 1;
   			break;
   		}
   	}
   	cout << (!flag ? "APPROVED\n" : "DENIED\n");

}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector<int> csum(n+1,0);
  REP(i,n-1){
    if(s[i] == 'A' && s[i+1] == 'C')csum[i+1] = csum[i] + 1;
    else csum[i+1] = csum[i];
  }
  // REP(i,n+1){
  //   cout << i <<  " " << csum[i] << endl;
  // }
  REP(i,q){
    int l,r;
    cin >> l >> r;
    cout << csum[r-1] - csum[l-1] << endl;
  }

}



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

class Assignment {
  static void Main() {
    var N = int.Parse(Console.ReadLine().Trim());
    var S = Console.ReadLine().Trim();
    var index = 0;
    var counter = 0;
    
    if(S.Length >= 2) {
      while(true) {
        if(S.Substring(index, 1) != S.Substring(index + 1, 1)) {
          counter++;
        }
        index++;        
        if(index == S.Length - 1) {
          break;
        }
      }
    }
    
    Console.WriteLine(counter + 1);
    
  }
}

Measured memory_bytes: 17240
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int dfs(vector<vector<int>>&adj,int idx,vector<int>&dp){
  if(dp[idx]!=-1)
    return dp[idx];
  int maxx=0;
  for(auto it=adj[idx].begin();it!=adj[idx].end();it++){
    maxx=max(maxx,dfs(adj,*it,dp)+1);
  }
  dp[idx]=maxx;
  	return dp[idx];
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>>adj(n+1);
  int u,v;
  for(int i=1;i<=m;i++){
    cin>>u>>v;
    adj[u].push_back(v);
  }
  int ans=INT_MIN;
  vector<int>dp(n+1,-1);
  for(int i=1;i<=n;i++){
    ans=max(ans,dfs(adj,i,dp));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11824
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define int long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

template <typename F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) noexcept : F(std::forward<F>(f)) {}
    template <typename... Args>
    constexpr decltype(auto)
    operator()(Args &&... args) const {
        return F::operator()(*this, std::forward<Args>(args)...);
    }
};

template <typename F>
static inline constexpr decltype(auto)
make_func(F &&f) noexcept {
    return FixPoint<F>{std::forward<F>(f)};
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<bool> used(n, false);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            used[a - 1] = true;
        }
    }

    int ans = 0;
    rep(i, n) if (!used[i]) ans += 1;
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int n,m,par[100005],fa[100005];
long long a[100005],b[100005],c[100005],s[100005],ans[100005];
vector<int>E[100005],E1[100005];
bool vis[100005];
bool cmp(int x,int y){
	return c[x]<c[y];
}
int find(int x){
	if(x!=fa[x])fa[x]=find(fa[x]);
	return fa[x];
}
void dfs(int u){
	s[u]=b[u];ans[u]=1e18;
	for(int i=0;i<E1[u].size();i++){
		int v=E1[u][i];
		dfs(v);
		s[u]+=s[v];
	}
	for(int i=0;i<E1[u].size();i++){
		int v=E1[u][i];
		ans[u]=min(ans[u],s[u]-s[v]+max(c[u],ans[v]));
	} 
	if(ans[u]==1e18)ans[u]=b[u]+c[u];
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
		c[i]=max(0LL,a[i]-b[i]);
		par[i]=fa[i]=i;
	}
	sort(par+1,par+n+1,cmp);
	while(m--){
		int u,v;
		scanf("%d%d",&u,&v);
		E[u].push_back(v);	
		E[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		int u=par[i];
		for(int j=0;j<E[u].size();j++){
			int v=E[u][j];
			if(vis[v]&&find(v)!=u){
				E1[u].push_back(find(v));
				fa[find(v)]=u;
			}
		}
		vis[u]=1;
	}
	dfs(par[n]);
	printf("%lld\n",ans[par[n]]);
}

Measured memory_bytes: 23044
#include<iostream>
using namespace std;
int n,c,a[30][1<<18];
main()
{
	cin>>n>>c;
	for(int i=0;i<n;i++)
	{
		int s,t,C;cin>>s>>t>>C;
		s*=2;t*=2;C--;
		a[C][s]++,a[C][t]--;
	}
	int ans=0;
	for(int i=1;i<1<<18;i++)
	{
		for(int j=0;j<c;j++)
		{
			a[j][i]+=a[j][i-1];
		}
	}
	for(int i=1;i<1<<18;i++)for(int j=0;j<c;j++)if(a[j][i]>0&&a[j][i-1]==0)a[j][i-1]=1;
	for(int i=0;i<1<<18;i++)
	{
		int now=0;
		for(int j=0;j<c;j++)now+=a[j][i];
		ans=ans<now?now:ans;
	}
	cout<<ans<<endl;
}

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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> A(N,0), B(N-1,0);
  for(int i = 0; i < N-1; i++) {
    cin>>B[i];
  }
  ll ans = B[0] + B[N-2];
  for(int i = 0; i < N-2; i++) {
    ans	+= min(B[i], B[i+1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
	std::string S;

	std::cin >> S;

	int y, m, d;

	y = 1000*(S[0]-'0')+100*(S[1]-'0')+10*(S[2]-'0')+(S[3]-'0');
	m = 10*(S[5]-'0')+(S[6]-'0');
	d = 10*(S[8]-'0')+(S[9]-'0');
	if(y <= 2018){
		goto heisei;
	}


	if(y <= 2019 and m < 5){
		goto heisei;
	}




	goto not_heisei;

	heisei:

	std::cout << "Heisei" << std::endl;

	return 0;

	not_heisei:

	std::cout << "TBD" << std::endl;
	return 0;

}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    string s;
    cin >> s;

    vll lbs(s.length()+1, 0);
    ll idx = 0;
    ll ndec = 0;
    ll c = 0;
    while(idx<s.length()){
        if(s[idx]=='>') ++ndec;
        else{
            while(ndec>0){
                lbs[c] = ndec;
                --ndec;
                ++c;
            }
            c = idx+1;
        }
        ++idx;
    }
    if(ndec>0){
        while(ndec>0){
            lbs[c] = ndec;
            --ndec;
            ++c;
        }
    }
    ll lb = 0;
    ll sum = 0;
    rep(i, lbs.size()){
        lb = max(lb, lbs[i]);
        sum += lb;
        if(i<s.length()){
            if(s[i]=='<') ++lb;
            else lb = 0;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4740
while True:
    try:
        lst = []
        ju = True
        while True:
            a, b = map(int, input().split())
            if a == 0:
                break
            lst.append(a)
            lst.append(b)

        anslst = []
        for i in range(1, max(lst)+1):
            anslst.append(lst.count(i))

        if anslst[0]%2 == 0 or anslst[1]%2 == 0:
            ju = False

        else:
            for i in anslst[2:]:
                if i%2 !=0:
                    ju = False
                    break    

        if ju:
            print('OK')
        else:
            print('NG')

    except EOFError:
        break


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

#define print2(a, b) cerr << "(" << a << "," << b << ")" << endl
#define print3(a, b, c) cerr << "(" << a << "," << b << "," << c << ")" << endl


void solve(long long N, long long K) {
    cout << (N % K == 0 ? 0 : 1) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	rep(i,s.size()){
		s[i] = (s[i] - 'A' + n)%26 + 'A';
	}
	cout << s << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  vi a(3);
  cin >> a[0] >> a[1] >> a[2];
  if (a[0] == a[1] && a[1] == a[2]) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,x,y,z,temp;
	scanf("%d %d",&a,&b);
	x=a+b;
	y=a-b;
	z=a*b;
	if(x<y){ temp=x; x=y; y=temp; }
	if(y<z){ temp=y; y=z; z=temp; }
	if(x<y){ temp=x; x=y; y=temp; }
	printf("%d\n",x);
}





Measured memory_bytes: 1696
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n = 0, sum = 0; int a[22] = { 0 }, b[22] = { 0 };
	for (int h = 0; h < 10; h++) {
		cin >> a[h];
	}
	sort(a, a + 10);
	n += a[7]; n += a[8]; n += a[9];
	for (int h = 0; h < 10; h++) {
		cin >> b[h];
	}
	sort(b, b + 10);
	sum += b[9] + b[8] + b[7];
	cout << n << ' ' << sum << endl;
	cin >> n;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

int main(){
	//ios::sync_with_stdio(0);cin.tie(0);
	bool t[26];
	string s;
	memset(t,false,sizeof(t));
	cin>>s;
	for(char c:s){
		t[c-'a']=true;
	}
	rep(i,26){
		if(!t[i]){
			printf("%c",i+'a');
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

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

	if (n == m) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

bool check(string t){
  int n = t.size();

  bool flag = true;

  rep(i,n/2){
    if(t[i] != t[n-i-1]){
      flag = false;
    }
  }
  return flag;
}


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

    string s;cin >> s;

    int N = s.size();

    string l = s.substr(0,(N-1)/2);
    string r = s.substr((N+1)/2,(N-1)/2);

    bool ans = check(s) && check(l) && check(r);

    cout << (ans?"Yes":"No") << endl;
}


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

int main() {
	int x;
	cin >> x;
	if (400 <= x && x <= 599) {
		cout << 8 << endl;
	}
	else if (600 <= x && x <= 799) {
		cout << 7 << endl;
	}
	else if (800 <= x && x <= 999) {
		cout << 6 << endl;
	}
	else if (1000 <= x && x <= 1199) {
		cout << 5 << endl;
	}
	else if (1200 <= x && x <= 1399) {
		cout << 4 << endl;
	}
	else if (1400 <= x && x <= 1599) {
		cout << 3 << endl;
	}
	else if (1600 <= x && x <= 1799) {
		cout << 2 << endl;
	}
	else if (1800 <= x && x <= 1999) {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

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

    int p = 1, q = 3;
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) {
        cin >> A[i];
    }
    vll B(N+1);
    partial_sum(A.begin(), A.end(), B.begin() + 1);

    ll re = LLONG_MAX;
    FOR(m, 2, N - 1) {
        while (1) {
            ll x = abs(B[m] - B[p] - (B[p] - B[0]));
            ll y = abs(B[m] - B[p + 1] - (B[p + 1] - B[0]));
            if (y < x)p++;
            else break;
        }
        while (1) {
            ll x = abs(B[q] - B[m] - (B[N] - B[q]));
            ll y = abs(B[q + 1] - B[m] - (B[N] - B[q + 1]));
            if (y < x)q++;
            else break;
        }
        ll z[4] = { B[m] - B[p], B[p] - B[0], B[q] - B[m], B[N] - B[q] };
        sort(z, z + 4);
        smin(re, z[3] - z[0]);
    }
    cout << re << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int A,B;
    string S;
    cin>>A>>B>>S;

    for(int i=0;i<A;i++){
        if(S[i]<'0'||'9'<S[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    if(S[A]!='-'){
        cout<<"No"<<endl;
        return 0;
    }

    for(int i=A+1;i<S.length();i++){
        if(S[i]<'0'||'9'<S[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
A, B, K = list(map(int, input().split()))

nth = 0
max_divider = min(A, B)
for divider in range(max_divider, 0, -1):
    is_dividable_both = A % divider == 0 and B % divider == 0
    if is_dividable_both:
        nth += 1
    if nth == K:
        break

print(divider)


Measured memory_bytes: 2940
n = int(input())

com = [[0 for j in range(10)] for i in range(10)]

for i in range(1, n+1):
    s, l = int(str(i)[0]), int(str(i)[-1])
    com[s][l] += 1

ans = 0

for i in range(1, 10):
    for j in range(1, 10):
        ans += com[i][j] * com[j][i]

print(ans)


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

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, sum = 0;
    cin >> n;
    for ( int i = 1; i<=n; i++) {
        for ( int j = 1; j<=n; j++) {
            int x = __gcd(i,j);
            for ( int k = 1; k<=n; k++) {
                sum+=__gcd(x,k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3640
from collections import deque


def bfs(S):  # 幅優先探索  # キュー
    dist = [-1] * (w * h)  # 前処理
    que = deque()
    for i, Si in enumerate(S):
        for j, Sij in enumerate(Si):
            if Sij == '#':
                dist[j + (w * i)] = 0
                que.append((i, j))

    while len(que) > 0:
        (x, y) = que.popleft()
        near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        for i, j in near:  # 移動先の候補
            if 0 <= i < h and 0 <= j < w and dist[j + (w * i)] < 0:
                dist[j + (w * i)] = dist[y + (w * x)] + 1
                que.append((i, j))
    return max(dist)


h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(bfs(a))


Measured memory_bytes: 115740
#include <stdio.h>
 #include<string.h>
 int main()
 {
 int a[101][101];
 int b[101];
 int n,m;
 scanf("%d %d",&n,&m);
 for(int i=0;
i<n;
i++)
{
 for(int j=0;
j<m;
j++)
{
 scanf("%d",&a[i][j]);
 }
 } 
for(int i=0;
i<m;
i++)
{
 scanf("%d",&b[i]);
 }
 for(int i=0;
i<n;i++)
{
 int ans=0;
 for(int j=0;
j<m;
j++)
{
 ans+=a[i][j]*b[j];
 }
 printf("%d\n",ans);
 }
 } 



Measured memory_bytes: 2104
#include"bits/stdc++.h"
#include<atcoder/segtree.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return -1;
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    rep(i, N)cin >> A[i];

    segtree<int, op, e> seg(A);
    rep(_, Q) {
        int T;
        cin >> T;
        if (T == 1) {
            int X, V;
            cin >> X >> V;
            X--;
            seg.set(X, V);
        }
        else if (T == 2) {
            int L, R;
            cin >> L >> R;
            L--;
            cout << seg.prod(L, R) << endl;
        }
        else {
            int X, V;
            cin >> X >> V;
            X--;
            auto f = [&](int val) {
                return val < V;
            };
            cout << seg.max_right(X, f) + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 22;

double p[MAXN];

int main()
{
    p[0] = 1;
    REP(MAXN - 1) p[i+1] = p[i] * 3.0;
    //REP(MAXN) cout << i << ":" << p[i] << endl;

    double n;
    int ans ;
    while(cin >> n && n)
        REP(MAXN)if(p[i] < n && p[i+1] >= n) { cout <<  i + 1 << endl; break;}

    return 0;
}

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

int main()
{
	int a,b,c,d,e,f,g;
	cin>>a>>b>>c;
	d = a + b;
	if(d<c)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

int main (){
	int n,k; cin>>n>>k;
	vector<int> v(200001);
	rep(i,n){
		int a; cin >> a;
		v[a]++;
	}
	sort(all(v));
	int count = 0;
	rep(i,200001){
		if (v[i]==0)continue;
		if (k < 200001 - i){
			for(int j = 0; j < 200001 - i - k; j++){
				count += v[i+j];
			}
			break;
		}else{
			break;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		sc.nextLine();
		System.out.println(sc.nextLine().contains("Y")?"Four":"Three");
		
	}
}


Measured memory_bytes: 23764
N = int(input())
S = input()

li1 = [0] * 26
li2 = [0] * 26

ans = 0

for s in S:
    si = ord(s) - 97
    li1[si] += 1

for s in S:
    si = ord(s) - 97
    li2[si] += 1
    li1[si] -= 1

    t = 0
    for i in range(26):
        if li1[i] > 0 and li2[i] > 0:
            t += 1

    ans = max(ans, t)

print(ans)

Measured memory_bytes: 8980
km, houseNum = map(int, input().split())

lst = list(map(int, input().split()))

maxDistance = 0

# まずリスト最初と最後の間の距離を求める
maxDistance = lst[0] + (km - lst[-1])

prevPos = lst[0]
for house in lst[1:]:
    maxDistance = max(maxDistance, house - prevPos)
    prevPos = house

print(km - maxDistance)

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

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

int dfs(int s, vector<vector<int>>& G, vector<bool>& calculated, vector<int>& memo){
    if(memo[s] > 0){
        if(!calculated[s]) return -1;
        else return memo[s];
    }
    memo[s] = 1;
    for(int v: G[s]){
        int ret = dfs(v, G, calculated, memo);
        if(ret == -1) return -1;
        memo[s] = max(memo[s], ret+1);
    }
    calculated[s] = true;
    return memo[s];
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N-1));
    REP(i, N){
        REP(j, N-1){
            cin >> A[i][j];
            --A[i][j];
        }
    }

    // 各試合を頂点と見立てて id を振る
    vector<vector<int>> id(N, vector<int>(N));
    int count = 0;
    REP(i, N){
        FOR(j, i+1, N){  // i < j とする
            id[i][j] = count;
            ++count;
        }
    }
    REP(i, N){
        REP(j, i) id[i][j] = id[j][i];
    }

    // 有向グラフを作る
    vector<vector<int>> G(N*(N-1)/2);
    REP(i, N){
        REP(j, N-2){
            G[id[i][A[i][j]]].push_back(id[i][A[i][j+1]]);
        }
    }

    // グラフの最長経路を探索
    int ans = 0;
    vector<int> memo(N*(N-1)/2, 0); // max length of path from v
    vector<bool> calculated(N*(N-1)/2, false); // cycle detection
    REP(i, N*(N-1)/2){
        int ret = dfs(i, G, calculated, memo);
        if(ret == -1){ // 閉路があったらだめ
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, ret);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 37632
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

constexpr int MAX_N = 10;

int dist, n, max_bound;
double p[MAX_N], h[MAX_N];

constexpr double EPS = 1e-8;

// ax^2 + bx + c = 0
vector<double> solve_quadratic_equation(double a, double b, double c) {
	if(abs(a) <= EPS) {
		if(abs(b) <= EPS) {
			if(abs(c) <= EPS) return {0};
			return {};
		}
		return {-c / b};
	}

	const double d = b * b - 4 * a * c;
	if(d < 0) return {};

	return {(-b - sqrt(d)) / (2 * a), (-b + sqrt(d)) / (2 * a)};
}

double calc_y(double vx, double vy, double x) {
	return - (1.0 / (2.0 * vx * vx)) * (x * x) + (vy / vx) * x;
}

double calc_vx(double x, double y, double theta) {
	const double a = (x * sin(theta) / cos(theta) - y);
	const double b = 0.0;
	const double c = - x * x / 2.0;

	double res = 0.0;
	for(const auto &e : solve_quadratic_equation(a, b, c)) {
		if(e > 0.0) {
			res = e;
			break;
		}
	}

	return res;
}

double calc_vy(double vx, double theta) {
	return vx * sin(theta) / cos(theta);
}

bool check(int bound, double theta) {
	const double jump_dist = dist / (bound + 1.0);
	const double vx = calc_vx(jump_dist, 0, theta);
	const double vy = calc_vy(vx, theta);

	for(int i = 0; i < n; ++i) {
		double s = 0.0;
		while(s + jump_dist + EPS < p[i]) {
			s += jump_dist;
		}

		if(calc_y(vx, vy, p[i] - s) + EPS < h[i]) return false;
	}
	
	return true;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	cin >> dist >> n >> max_bound;

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

	double ans = INT_MAX;
	for(int bound = 0; bound <= max_bound; ++bound) {
		double L = M_PI / 4.0, R = M_PI / 2.0;

		for(int i = 0; i < 100; ++i) {
			const double M = (L + R) / 2;

			if(check(bound, M)) {
				R = M;
			}
			else {
				L = M;
			}
		}

		const double vx = calc_vx(dist / (bound + 1.0), 0, L);
		const double vy = calc_vy(vx, L);
		ans = min(ans, vx * vx + vy * vy);
	}

	cout << sqrt(ans) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
int n,m,k,a[10][10],vis[10][10],ans;
int check(){
	int sum=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(a[i][j]==1&&vis[i][j]==0)
					sum++;
	return sum;
}
//void print(){
//	for(int i=1;i<=n;++i,cout<<endl)
//		for(int j=1;j<=m;++j)
//			cout<<vis[i][j]<<" ";
//}
void dfs(int x,int g){
	if(check()<k)
		return;
	if(x==n+m+1&&g==1){
		if(check()==k)
			ans++;//,print();
			return;
	}
	if(x==n+m+1&&g==0){
		return;
	}
	if(g==0){
		dfs(x+1,0),dfs(x+1,1);
		return;
	}
	int t=x;
	if(g==1)
	if(x>n){
		t=x-n;
		for(int i=1;i<=n;++i)
			vis[i][t]++;
		dfs(x+1,0);
		dfs(x+1,1);
		for(int i=1;i<=n;++i)
			vis[i][t]--;
	}
	else{
		for(int i=1;i<=m;++i)
			vis[x][i]++;
		dfs(x+1,0);
		dfs(x+1,1);
		for(int i=1;i<=m;++i)
			vis[x][i]--;
	}
}
int main(){
	char ch;
	cin>>n>>m>>k;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			cin>>ch,a[i][j]=(ch=='#'?1:0);
	dfs(1,0);
	dfs(1,1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    float res = 0;
    if (N % 2 == 0) {
        res = 0.5;
    } else {
        res = (N - N/2) / float(N);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    input = input[0]
    switch(input) {
        case 'A': {
            console.log('T');
            return;
        }
        case 'T': {
            console.log('A');
            return;
        }
        case 'C': {
            console.log('G');
            return;
        }
        case 'G': {
            console.log('C');
            return;
        }
        default: {
            return;
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

Measured memory_bytes: 580
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
vi vec[100005];
bool vis[100005]={0};
map<pair<int,int>,int>mm;

void dfs(int ind){
    for(auto it:vec[ind]){
        if(!vis[it]){
            vis[it]=1;
            dfs(it);
        }
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input_file.txt", "r", stdin);
    //freopen("output_file.txt", "w", stdout);
    #endif
    int i,j,k,l,n,test_case,m,r;
    test_case=1;
    //cin>>test_case;
    while(test_case--){
        cin>>n>>m;
        
        // memset(vis,0,sizeof vis);
        vi x(m),y(m),z(m);
        rep(i,0,m){
            cin>>x[i]>>y[i]>>z[i];
            x[i]--;
            y[i]--;
            mm[{x[i],y[i]}]=z[i];
            vec[x[i]].pb(y[i]);
            vec[y[i]].pb(x[i]);
        }
        int cnt=0;
        rep(i,0,n){
            if(vis[i]==0){
                vis[i]=1;
                cnt++;
                dfs(i);
            }
        }
        cout<<cnt;



    }
    
    return 0;
}

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

using namespace std;

int a, b;

int main() {
  scanf("%d %d", &a, &b);
  
  if(a <= 0 && b >= 0)
    puts("Zero");
  else if(a < 0 && b < 0) {
    if((abs(a) - abs(b) + 1) % 2 == 1)
      puts("Negative");
    else
      puts("Positive");
  } else
    puts("Positive");

  return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;
    vector<int>v;
    int last , d = 0 , ans = 0;

    for(int i=0; i<5 ;i++){
        int x;
        scn(x);
        int k = (x/10)*10;
        if(x != k) k += 10;

        if(k-x>d){
            d = k-x;
        }
        ans += k;
    }
    ans -= d;
    cout<<ans;
    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 256
/**
 * @author      : omgursocute
 * @created     : 21/02/2020
 * @task        : C
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main() {
	// freopen("C.inp", "r", stdin);
	// freopen("C.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n;
	map<string, int> mp;
	int ans = 0;
	cin >> n;
	while(n--) {
		string s;
		cin >> s;
		ans = max(ans, ++mp[s]);
	}
	
	for(auto p: mp)
		if(p.second == ans) cout << p.first << '\n';

	return 0;
}



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

class A
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int a = h[0], b = h[1];
		Console.WriteLine(a > 0 ? "Positive" : b >= 0 ? "Zero" : (b - a) % 2 == 1 ? "Positive" : "Negative");
	}
}


Measured memory_bytes: 13268
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
int main(){
  set <int> nums;
  int a[10000],b[10000],c[10000],d[10000],i,j,N,ch[10000]={0},cp[10000]={0},h[10000]={0},p=0,g=0,o[1000]={0},k=0,y=1;
  cin >> N;
  for(i=1;i<=N*(N-1)/2;i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  for(i=1;i<=N*(N-1)/2;i++){
    if(c[i]>d[i]){
      ch[a[i]]=ch[a[i]]+3;
    }
    else if(c[i]<d[i]){
      ch[b[i]]=ch[b[i]]+3;
    }
    else if(c[i]==d[i]){
      ch[a[i]]++;
      ch[b[i]]++;
    }
  }
  for(i=1;i<=N;i++){
    cp[i]=ch[i];
  }
  sort(cp+1,cp+N+1);
  reverse(cp+1,cp+N+1);
  for(i=1;i<=N;i++){
    if(k!=cp[i]){
    o[y]=cp[i];
    }
    k=cp[i];
    y++;
  }
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      if(o[i]==ch[j]){
	h[j]=i;
	
      }
    }
  }
  for(i=1;i<=N;i++){
    cout << h[i] << endl;
  }
}

Measured memory_bytes: 1396
from collections import defaultdict

N, A = map(int, input().split())
x = [int(x) for x in input().split()]

for i in range(N):
    x[i] -= A
X = max(max(x), A)

dp = [defaultdict(int) for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    for j in range(-N * X, N * X + 1):
        if - N * X <= j - x[i] <= N * X:
            dp[i + 1][j] = dp[i][j] + dp[i][j - x[i]]
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[N][0] - 1)


Measured memory_bytes: 21156
def main():
	a,b , c = map(int , input().split())
	ans = a*b*c
	ans = min(ans, abs(b*c*((a//2)-(a-(a//2)))))
	ans = min(ans, abs(a*c*((b//2)-(b-(b//2)))))
	ans = min(ans, abs(b*a*((c//2)-(c-(c//2)))))
	print(ans)
if __name__=="__main__":
	main()

Measured memory_bytes: 61948
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

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

    if (A == B)cout << "Draw" << endl;
    else if (A == 1 || (B != 1 && A > B))cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  double ans = (v[0] + v[1]) /2;
  for(int i=2;i<n;i++){
    ans = (ans + v[i])/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> V(n + 1), W(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> V[i] >> W[i];
    }
    lint q;
    cin >> q;
    vector<lint> v(q), l(q);
    lint L = 0;
    for (int i = 0; i < q; ++i) {
        cin >> v[i] >> l[i];
        chmax(L, l[i]);
    }
    int up = min(1LL << 10, n + 1);
    vector<vector<lint>> dp(up, vector<lint>(L + 1, 0));
    for (int i = 1; i < up; ++i) {
        int p = i / 2;
        for (int j = 0; j <= L; ++j) {
            chmax(dp[i][j], dp[p][j]);
            if (j - W[i] >= 0)
                chmax(dp[i][j], dp[p][j - W[i]] + V[i]);
        }
    }
    for (int i = 1; i < up; ++i) {
        for (int j = 1; j <= L; ++j) {
            chmax(dp[i][j], dp[i][j - 1]);
        }
    }
    for (int i = 0; i < q; ++i) {
        if (v[i] < (up)) {
            cout << dp[v[i]][l[i]] << "\n";
        } else {
            vector<lint> vv, ww;
            lint c = v[i];
            while (c >= (up)) {
                vv.push_back(V[c]);
                ww.push_back(W[c]);
                c /= 2;
            }
            int k    = vv.size();
            lint ret = 0;
            for (int j = 0; j < 1 << k; ++j) {
                lint vs = 0;
                lint ws = 0;
                for (int x = 0; x < k; ++x) {
                    if (j >> x & 1) {
                        vs += vv[x];
                        ws += ww[x];
                    }
                }
                if (ws <= l[i]) {
                    chmax(ret, vs + dp[c][l[i] - ws]);
                }
            }
            cout << ret << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 812564
H, W, A, B = map(int, input().split())

MOD = 1000000007

fac = [1, 1]
inverse = [0, 1]
ifac = [1, 1]
  
for i in range(2, H+W):
  fac.append((fac[-1] * i) % MOD)
  inverse.append((-inverse[MOD % i] * (MOD // i))  % MOD)
  ifac.append((ifac[-1] * inverse[i]) % MOD)

def f(n):
  return fac[B+n+H-A-1] * fac[W-B-1-n+A-1] * ifac[B+n] * ifac[H-A-1] * ifac[W-B-1-n] * ifac[A-1]

def sigma(func, frm, to):
  result = 0
  for i in range(frm, to+1):
    result += func(i)
  return result
 
print(sigma(f, 0, W-B-1)%MOD)


Measured memory_bytes: 27120
#include <iostream>
using namespace std;
int n,A[50];

bool solve(int m,int j){
    if (m==0)return 1;
    if(j>=n)return 0;
    int res=solve(m, j+1)||solve(m-A[j], j+1);
    return res;
}

int main(){
    int q,m;
    cin>>n;
    for (int i=0; i<n; i++)cin>>A[i];
    cin>>q;
    for (int i=0; i<q; i++) {
        cin>>m;
        if(solve(m, 0)){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108