akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int n, m;
	cin >> n >> m;
	if(n == m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
//#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 1000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;
bool IsPrime(ll num)//素数
{
    if (num < 2ll) return false;
    else if (num == 2ll) return true;
    else if (num % 2ll == 0ll) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3ll; i <= sqrtNum; i += 2ll)
    {
        if (num % i == 0ll)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
    int n;
    std::cin >> n;
    int ans=0;
    rep(i,n){
        int a;
        std::cin >> a;
        if(IsPrime(a))ans++;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3148
class Integer

  # O(min(n-k,k) log m)
  # combination: nPk / k! (mod p), note: m must be a prime number
  def cmb(k, m=10**9+7)
    n = self
    return 0 if k < 0 || n < k
    k = n - k if k > n - k
    n.prm(k, m) * k.prm(k,m).modinv(m) % m
  end

  # mod must be a prime number
  # O(log m)
  def modinv(mod = 10**9+7)
    pow(mod-2, mod)
  end

  # O(log n)
  def pow(n , mod = nil )
    a = self
    res = 1
    while n > 0
      if (n & 1) != 0
        res *= a
        res %= mod if mod
      end
      a *= a
      a %= mod if mod
      n >>= 1
    end
    res
  end

  # O(k)
  def prm(k, mod = nil)
    (0...k).reduce(1) do |res,i|
      res *= (self - i )
      res %= mod if mod
      res
    end
  end
end

class Facts

  def initialize(mod=10**9+7, n_max=1)
    @mod = mod
    @n_max = n_max
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    setup_table(n_max) if 1 < @n_max
  end

  def cmb(n,r)
    return 0 if r < 0 || n < r
    setup_table(n) if @n_max < n
    @fact[n] * (@factinv[r] * @factinv[n-r] % @mod) % @mod
  end

  def factorial(n)
    setup_table(n) if @n_max < n
    @fact[n]
  end

  def prm(n,k)
    setup_table(n) if @n_max < n
    @fact[n] * @factinv[n-k] % @mod
  end

  private
    # O(t)
    def setup_table(t)
      (@n_max+1).upto(t) do |i|
        @fact.push( @fact[-1] * i % @mod )
        @inv.push( -@inv[@mod % i] * (@mod / i) % @mod )
        @factinv.push( @factinv[-1] * @inv[-1] % @mod )
      end
      @n_max = t
    end
end

mod = 998244353

n, m, k = gets.to_s.split.map{|e|e.to_i}

# p (n-1).cmb(k, 998244353) * prm

a = Array.new(k+1)
b = Array.new(k+1)
# a[0] = m
b[-1] = m * (m-1).pow(n-1-k, mod)

k.times do |i|
  # a[i+1] = a[i] * m %  mod
  b[-2-i] = b[-1-i] * (m-1) % mod
end
# p a
# p b
ans = 0

f = Facts.new(mod)

(k+1).times do |i|
  # p (n-1).cmb(i, mod)
  ans += f.cmb(n-1, i) * b[i] % mod
end

# ans = 100
# 99.times do |i|
#   ans *= 99
# end

puts ans % mod

Measured memory_bytes: 22384
from itertools import groupby
n = int(input())
s = input()
ldx = 0
for i in range(n):
    if s[i] == "#":
        break
    else:
        ldx += 1

s = s[ldx:]
m = len(s)

if m > 1:
    rdx = m
    for i in range(m):
        if s[m-1-i] == ".":
            break
        else:
            rdx = m-1-i
    s = s[:rdx]
    m = len(s)

ans1 = s.count(".")
if m <= 1:
    print(0)
    exit()

w = []
b = []
for k, g in groupby(s):
    if k == "#":
        b.append(sum(1 for _ in g))
    else:
        w.append(sum(1 for _ in g))

S_b = [0]
S_w = [0]
m = len(b)
for i in range(m):
    S_b.append(S_b[-1] + b[i])
    S_w.append(S_w[-1] + w[i])

ans = float("inf")
for i in range(m+1):
    ans = min(ans, S_b[i] + (S_w[-1]-S_w[i]))
print(ans)


Measured memory_bytes: 13176
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	ll A;
	string S;
	cin >> A >> S;
	if (A >= 3200) {
		cout << S;
	}
	else {
		cout << "red";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  REP2(i,1,n+1) cin >> a[i];

  int cnt = 0;
  int now = 1;
  bool ok = false;
  map<int, bool> mp;
  REP(i,n){
    if(now == 2){
      ok = true;
      break;
    }
    if(mp[now] == true) {
      cout << -1 << endl;
      return 0;
    }
    mp[now] = true;
    now = a[now];
    cnt++;
  }

  if(now == 2) {
    ok = true;
  }

  if(ok) cout << cnt << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 8124
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
minimam = 10**12
for x in make_divisors(N)[::2]:
    minimam = min(minimam, int(x + N/x - 2))
print(minimam)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
int dp[2005][2005][2];
int main()
{
    int M, N;
    map < char , int > mp;
    string S, T;
    cin >> M >> N >> S >> T;
    mp['I'] = 1, mp['O'] = 0;
    fill_n(**dp, 2005 * 2005 * 2, -INF);
    dp[0][0][0] = 0;
    for(int i = 0; i <= M; i++) {
        for(int j = 0; j <= N; j++) {
            for(int k = 0; k < 2; k++) {
                if(i < M) {
                    if(S[i] == 'I' && k == 0) dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + 1);
                    else if(S[i] == 'O' && k == 1) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + 1);
                    else dp[i + 1][j][mp[S[i]]] = max(dp[i + 1][j][mp[S[i]]], mp[S[i]]);
                }
                if(j < N) {
                    if(T[j] == 'I' && k == 0) dp[i][j + 1][1] = max(dp[i][j + 1][1], dp[i][j][k] + 1);
                    else if(T[j] == 'O' && k == 1) dp[i][j + 1][0] = max(dp[i][j + 1][0], dp[i][j][k] + 1);
                    else dp[i][j + 1][mp[T[j]]] = max(dp[i][j + 1][mp[T[j]]], mp[T[j]]);
                }
            }
        }
    }
    int maxv = 0;
    for(int i = 0; i <= M; i++) {
        for(int j = 0; j <= N; j++) {
            maxv = max(maxv, dp[i][j][1]);
        }
    }
    cout << maxv << endl;
    return (0);
}



Measured memory_bytes: 34632
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S));

        sc.close();
    }

    static int solve(String S) {
        return (int) IntStream.range(1, S.length()).filter(i -> S.charAt(i) != S.charAt(i - 1)).count();
    }
}

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

int chk(int x) {
        for(int i = 2; i * i <= x; i++) if(x % i == 0) return 0;
        return 1;
}

int32_t main() {
        int x; cin >> x;
        for(int i = x; i; i++) if(chk(i)) {
                cout << i << endl;
                return 0;
        }
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int n; cin >> n;
  vector <int> A, B;
  while(n--) {
    int x, y; cin >> x >> y;
    A.pb(x+y); B.pb(x-y);
  }
  sort(all(A)); sort(all(B));
  int ans = max(A.back()-A[0], B.back()-B[0]);
  cout << ans << '\n';
}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1; // cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

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


int SelectionSort(vector<int>& a) {
    int N = a.size();
    int ans=0;
    for(int i=0; i<N; i++) {
	int minj = i;
	for(int j=i; j<N; j++) {
	    if(a[j] < a[minj] )
		minj = j;
	}
	if( i != minj ) {
	    swap(a[i],a[minj]);
	    ans++;
	}
    }
    return ans;
}

int main() {
    int n; cin >>  n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int ans = SelectionSort(a);

    for(int i=0; i<n; i++)
	if(i != n-1)
	    cout << a[i] << " ";
	else
	    cout << a[i] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3112
package main
import (
    "fmt"
)

func solveMeFirst(a uint32,b uint32) uint32{
    if (a < b) {
        return 0
    } else {
        return a - b
    }
}

func main() {
    var a, b uint32
    fmt.Scanf("%v %v", &a,&b)
    fmt.Println(solveMeFirst(a, b))
}



Measured memory_bytes: 512
N = int(input())
# N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N - 1)]

ans = [-1] * N
P = [set() for _ in range(N)]
for l in L:
    u, v, w = l
    P[u - 1].add(((v - 1), w))
    P[v - 1].add(((u - 1), w))

ans[0] = 0
F = [0] * (N + 1)
it = 0
po = 1
already = {0}
for _ in range(N + 1):
    if it > po:
        break
    u = F[it]
    it += 1
    for (v, w) in P[u]:
        if v in already:
            continue
        ans[v] = ans[u] if w % 2 == 0 else 1 - ans[u]
        F[po] = v
        already.add(v)
        po += 1

res = ""
for a in ans:
    res += "{}\n".format(a)
print(res)


Measured memory_bytes: 80776
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, M = map(int, input().split())
    ks = [[] for _ in range(M)]
    for i in range(M):
        k, *s = map(int, input().split())
        ks[i] = list(s)
    p = list(map(int, input().split()))
    comb = itertools.product([0, 1], repeat=N)

    ans = 0
    for c in comb:
        f = True
        for i in range(M):
            count = 0
            for j in ks[i]:
                count += c[j - 1]
            if count % 2 != p[i]:
                f = False
                break
        if f:
            ans += 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
W, H, x, y = map(int, input().split())
flag = 0

menseki = float(W * H * 0.5)

if x == W/2 and y == H/2:
    flag = 1

# elif x == W and (y == 0 or y == H):
#     flag = 1

# elif y == H and (x == 0 or x == H):
#     flag = 1

print(menseki,flag)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <array>

using namespace std;

int main(void) {
	vector<int> result;
	array<int, 2> input_add_number;
	while(cin >> input_add_number[0]){
		cin >> input_add_number[1];
		int add_result = input_add_number[0] + input_add_number[1];
		int count = 0;
		for(int i = 1; (add_result / i) != 0; i *= 10){
			count++;
		}
		result.push_back(count);
	}
	for(const auto element : result){
		cout << element << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		String S = I.next();
		long[] pref = new long[26]; //These are multiplicative, therefore long them
		long ans = 0;
		long mod = (long)(1e9)+7;
		for (int i = 0; i < N; i++) {
			pref[S.charAt(i)-'a']++;
		}
		for (int i = 1; i <= N; i++) {
			char cur = S.charAt(i-1);
			pref[cur-'a']--; //The letter is behind us now
			int avoid = cur-'a';
			long curans = 1;
			for (int j = 0; j < 26; j++) {
				if (j!=avoid) {
					curans*=(pref[j]+1); //Null set as well
					curans%=mod;
				}
			}
			ans+=curans;
			ans%=mod;
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string s;
int cnt[26];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    for(auto &i : s) cnt[i - 'a'] = 1;
    for(int i = 0 ; i < 26 ; i++)
        if(cnt[i] == 0) finish(s << char(i + 'a'));
    string t = s;
    if(next_permutation(t.begin(), t.end())){
        bool b = 0;
        for(int i = 0 ; i < 26 ; i++){
            if(b == 0) cout << t[i];
            if(t[i] > s[i]) b = 1;
        }
        cout << endl;
    }
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;

double EPS = 1e-10;



// ??????????????????????¶????????????????
double add(double a,double b){
	if(abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
	return a + b;
}

// ????¬?????????????????§???????
struct P {
	double x,y;
	P(){}
	P(double x,double y) : x(x), y(y){
	}
	P operator + (P p){
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p){
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d){
		return P(x * d, y * d);
	}
	double dot(P p){	// ??????
		return add(x * p.x, y * p.y);
	}
	double det(P p){	// ??????
		return add(x * p.y, -y * p.x);
	}
};

int main(){
	int n;
	vector<P> p(5);
	cin>>n;
	while(n--){
		rep(i, 5) cin>>p[i].x>>p[i].y;
		bool f1 =true, f2 = true;
		for(int i = 0; i < 3; i++){
			if((p[3]-p[i]).det(p[(i+1)%3]-p[i])>0
				!=(p[3]-p[(i+1)%3]).det(p[(i+2)%3]-p[(i+1)%3])>0){
				f1 = false;
				break;
			}
		}
		for(int i = 0; i < 3; i++){
			if(((p[4]-p[i]).det(p[(i+1)%3]-p[i])>0)
				!=((p[4]-p[(i+1)%3]).det(p[(i+2)%3]-p[(i+1)%3])>0)){
				f2 = false;
				break;
			}
		}
		cout<<(f1^f2?"OK":"NG")<<endl;
	}
}

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

const long long mod=(1e9)+7;
string a, b, res;

void _input(){
    cin>>a>>b;
}

void _solve(){
    if(a==b.substr(0, a.size()))
        res="Yes";
    else
        res="No";
}

void _output(){
    cout<<res;
}

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

//    freopen("input.inp", "r", stdin);

    _input();
    _solve();
    _output();

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>
#include <climits>
#include <ctime>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef double db;
#define lowbit(x) (x)&(-x)
#define gcd(a,b) __gcd(a,b)
#define sqre(x) (x)*(x)
#define mem(x,y) memset(x,y,sizeof(x))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
const int MaxN = 1e6 + 1005;
const int inf = 1e8;
const double PI = acos(-1.0);
const LL mod = 100000007;

priority_queue<int,vector<int> ,greater<int> > que;
vector<int> t[MaxN];

set<int> st[30],ss[30];
int Mix(char x){
	return x - 'a';
}
int main()
{
	string s,t;
	cin >> s >> t;
	int len = s.length();
	for(int i = 0 ; i < len ;i++){
		ss[Mix(s[i])].insert(Mix(t[i]));
		st[Mix(t[i])].insert(Mix(s[i]));
	}
	bool flag = false;
	for(int i = 0 ; i < 26 ; i++){
		if(st[i].size() > 1 || ss[i].size() > 1)flag = true;
	}
	if(!flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n, b, ans = 0;
	cin >> n;
	vector<int> a(n), c(n);
	for(int i = 0; i < n; ++i) cin >> a[i];
	for(int i = 0; i < n; ++i){cin >> b; ans += b; }
	for(int i = 0; i < n; ++i) cin >> c[i];

	for(int i = 1; i < n; ++i)
	{
		if (a[i - 1] + 1 == a[i])
		{
			ans += c[a[i - 1] - 1];
		}
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
    while (b) {
        ll t = a / b;
        a -= b * t;
        swap(a, b);
    }
    return a;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    ll d = a[0];
    for (int i = 1; i < n; ++i) {
        d = gcd(d, a[i]);
    }
    cout << d << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int dp[5001][5001];


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

	reverse(s.begin(), s.end());

	for (int i = 0; i < s.length(); i++){
		if (s[i] == s[0]){
			dp[i][0] = 1;
			dp[0][i] = 1;
		}else{
			dp[i][0] = 0;
			dp[0][i] = 0;
		}
	}

	for (int i = 1; i < s.length(); i++){
		for (int j = 1; j < s.length(); j++){
			if (s[i] == s[j]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}else{
				dp[i][j] = 0;
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < s.length(); i++){
		for (int j = i+1; j < s.length(); j++){
			if (i + dp[i][j] > j) ans = max(ans, j-i);
			else ans = max(ans, dp[i][j]);
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 97920
#include <iostream>
#include <math.h>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define int long long
inline int in() {int32_t x ; scanf("%d",&x) ; return x ; }
inline string getStr() {char ch[200000] ; scanf("%s",ch) ; return ch ; }
inline char getCh() {char ch ; scanf(" %c",&ch) ; return ch;}
template<class P, class Q> inline P smin(P &a, Q b) { if (b < a) a = b; return a; }
template<class P, class Q> inline P smax(P &a, Q b) { if (a < b) a = b; return a; }
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 10;
const int MA_LG = 21;
const int base = 29;
vector< pair<int,int> > g[MAX_N];
int res[MAX_N];
bool vis[MAX_N];
int mark[MAX_N];
inline bool dfs(int v , int cst = 0)
{
    
    mark[v] = 1;
    
    for (int pt = 0 ; pt < g[v].size() ; pt ++)
    {
        int u = g[v][pt].second , w = g[v][pt].first;
        if(!mark[u]) {if (dfs(u , w + cst)) return 1;}
        else if (mark[u] == 1 && w + cst < 0) return 1;
    }
    mark[v] ++;
    return 0;
}
int32_t main()
{
    int n = in() , m = in() , source = in();
    for (int i = 0 ; i < m ; i ++)
    {
        int v = in() , u = in() , w = in();
        g[v].push_back({u,w});
    }
    for (int v = 0 ; v < n ; v ++)
        res[v] = 1e18;
    res[source] = 0;
    if (dfs(0))
    {
        cout << "NEGATIVE CYCLE\n";
        exit(0);
    }
    priority_queue<pair<int , int >> pq;
    pq.push({0,source});
    res[source] = 0;
    while (!pq.empty())
    {
        int v = pq.top().second;
        int di = -pq.top().first;
        pq.pop();
        if (vis[v] && res[v] <= di) continue;
        vis[v] = true;
        res[v] = di;
        for (int pt = 0 ; pt < g[v].size() ; pt ++)
        {
            int u = g[v][pt].first , w = g[v][pt].second;
            if (res[u] > w + di)
            {
                res[u] = w + di;
                pq.push({-w-di , u});
            }
        }
    }
    for (int i = 0 ; i < n ; i ++)
    {
        if (res[i] >= 1e18)
        {
            cout << "INF\n";
        }else
        cout << res[i] << "\n";
    }
    
}

Measured memory_bytes: 19948
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=41;
ll f[N][N][N][N],g[N][N][N][N];
int vis[N][N][N][N];
int n,E[N][N];
void dfs(int a,int b,int c,int d) {
    if(vis[a][b][c][d]) return;
    vis[a][b][c][d]=1;
    if(b==a-1&&d==c-1) {
        g[a][b][c][d]=f[a][b][c][d]=1;
        return;
    }
    if(b<a||d<c) return;
    for(int x=a;x<=b;++x)
        for(int y=c;y<=d;++y) if(E[x][y]) {
            dfs(a,x-1,x+1,b),dfs(c,y-1,y+1,d);
            g[a][b][c][d]+=f[a][x-1][x+1][b]*f[c][y-1][y+1][d];
        }
    f[a][b][c][d]=g[a][b][c][d];
    for(int x=a;x<b;++x)
        for(int y=c+1;y<=d;++y) {
            dfs(a,x,y,d),dfs(x+1,b,c,y-1);
            f[a][b][c][d]+=f[a][x][y][d]*g[x+1][b][c][y-1];
        }
}
char str[N];
int main() {
    rd(n); n*=2;
    for(int i=1;i<=n;++i) {
        scanf("%s",str+1);
        for(int j=1;j<=n;++j) E[i][j]=str[j]-'0';
    }
    ll ans=0;
    for(int i=2;i<=n;++i) if(E[1][i]) {
        dfs(2,i-1,i+1,n);
        ans+=f[2][i-1][i+1][n];
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 52608
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    vector<int> p(N);
    for (int i = 0; i < N; i++)
        cin >> p[i];

    map<int, double> mp;
    for (int i = 1; i < 1001; i++) {
        mp[i] = i * (i + 1) / 2.0 / i;
    }

    vector<double> v(N);
    for (int i = 0; i < N; i++)
        v[i] = mp[p[i]];

    vector<double> imos(N + 1, 0.0);
    for (int i = 0; i < N; i++)
        imos[i + 1] = imos[i] + v[i];

    double ans = 0.0;
    for (int i = 0; i <= N - K; i++) {
        double sum = imos[i + K] - imos[i];

        ans = max(ans, sum);
    }

    cout << fixed << setprecision(30) << ans << endl;

    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int x, y, s;
	while (cin >> x >> y >> s && (x || y || s)) {
		vector<vector<int> > tax(1000, vector<int>(2));
		int maxi = 0, i = 0, a = 1, b;
		while (a < s / 2 + 1) {
			b = (s - (int)((a * (100 + x)) / 100.0) + 1) / ((100 + x) / 100.0);
			if (((int)((a * (100 + x)) / 100.0) + (int)((b * (100 + x)) / 100.0)) == s && b != 0) {
				tax[i][0] = a; tax[i][1] = b;
				maxi = max(maxi, (int)((tax[i][0] * (100 + y)) / 100.0) + (int)((tax[i][1] * (100 + y)) / 100.0));
				i++;
			}
			a++;
		} 

		cout << maxi << endl;
	}

	return 0;
}



Measured memory_bytes: 3220
def solve():
    X,N = map(int, raw_input().split())
    if N == 0:
        return  X

    P = map(int, raw_input().split())
    P = sorted(P)
    x = P[-1]
    for p in P:
        if X <= p:
            x = p
            break

    m = 1000000
    ans = 0
    for i in range(x-110, x+110):
        if i not in P:
            d = abs(X - i)
            if d < m:
                m = d
                ans = i
    return ans

print solve()

Measured memory_bytes: 64244
#include <stdio.h>

int main(void)
{
  int i, j, k;
  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
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int n[6];
    a=0;
    b=0;
    c=0;
    d=0;
    for (int i=0;i<6;i++) cin>>n[i];
    for (int i=0;i<6;i++){
        
        if (n[i]==1){
            a++;
        }
        else if (n[i]==2){
            b++;
        }
        else if (n[i]==3){
            c++;
        }
        else d++;
    }
    if (a==3 || b==3){
        cout<<"NO"<<endl;
    }
    else if(c==3 || d==3){
        cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; long long c; cin >> n >> c;
    long long x[n], v[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> v[i];
    long long f1[n], f2[n], b1[n], b2[n];
    f1[0] = max(0LL, v[0] - x[0]);
    f2[0] = max(0LL, v[0] - 2*x[0]);
    long long cur = v[0];
    for (int i = 1; i < n; i++) {
        cur += v[i];
        f1[i] = max(f1[i-1], cur - x[i]);
        f2[i] = max(f2[i-1], cur - 2 * x[i]);
    }
    b1[n-1] = max(0LL, v[n-1] - c + x[n-1]);
    b2[n-1] = max(0LL, v[n-1] - 2 * (c - x[n-1]));
    cur = v[n-1];
    for (int i = n-2; i >= 0; i--) {
        cur += v[i];
        b1[i] = max(b1[i+1], cur - (c - x[i]));
        b2[i] = max(b2[i+1], cur - 2 * (c - x[i]));
    }
    long long ans = max(f1[n-1], b1[0]);
    for (int i = 1; i < n; i++) ans = max({ans, f1[i-1] + b2[i], f2[i-1] + b1[i]});
    cout << ans << endl;
}


Measured memory_bytes: 4992
// ITP1_6_C:   Official House
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int b, f, r, v;;
	int house[5][4][11];
	int i, n;

	for (b = 1; b <= 4; b++) {
		for (f = 1; f <= 3; f++) {
			for (r = 1; r <= 10; r++) house[b][f][r] = 0;
		}
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
		house[b][f][r] += v;
	}

	for (b = 1; b <= 4; b++) {
		for (f = 1; f <= 3; f++) {
			for (r = 1; r <= 10; r++) printf(" %d", house[b][f][r]);
			putchar('\n');
		}
		if (b < 4) puts("####################");
	}
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	int n;
	ll k;
	cin >> n >> k;

	int a[n+1];
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	// for (int i = 0; i <= n; i++)
	// 	cout << a[i] << " ";
	// cout << endl;

	int vis[n+1], rem_town[n+1] = {0};
	memset(vis, -1, sizeof(vis));

	int cur = 1, step = 0;
	while (vis[cur] == -1) {
		vis[cur] = step;
		rem_town[step] = cur;
		step++;
		cur = a[cur];
	}

	// for (int i = 0; i <= n; i++)
	// 	cout << vis[i] << " ";
	// cout << endl;

	// for (int i = 0; i <= n; i++)
	// 	cout << rem_town[i] << " ";
	// cout << endl;

	int offset = vis[cur], cycle_len = step - vis[cur], rem;

	// deb(step);
	// deb(vis[cur]);
	// deb(cycle_len);

	if (k < offset) {
		cout << rem_town[k] << endl;

	} else {
		k -= (ll)offset;
		k = k % (ll)cycle_len;
		k += (ll)offset;

		// deb(k);
		// deb(offset);
		cout << rem_town[(int)k] << endl;
	}



	return 0;
}

Measured memory_bytes: 5988
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		
		Pattern pattern = Pattern.compile("^A[a-z]+C[a-z]+$");
		Matcher matcer = pattern.matcher(str);
		if(matcer.find()) {
			System.out.println("AC");
		} else {
			System.out.println("WA");
		}
		
	}

}

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

void solve(long long N, long long M, std::vector<long long> p, std::vector<std::string> S) {
    map<long long, long long> map;
    long long ansac = 0;
    long long answa = 0;
    for (long long i = 0; i < M; i++) {
        if (map.count(p[i]) == 0) {
            map[p[i]] = 0;
        }
        if (S[i] == "WA") {
            if (map[p[i]] != -1) {
                map[p[i]]++;
            }
        } else if (S[i] == "AC") {
            if (map[p[i]] != -1) {
                ansac++;
                answa += map[p[i]];
                map[p[i]] = -1;
            }
        }
    }
    printf("%lld %lld\n", ansac, answa);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> p(M);
    std::vector<std::string> S(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &p[i]);
        std::cin >> S[i];
    }
    solve(N, M, std::move(p), std::move(S));
    return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int comb(long long int n,long long int r){
    
}
int main(){
    long long int n,m=1000000000,ans;
    cin >> n;
    vector<long long int> x(n);
    for(long long int i=0;i<n;i++)    cin >> x[i];
    sort(x.begin(),x.end());
    for(int i=0;i<n-1;i++){
        if(x[n-1]/2>=x[i]){
            if(m>abs(x[n-1]-x[i])){
                  ans = i;
                  m = abs(x[n-1]-x[i]);
            }
        }
        else{
            if(m>x[i]) ans = i;
            m = x[i];
        }
    }
    cout << x[n-1] <<' '<< x[ans] << endl;
    return 0;
} 

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int data[600][600];
int data_s[600][600];
int L[200000];
int R[200000];
int p[100000];
int q[100000];

int main(int argc, char** argv) {
    int N, M, Q;
    cin >> N >> M >> Q;
    for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
    for (int i = 0; i < Q; i++) cin >> p[i] >> q[i];

    for (int i = 0; i < M; i++) data[L[i]][R[i]] += 1;
    for (int i = 0; i <= N; i++) for (int j = 0; j <= N; j++) {
        if (j != 0) {
            data_s[i][j] = data_s[i][j - 1] + data[i][j];
        } else {
            data_s[i][j] = data[i][j];
        }
    }
    for (int i = 0; i < Q; i++) {
        int ans = 0;
        for (int p2=p[i]; p2<=q[i]; p2++) {
            ans += data_s[p2][q[i]];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        int count = 1;
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i-1) != s.charAt(i)) count++;
        }

        System.out.println(s.isEmpty() ? 0 : count);
    }
}

Measured memory_bytes: 26324
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int ma=-1,cnt=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)=="A" ||s.substr(i,1)=="C" ||s.substr(i,1)=="G" ||s.substr(i,1)=="T" ){
			cnt++;
		}else{
			ma=max(cnt,ma);
			cnt=0;
		}
	}
	ma=max(cnt,ma);
	cout<<ma<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 160090;

int par[MAX_N], Rank[MAX_N], size[MAX_N];
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        Rank[i] = 0;
        size[i] = 1;
    }
}
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (Rank[x] < Rank[y])
    {
        par[x] = y;
        size[y] += size[x];
    }
    else
    {
        par[y] = x;
        size[x] += size[y];
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}
int main()
{
    map<int, int> mp1, mp2;
    int n, m;
    cin >> n >> m;
    init(n);
    int x[m], y[m], z[m];
    for (int i = 0; i < m; i++)
    {
        cin >> x[i] >> y[i] >> z[i];
        x[i]--,y[i]--;
        mp2[x[i]]++;
        mp2[y[i]]++;
        unite(x[i], y[i]);
    }
    for (int i = 0; i < m; i++)
    {
        mp1[find(x[i])]++;
        mp1[find(y[i])]++;
    }
    int sum = 0;
    cout << mp1.size() + (n - mp2.size()) << endl;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,temp,sum=0;
    cin>>n>>k;
    temp=k;
    if(k==1)
    {
         cout<<0<<endl;
    }
    else if(n>=k)
    {
        cout<<"1"<<endl;
    }
    else
    {
       int flag=1, num=n-1;
       while(temp>n)
       {
           sum=sum+num;
           temp=k-sum;
           flag++;
       }
    cout<<flag<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;

int main(){
  string s;
  long long q;
  cin >> s >> q;
  vector<vector<long long>> t(q,vector<long long>(2,0));
  vector<char> c(q);
  long long jyu =0;
  for(long long i = 0; i < q; i++){
    cin >> t[i][0];
    if(t[i][0]== 2){
      cin >> t[i][1] >> c[i];
    }
    if(t[i][0]==1){
      jyu++;
    }
    else{
      if(jyu%2==0){
        if(t[i][1]==1){
          s.insert(s.begin(),c[i]);
        }
        else{
          s.push_back(c[i]);
        }
      }
      else{
        if(t[i][1]==2){
          s.insert(s.begin(),c[i]);
        }
        else{
          s.push_back(c[i]);
        }
      }
    }
  }
  if(jyu %2 ==1){
    reverse(s.begin(),s.end());
  }
    cout << s << endl;

}


Measured memory_bytes: 13696
def prime_decomposition(n):
  i = 2
  d = {}
  while i * i <= n:
    while n % i == 0:
      n //= i
      if i not in d:
          d[i] = 0
      d[i] += 1
    i += 1
  if n > 1:
    if n not in d:
        d[n] = 1
  return d

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

A,B = map(int,input().split())
d = gcd(A,B)
p = prime_decomposition(d)
ans = 1
for i in p:
    ans += 1
print(ans)

Measured memory_bytes: 38640
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int T, N, K;
string S;
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;
    return 0;
}

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

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

    int oe = N % 2;
    vector<int> memo(N/2+1,2);

    memo[0] = 1;

    for(int i=0;i<N;++i)
    {
        int a;
        cin >> a;
        if (a==0)
        {
            if (oe == 1)
            {
                memo[a]--;
            }
            else
            {
                cout << 0 << endl;
                return 0;
            }
        }
        else
        {
            if (oe == 1)
            {
                if (a % 2 == 1)
                {
                    cout << 0 << endl;
                    return 0;
                }
                memo[(a+1)/2]--;
            }
            else
            {
                if (a % 2 == 0)
                {
                    cout << 0 << endl;
                    return 0;
                }
                memo[a/2]--;
            }
        }
    }

    long long ans = 1;

    if (N>1)
    {
        if (oe == 1)
        {
            for(int i=1;i<(N+1)/2;++i)
            {
                if (memo[i] != 0)
                {
                    cout << 0 << endl;
                    return 0;
                }
                ans = ans * 2 % (1000000007);
            }
        }
        else
        {
            ans = 2;
            for(int i=1;i<N/2;++i)
            {
                if (memo[i] != 0)
                {
                    cout << 0 << endl;
                    return 0;
                }
                ans = ans * 2 % (1000000007);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

void char_push(char *s, int *len, char inp)
{
   // printf("%d %c\n", *len, inp);
   s[*len] = inp;
   *len = *len + 1;
   s[*len] = '\0';
   return;
}

int main(void)
{
   int Q;
   char S[3 * 100000];
   char S_pre[2 * 100000];
   int T;
   int resF;
   char response;
   int Spre_i=0, Spost_i = 0, arrow = 0;

   scanf("%s", S);
   scanf("%d", &Q);

   for (Spost_i = 0; S[Spost_i] != '\0'; Spost_i++)
   {
   }

   // printf ("%d\n", Spost_i);
   for (int i = 0; i < Q; i++)
   {

      scanf("%d", &T);
      if (T == 1)
      {
         arrow = arrow ^ 1;
      }
      else
      {
         scanf("%d %c", &resF, &response);
         resF = 2 - resF;
         // resF = 0  -> 後ろに
         if ((resF ^ arrow) == 0)
         { char_push(S,&Spost_i, response );}
         else
         { char_push(S_pre, &Spre_i, response);}
         
      }
   }
   if (arrow == 0)
   {
      for (int i = 0; i < Spre_i; i++)
      {
         printf("%c", S_pre[Spre_i -1  - i]);
      }
      printf("%s\n", S);
   }
   else
   {
      for (int i = 0; i < Spost_i; i++)
      {
         printf("%c", S[Spost_i-1 - i]);
      }
      printf("%s\n", S_pre);
   }
   return 0;
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;
const int inv2 = 5e8+4;

int n,a[maxn],b[maxn],g[4020][4020],fac[maxn],ifac[maxn],inv[maxn];

#define f(x,y) g[x+2003][y+2003]

int c(int a,int b) {return 1ll*fac[a]*ifac[b]%mod*ifac[a-b]%mod;}

void gen() {
    int N=2e4;fac[0]=ifac[0]=inv[0]=inv[1]=1;
    for(int i=1;i<N;i++) {
        fac[i]=1ll*fac[i-1]*i%mod;
        if(i>1) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
        ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    }
}

int main() {
    read(n);gen();
    for(int i=1;i<=n;i++) read(a[i]),read(b[i]),f(-a[i],-b[i])++;
    for(int i=-2000;i<=2000;i++)
        for(int j=-2000;j<=2000;j++)
            f(i,j)=((f(i,j)+f(i-1,j))%mod+f(i,j-1))%mod;
    int ans=0;
    for(int i=1;i<=n;i++) ans=(ans+f(a[i],b[i]))%mod;
    for(int i=1;i<=n;i++) ans=(ans-c(2*(a[i]+b[i]),a[i]*2)+mod)%mod;
    write(1ll*ans*inv2%mod);
    return 0;
}


Measured memory_bytes: 72064