akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-conversion"

#define NDEBUG
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using uint = unsigned int;
using usize = std::size_t;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<typename T> constexpr T popcount(const T u) { return u ? static_cast<T>(__builtin_popcountll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T log2p1(const T u) { return u ? static_cast<T>(64 - __builtin_clzll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T msbp1(const T u) { return log2p1(u); }
template<typename T> constexpr T lsbp1(const T u) { return __builtin_ffsll(u); }
template<typename T> constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast<T>(u); }
template<typename T> constexpr bool ispow2(const T u) { return u and (static_cast<u64>(u) & static_cast<u64>(u - 1)) == 0; }
template<typename T> constexpr T ceil2(const T u) { return static_cast<T>(1) << clog(u); }
template<typename T> constexpr T floor2(const T u) { return u == 0 ? static_cast<T>(0) : static_cast<T>(1) << (log2p1(u) - 1); }
template<typename T> constexpr bool btest(const T mask, const usize ind) { return ((static_cast<u64>(mask) >> ind) & static_cast<u64>(1)); }
template<typename T> constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast<T>(0) : static_cast<T>((static_cast<u64>(mask) << (64 - ind)) >> (64 - ind)); }
template<typename T> bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); }
template<typename T> bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); }
constexpr unsigned int mod                  = 1000000007;
template<typename T> constexpr T inf_v      = std::numeric_limits<T>::max() / 4;
template<typename Real> constexpr Real pi_v = Real{3.141592653589793238462643383279502884};
template<typename T>
T read()
{
    T v;
    return std::cin >> v, v;
}
template<typename T>
std::vector<T> read_vec(const std::size_t size)
{
    std::vector<T> v(size);
    for (auto& e : v) { std::cin >> e; }
    return v;
}
template<typename... Types>
auto read_vals() { return std::tuple<std::decay_t<Types>...>{read<Types>()...}; }
#define SHOW(...) static_cast<void>(0)
template<typename T>
std::vector<T> make_v(const std::size_t size, T v) { return std::vector<T>(size, v); }
template<class... Args>
auto make_v(const std::size_t size, Args... args) { return std::vector<decltype(make_v(args...))>(size, make_v(args...)); }
int main()
{
    const auto t1 = read<int>(), t2 = read<int>();
    const auto r1 = read<int>(), r2 = read<int>();
    const int db = (r1 != -1 and r2 != -1 ? r2 - r1 : t1 - t2);
    std::cout << (db > 0 ? "Bob" : db < 0 ? "Alice" : "Draw") << std::endl;
    return 0;
}



Measured memory_bytes: 3120
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	int n;
	cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	sort(all(a));
    cout<<a[n/2]-a[n/2-1];
}


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

vector<vector<int>> dp(10005 , vector<int>(1005 , 1e18+7));

int solve(int h , int n , int a[] , int b[]) {
	if(h <= 0) return 0;
	if(n <= 0) return 1e18+7;
	if(dp[h][n] < 1e18+7) return dp[h][n];
	else {
		dp[h][n] = solve(h , n-1 ,a , b); // without using last one anytime
		dp[h][n] = min(dp[h][n] , b[n] + solve(h-a[n] , n , a, b)); // using last one
		return dp[h][n];
	}
}

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

	int h , n;
	cin >> h >> n;
	int a[n+1] , b[n+1];
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	cout << solve(h , n , a , b) << "\n";
    return 0;
}


Measured memory_bytes: 80000
n = int(input())
tn = n - n%2

edge_num = tn * (tn - 2) // 2
if n % 2 == 1:
    edge_num += n - 1
print(edge_num)

for i in range(tn):
    for j in range(i, tn):
        if i == j or tn - 1 - i == j:
            continue
        print(i+1, j+1)
if n % 2 == 1:
    for i in range(tn):
        print(i+1, n)

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

int main()
{
  int a;
  int max = 0;
  int sum = 0;

  for(int i = 0; i < 5; i++){
    cin >> a;

    sum += a;
    a %= 10;

    if(a != 0){
      sum += (10 - a);
      if(max < 10 - a) max = 10 - a;
    }
  }

  cout << sum-max << endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Long> num = new ArrayList<Long>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextLong()) {
				num.add(sc.nextLong());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Long> num, ArrayList<String> param) {
		HashMap<Long,Long> list = new HashMap<Long,Long>();
		int count = 0;

		for(int i = 2; i < num.size(); i+=2){
			if(list.containsKey(num.get(i))){
				list.put(num.get(i), list.get(num.get(i)) + num.get(i + 1));
			}else{
				list.put(num.get(i), num.get(i + 1));
			}
		}
		Object[] mapkey = list.keySet().toArray();
        Arrays.sort(mapkey);

        for (Object nKey : mapkey)
        {
        	if(num.get(1) - list.get(nKey) <= 0){
        		System.out.println(nKey);
        		System.exit(0);
        	}else{
        		num.set(1, num.get(1) - list.get(nKey));
        	}
        	count++;
        }
	}
}

Measured memory_bytes: 96748
#include<bits/stdc++.h>
using namespace std;
int issorted(vector<int> res) {
  for(int i = 0;i < res.size();i++) {
      if(res[i] != i+1) {
          return 0;
      }
  }
  return 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  vector<int> vc;
  cin >> n;
  for(int i = 0;i < n;i++) {
      int x;
      cin >> x;
      vc.push_back(x);
  }
  int stock1=0, stock2=0;
  int num1=-1, num2=-1;
  for(int i = 0;i < n;i++) {
      if(vc[i] != i+1) {
          stock2 = stock1;
          stock1 = vc[i];
          num2 = num1;
          num1 = i;
      }
  }
  if(num1!=-1&&num2!=-1) {
     swap(vc[num1], vc[num2]);
  }
  int res;
  res = issorted(vc);
  if(res == 1) {
      cout << "YES" << '\n';
  } else {
      cout << "NO" << '\n';
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
void compare( int * const a, int * const b);
 
int main( int argc, char *argv[] ){
   int x, y, z;
 
   if ( scanf( "%d %d %d", &x, &y, &z ) != 3 ){
      exit( 1 );
   }
 
   compare( &x, &y );
   compare( &y, &z );
   compare( &x, &y );
 
   printf( "%d %d %d\n", x, y, z );
   return 0;
}
 
void compare( int * const a, int * const b ){
   int tmp;
 
   if ( *a > *b ){
      tmp = *a;
      *a = *b;
      *b = tmp;
   }
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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 ll;
using namespace std;
int main(void){
    string s;cin>>s;
    reverse(s.begin(),s.end());
    s+='0';
    int n=s.size();
    vector<vector<ll>> t(2,vector<ll>(n+10,1e9));
    t[0][0]=0;
    rep(i,n){
        int now=s[i]-'0';
        rep(j,2){
            now+=j;
            rep(k,10){
                int nj=0;
                int b=k-now;
                if(b<0){
                    nj=1;
                    b+=10;
                }
                chmin(t[nj][i+1],t[j][i]+k+b);
            }
        }
    }
    ll res=1e9;
    chmin(res,min(t[0][n],t[1][n]));
    cout<<res<<endl;
}

Measured memory_bytes: 27732
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
inline ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

int ret;
int p[11];
vector<int> K[11];
int N, M;

vector<int> switch_on;

void dfs(int last)
{
    if(last >= N) return;
    
    int bulb = 0;
    auto on = new bool[N]();
    for(auto v : switch_on)
        on[v] = true;
    
    for(int i = 0; i < M; i++)
    {
        int number = 0;
        for(int j = 0; j < K[i].size(); j++)
        {
            auto cur = K[i][j];
            if(on[cur])
                number += 1;
        }
        if(number % 2 == p[i])
            bulb += 1;
    }
    
    delete [] on;
    
    if(bulb >= M)
    {
        ret += 1;
    }
    
    for(int i = last + 1; i < N; i++)
    {
        switch_on.push_back(i);
        dfs(i);
        switch_on.pop_back();
    }
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < M; i++)
    {
        int k; cin >> k;
        for(int j = 0; j < k; j++)
        {
            int s; cin >> s;  s -= 1;K[i].push_back(s);
        }
    }
    for(int i = 0; i < M; i++)
        cin >> p[i];
    dfs(-1);
    
    cout << ret << endl;
   
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		String s = sc.next();
		int ans = 0, x = 0;

		for (int i = 0; i <= n; i++) {
			if (s.substring(i).startsWith("I")) {
				x++;
			} else {
				x--;
			}
			if (ans < x) {
				ans = x;
			}
		}

		System.out.println(ans);
		sc.close();
	}
}


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

int main()
{
  double a, b, x;
  cin >> a >> b >> x;
  double theta;
  if (x <= a * a * b / 2.0)
  {
    theta = atan(a * b * b / (2.0 * x)) * 180.0 / M_PI;
  }
  else
  {
    theta = atan(2 * (a * a * b - x) / (a * a * a)) * 180.0 / M_PI;
  }
  printf("%.10f\n", theta);
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a<10){
		int ans = 0;
		for(int i=1;i*10 + i <= 10*a + b;i++){
			ans++;
		}
		cout << ans << endl;
	}
	else if(a>=10){
		if(a<=b){
			cout << a << endl;
		}
		else{
			cout << a-1 << endl;
		}
	}
}

Measured memory_bytes: 256
from sys import stdin
def main():
  from itertools import repeat
  from builtins import range
  readline = stdin.readline
  h, w = map(int, readline().split())
  s = [readline().rstrip('\r\n') + '#' for _ in range(h)]
  s.append('#' * w)
  yoko = [[0] * w for _ in range(h)]
  for i in range(h):
    start = -1
    si = s[i]
    yokoi = yoko[i]
    for j in range(w + 1):
      if si[j] == '#':
        if start != -1:
          t = j - start
          yokoi[start:j] = repeat(t, t)
          start = -1
      else:
        if start == -1:
          start = j
  result = 0
  for i in range(w):
    start = -1
    for j in range(h + 1):
      if s[j][i] == '#':
        if start != -1:
          t = yoko_max + j - start - 1
          if t > result:
            result = t
          start = -1
      else:
        yji = yoko[j][i]
        if start == -1:
          start = j
          yoko_max = yji
        else:
          if yji > yoko_max:
            yoko_max = yji
  print(result)
main()

Measured memory_bytes: 38900
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#define fora(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T> void UNIQUE(vector<T> &a){ SORT(a);a.erase(unique(ALL(a)),a.end());}
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    set<string> se;
    rep(i,N){
        string S; cin>>S;
        se.insert(S);
    }
    cout<< se.size()<<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; rep(QQ,Qkai) Main();
    Main();
}
//-----------------------------------------

Measured memory_bytes: 19244
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  long long N,ans;
	ans=0;
	cin>>N;
	vector<long long> a(N);
	rep(i,N)cin>>a[i];
	sort(a.rbegin(),a.rend());
	for(long long i=0;i<N;i++){
		if(i%2==0)ans+=a[i];
		else ans-=a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<int> value(n), weight(n);
    for (auto i = 0; i < n; i++) cin >> value[i] >> weight[i];

    vector<vector<int>> dp(n, vector<int>(w + 1, 0));
    dp[0][weight[0]] = value[0];
    for (auto i = 1; i < n; i++) {
        for (auto j = 0; j <= w; j++) {
            dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));
            if(w - j >= weight[i]) {
                dp[i][j + weight[i]] = max(dp[i][j + weight[i]], dp[i - 1][j] + value[i]);
            }
        }
//        for (auto j = 0; j < n; j++) {
//            for (auto k = 0; k <= w; k++) {
//                cout << dp[j][k] << " ";
//            }
//            cout << endl;
//        }
    }

    cout << dp[n - 1][w] << endl;
    return 0;
}


Measured memory_bytes: 6828
{-
fibonacci :: Int -> Int
fibonacci = fibo (1, 1) 2
    where
      fibo :: (Int, Int) -> Int -> Int -> Int
      fibo (pp, prev) pos n
          | n < 2 = 1
          | pos >= n = pp + prev
          | otherwise = fibo (prev, pp+prev) (pos+1) n
-}

fibonacci :: Int -> Integer
fibonacci = (map fibo [0 ..] !!)
    where
      fibo n
          | n < 2 = 1
          |otherwise = fibonacci (n-2) + fibonacci (n-1)

main :: IO ()
main = do
  n <- readLn
  putStrLn $ show $ fibonacci n

Measured memory_bytes: 3680
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	for(int i=0; i<3; i++){
		int h1, m1, s1, h2, m2, s2;
		cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;

		int t1 = h1*3600+m1*60+s1;
		int t2 = h2*3600+m2*60+s2;

		int t3 = t2-t1;

		int h3 = t3/3600;
		int m3 = t3%3600/60;
		int s3 = t3%60;

		cout << h3 << ' ' << m3 << ' ' << s3 << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a = 0, b = 0, c = 0, d = 0;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    if(s == "AC") a++;
    else if(s == "WA") b++;
    else if(s == "TLE") c++;
    else d++;
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

const int INF = (1<<30);
vector<int> dp;
vector<int> ans;
vector<int> num;
vector<vector<int>> G;

void dfs(int u){ // 頂点uについて考える
    int i = lower_bound(all(dp), num[u]) - dp.begin(); // LISでよくやるやつ
    int save = dp[i]; dp[i] = num[u]; // saveしてから更新
    ans[u] = lower_bound(all(dp), INF) - dp.begin(); // 答えの保存
    for(auto next : G[u]) if(ans[next] == -1) dfs(next); // 深さ優先探索をする
    dp[i] = save; // 巻き戻す
}

int main(){
    int n; cin >> n;
  	dp.assign(n, INF);
  	ans.assign(n, -1);
  	num.assign(n, 0);
    rep(i,n) cin >> num[i];
 	G.assign(n, vector<int>());
    rep(i,n-1){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0);

    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 25080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int mapping[510][510] = {0};
void solve(long long N, long long M, long long Q, std::vector<long long> L, std::vector<long long> R, std::vector<long long> p, std::vector<long long> q)
{
    for (int i = 0; i < M; i++)
    {
        mapping[L[i]][R[i]]++;
    }

    for (int i = 1; i <= 500; i++)
    {
        for (int j = 1; j <= 500; j++)
        {
            mapping[i][j + 1] += mapping[i][j];
        }
    }
    for (int i = 1; i <= 500; i++)
    {
        for (int j = 500; j >= 1; j--)
        {
            mapping[j][i] += mapping[j + 1][i];
        }
    }
    for (int i = 0; i < Q; i++)
    {
        cout << mapping[p[i]][q[i]] << endl;
    }
    
    
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &L[i]);
        scanf("%lld", &R[i]);
    }
    std::vector<long long> p(Q);
    std::vector<long long> q(Q);
    for (int i = 0; i < Q; i++)
    {
        scanf("%lld", &p[i]);
        scanf("%lld", &q[i]);
    }
    solve(N, M, Q, std::move(L), std::move(R), std::move(p), std::move(q));
    return 0;
}


Measured memory_bytes: 6656
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

long long gcd( long long m, long long n )
{
  long long a=m, b=n, tmp, r;
    /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}//gcd

int main() {
  long long n, x;
  scanf("%lld %lld", &n, &x);
  long long X[n];
  for( int i=0; i<n; i++ ){
    scanf("%lld", &X[i]);
    X[i] = abs(X[i]-x);
  }
  long long res=X[0];
  for( int i=1; i<n; i++ ){
    res = gcd(res,X[i]);
  }

  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
  ll n, i;
  cin>>n>>i;
  cout<<n-i+1<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
int main(int argc, char const *argv[]) {
  int N, K;
  cin >> N >> K;
  long int a = pow(K - 1, N - 1);
  cout << K * a << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  vector<vector<int>> G(N, vector<int>(N));
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
    G[A[i]][B[i]] = G[B[i]][A[i]] = 1;
  }
  auto can_reach = [&](int a, int b) -> bool {
    vector<bool> visited(N);
    queue<int> que;
    que.push(a);
    while (!que.empty()) {
      auto v = que.front();
      que.pop();
      visited[v] = true;
      for (int i = 0; i < N; i++) {
        if (!G[v][i]) continue;
        if (visited[i]) continue;
        que.push(i);
      }
    }
    return visited[b];
  };
  int ans = 0;
  for (int i = 0; i < M; i++) {
    G[A[i]][B[i]] = G[B[i]][A[i]] = 0;
    if (!can_reach(A[i], B[i])) ans++;
    G[A[i]][B[i]] = G[B[i]][A[i]] = 1;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 MOD = 1e9 + 7;

struct Combination {
  int64 fac[2020202];
  int64 inv[2020202];
  int64 finv[2020202];
};

constexpr Combination lookup_table() {
  Combination com {};
  com.fac[0] = 1; com.fac[1] = 1;
  com.finv[0] = 1; com.finv[1] = 1;
  com.inv[1] = 1;
  for (int i = 2; i <2020202; ++i) {
    com.fac[i] = com.fac[i - 1] * i % MOD;
    com.inv[i] = MOD - com.inv[MOD % i] * (MOD / i) % MOD;
    com.finv[i] = com.finv[i - 1] * com.inv[i] % MOD;
  }
  return com;
}

const Combination table = lookup_table();

int64 my_com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return table.fac[n] * (table.finv[k] * table.finv[n - k] % MOD) % MOD;
}

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

  int x, y; cin >> x >> y;
  auto ok = [](int xx, int yy) -> bool {
    if (xx * 2 < yy || xx > yy * 2) return false;
    return (xx + yy) % 3 == 0;
  };

  if (!ok(x, y)) {
    cout << 0 << endl;
    return 0;
  }

  int nn = (x + y) / 3;
  int r = x - nn;

  cout << my_com(nn, r) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int now, right, left, count;

int cmp_char(char a[], char b[]);

int main(void)
{
    char input[3];
    int data, i;

    scanf("%d",&data);
    while (data) {
        count = 0;
        now = -1;
        right = -1;
        left = -1;
        for (i = 0; i < data; i++) {
            scanf("%s",input);
            if (cmp_char(input, "lu")) {
                left = 1;
            } else if (cmp_char(input, "ld")) {
                left = -1;
            } else if (cmp_char(input, "ru")) {
                right = 1;
            } else if (cmp_char(input, "rd")) {
                right = -1;
            }
            if (now != right && now != left) {
                now = right;
                count++;
            }
        }
        printf("%d\n",count);
        scanf("%d",&data);
    }
    return 0;
}

int cmp_char(char a[], char b[])
{
    int i;
    for (i = 0; i < 2; i++) {
        if (a[i] != b[i]) {
            return 0;
        }
    }
    return 1;
}

Measured memory_bytes: 604
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

def lcm(m, n):
  return (m * n) // gcd(m, n)

ans = T[0]
for i in range(1,N):
  ans = lcm(ans, T[i])
print(ans)

Measured memory_bytes: 3064
while True:
    x=int(input())
    if x == 0:
        break
    a=(1000-x)//500
    b=(1000-x)%500//100
    c=(1000-x)%500%100//50
    d=(1000-x)%500%100%50//10
    e=(1000-x)%500%100%50%10//5
    f=(100-x)%500%100%50%10%5
    print(a+b+c+d+e+f)



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

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

    cout << a+b+c-max({a,b,c}) << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,int> Q;

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=2e5+9;
const ll maxx=1e12+9;

ll n,d,x,y;

int main()
{
    scanf("%lld%lld",&n,&d);
    int cnt=0;
    while(n--)
    {
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3256
"use strict"

function Main(input) {
  let dataList = input.split("\n");
  dataList.shift();
  dataList.pop();
  let restaurants = dataList.map((data, index) => {
    const tmp = data.split(" ")
    return { index: index + 1, city: tmp[0], score: parseInt(tmp[1]) }
  });
  restaurants.sort(function(a, b) {
    if (a.city < b.city) return -1
    if (a.city > b.city) return 1
    if (a.score < b.score) return 1
    if (a.score > b.score) return -1
  });
  restaurants.forEach(restaurant => {
    console.log(restaurant.index);
  });
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <iostream>

using namespace std;

int main()
{
     char a[4];
     int p=0,l=0,sum;
    for(int i=0;i<4;i++)
       {
           cin>>a[i];
           if(a[i]=='+')
            p++;
           else if(a[i]=='-')
            l++;
       }
       sum=p-l;

   cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

ll dfs(string t, bool san, bool go, bool nana, bool ok){
    ll num = t[0] - '0';
    if(t.size()==1){
        if(ok){
            ll cnt = 0;
            if(san) cnt++;
            if(go) cnt++;
            if(nana) cnt++;
            if(cnt<2) return 0;
            else if(cnt==2) return 1;
            else return 3;
        }
        if(num<3) return 0;
        else if(num<5){
            if(go && nana) return 1;
        }
        else if(num<7){
            ll res = 0;
            if(nana && go) res++;
            if(san && nana) res++;
            return res;
        }
        else{
            ll res = 0;
            if(nana && go) res++;
            if(san && nana) res++;
            if(san && go) res++;
            return res;
        }
    }
    ll res = 0;
    t.erase(t.begin());
    if(ok) {
        res += dfs(t,true,go,nana,true);
        res += dfs(t,san,true,nana,true);
        res += dfs(t,san,go,true,true);
        if(!san && !go && !nana) res += dfs(t,san,go,nana,true);
        return res;
    }

    if(!san && !go && !nana) res += dfs(t,san,go,nana,true);
    
    if(num>3) res += dfs(t,true,go,nana,true);
    else if(num==3) res += dfs(t,true,go,nana,false);
    if(num>=5) {
        if(num>5) res += dfs(t,san,true,nana,true);
        else res += dfs(t,san,true,nana,false);
    }
    if(num>=7) {
        if(num>7) res += dfs(t, san, go, true,true);
        else res += dfs(t,san,go,true,false);
    }
    return res;
}

int main() {
    string s; cin >> s;
    ll ans = dfs(s,false,false,false,false);
    cout << ans << endl;
}

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

const int MN = 200012;

int n, k;
int a[MN];

bool check(int x) {
  int ctr = k;
  for (int i = 0; i < n; i++) {
    int cuts = (a[i] - 1) / x;
    if (cuts > ctr)
      return false;
    ctr -= cuts;
  }
  return true;
}

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int res = *max_element(a, a + n);
  int lo = 1, hi = res;
  while (lo <= hi) {
    int mi = (lo + hi) / 2;
    if (check(mi)) {
      hi = mi - 1;
      res = mi;
    } else {
      lo = mi + 1;
    }
  }
  cout << res << '\n';
  return 0;
}



Measured memory_bytes: 4400
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int s; cin >> s;
  int m = 0;
  vector<int>a(1000000);
  a[0] = s;
  for(int i = 0;i < 1000000;i++){
    if(a[i] % 2 == 0){
      a[i+1] = a[i]/2;
    }else{
      a[i+1] = a[i]*3+1;
    }
    if (a[i] == 4 || a[i] == 2 || a[i] == 1){
      m = i + 4;
      break;
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  int c = 0;
  for (int i = min(a, b); i >= 1; --i) {
    if (a % i == 0 && b % i == 0) ++c;
    if (c == k) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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

int main(void) {

	//0005
	/*
	int a, b, G, R, L, r;
	while (cin >> a >> b) {
		R = a;
		L = b;
		int tmp;
		if (b > a) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (1) {
			r = a%b;
			if (r == 0)break;
			a = b;
			b = r;
		}
		G = b;
		R = R / G;
		L = L / G;
		cout << G << " " << R*L * G << endl;
	}
	*/
	//0006
	/*
	string name;
	cin >> name;
	int L = name.size();
	string Ans;
	for (int i = 0; i < L; i++) {
		Ans += name.substr(L-i-1, 1);
	}
	cout << Ans << endl;
	*/
	//0007
	int Dept = 100000;
	int week;
	cin >> week;
	for (int i = 0; i < week; i++) {
		Dept = Dept * 1.05;
		if (Dept % 1000 == 0) {
			Dept = (Dept / 1000);
		}
		else {
			Dept = (Dept / 1000 + 1);
		}
		Dept = Dept * 1000;
	}
	cout << Dept << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    cin >> d;
    if (d == 22) {
        cout << "Christmas Eve Eve Eve";
    } else if (d == 23) {
        cout << "Christmas Eve Eve";
    } else if (d == 24) {
        cout << "Christmas Eve";
    } else if (d == 25) {
        cout << "Christmas";
    }   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

int max_n = 1e6 + 1;

void solve() {
    int n;
    cin >> n;
    ll wod = 8;
    ll m0 = 1;
    ll m9 = 1;
    ll wd = 0;
    rep(i, n-1) {
        wd = (wd * 10 + m0 + m9) % MOD;
        m0 = (wod + m0 * 9) % MOD;
        m9 = (wod + m9 * 9) % MOD;
        wod = (wod * 8) % MOD;
    }
    cout << wd;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


Measured memory_bytes: 3640
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;

    if(s.back() == '1' || s.front() == '0'){
        cout << -1 << endl;
        return 0;
    }
    s.pop_back();

    ll n = s.size();

    vector<pair<ll,ll>> e;
    ll root = 0;
    ll now = 1;
    rep(i, s.size()){
        if(s[i] != s[n - 1 - i]){
            cout << -1 << endl;
            return 0;
        }
        if(s[i] == '1'){
            e.push_back({root, now});
            root = now;
            now++;
        } else {
            e.push_back({root, now});
            now++;
        }
    }

    // if(n % 2 != 0){
    //     if(s[n / 2 + 1] == '1'){
    //         e.push_back({root, now});
    //         now++;
    //         root++;
    //     } else {
    //         e.push_back({root, now});
    //         now++;
    //     }
    // }
    rep(i, e.size()){
        cout << e[i].first + 1 << " " << e[i].second + 1 << endl;
    }
}


Measured memory_bytes: 5500
Imports System.Collections.Generic

Module Module1

    Sub Main()

        Dim N As Integer = CInt(Console.ReadLine())
        Dim S As String = Console.ReadLine()
        Dim i As Integer
        Dim wk As String = ""

        For i = 1 To Len(S)
            wk += cnv(Mid(S, i, 1), N)
        Next

        Console.WriteLine(wk)
        Console.ReadLine()

    End Sub

    Private Function cnv(s As String, n As Integer)

        Dim c As Integer

        c = Asc(s) - 64
        c += n
        If c > 26 Then
            c -= 26
        End If

        Return Chr(c + 64)

    End Function

End Module


Measured memory_bytes: 42192
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool flg;
int expr(string s,int& p);
int term(string s,int& p);
int factor(string s,int& p);
int number(string s,int& p);
int expr(string s,int& p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(flg) return 0;
    if(s[p]=='+'){
      p++;
      res+=term(s,p);
      continue;
    }
    if(s[p]=='-'){
      p++;
      res-=term(s,p);
      continue;
    }
    break;
  }
  return res;
}
int term(string s,int& p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(flg) return 0;
    if(s[p]=='*'){
      p++;
      res*=factor(s,p);
      continue;
    }
    break;
  }
  return res;
}
int factor(string s,int& p){
  int res;
  if(s[p]=='-'){
    p++;
    res=-factor(s,p);
  }else if(s[p]=='('){
    p++;
    res=expr(s,p);
    if(p>=(int)s.size()||s[p]!=')'){
      flg=1;
      return 0;
    }
    p++;
  }else if(isdigit(s[p])){
    res=number(s,p);
  }else{
    flg=1;
    return 0;
  }
  return res;
}
int number(string s,int& p){
  if(s[p]=='0'){
    if(p+1<(int)s.size()&&isdigit(s[p+1])){
      flg=1;
      return 0;
    }
    p++;
    return 0;
  }
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p])) res=res*2+s[p++]-'0';
  return res;
}
bool check(string s){
  if(s.size()==0) return 0;
  int op=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='(') op++;
    if(s[i]==')') op--;
    if(op<0) return 0;
  }
  if(op) return 0;
  return 1;
}
//set<string> ss;
int Q(string s){
  if(count(s.begin(),s.end(),'=')!=1) return 0;
  int k=s.find('=');
  string a=s.substr(0,k);
  string b=s.substr(k+1,s.size()-(k+1));
  if(!check(a)) return 0;
  if(!check(b)) return 0;
  //cout<<s<<endl;
  //cout<<a<<" "<<b<<endl;
  flg=0;
  int p=0;
  int x=expr(a,p);
  //cout<<flg<<" "<<p<<" "<<x<<endl;
  if(flg||p!=(int)a.size()) return 0;
  p=0;
  int y=expr(b,p);
  //cout<<flg<<" "<<p<<" "<<y<<endl;
  if(flg||p!=(int)b.size()) return 0;
  //cout<<a<<" "<<b<<endl;
  //cout<<x<<":"<<y<<endl;
  return x==y;
}
int ans=0;
string l="01+-*()=";
void dfs(string s,int b){
  bool f=1;
  for(int i=0;i<(int)s.size();i++){
    if(!isalpha(s[i])) continue;
    f=0;
    char c=s[i];
    for(int j=0;j<(int)l.size();j++){
      if((b>>j)&1) continue;
      string t=s;
      for(int k=0;k<(int)s.size();k++){
    if(t[k]==c) t[k]=l[j];
      }
      dfs(t,b+(1<<j));
    }
    break;
  }
  if(f) ans+=Q(s);
}
signed main(){
  string s;
  cin>>s;
    
  dfs(s,0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3220
[X, Y, A, B, C] = list(map(int, input().split()))

p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

eatCandi = sorted(p[0:X] + q[0:Y] + r[0:X+Y], reverse=True)

print(sum(eatCandi[0:X+Y]))


Measured memory_bytes: 23200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0; i<n; i++)
#define loopo(i,n) for(int i=0; i<n; i++)
const int INF = 2e18;

void solve(){
	int n;cin>>n;
	int d;cin>>d;

	int ans = 0;
	loop(n){
		int x,y;cin>>x>>y;
		double b = (double)sqrt( x*x + y*y );
		if(b<=(double)d)ans++;
	}
	cout<<ans<<endl;



}
	
signed main(){
    fast;    
    // int t;cin>>t;while(t--)
    solve();    
    return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
#include <stdlib.h>
#include <set>

#define MAX_N (10)
#define MAX_D (10)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, D, xss[MAX_N][MAX_D];
  scanf("%d %d", &N, &D);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      scanf("%d", &xss[i][j]);
    }
  }

  // calculate squares
  set<int> squares;
  for (int i = 0; i < 10000; i++) {
    squares.insert(i * i);
  }

  // count pairs
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int d2 = 0;
      for (int k = 0; k < D; k++) {
        d2 += (xss[i][k] - xss[j][k]) * (xss[i][k] - xss[j][k]);
      }
      if (squares.find(d2) != squares.end()) {
        ans++;
      }
    }
  }
  printf("%d\n", ans);
  
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  int num=0;
  int A[N+1]={0};
  for(int i=2;i<=N;i++){
    cin>>num;
    A[num]++;
  }
  for(int i=1;i<=N;i++){
    printf("%d\n",A[i]);
  }

}

Measured memory_bytes: 4476
import copy
N = int(input())
X = [int(i) for i in input().split()]
Y = copy.deepcopy(X)
Y.sort()

ML, MH = Y[N//2 - 1], Y[N//2]
for i in range(N):
    if X[i] >= MH:
        print(ML)
    else:
        print(MH)

Measured memory_bytes: 27156
#include<stdio.h>

int max(int a, int b){return a<b?b:a;}

int N, A[100000], B[100000], C[100000], i;
int ans[100000][3], pmax;

int main(){
	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d%d%d", A+i, B+i, C+i);
	}
	ans[0][0]=A[0];
	ans[0][1]=B[0];
	ans[0][2]=C[0];
	for(i=1; i<N; i++){
		ans[i][0]=max(ans[i-1][1]+A[i], ans[i-1][2]+A[i]);
		ans[i][1]=max(ans[i-1][0]+B[i], ans[i-1][2]+B[i]);
		ans[i][2]=max(ans[i-1][0]+C[i], ans[i-1][1]+C[i]);
	}
	pmax=max(ans[N-1][0], ans[N-1][1]);
	pmax=max(pmax, ans[N-1][2]);
	printf("%d\n", pmax);
}


Measured memory_bytes: 2560
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int n, m;
int a[50], b[50];
bool graph[50][50];
bool visited[50];


void dfs(int v) {
	//着いたらマークする
	visited[v] = true;

	//現在vにいて、vから行ける頂点すべてに対して。
	for (int v2 = 0; v2 < n; v2++) {

		//次の頂点に行けるかチェック
		if (graph[v][v2] == false)continue;
		if (visited[v2] == true)continue;

		dfs(v2);
	}
}

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

	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}

	int ans = 0;

	for (int i = 0; i < m; i++) {
		graph[a[i]][b[i]] = false;
		graph[b[i]][a[i]] = false;

		for (int j = 0; j < n; j++)visited[j] = false;

		dfs(0);

		bool bridge = false;
		for (int j = 0; j < n; j++) {
			if (visited[j] == false) {
				bridge = true;
			}
		}

		if (bridge) {
			ans++;
		}

		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256