akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


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

	// 5個とって合成数にするには5の倍数を考えるべき？？
	// とりあえずやってみる。

	ll cnt = 0;
	vector<ll> debug;
	vector<bool> is_pnum(55556, true);
	repeq(i, 2, 55555) {
		if (cnt < N && is_pnum[i]) {
			if (i % 5 == 1) {
				cnt++;
				std::cout << i << " ";
				debug.push_back(i);
			}
			for (ll j = i + i; j <= 55555; j += i) {
				is_pnum[j] = false;
			}
		}
	}
	std::cout << endl;

	// 実験
	/*
	stack<tuple<ll, ll, ll>> st;
	st.push({ 0,0,0 });
	while (!st.empty()) {
		auto cur = st.top();
		st.pop();
		if (get<0>(cur) < 4) {
			for (ll i = get<2>(cur); i < N; i++) {
				auto tmp = cur;
				get<0>(tmp)++;
				get<1>(tmp) += debug[i];
				get<2>(tmp) = i + 1;
				st.push(tmp);
			}
		}
		else {
			for (ll i = get<2>(cur); i < N; i++) {
				std::cout << get<1>(cur) + debug[i] << " " << IsPrimeNumber(get<1>(cur) + debug[i]) << endl;
			}
		}
	}
	*/

	return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#define repeat(i,n)     for(int i=0; i<(n); ++i)
#define repeat1(i,n)    for(int i=1; i<=(n); ++i)
#define range(i,l,r)    for(int i=(l); i<(r); ++i)

using namespace std;
typedef long long llint;

int main() {
    int n, a, b;
    char    str[100005];
    int dom=0, os=0;

    scanf("%d%d%d", &n, &a, &b);
    scanf("%s", str);

    repeat(i, n) {
        if(str[i] == 'a' && dom + os < a + b) {
            ++ dom;
            printf("Yes\n");
        }
        else if(str[i] == 'b' && dom + os < a + b && os < b) {
            ++ os;
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    return 0;
}


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

int d(int num){
    int cnt = 1;
    while(num/10){
        num /= 10;
        cnt++;
    }
    return cnt;
}

bool is_squared(int num){
    for(int i = 1; i*i <= num; ++i){
        if(i*i==num) return true;
    }
    return false;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    
    for (int i = 0; i < d(b); ++i) a *= 10;

    if(is_squared(a+b)) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
n = int(input())
graph = {}
ans = []
np = set(range(1,n+1))
for i in range(n):
    t = list(map(int, input().split()))
    v = t[0]
    k = t[1]
    graph[v] = [t[i+2] for i in range(k)]
    np=np - set(graph[v])
    ans.append([v,None,None])

class Time:
    def __init__(self):
        self.time = 0
    def getTime(self):
        self.time += 1
        return self.time

t = Time()

visited = set()
def dfs(graph, target):
    visited.add(target)
    # ???????????????????¨????
    if ans[target - 1][1] is None:
        ans[target - 1][1] = t.getTime()
    if graph[target] == []:
        if ans[target - 1][2] is None:
            ans[target - 1][2] = t.getTime()        
        return
    for v in sorted(graph[target]):
        # # ???????????????????¨????
        if v not in visited:        
            if ans[v - 1][1] is None:
                ans[v - 1][1] = t.getTime()        
            visited.add(target)
            dfs(graph,v)
    if ans[target - 1][2] is None:
        ans[target - 1][2] = t.getTime()

if np == set():
    np = [1]
for v in sorted(list(np)):
    dfs(graph,v)
for row in ans:
    print(*row)

Measured memory_bytes: 7800
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

using ll = long long;

constexpr ll mod = 1000000007;

ll N;
ll T[MAX_N], A[MAX_N];
ll p[MAX_N];
bool fl;

int main()
{
  scanf( "%lld", &N );

  ll prv = 0;
  rep( i, N )
  {
    scanf( "%lld", T+i );

    if( prv != T[i] )
    {
      if( p[i] && p[i] != T[i] )
        fl = true;

      p[i] = T[i];
    }

    prv = T[i];
  }

  rep( i, N )
    scanf( "%lld", A+i );

  prv = 0;
  for( int i = N-1; i >= 0; --i )
  {
    if( prv != A[i] )
    {
      if( p[i] && p[i] != A[i] )
        fl = true;

      p[i] = A[i];
    }

    prv = A[i];
  }

  ll ans = 1;

  rep( i, N )
  {
    if( p[i] > A[i] || p[i] > T[i] )
    { fl = true; break; }

    if( !p[i] )
      ans = ans*std::min( T[i], A[i] ) % mod;
  }

  printf( "%lld\n", fl?0:ans );

  return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	vd a(n);
	rep(i, n) cin >> a[i];

	double tmp = 0;

	for (int i = 0; i < n; ++i) {
		tmp += 1.0 / a[i];
	}
	cout << setprecision(10) << 1.0 / tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

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

  int a, b, c, d;
  a = (int)s[0] - '0';
  b = (int)s[1] - '0';
  c = (int)s[2] - '0';
  d = (int)s[3] - '0';
  if (a + b + c + d == 7)
    cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
  else if (a - b + c + d == 7)
    cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
  else if (a + b - c + d == 7)
    cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
  else if (a + b + c - d == 7)
    cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
  else if (a - b - c + d == 7)
    cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
  else if (a - b + c - d == 7)
    cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
  else if (a + b - c - d == 7)
    cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
  else if (a - b - c - d == 7)
    cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch>'9'||ch<'0') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
}

char a[N],b[N];
int n,m,sa[N],sb[N],T;

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
	srand(time(0));
	time_tester(0);
#endif
	scanf("%s%s%d",a+1,b+1,&T);
	n=strlen(a+1);m=strlen(b+1);
	for(int i=1;i<=n;i++)
		if(a[i]=='A') sa[i]=(sa[i-1]+1)%3; else sa[i]=(sa[i-1]+2)%3;
//	for(int i=1;i<=n;i++) printf("%d ",sa[i]);puts("");
	for(int i=1;i<=m;i++)
		if(b[i]=='A') sb[i]=(sb[i-1]+1)%3; else sb[i]=(sb[i-1]+2)%3;
//	for(int i=1;i<=m;i++) printf("%d ",sb[i]);puts("");
	while(T--){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		puts((sa[b]-sa[a-1]-sb[d]+sb[c-1])%3?"NO":"YES");
	}
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}



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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    int n,l;
    int arr[100010];
    sc(n);sc(l);
    FOR(i,n){
        sc(arr[i]);
    }
    ii arz[100010];
    FOR(i,n-1){
        arz[i].first = arr[i] + arr[i+1];
        arz[i].second = i;
    }

    sort(arz, arz + (n-1));

    if(arz[n-2].first >= l){
        cout <<"Possible"<<endl;
        int idx = arz[n-2].second;
        FOR(i,idx){
            printf("%d\n", (i+1));
        }

        for(int i = n-2;i>=idx+1;i--){
            printf("%d\n", i+1);
        }

        printf("%d\n", idx+1);
    }else{
        cout <<"Impossible"<<endl;
    }


    return 0;
}





Measured memory_bytes: 2048
import numpy as np
import fractions
from functools import reduce
N,X = map(int,input().rstrip().split())
x = []
x = list(map(int,input().rstrip().split()))
x.append(X)
x.sort()


mini = []
for i in range(len(x)-1):
	mini.append(x[i+1] - x[i])
print(reduce(fractions.gcd, mini))

Measured memory_bytes: 25012
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        n %= 500;
        if (n <= a) {
            System.out.println("Yes");
        } else {

            System.out.println("No");
        }
    }
}


Measured memory_bytes: 79188
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}


ll n;


int main(int argc,char const* argv[])
{
  while(1)
    {
      cin >> n;
      if(!n) break;
      int ans=0;
      for(ll i=1;i*i<=n;i++)
	{
	  if(i*i==n) ans++;
	  for(int j=i;j*j<=n;j++)
	    {
	      if(i*i+j*j==n) ans++;
	      for(int k=j;k*k<=n;k++)
		{
		  if(i*i+j*j+k*k==n) ans++;
		  for(int l=k;l*l<=n;l++)
		    {
		      if(i*i+j*j+k*k+l*l==n) ans++;
		    }
		}
	    }
	}
      cout << ans << endl;
    }
  return 0;
}
			       
	



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

using namespace std;

int main() {
    stack<char> stk;
    string x;
    cin >> x;
    for (int i = 0; i < x.size(); i++) {
        if (!stk.empty())
            if (stk.top() == 'S' && x[i] == 'T') {
                stk.pop();
                continue;
            }
        stk.push(x[i]);
    }
    cout << (stk.empty() ? 0 : stk.size());
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int n;
    cin>>n;
    double x;
    double s=0;
    for(int i=0;i<n;i++){
        cin>>x;
        s+=1/x;
    }
    cout<<1/s<<endl;
    }

Measured memory_bytes: 256
def digitsum(s):
  s = str(s)
  a = 0
  for i in range(len(s)):
    a += int(s[i])
  return a

N, A, B = list(map(lambda x: int(x), input().split(" ")))

print(sum([j for j in range(N + 1) if A <= digitsum(j) <= B]))

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

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

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  llvec A(N+1);
  rep(i, N)cin >> A[i+1];
  for(ll i=K+1;i<=N;i++){
    if(A[i]>A[i-K])cout << "Yes"<<endl;
    else cout << "No"<<endl;
  }
  return 0;
}


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


int main() {
  int X; cin >> X;
  int ans = 0;

  if(X==1){
    cout << 1 << endl;
    return 0;
  }

  for(int i=2; i<=X; i++){
    int ex = i;
    int temp = ex*ex;
    if(temp > X) continue;
    while(temp<=X){
      ex = temp;
      temp *= i;
    }
    
    ans = max(ans, ex);

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll memo[100010];

int N,M,tmp;
int main(){
    cin >> N >> M;
    vector<int> a(100010);
    rep(i,M) cin >> tmp, a[tmp] = 1;
    
    memo[0] = 1;
    memo[1] = !a[1];
    
    repi(i,2,N) memo[i] = memo[i-1]*!a[i-1]%MOD + memo[i-2]*!a[i-2]%MOD;
    
    pr(memo[N]%MOD);
    
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << (x2 - (y2 - y1)) << ' ' << (y2 + x2 - x1) << ' ' << x1 - (y2 - y1) << ' ' << y1 + x2 - x1 << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(i64);
    println!("{}", n * (n + 1) / 2)
}


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

int main() {
    int N;
    cin >> N;
    vector<int> heights(N), dp(N);
    /* Read in first two heights for use in computing the base case */
    cin >> heights[0] >> heights[1];
    /* Compute base case n = 1 (n = 0 is already solved) */
    dp[1] = abs(heights[1] - heights[0]);
    for (int i = 2; i < N; ++i) {
		cin >> heights[i];
		/* Min total cost of reaching stone i is the min of the total costs
		   of going from either stone i-1,i-2 to stone i */
		dp[i] = min(dp[i-1] + abs(heights[i] - heights[i-1]),
					dp[i-2] + abs(heights[i] - heights[i-2]));
    }
    /* Answer is the min total cost of reaching stone N-1 */
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll h;
    cin >> h;

    ll ans = 0;
    ll tmp = 1;
    while (h) {
        ans += tmp;
        tmp *= 2;
        h /= 2;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
int main()
{
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);

if(c%4==2 && b%2==1) printf("YES");
else if(c%4==0 && b%2==0) printf("YES");
else printf("NO");
return 0;
}

Measured memory_bytes: 128
from collections import Counter
N,M = map(int,input().split())
l = []
for _ in range(N):
    l += list(map(int,input().split()))[1:]
c1 = Counter(l)
c2 = Counter(c1.values())
if N in c2.keys():
    print(c2[N])
else:
    print(0)

Measured memory_bytes: 3316
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

struct UF {
  vector<int> par;
  vector<int> sizes;
  UF(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return;
    }
    if (sizes[x] < sizes[y]) {
      swap(x, y);
    }
    par[y] = x;
    sizes[x] += sizes[y];
    sizes[y] = 0;
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};

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

  rep (i, n) {
    int k;
    cin >> k;
    rep (j, k) {
      int im;
      cin >> im;
      im -= 1;
      g[im].eb(i);
    }
  }
  UF uf(n);
  rep (i, m) {
    int sz = g[i].size();
    FOR (j, 1, sz) {
      uf.unite(g[i][0], g[i][j]);
    }
  }

  if (uf.size(0) == n) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  
  return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<stdio.h>
#include<fstream>
using namespace std;

int main()
{
	//ofstream fout;
	//fout.open("sum.txt");
	int i, k, j;
	while ( cin >> i >> k >> j )
	{
		long long a[i][k],b[k][j],out[i][j];
		

		for ( int a_zero_i = 0; a_zero_i < i; a_zero_i++)
		{
			for ( int a_zero_j = 0; a_zero_j < k; a_zero_j++)
			{
				a[a_zero_i][a_zero_j] = 0;
			}
		}
		
		for ( int b_zero_i = 0; b_zero_i < k; b_zero_i++)
		{
			for ( int b_zero_j = 0; b_zero_j < j; b_zero_j++)
			{
				b[b_zero_i][b_zero_j] = 0;
			}
		}
		
		for ( int out_zero_i = 0; out_zero_i < i; out_zero_i++)
		{
			for ( int out_zero_j = 0; out_zero_j < j; out_zero_j++)
			{
				out[out_zero_i][out_zero_j] = 0;
			}
		}
		
		for ( int in_ai = 0; in_ai < i; in_ai++)
		{
			for ( int in_ak = 0; in_ak < k; in_ak++)
			{
				cin >> a[in_ai][in_ak];
			}
		}
		
		for ( int in_bk = 0; in_bk < k; in_bk++)
		{
			for ( int in_bj = 0; in_bj < j; in_bj++)
			{
				cin >> b[in_bk][in_bj];
			}
		}
		
		for ( int out_i = 0; out_i < i; out_i++)
		{
			for ( int out_j = 0; out_j < j; out_j++)
			{
				for ( int sum = 0; sum < k; sum++)
				{
					out[out_i][out_j] += a[out_i][sum] * b[sum][out_j];
				}
			}
		}
		
		for ( int outp_i = 0; outp_i < i; outp_i++)
		{
			for ( int outp_j = 0; outp_j < j; outp_j++)
			{
				if ( outp_j != j-1)
				{
					//printf("%lld ",out[outp_i][outp_j]);
					cout << out[outp_i][outp_j] << " ";
				}
				else
				{
					//printf("%lld\n",out[outp_i][outp_j]);
					cout << out[outp_i][outp_j] << endl;
				}
			}
		}
	}
	return 0;
} 


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    string s;
    cin >> s;
    map<char,int> ee;
    REP(i, 4)
    {
        ee[s[i]]++;
    }
    if (ee.size() == 2)
    {
        if ((*ee.begin()).SE == 2)
        {
            cout << "Yes" << endl;
        }else
        {
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    for (auto ite = ee.begin(); ite != ee.end();++ite){

    }
}

Measured memory_bytes: 256
//OM
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <sstream>
#include <algorithm>
using  namespace  std;

#define  x first
#define  y second
#define  pb push_back
#define  mp make_pair
#define  PI (acos(-1.0))
#define  mem(a,b) memset(a,b,sizeof(a))
#define  Sort(x) sort(x.begin(),x.end())
#define  FOR(i, b, e) for(int i = b; i <= (int)(e); i++)
#define  FORR(i, b, e) for(int i = b; i >=(int)(e); i--)
#define  FORI(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define  pr(x) cout<<x<<"\n"
#define  prs(x) cout<<x<<" "
#define  pr2(x,y) cout<<x<<" "<<y<<"\n"
#define  pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define  ppr(a) cout<<a.x<<" "<<a.y<<"\n"
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef  long long ll;
typedef  pair <int, int> pii;
typedef  pair <double, double> pdd;
typedef  vector <int> vi;
typedef  vector <pii> vpii;


//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 Direction

#define  EPS 1e-9
#define  MAX 100007
#define  MOD 1000000007

int main()
{
//    READ("in.txt");
//    WRITE("out.txt");
    int T,n;
    int a[100];
    FOR(i,0,3)
    scanf("%1d",&a[i]);

    FOR(i,0,7){
        int res=a[0];
        FOR(j,1,3){
            int val=i&(1<<(j-1));
            //prs(val);
            if(val){
                res+=a[j];
            }
            else res-=a[j];
        }
        //pr(res);
        if(res==7){
           // prs(a[0]);
            printf("%d",a[0]);
            FOR(j,1,3){
            if(i&(1<<(j-1))){
                printf("+%d",a[j]);
            }
            else printf("-%d",a[j]);
            }
            pr("=7");
            return 0;
        }
    }
    return 0;
}



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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

template <class T>
struct Bit{
	std::vector<T> v;
	int n;
	Bit(int n_): n(n_){ v.assign(n_, 0); }
	// i must be 0 <= i < n
	T sum(int i){
		T s=0;
		while(i>0){ s += v[i]; i -= i & -i; }
		return s;
	}
	// i must be 1 <= i < n
	void add(int i, T x){
		while(i < n){ v[i] += x; i += i & -i; }
	}
};

// v: permutation of (1, ... , n)
int crossing(std::vector<int> &v){
	Bit<int> bit(v.size()+1);
	int count = 0;
	for(int i=0; i<v.size(); i++){
		count += i - bit.sum(v[i]);
		bit.add(v[i], 1);
	}
	return count;
}

int _main(){
	using namespace std;
	Bit<int> bit(10);
	bit.add(1,10);
	bit.add(5,20);
	assert(bit.sum(0)==0);
	assert(bit.sum(2)==10);
	assert(bit.sum(5)==30);
	assert(bit.sum(8)==30);

	vector<int> v = {3, 5, 1, 2, 4};
	assert(crossing(v)==5);
	return 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	dbg("pohe");

	Bit<int> bit(n+2);
	for(int i=0; i<n; i++){
		bit.add(i+1, a[i]);
		bit.add(i+2, -a[i]);
	}
	for(int j=0; j<k; j++){
		Bit<int> next(n+2);
		for(int i=0; i<n; i++){
			int b = bit.sum(i+1);
			dbg(j, i, b, max(0, i-b), min(n, i+b+1)+1, 1);
			next.add(max(0, i-b)+1, 1);
			next.add(min(n, i+b+1)+1, -1);
		}
		bit = next;
		int xmin = n;
		for(int i=0; i<n; i++){
			xmin = min(xmin, bit.sum(i+1));
		}

		if(xmin==n) break;
	}


	vector<int> ans(n);
	for(int i=0; i<n; i++){
		ans[i] = bit.sum(i+1);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, cnt = 0;
  string s;
  cin >> n >> s;
  REP(i, n - 2) {
    if(s.substr(i, 3) == "ABC")
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){

    /*---------*/
    /*  input  */
    /*---------*/

    int D;
    cin >> D;

    int i,j;
    vector<int> c(26+1);
    for( i = 1; i <= 26; i++ ){
        cin >> c[i];
    }

    vector< vector<int> > s(D+1, vector<int>(26+1));
    for( i = 1; i <= D; i++ ){
        for( j = 1; j <= 26; j++ ){
            cin >> s[i][j];
        }
    }

/*
    vector<int> t(365+1);
    for( i = 1; i <= D; i++ ){
        cin >> t[i];
    }
*/

    /*--------*/
    /*  calc  */
    /*--------*/

    long long int p = 0;
    int m = 0;
    int d;   // d: 1 --> D(365)
    vector<int> last(26+1);
    vector<int> real_last(26+1);
    long long int total = 0;
    long long int score;
    long long int ans = -10000000000;
    int x,k;

    for( d = 1; d <= D; d++ ){

        for( k = 1; k <= 26; k++ ) last[k] = real_last[k];
        ans = -100000000000;

        for( i = 1; i <= 26; i++ ){
            p = s[d][i];
            // minus
            m = 0;
            // last[]を更新
            last[i] = d;
            for( j = 1; j <= 26; j++ ){
                m += c[j] * ( d - last[j] );
            }
            score = p - m;
            if( score > ans ){
                x = i;
                ans = score;
            }
        }
        // real_last[]を更新
        real_last[ x ] = d;
        cout << x << endl;
    }


       

}


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n),c(n);
    for(int i = 0;i < n;i ++){
        cin >> s.at(i) >> p.at(i);
        c.at(i) = i;
    }

    vector<pair<pair<string,int>,int>> spc(n);

    for(int i = 0;i < n;i ++){
        spc.at(i).first.first = s.at(i);
        spc.at(i).first.second = p.at(i) * -1;
        spc.at(i).second = c.at(i);
    }

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

    for(int i = 0;i < n;i ++){
        cout << spc.at(i).second +1 << endl;
    }

}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int s1 = (a+d-1)/d;
    int s2 = (c+b-1)/b;

    if(s1 >= s2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int ans=0;
	for(int i=10;i<=b;i++)
	{
		if(i/10>=2&&i%10>=2&&(i/10)*(i%10)<=a)
			ans++;
	}
	printf("%d\n",ans); 
	return 0;
}


Measured memory_bytes: 256
import sys
l=[i.split() for i in sys.stdin]
d={}
for i in l:
  if i[0] not in d:
    d[i[0]]=[i[1]]
  else:
    d[i[0]].append(i[1])
for i in sorted(d.keys()):
  print(i)
  d[i]=list(map(int,d[i]))
  print(" ".join(map(str,sorted(d[i]))))



Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <functional>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
using namespace std;
#define		ll		long long
#define		ull		unsigned long long
#define		vi		vector<int>
#define 	vll		vector<long long>
#define		pii		pair<int,int>
#define		pll		pair<long long,long long>
#define		mii		map<int,int>
#define		mll		map<long long,long long>
#define		PB		push_back
#define		MP		make_pair
#define 	ff		first
#define		ss		second
#define		IT		iterator
#define		IOS		ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define		DB		cout<<"DEBUG "
#define		CS		<<" "<<
#define		LB		cout<<"\n"
#define		endl	"\n"

int a,b;

int main(){
	cin >> a >> b;
	if(a%b==0) cout << -1 << endl;
	else cout << a << endl;
}

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

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

class UnionFind
{
public:
  int n;
  vector<int> par, rnk;

  UnionFind(int n_)
  {
    n = n_;
    par.resize(n);
    rnk.resize(n);
    for(int i = 0; i < n; i++){
      par[i] = i;
      rnk[i] = 0;
    }
  }

  int find(int x)
  {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]){
      par[x] = y;
    }else{
      par[y] = x; 
      if(rnk[x] == rnk[y]) rnk[x]++;
    }
  }

  bool same(int x, int y)
  {
    return find(x) == find(y);
  }
};

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

	vi x(m), y(m), z(m);
	UnionFind uf(n);
	rep(i, 0, m){
		cin >> x[i] >> y[i] >> z[i];
		x[i]--; y[i]--;
		uf.unite(x[i], y[i]);
	}

	set<int> st;
	rep(i, 0, n){
		st.insert(uf.find(i));
	}

	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
double dist[1005],x[1005],y[1005],r[1005];
vector< pair<ll,double> >adj[1005];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>x[0]>>y[0]>>x[1]>>y[1];
    cin>>n;n+=2;
    for(ll i=2;i<n;i++)cin>>x[i]>>y[i]>>r[i];
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            double dist = hypot(x[i]-x[j],y[i]-y[j]) - r[i] - r[j];
            dist=max(dist , 0.0);
            adj[i].push_back({j,dist});
            adj[j].push_back({i,dist});
        }
        dist[i]=(1.0e+12);
    }
    priority_queue< pair<double,ll> > pq;
    pq.push({0,0});
    dist[0]=0;
    while(!pq.empty()){
        ll u = pq.top().second;
        pq.pop();
        for(auto &ele:adj[u]){
            if(dist[ele.first] > dist[u] + ele.second ){
                dist[ele.first] = dist[u] + ele.second;
                pq.push({-dist[ele.first] , ele.first});
            }
        }
    }
    cout<<fixed<<setprecision(18)<<dist[1];
}

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

#define LL long long

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

	int a,b;
	cin>>a>>b;

	for(int i=0;i<16;i++){
		if(i%2==0){
			if(a>0){a--;}
		}else{
			if(b>0){b--;}
		}
	}
	if(a==0 && b==0){cout<<"Yay!"<<endl;}
	else{cout<<":("<<endl;}
}

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

int main()
{
    int T ;
    while(1)
    {
        double sum = 0.00 ;
        cin >> T ;
        if(T == 0) break ;
        else
        {
            vector <double> v ;
            for(int i = 0 ; i < T ; i++)
            {
                double G ;
                cin >> G ;
                sum += G ;
                v.push_back(G) ;
            }
            double mean = sum/T ;
            //cout << mean << endl ;
            sum = 0.00 ;
            for(int i = 0 ; i < T ; i++)
            {
                sum += (v[i] - mean)*(v[i] - mean) ;
            }
            double variance = sum/T ;
            //cout << variance << endl ;
            double ans = sqrt(variance) ;
            printf("%.8lf\n" , ans) ;
        }
    }
}


Measured memory_bytes: 3280
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int l = 0;
                int[] a = new int[l];
		int[] b = new int[l];

		do {
			int x = sc.nextInt();
			if (x == 0) {
				break;
			}
			l++;
			a = new int[l];
			for (int i = 0; i < l - 1; i++) {
				a[i] = b[i];
			}
			a[l - 1] = x;
			b = new int[l];
			for (int i = 0; i < l; i++) {
				b[i] = a[i];
			}
		} while (true);

		for (int i = 0;i < b.length;i++) {
			System.out.println("Case " + (i+1) + ": " + b[i]);
		}
	}
}

Measured memory_bytes: 162308
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int a;
    cin >> a;
    double ans = (double)(a/2+a%2)/(double)a;
    printf("%f",ans);
    return 0;
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  double base = 1 / (double)n;
  double cur = 2;
  double tot = 0;
  for (int i = n; i >= 1; i--) {
    if (i >= k)
      tot += base;
    else {
      while (i * cur < k) {
        cur *= 2;
      }
      tot += base / cur;
    }
  }
  printf("%.20f\n", tot);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

#define VMAX 1000000
#define KMAX 30

using namespace std;

	int K[KMAX];
	char T[KMAX][VMAX];

void eratos(int n,bool prime[]){
	for(int i=0;i<=n;i++)prime[i]=false;
	for(int i=3;i<=n;i+=2)prime[i]=true;
	prime[2]=true;
	int lim=(int)sqrt((double)n)+1;
	for(int i=3;i<=lim;i+=2){
		if(!prime[i])continue;
		for(int j=i+i;j<=n;j+=i)prime[j]=false;
	}
}	

int main(){
	bool prime[VMAX+1];
	eratos(VMAX,prime);
	
	int k,v;

	while(cin>>k>>v && !(k==0 && v==0)){
		for(int i=0;i<k;i++)cin>>K[i];
		
		for(int j=0;j<=v;j++)T[0][j]=0;
		for(int j=K[0];j<=v;j+=K[0])T[0][j]=1;
		for(int i=0;i<k;i++)T[i][0]=1;
		
		for(int i=1;i<k;i++){
			for(int j=1;j<K[i];j++)T[i][j]=T[i-1][j];
			for(int j=K[i];j<=v;j++){
				T[i][j]=(T[i-1][j] | T[i][j-K[i]]);
			}
		}
		int ans=-1;
		for(int i=v;i>=2;i--){
			if(prime[i] && T[k-1][i]){
				ans=i;
				break;
			}
		}
		if(ans==-1)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}

}

Measured memory_bytes: 31428
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr;
            while (IsInput(out arr))
            {
                if (arr[0] < 0 || arr[1] < 0) { Console.WriteLine("F"); continue; }

                var x = arr[0] + arr[1];
                if(x >= 80) Console.WriteLine("A");
                else if(x >= 65) Console.WriteLine("B");
                else if(x >= 50) Console.WriteLine("C");
                else if(x >= 30) Console.WriteLine(arr[2] >= 50 ? "C" : "D");
                else Console.WriteLine("F");
            }
        }

        private static bool IsInput(out int[] arr)
        {
            var s = Console.ReadLine();
            if (s == "-1 -1 -1") { arr = null; return false; }

            arr = s.Split(' ').Select(int.Parse).ToArray();
            return true;
        }
    }
}


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

using namespace std;

const int BUILDINGS = 4;
const int FLOORS = 3;
const int ROOMS = 10;

int buildings[BUILDINGS][FLOORS][ROOMS];

void print_building(int i) {
	for (int j = 0; j < FLOORS; ++j) {
		for (int k = 0; k < ROOMS; ++k) {
			cout << ' ' << buildings[i][j][k];
		}
		cout << '\n';
	}
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		buildings[b-1][f-1][r-1] += v;
	}
	print_building(0);
	for (int i = 1; i < BUILDINGS; ++i) {
		cout << "####################\n";
		print_building(i);
	}
}


Measured memory_bytes: 3084