akhauriyash/Code-Regression huggingface dataset:
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];

ll dp[MAX][5];



int main()
{
 

//cout << setprecision(15) << fixed;
fast

	cin >> n;
	fr(i,1,1+n)
	{
		ll a,b,c;
		cin >> a >> b >> c;
		dp[i][1] = max(dp[i-1][2],dp[i-1][3])+a;
		dp[i][2] = max(dp[i-1][1],dp[i-1][3])+b;
		dp[i][3] = max(dp[i-1][2],dp[i-1][1])+c;
	}
	ll ans = -1;

	fr(i,1,4)
		ans = max(dp[n][i],ans);
	cout << ans;



 
  return 0;
 
}


Measured memory_bytes: 4352
import itertools

MOD = 10 ** 9 + 7

H, W = map(int, input().split())
A = [input() for _ in range(H)]

dp = [[0 for _ in range(W + 1)] for _ in range(H + 1)]
dp[1][1] = 1

it = itertools.product(range(H), range(W))
next(it)
for h, w in it:
    if A[h][w] == '.':
        dp[h + 1][w + 1] = (dp[h][w + 1] + dp[h + 1][w]) % MOD
print(dp[H][W])


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int sum=6;
    int n;
    cin>>n;
    sum-=n;
    cin>>n;
    sum-=n;
    cout<<sum;
    return 0;
}



Measured memory_bytes: 256
// Echo.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
	int N;
	string S;
	string frontS, backS;
	cin >> N;
	cin >> S;
	if (N % 2 == 1) {
		cout << "No" << endl;
		exit(0);
	}
	frontS = S.substr(0, N / 2);
	backS = S.substr(N / 2, N);
	if (frontS.compare(backS) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3580
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from bisect import bisect_left, bisect_right
def resolve():
    n, m = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB.sort()
    AB.append([INF, 0])
    X = [0] * (n + 1)
    X[0] = AB[0][1]
    for i in range(n, 0, -1):
        AB[i][1] ^= AB[i - 1][1]

    E = [[] for _ in range(n + 1)]
    for i in range(m):
        u, v = map(int, input().split())
        l = bisect_left(AB, [u, 0])
        r = bisect_right(AB, [v, 1])
        E[l].append((r, i + 1))
        E[r].append((l, i + 1))

    ans = []
    used = [False] * (n + 1)
    def dfs(v):
        used[v] = True
        res = AB[v][1]
        for nv, i in E[v]:
            if used[nv]:
                continue
            r = dfs(nv)
            if r:
                ans.append(i)
            res ^= r
        return res

    for v in range(n + 1):
        if used[v]:
            continue
        if dfs(v):
            print(-1)
            return

    print(len(ans))
    if ans:
        print(*sorted(ans))
resolve()

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  string s; cin >> s;
  map<string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;
  cout << mp[s] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;


int main(){
    cout << fixed << setprecision(10);
    
    double R;
    cin >> R;
    
    cout << 2 * R * 3.14159265359;

    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0)
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  IO;
  int n; ll W; cin>>n>>W;
  vector<ll> dp(n*1000+1, 1e15);
  dp[0] = 0;

  for (int i = 1; i <= n; i++) {
    ll w, v; cin>>w>>v;
    for (int tval = n*1000 - v; tval >= 0; tval--) {
      dp[tval + v] = min(dp[tval + v], dp[tval] + w);
    }
  }

  for (int tval = n*1000; tval >= 0; tval--) if (dp[tval] <= W) return cout<<tval<<"\n", 0;
}


Measured memory_bytes: 1024
n = int(input())
A = list(map(int,input().split()))

col = [0 for _ in range(9)]
for a in A:
  if a >= 3200:
    col[8] += 1
    continue
  col[a//400] = 1
  
ans_min = sum(col[:-1])
if ans_min == 0 and col[-1] != 0:
  ans_min = 1
print(ans_min, sum(col))



Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int W,H,N;
  cin >> W >> H >> N;
  vector<int> x(N),y(N),a(N);
  rep(i,N) cin >> x[i] >> y[i] >> a[i];
  int lx = 0;
  int rx = W;
  int ly = 0;
  int ry = H;
  rep(i,N)
  {
    if(a[i]==1) lx = max(x[i],lx);
    else if(a[i]==2) rx = min(x[i],rx);
    else if(a[i]==3) ly = max(y[i],ly);
    else ry = min(y[i],ry);
  }
  int yoko = rx - lx;
  int tate = ry - ly;
  if(yoko<=0||tate<=0)
  {
    cout << 0 << endl;
    return 0;
  }
  cout << tate*yoko << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	bool ok = false;
	for (int i = 0; i * 4 <= n; i++)
		if ((n - i * 4) % 7 == 0)
			ok = true;
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
n,a,b = gets.split(" ").map(&:to_i)
if (b-a)%2 == 0 then
    print (b-a)/2
else
    if a-1 < n-b then
        if b-1 > a + (b-a-1)/2 then
            print a + (b-a-1)/2
        else
            print b-1
        end
    else
        if n-a > n-b+1 + (-a+b-1)/2 then
            print n-b+1 + (-a+b-1)/2
        else
            print n-a
        end
    end
end

Measured memory_bytes: 1788
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int X;
    cin >> X;
    int count = 0;
    count += 1000 * (int)(X / 500);
    X -= 500 * (int)(X / 500);
    while (X >= 5)
    {
        count += 5 * (int)(X / 5);
        X -= 5 * (int)(X / 5);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long n,w;
	cin >> n >> w;
	long long weight[n];
	long long value[n];
	for(long long i = 0; i<n; i++)
	{
		cin >> weight[i] >> value[i];
	}
	long long knap[n+1][w+1];
	for(long long i = 0; i<=n; i++)
	{
		for(long long j = 0; j<=w; j++)
		{
			if(i == 0 || j == 0)
			{
				knap[i][j] = 0;
			}
			else if(weight[i-1] <= j)
			{
				knap[i][j] = max(value[i-1]+ knap[i-1][j-weight[i-1]], knap[i-1][j]);
			}
			else
			{
				knap[i][j] = knap[i-1][j];
			}
		}
	}
	cout << knap[n][w];
}

Measured memory_bytes: 79104
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=[]
for i in range(N):
    B.append(int(input()))

import numpy as np
A=np.array(A)

bingo=np.zeros((3,3),int)
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            bingo[i][j]=1

flag=False
for x in bingo.sum(axis=1):
    if x ==3:
        flag=True
for x in bingo.sum(axis=0):
    if x ==3:
        flag=True
y=0
for i in range(3):
    y+=bingo[i,i]
if y==3:
    flag=True
y=0
for i in range(3):
    y+=bingo[2-i,i]
if y==3:
    flag=True

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

Measured memory_bytes: 21056
#include<bits/stdc++.h>
using namespace std;
//#define MAX_N 200010
int main(){
	int n;
	cin>>n;
	int arr[105000];
	int p,q;
	cin>>p>>q;
	for(int i=1;i<=q;i++){
		int k;
		cin>>k;
		///k--;
		arr[k]++;
	}
	for(int i=1;i<=n;i++){
		if(arr[i]+p-q<=0)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <int> P(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> P[ii];
	}
	vector <int> Q(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> Q[ii];
	}

	vector <int> v;
	for (int ii = 1; ii <= N; ++ii){
		v.push_back(ii);
	}

	int a = -1;
	int b = -1;
	int cnt = 0;
	do {
		//Pと比較
		if (a == -1){
			bool ok = true;
			for (int ii = 0; ii < N; ++ii){
				if (P[ii]!=v[ii]){
					ok = false;
					break;
				}
			}
			if (ok){
				a = cnt;
			}
		}

		//Qと比較
		if (b == -1){
			bool ok = true;
			for (int ii = 0; ii < N; ++ii){
				if (Q[ii]!=v[ii]){
					ok = false;
					break;
				}
			}
			if (ok){
				b = cnt;
			}
		}

		cnt++;
	} while(next_permutation(v.begin(), v.end()));


	cout << abs(a - b) << "\n";

	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

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

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

using namespace std;

int main() {
	int p[] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 };
	int n;
	cin >> n;
	int a[20] = {};
	for (int i = 2; i <= n; i++) {
		int j = 0, k = i;
		while (k > 1 && j < 15) {
			if (k%p[j]) j++;
			else {
				k /= p[j];
				a[j]++;
			}
		}
	}
	int x = upper_bound(a, a + 15, 2, greater<int>()) - a;
	int y = upper_bound(a, a + 15, 4, greater<int>()) - a;
	int z = upper_bound(a, a + 15, 14, greater<int>()) - a;
	int u = upper_bound(a, a + 15, 24, greater<int>()) - a;
	int v = upper_bound(a, a + 15, 74, greater<int>()) - a;
	cout << v + u * (x - 1) + z * (y - 1) + y * (y - 1) / 2 * (x - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, a[200005], ans;
bool b[200005][30],sum[30];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j < 30; j++) {
			if ((a[i] >> j) & 1)b[i][j] = true;
		}
	}
	int r = 0;
	for (int i = 0; i < 20; i++) {
		if (b[0][i])sum[i] = true;
	}
	for (int i = 0; i < n; i++) {
		while (r + 1 < n) {
			r++;
			for (int j = 0; j < 20; j++) {
				if (sum[j] && b[r][j]) {
					for (int k = 0; k < j; k++) {
						if (b[r][k])sum[k] = false;
					}
					r--;
					goto loop;
				}
				else if (b[r][j])sum[j] = true;
			}
		}
	loop:;
		ans += r - i + 1;
		for (int j = 0; j < 20; j++) {
			if (b[i][j])sum[j] = false;
		}
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 7680
# 13:45~
n, q = map(int, input().split())
s = input()

queries = []
for i in range(q):
    l, r = map(int, input().split())
    queries.append((l, r))

count = [0]*(n+1)
count[0] = 0
aFlag = False
for i, c in enumerate(s):
    count[i+1] = count[i]

    if c == 'C' and aFlag:
        count[i+1] = count[i] + 1

    if c == 'A':
        aFlag = True
    else:
        aFlag = False

for i, query in enumerate(queries):
    l = query[0]
    r = query[1]
    print(count[r] - count[l])

Measured memory_bytes: 19776
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P>v;
ll n,a,b,cnt;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back(P(b,a));
    }
    sort(v.begin(),v.end());
    for(auto x:v){
        cnt+=x.second;
        if(cnt>x.first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 6128
#include <stdio.h>

int main(void)
{
     int a,b;

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

     if(a < b){
       printf("a < b\n");
     }else if(a > b){
       printf("a > b\n");
     }else if(a == b){
       printf("a == b\n");
     }

    return 0;
}

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

using namespace std;


void solve() {
    int a; string s;
    cin >> a >> s;
    cout << (a<3200? "red": s);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
      
        int n; cin >> n;
        int m; cin >> m;
        int dsu[n + 1];
        for(int i = 0; i <= n; i++)
        	dsu[i] = i;
        function<int(int)> root = [&](int a){
        	if(dsu[a] == a)
        		return a;
        	return dsu[a] = root(dsu[a]);
        };
        function<void(int, int)> update = [&](int a, int b){
        	a = root(a);
        	b = root(b);
        	dsu[a] = b;
        };
        for(int i = 0; i < m; i++){
        	int x, y; cin >> x >> y;
        	update(x, y);
        }
        int ansr = 0;
        for(int i = 1; i<= n; i++)
        	if(dsu[i] == i)
        		ansr++;
        cout << ansr - 1<< '\n';
        return 0;
}

Measured memory_bytes: 4400
///
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Mar 14 22:33:11 2018
//
package main

import (
	"fmt"
)

type item struct {
	v, w int
}

var N, W int
var items []item

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	fmt.Scan(&N, &W)

	items = make([]item, N+1)
	for i := 1; i <= N; i++ {
		fmt.Scan(&items[i].v, &items[i].w)
	}

	dp := make([][]int, N+1)
	for i := range dp {
		dp[i] = make([]int, W+1)
		for j := range dp[i] {
			dp[i][j] = -1
		}
	}

	dp[0][0] = 0
	for i := 1; i <= N; i++ {
		item := items[i]
		for w := 0; w <= W; w++ {
			if w-item.w >= 0 && dp[i-1][w-item.w] != -1 {
				dp[i][w] = max(dp[i-1][w], dp[i-1][w-item.w]+item.v)
			} else {
				dp[i][w] = dp[i-1][w]
			}
		}
	}

	max_val := 0
	for i := range dp[N] {
		max_val = max(max_val, dp[N][i])
	}

	fmt.Println(max_val)
}



Measured memory_bytes: 9692
S = input()

   
ans = 0
for i in range(2 ** (len(S)-1)):
    oparr = []
    for j in range(len(S)-1):
        if (i >> j) & 1:
            oparr.insert(0,"+")
        else:
            oparr.insert(0,"")
    oparr.append("")
    tmp = ""
    for k in range(len(S)):
        tmp += S[k] + oparr[k]
    ans += eval(tmp)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	n%=10;
	if(n==2 || n==4||n==5||n==7||n==9)
		cout<<"hon\n";
	else if(n==3)
		cout<<"bon\n";
	else
		cout<<"pon\n";
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,w; cin >> n >> w;
    vvc<ll> dp(n+1,vc<ll>(w+1,0));
    rep(i,n){
        int a,b; cin >> a >> b;
        rep(j,w+1){
            if(j+a <= w) chmax(dp[i+1][j+a],dp[i][j]+b);
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 80256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string a,b;
    cin>>a>>b;
    string s=a+b;
    int n=stoi(s);
    bool answer=false;
    rep(i,1000) {
        if(i*i==n) answer=true;
    }
    if(answer) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	sort(s.begin(),s.end());
	if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]){
		cout<< "Yes";
	}else{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
void solve() {
	string s; getline(cin, s);
	for1(a, 25) {
		if (a % 2 == 0 || a % 13 == 0)continue;
		for0(b, 26) {
			string s1;
			for (char ch : s)if (ch != ' ')s1 += 'a' + ((ch - 'a') * a + b) % 26; else s1 += ' ';
			if (s1.substr(0, 5) == "this " || s1.substr(0, 5) == "that " || s1.find(" this ") < s.size() || s1.find(" that ") < s.size() || s1.substr(s1.size() - 5, 5) == " this" || s1.substr(s1.size() - 5, 5) == " that") {
				cout << s1 << endl;
				return;
			}
		}
	}
}
signed main() {
	string n; getline(cin, n);
	for0(i, stoi(n))solve();
}


Measured memory_bytes: 3148
from collections import deque

n,q = map(int,input().split())
edge = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

ans = [0] * n
for i in range(q):
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x


isVisited = [False] * n
dq = deque([0])
isVisited[0] = True
while len(dq) > 0:
    parent = dq.popleft()
    for j, son in enumerate(edge[parent]):
        if isVisited[son]:
            continue
        ans[son] += ans[parent]
        isVisited[son] = True
        dq.append(son)

print(' '.join(map(str, ans)))


Measured memory_bytes: 67204
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
 
int dfs(int a, int b){
  while(a >= b){
    if(a % b == 0){
      a /= b;
    }
    else{
      a %= b;
    }
  }
  return a;
}
 
 
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  int N;
  cin >> N;
  if(N == 2){
    cout << 1 << endl;
    return 0;
  }
  int ans = 0;
  for(int i=2;i*i<=(N-1);i++){
    if((N-1) % i == 0){
      ans += 2;
      if(i*i == N-1){
        ans--;
      }
    }
  }
  for(int i=2;i*i<=N;i++){
    if(N % i == 0){
      if(dfs(N, i) == 1) ans++;
    }
  }
  cout << ans+2 << endl;
  
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main() {
	double n=0.5,m=6,n2=30;
	int a,b,n4,e=0;
	cin>>n4;
	for(int i=0;i<n4;i++){
		string d;
		cin>>d;
		d+=":";
		string h;
		e=0;
		for(int j=0;j<d.length();j++){
			if(d[j]==':'){
				if(e==0)
					a=atoi(h.c_str());
				else
					b=atoi(h.c_str());
				h="";
				e++;
			}
			else
				h+=d[j];
		}
		double n3,m3;
		n3=0;
		n3+=(a*n2+b*n);
		m3=0;
		m3+=b*m;
		double c=n3-m3;
		if(c<0)
			c=0-c;
		if(360-c<c){
			c=360-c;
		}
		if(c>=90&&c<=180)
			printf("safe\n");
		else if(c>=0&&c<30)
			printf("alert\n");
		else
			printf("warning\n");
	}
}

Measured memory_bytes: 3116
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    string s;
    cin >> s;
    if (s == ".") break;
    vector<int> v(3);
    function<int(int &)> dfs = [&](int &i) -> int {
      if (s[i] == '(') {
        i++;
        int e = dfs(i);
        if (s[i] == '+') {
          i++;
          cmax(e, dfs(i));
        }
        if (s[i] == '*') {
          i++;
          cmin(e, dfs(i));
        }
        i++; // ')'
        return e;
      }
      if (s[i] == '-') {
        i++;
        return 2 - dfs(i);
      }
      if (isdigit(s[i])) return s[i++] - '0';
      return v[s[i++] - 'P'];
    };
    int cnt = 0;
    for (v[0] = 0; v[0] < 3; v[0]++) {
      for (v[1] = 0; v[1] < 3; v[1]++) {
        for (v[2] = 0; v[2] < 3; v[2]++) {
          int i = 0;
          cnt += dfs(i) == 2;
        }
      }
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3088
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long pow = 1L;
    	for (int i = 1; i <= N; i++) {
    		pow = pow*i%1000000007;
    	}
    	System.out.println(pow);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a[2];
    a[1].resize(n);
    a[0].resize(n);
    REP(i,0,n){
        cin>>a[0][i];
    }
    REP(i,0,n){
        cin>>a[1][i];
    }
    vector<int>par[2];
    par[0].resize(n+2,0);
    par[1].resize(n+2,0);
    for(int i=0;i<n;i++){
        par[0][i+1]=par[0][i]+a[0][i];
    }
    for(int i=n;i>=1;i--){
        par[1][i]=par[1][i+1]+a[1][i-1];
    }
    // deb(par[0]);
    // deb(par[1]);
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,par[0][i]+par[1][i]);
    }
    // deb(ans);
    cout<<ans<<"\n";



	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int N, K, C;

    std::cin >> N >> K >> C;

    string days;
    cin >> days;

    vector<int> leftDays(N);
    vector<int> rightDays(N);

    leftDays[0] = 0;
    for (int i = 1; i < N; ++i) {
        if (days[i] == 'o' && i - C - 1 >= 0)
            leftDays[i] = leftDays[i - C - 1] + 1;
        else
            leftDays[i] = leftDays[i-1];
    }

    rightDays[N-1] = 0;
    for (int i = N-2; i >= 0; --i) {
        if (days[i] == 'o' && i + C + 1 < N)
            rightDays[i] = rightDays[i + C + 1] + 1;
        else
            rightDays[i] = rightDays[i+1];
    }

    vector<int> out;
    for (int i = 0; i < N; ++i) {
        if (days[i] == 'o' && leftDays[i] + rightDays[i] + 1 == K &&
           (i == 0 || (i > 0 && leftDays[i-1] != leftDays[i])) && (i == N-1 || (i < N-1 && rightDays[i] != rightDays[i+1])))
            out.push_back(i + 1);
    }

    for (int i : out)
        cout << i << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define inf 1e18
int main()
{
	ll n,q;
	cin>>n;
	ll a[n+2];
	unordered_map<ll,int> m;
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		m[a[i]]++;
	}
	cin>>q;
	ll b,c;
	for(int i=0;i<q;i++)
	{
		cin>>b>>c;
		if(m[b]==0)
		{
			cout<<sum<<"\n";
			continue;
		}
		else
		{
			ll temp=(b*m[b]);
			sum=sum-temp;
			temp=(m[b]*c);
			sum=sum+temp;
			m[c]=m[c]+m[b];
			m[b]=0;
		}
		cout<<sum<<"\n";
	}
}


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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
// #define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77;

string s;

int32_t main()
{
    cin >> s;
    int n = s.size();

    vector<int> A(n,1);

    for(int i = 0; i < n ; ++i){
        if(s[i]=='R' && s[i+1]=='R'){
            A[i+2] += A[i];
            A[i] = 0;
        }
    }

    for(int i = n-1 ; i >= 0 ; --i){
        if(s[i]=='L' && s[i-1]=='L'){
            A[i-2] += A[i];
            A[i] = 0;
        }
    }

    for(int i = 0 ; i < n ; ++i){
        if(i==0) cout << A[i] ;
        else cout << ' ' << A[i];
    }
    cout << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> vecV(N);
  vector<int> vecC(N);
  
  for(int i = 0; i < N; i++){
    int V;
    cin >> V;
    vecV[i] = V;
  }
   for(int i = 0; i < N; i++){
    int C;
    cin >> C;
    vecC[i] = C;
  }
  
  int p = 0;
  for(int i = 0; i < N; i++){
   if(vecV[i] > vecC[i]){
     p = p + vecV[i] - vecC[i];
   }
  }
  cout << p << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_map>

template<typename T>
class cUnionFind{
private:
	struct cNode{
		T data;
		size_t parent;
		size_t rank;
	};
private:
	std::vector<cNode> Buf;
	std::unordered_map<T,size_t> Hash;
public:
	cUnionFind(){}
private:
	bool link(T x_,T y_){
		auto x_itr=Hash.find(x_);
		auto y_itr=Hash.find(y_);

		if(x_itr==Hash.end() || y_itr==Hash.end())return true;

		size_t x_index=x_itr->second;
		size_t y_index=y_itr->second;

		if(Buf[x_index].rank>Buf[y_index].rank){
			Buf[y_index].parent=x_index;
		}
		else{
			Buf[x_index].parent=y_index;
			if(Buf[x_index].rank==Buf[y_index].rank){
				++Buf[y_index].rank;
			}
		}

		return false;
	}
	size_t find_set_helper(size_t index_){
		if(index_!=Buf[index_].parent){
			size_t ans_index=find_set_helper(index_);
			Buf[index_].parent=ans_index;
		}

		return Buf[index_].parent;
	}
public:
	bool make_set(T data_){
		size_t index=Buf.size();
		Buf.emplace_back({data_,index,0});
		auto ans=Hash.insert(std::make_pair(data_,index));
		return !ans.second;
	}
	bool union_set(T x_,T y_){
		return link(x_,y_);
	}
	std::pair<T,bool> find_set(T x_){
		auto x_itr=Hash.find(x_);
		if(x_itr==Hash.end())return std::make_pair(x_,true);

		size_t index=x_itr->second;
		if(Buf[index].parent!=index){
			Buf[index].parent=find_set_helper(Buf[index].parent);
		}

		return std::make_pair(Buf[Buf[index].parent].data,false);
	}
};

template<>
class cUnionFind<int>{
private:
	struct cNode{
		int parent;
		int rank;
	};
private:
	std::vector<cNode> Buf;
public:
	explicit cUnionFind(size_t size_)
		:Buf(size_){
		//make_set?????????
		for(int i=0;i<Buf.size();++i){
			Buf[i].parent=i;
			Buf[i].rank=0;
		}
	}
private:
	bool link(int x_,int y_){
		if(x_<0 || Buf.size()-1<x_ || y_<0 || Buf.size()-1<y_)return true;

		if(Buf[x_].rank>Buf[y_].rank){
			Buf[y_].parent=x_;
		}
		else{
			Buf[x_].parent=y_;
			if(Buf[x_].rank==Buf[y_].rank){
				++Buf[y_].rank;
			}
		}

		return false;
	}
public:
	std::pair<int,bool> find_set(int x_){
		if(Buf[x_].parent!=x_){
			auto ans_pair=find_set(Buf[x_].parent);
			Buf[x_].parent=ans_pair.first;
		}

		return std::make_pair(Buf[x_].parent,false);
	}
	bool union_set(int x_,int y_){
		return link(find_set(x_).first,find_set(y_).first);
	}
};

using namespace std;

const double pi=4*atan(1.0);

int mod=1000000007;

int main() {
	int n,q;
	cin>>n>>q;
	cUnionFind<int> UnionFind(n);

	for(int i=0;i<q;++i){
		int query,x,y;
		cin>>query>>x>>y;

		if(query==0){
			UnionFind.union_set(x,y);
		}
		else{
			if(UnionFind.find_set(x)==UnionFind.find_set(y)){
				cout<<1<<endl;
			}
			else{
				cout<<0<<endl;
			}
		}
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <stdio.h>

#define MAX_N 100

using namespace std;

int H[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  int res = 0;
  while (true) {
    int i = 0;
    int cnt = 0;
    while (i < N) {
      while (i < N && H[i] <= 0) {
        ++i;
      }
      if (i >= N) {
        break;
      }
      while (i < N && H[i] > 0) {
        --H[i];
        ++i;
      }
      ++cnt;
    }
    if (cnt == 0) {
      printf("%d\n", res);
      return 0;
    } else {
      res += cnt;
    }
  }
}

Measured memory_bytes: 3228
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
    

int main() {
    int N;
    cin >> N;
    for(int i = 0; i < 9; i++){
        for(int j = 0; j < 9; j++){
            double A = N;
            A /= (j+1);
            A /= (i+1);
            if(A == 1){
                cout << "Yes" <<endl;
                return 0;
            }
        }
    }
    cout << "No" <<endl;
}

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

typedef long long ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> pii;
typedef tuple<ll,ll,ll> tii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef map<ll,ll> mi;
typedef map<pii,ll> mii;


#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define rep(i,a,b) for(int i = a; i < b; i++)
ll mod=1000000007;
#define PI 3.141592653589793238

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    IOS

    ll n;
    cin>>n;

    for(ll i=0;i<=120;i++)
    {
        for(ll j=-118;j<=119;j++)
        {
            if(exp(i,5)-exp(j,5)==n)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }

    cout<<-1<<endl;
    
    return 0;
}


Measured memory_bytes: 3640
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	x, n := nextInt(), nextInt()
	p := map[int]bool{}
	for i := 0; i < n; i++ {
		pi := nextInt()
		p[pi] = true
	}

	ans := -100
	for i := 0; i <= 101; i++ {
		if p[i] {
			continue
		}
		if abs(x-i) < abs(x-ans) {
			ans = i
		}
	}

	puts(ans)
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  if((a<=0 && 0<=b) || a==0 || b==0){
    cout << "Zero" << endl;
  }
  else if(0<=a){
    cout << "Positive" << endl;
  }
  else{
    if((-a-b+1)%2==0) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    vector<int> v;
    for(auto p : mp) {
        v.push_back(p.second);
    }
    sort(ALL(v));
    int ans = 0;
    for(int i = 0; i < max(0, (int)v.size() - k); i++) {
        ans += v[i];
    }
    cout << ans << endl;
}

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

typedef pair<int,int> p;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(void){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H,vector<char>(W));
    vector<vector<int>> times(H,vector<int>(W,-1));
    queue<p> que;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            cin >> A[i][j];
            if (A[i][j] == '#') {
                que.push(make_pair(i,j));
                times[i][j] = 0;
            }
        }
    }
    while (!que.empty()){
        p pt = que.front();que.pop();
        for (int i=0;i<4;i++){
            int x = pt.first+dx[i];
            int y = pt.second+dy[i];
            if (x < 0 || x >= H || y < 0 || y >= W) continue;
            if (A[x][y] == '.' && times[x][y] < 0){
                times[x][y] = times[pt.first][pt.second] + 1;
                A[x][y] = '#';
                que.push(make_pair(x,y));
            }
        }
    }
    
    int ans = 0;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            ans = max(ans, times[i][j]);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main(){
    long long n;
    cin >> n;
    long long arr[n + 1] = {0}, arr1[n + 1] = {0}, cmp[n + 1] = {0};
    for(long long i = 0; i < n; ++i){
        cin >> arr[i];
    }
    for(long long i = 0; i < n; ++i){
        cin >> arr1[i];
    }
    for(long long i = 0; i < n; ++i){
        cmp[i] = i + 1;
    }
    long long cnt = 0, check = 0, tmp = 0;
    do {
        check = 0;
        cnt++;
        for(int i = 0; i < n; ++i){
            if(cmp[i] == arr[i]){
                check++;
                if(check == n){
                    tmp = cnt;
                }
            }
        }
    } while (next_permutation(cmp, cmp + n));
    cnt = 0;
    long long tmp1;
    do {
        check = 0;
        cnt++;
        for(int i = 0; i < n; ++i){
            if(cmp[i] == arr1[i]){
                check++;
                if(check == n){
                    tmp1 = cnt;
                }
            }
        }
    } while (next_permutation(cmp, cmp + n));

    cout << abs(tmp - tmp1);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    string s,t;cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <set>
using namespace std;

const int MAX_N=10000;
int a[100005]={};
int n;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	int c=0;
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(a[i]==a[i+1]) i++;
		else c++;
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 640