akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	int n;
	while (cin >> n, n) {
		vector<pii> ans[10]; // ????????°, ??????
		
		string name[10];
		
		REP(i, n) {
			cin >> name[i];
			
			int win = 0, lose = 0;
			REP(j, n - 1) {
				int in; cin >> in;
				if (in == 0) win++;
				if (in == 1) lose++;
			}
			ans[win].push_back(pii(lose, i));
		}
		
		REP(i, 10) sort(ALL(ans[i]));
		
		for (int i = 9; i >= 0; i--) {
			REP(j, ans[i].size()) cout << name[ans[i][j].se] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-22 15:47:32
 **/

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

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n, x; cin >> n >> x;
  vector<int> a(n); cin >> a;
  for (int& e : a) e = abs(e - x);
  cout << accumulate(all(a), 0, [](int p, int q){ return __gcd(p, q); }) << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    int n, h, a=0, b[100005], count=0;
    bool death = false;
    cin >> n >> h;
    for (int i = 0; i < n; i++) {
        int ta;
        cin >> ta >> b[i];
        if (a < ta) a = ta;
    }
    sort(b, b + n);
    stack<int> bb;
    bb.push(0);
    for (int i = 0; i < n; i++) bb.push(b[i]);
    while (a <= bb.top()) {
        h -= bb.top();
        bb.pop();
        count++;
        if (h <= 0)break;
    }
    if (h > 0) count += (h + a - 1) / a;
    cout << count << endl;
    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
           Console.WriteLine(ABC120_B());
        }

        static int ABC120_B()
        {
            var ABK = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];
            var list = new List<int>();
            for (var i = 1; i <= 100; i++)
            {
                if (A % i == 0 && B % i == 0)
                    list.Add(i);
            }
            return list.OrderByDescending(x => x).ToArray()[K - 1];
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

// B
int main(void){
    Cin(int, n, m);
    Cins(int, m, a);
    
    ll ans = n;
    For(i, m){
        ans -= a[i];
    }
    Cout(ans < 0 ? -1 : ans);
}


Measured memory_bytes: 3640
n = int(input())
list = [int(i) for i in input().split()]

ans = -1
check = True
while check:
    ans += 1
    for i in range(n):
        if list[i]%2==0:
            list[i] = list[i]//2
        else:
            check = False
            break
print(ans)


Measured memory_bytes: 2940
S="012 345 678 036 147 258 048 246 "
A=[input().split()for i in range(3)]
B=A[0]+A[1]+A[2]
for b in [input()for i in range(int(input()))]:
  if b in B:
    S=S.replace(str(B.index(b)),"")
print(["No","Yes"][S.find("  ")>-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

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

int main(){
  ll a,b;
  cin >> a >> b;
  if(a > b){
    swap(a,b);
  }
  cout << a * b / gcd(a,b) << endl;
}

Measured memory_bytes: 256
from sys import stdin
import re

S = stdin.readline().rstrip()

pattern1 = r"^A([a-z])C([a-z]{1,7})$"
pattern2 = r'^A([a-z]){2}C([a-z]{1,6})$'
pattern3 = r'^A([a-z]){3}C([a-z]{1,5})$'
pattern4 = r'^A([a-z]){4}C([a-z]{1,4})$'
pattern5 = r'^A([a-z]){5}C([a-z]{1,3})$'
pattern6 = r'^A([a-z]){6}C([a-z]{1,2})$'
pattern7 = r'^A([a-z]){7}C([a-z]{1})$'

if (re.match(pattern1, S)) or (re.match(pattern2, S)) or (re.match(pattern3, S)) or (re.match(pattern4, S)) \
        or (re.match(pattern5, S)) or (re.match(pattern6, S)) or (re.match(pattern7, S)):
    print('AC')
else:
    print('WA')

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

ll grundy(ll H) {
  if (H <= 0) return 0;
  int lsb = 0;
  while ((H & 1)==0) {
    H >>= 1;
    lsb++;
  }
  return 1LL << lsb;
}

struct Trie {
  int l, r;
  Trie(){
    l = -1;
    r = -1;
  }
};


int treesz = 0;
Trie tree[2000000];

void add(int id, int i, const string& s) {

  if (i == (int)s.size()) {
    return;
  }

  if (s[i] == '0' && tree[id].l == -1) {
    tree[id].l = treesz;
    tree[treesz++] = (Trie());
  }
  if (s[i] == '1' && tree[id].r == -1) {
    tree[id].r = treesz;
    tree[treesz++] = (Trie());
  }
  add((s[i]=='0' ? (tree[id].l) : (tree[id].r)), i+1, s);
}

ll ans = 0;
void run(int id, int slen, const ll L) {

  const Trie &node = tree[id];

  if (node.l == -1 && node.r == -1) {
    return;
  }

  if (node.l != -1) {
    run(node.l, slen+1, L);
  }
  if (node.r != -1) {
    run(node.r, slen+1, L);
  }


  if ((node.l == -1) ^ (node.r == -1)) {
    // cout << "s=" << s << " ";
    ll h = L - slen;
    // cout << "h=" << h << " " << grundy(h) << endl;
    ans ^= grundy(h);
  }


}

int main2() {
  int N = nextLong();
  ll L = nextLong();

  treesz = 0;
  Trie root = Trie();
  tree[treesz++] = (root);

  REP(i, N) {
    string s; cin >> s;
    add(0, 0, s);
  }

  ans = 0;
  run(0, 0, L);

  return ans != 0;
}

int main() {

  // int N = 20;
  // vector<int> gg(N+1);

  // gg[0] = 0;
  // gg[1] = 1;
  // for (int i = 2; i <= N; i++) {
  //   set<int> vis;
  //   vis.insert(0);
  //   int acc = 0;
  //   for (int j = i-1; j >= 0; j--) {
  //     acc ^= gg[j];
  //     vis.insert(acc);
  //   }

  //   int g = 0;
  //   while (vis.count(g) > 0) g++;
  //   gg[i] = g;

  //   cout << i << " " << gg[i] << " " << grundy(i) << endl;
  // }

  // return 0;


#ifdef LOCAL
  // for (;!cin.eof();cin>>ws)
#endif
    cout << (main2() ? "Alice" : "Bob") << endl;
  return 0;
}

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

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

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

  vector<int> C(N+1);
  for (int i = 1; i <= N; i++) {
    int tmp = __builtin_popcountll(i);
    C.at(i) = i % tmp;
  }

  int bit_cnt = 0;
  for (int i = 0; i < N; i++) {
    if (X.at(i) == '1') bit_cnt++;
  }

  int bit_plus = bit_cnt + 1;
  int bit_minus = bit_cnt - 1;

  // bit_plus、bit_minus で 2^0, 2^1, 2^2, ... の mod をとる
  vector<int> two_plus_mods(N);
  vector<int> two_minus_mods(N);
  int two_plus_mod = 1 % bit_plus;
  int two_minus_mod = bit_minus ? (1 % bit_minus) : 0;
  for (int i = 0; i < N; i++) {
    two_plus_mods.at(N-1-i) = two_plus_mod;
    if (bit_minus > 0) two_minus_mods.at(N-1-i) = two_minus_mod;
    two_plus_mod = two_plus_mod * 2 % bit_plus;
    if (bit_minus > 0) two_minus_mod = two_minus_mod * 2 % bit_minus;
  }

  // bit_plus、bit_minus で整数 X の mod をとる
  int mod_p = 0;
  int mod_m = 0;
  for (int i = 0; i < N; i++) {
    if (X.at(N-1-i) == '1') {
      mod_p = (mod_p + two_plus_mods.at(N-1-i)) % bit_plus;
      if (bit_minus > 0) mod_m = (mod_m + two_minus_mods.at(N-1-i)) % bit_minus;
    }
  }

  // 各桁を反転して、結果を出力
  for (int i = 0; i < N; i++) {
    int nx;
    if (X.at(i) == '1') {
      if (bit_minus == 0) {
        cout << 0 << endl;
        continue;
      }
      nx = mod(mod_m - two_minus_mods.at(i), bit_minus);
    }
    else {
      nx = (mod_p + two_plus_mods.at(i)) % bit_plus;
    }
    int cnt = 1;
    while (nx != 0) {
      nx = C.at(nx);
      cnt++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 5868
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n;
    cin >> n;
    if(n % 2 == 0) {
      double tmp = (double)n;
      double ans = tmp/2.0/tmp;
      print(ans);
    }
    else {
      double dtmp = (double)n;
      int tmp = n / 2 + 1;
      double ans = (double)tmp/dtmp;
      print(ans);
    }
}

Measured memory_bytes: 256
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;


signed main()
{
    fast;
    int n , m;
    cin >> n >> m;
    vector<int> a(n);
    int sum  = 0;
    for(int i=0 ; i <n ; i++ )
        cin >> a[i] , sum += a[i];
    sort(a.begin(),a.end() );
    for(int i=n-1 ; i>=n-m ; i-- )
        if( sum > a[i] * m * 4 )
            return cout << "No" , 0;
    cout << "Yes";
}





Measured memory_bytes: 256
from math import gcd

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]

t = []
d = {}
d[0] = {}
d[0][0] = 0
for a, b in AB:
    i = gcd(a, b)
    if i != 0:
        a //= i
        b //= i
    t.append((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    if a == 0 and b == 0:
        continue
    i = d[a][b]
    j, k, l = 0, 0, 0
    if -a in d and -b in d[-a]:
        j = d[-a][-b]
        used.add((-a, -b))
    if -b in d and a in d[-b]:
        k = d[-b][a]
        used.add((-b, a))
    if b in d and -a in d[b]:
        l = d[b][-a]
        used.add((b, -a))
    result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
    result %= 1000000007
result += d[0][0] - 1
result %= 1000000007
print(result)


Measured memory_bytes: 151324
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long sum = 1;
        long rank = 1;
        while(h > 1) {
            sum += Math.pow(2, rank);
            h = h/2;
            rank++;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<cstring>
using namespace std;
typedef long long ll;
ll a[1111111];
int main()
{
	ios::sync_with_stdio(false);
	ll n;	cin>>n;
	ll sum=0;
	for(ll i=0;i<n;i++)
		sum=sum+i;
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
d= {}
for _ in range(n):
    i = input()
    if i in d:
        d[i] += 1
    else: d[i] = 1

for _ in range(int(input())):
    i = input()
    if i in d:
        d[i] -= 1

print(max(max(d.values()), 0))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	int x, y;
	cin >> x;

	string s;
	while(cin >> s) {
		if(s == "=") break;

		if(s == "+") {
			cin >> y;
			x += y;
		} else if(s == "-") {
			cin >> y;
			x -= y;
		} else if(s == "*") {
			cin >> y;
			x *= y;
		} else if(s == "/") {
			cin >> y;
			x /= y;
		}
	}

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 1204
_, P = map(int, input().split())
A = [int(s) % 2 == 0 for s in input().split()]

evens = len(list(filter(lambda x: x == True, A)))
odds = len(A) - evens

evens_x = pow(2, evens)

if odds == 0 and P == 0:
    print(int(evens_x))
elif odds == 0 and P == 1:
    print(0)
else:
    odds_x = pow(2, odds - 1)
    print(int(evens_x * odds_x))


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

class P{
  static void Main(){
    
    int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int N = n[0];
    int K = n[1];
    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
    
    int tmp = 0, ans = int.MaxValue;
    for(int i = 0; i <= N - K; i++){
      tmp = Math.Min(Math.Abs(x[i]) + Math.Abs(x[i + K - 1] - x[i]), Math.Abs(x[i + K - 1]) + Math.Abs(x[i + K - 1] - x[i]));
      ans = Math.Min(ans, tmp);
    }
    
    Console.WriteLine(ans);
  }
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int x;
	cin >> x;

	long long int m = 100;
	int t = 0;

	while(m < x){
		m += 0.01 * m;
		t++;
	}

	cout << t;
	
	return 0;
}

Measured memory_bytes: 3612
// BWOTSHEWCHB

#include <bits/stdc++.h>

using namespace std ;

#define int long long
#define pb push_back
#define in insert
#define X first
#define Y second

const int MAXN = 1e6 + 69 , MOD = 1e9 + 7 ;

int n , arr[MAXN] ;
vector <int> ans ;

int32_t main() {
	ios::sync_with_stdio(false) ;
	cin.tie(0) ; cout.tie(0) ;
	cin >> n ;
	int sz = n ;
	for ( int i = 1 ; i <= n ; i ++ )
		cin >> arr[i] ;
	for ( int i = 1 ; i <= n ; i ++ ) {
		int indx = -1 ;
		for ( int j = 1 ; j <= sz ; j ++ )
			if ( arr[j] == j )
				indx = j ;
		if ( indx != -1 ) {
			ans.pb(indx) , sz -- ;
			for ( int j = indx ; j <= sz ; j ++ )
				arr[j] = arr[j + 1] ;
		}
		if ( indx == -1 and sz )
			return cout << "-1\n" , 0 ;
		if ( sz == 0 )
			break ;
	}
	reverse(ans.begin() , ans.end()) ;
	for ( auto it : ans )
		cout << it << " " ;
	cout << "\n" ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(9);
  FOR(i,0,n){
    ll a;
    	ci(a);
    if(a/400<=7) A[a/400]++;
    else A[8]++;
  }
  
  ll mini=0;
  ll maxi=0;
  ll e=8;
  FOR(i,0,e){
    if(A[i]!=0) mini++;   
  }
  if(mini==0) cout<<1<<" ";
  else cout<<mini<<" ";
  co(mini+A[8])
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll n,c=0;
    cin>>n;
    ll a[n],b[n]={0};
    fl(i,0,n){cin>>a[i];b[i]=a[i];}
    sort(a,a+n);
    fl(i,0,n)if(a[i]!=b[i])c++;
    if(c==2||c==0)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define nl "\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define trav(x) for(auto& i: x)

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

	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for(int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		ans += b[a[i] - 1];
	}
	for(int i = 1; i < n; i++) {
		if(a[i] - a[i - 1] == 1) {
			ans += c[a[i - 1] - 1];
		}
	}
	cout << ans << nl;
}

Measured memory_bytes: 256
N= int(input())
a = [0] * N
b = [0] * N
bi= [0] * N
for i in range(N):
    a[i],b[i]= map(str, input().split())
    bi[i] =int(b[i]) 
X =input()
for j in range(N):
    if X==a[j]:
        B = sum(bi[j+1:])
        print(B)

Measured memory_bytes: 3064
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(0) ;
using ll = long long ;
const ll INF = 1e10 + 10 ;

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

    vector<ll> v(n) ;
    for(ll i = 0; i < n; i++){
        cin >> v[i] ;
    }
    sort(v.begin(), v.end()) ;
    ll cnt = 0 ;
    for(ll i = 0; i < n; i++){
        for(ll j = i + 1; j < n; j++){
            for(ll c = j + 1; c < n; c++){
                if ( v[i] < v[j] + v[c] && v[j] < v[c] + v[i] && v[c] < v[i] + v[j] ) cnt++ ;
            }
        }
    }
    cout << cnt << endl;

    return 0 ;
}



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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int gcd(int x, int y){
  int b = max(x,y);
  int r = min(x,y);
  int pr;
  while (b%r != 0){    
    pr = b % r;
    b = r;
    r = pr; 
  }
  return r;
}

int main ()
{
  int K;
  long long res=0;
  cin >> K;

  for (int a=1;a<=K;a++){
    for (int b=1;b<=K;b++){
      for (int c=1;c<=K;c++){
        res += gcd(gcd(a,b),c);
      }
    }
  }

  printf("%lld\n",res);
  
  return 0;
}

Measured memory_bytes: 3732
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    d: [usize; n]
    }
    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            ans += d[i] * d[j];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[2])
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;

    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> x >> a >> b;
    if(b - a <= 0){
        cout << "delicious" << endl;
        return 0;
    }
    tri(b - a > x, "dangerous", "safe");
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
temp = 0
for i in range(N):
    if B[i] <= A[i]:
        res += B[i]
    else:
        res += A[i]
        res += B[i]-A[i] if A[i+1] - (B[i]-A[i]) >= 0 else A[i+1]
        A[i+1] = max(A[i+1] - (B[i]-A[i]), 0)
print(res)

Measured memory_bytes: 97792
#include <bits/stdc++.h>
using namespace std;
int main(){
		string s,t;
	cin>>s>>t;
	s=s+s;
	for(int i=0;i<s.size()/2;i++){
		if(s.substr(i,t.size())==t){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	N = N % K;
	cout << min(N, K-N) << endl;

	return 0;
}


Measured memory_bytes: 256
//        ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define debug(x) cout<<#x<<": "<<x<<endl
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 
 
 
#define PI 3.1415926535897932385
#define INF 1e18
#define EPS 1e-7
#define MAXN 1000005
#define MOD 1000000007
                                  //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
 
 
 
int main() {
    
    fastio;
    int n, k;
    cin >> n >> k;
    ll h[n];
    rep(i, n)
    cin >> h[i];
    ll dp[n] = {0};
    dp[0] = 0;
    
    fr(i, 1, n-1)
    {
        ll min = abs(h[i]-h[i-1])+dp[i-1];
        for(int j=1;j<=k;j++)
        {
            if(i-j >= 0)
            {
                ll x = abs(h[i]-h[i-j]);
                x += dp[i-j];
                if(x < min)
                min = x;
            }
             else
                break;
        }
        dp[i] = min;
    }
    cout << dp[n-1];
    
    return 0; 
}

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

int main() 
{
    long long int n,i,total=0;
    cin>>n;
    long long int a[n+1],b[n];
    
    for(i=0;i<n+1;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
        
    for(i=0;i<n;i++)
    {
        if(b[i]>=a[i])
        {
            total=total+a[i];
            if(a[i+1]>=(b[i]-a[i]))
            {
                total = total+b[i]-a[i];
                a[i+1]=a[i+1]-(b[i]-a[i]);
            }
            else
            {
                total = total+a[i+1];
                a[i+1]=0;
            }
        }
        else
        {
            total=total+b[i];
        }
    }
    cout<<total;
}


Measured memory_bytes: 1792
use std::error::Error;
use std::io;
use std::process;

fn main() {
    if let Err(_) = run() {
        process::exit(1);
    }
}

fn run() -> Result<(), Box<Error>> {
    let mut n = String::new();
    io::stdin().read_line(&mut n)?;
    let n: i32 = n.trim().parse()?;
    let mut ans = 1;
    let mut m_ans = 0;
    for x in 1..n+1 {
        let m = f(x);
        if m_ans < m {
            ans = x;
            m_ans = m;
        }
    }
    println!("{}", ans);
    Ok(())
}

fn f(n: i32) -> i32 {
    let mut n = n;
    let mut ans = 0;
    while n % 2 == 0 {
        ans += 1;
        n = n / 2;
    }
    ans
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <string>
#include <memory.h>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <time.h>
#include <assert.h>
#include <cmath>
#include <stack>
#include <string.h>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 200000;
int n, m;
vector<vector<pair<int, int> > > g;
int loc[N];
bool vis[N];
void DFS(int u, int at) {
	if (vis[u]) {
		if (at != loc[u]) {
			puts("No");
			exit(0);
		}
		return;
	}
	loc[u] = at;
	vis[u] = true;
	for (int i = 0; i < g[u].size(); ++i)
		DFS(g[u][i].first, at + g[u][i].second);
}
int main()
{
	scanf("%d%d", &n, &m);
	g.resize(n);
	for (int i = 0, a, b, c; i < m; ++i) {
		scanf("%d%d%d", &a, &b, &c);
		--a; --b;
		g[a].push_back({ b,c });
		g[b].push_back({ a,-c });
	}
	for (int i = 0; i < g.size(); ++i)
		if (!vis[i]) {
			DFS(i, 0);
		}
	puts("Yes");
	return 0;
}

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

int main(){
  long long int a,b,c;
  cin>>a>>b>>c;
  set<tuple<long long int,long long int,long long int>> s;
  for(int i=0;;i++){
    auto x=make_tuple(a,b,c);
    if(s.count(x)){
      cout<<-1<<endl;
      return 0;
    }
    s.insert(x);

    if(a%2==0 && b%2==0 && c%2==0){
      int newa=(b+c)/2;
      int newb=(a+c)/2;
      int newc=(a+b)/2;
      a=newa;
      b=newb;
      c=newc;
    }
    else{
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string s;
    cin>>s;
    int n = sz(s);
    int ans = 0;
    int cnt = 0;
    rep(i, n) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') cnt++;
        else {
            chmax(ans, cnt);
            cnt = 0;
        }
    }
    chmax(ans, cnt);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque

if __name__ == '__main__':
    que = deque()
    for _ in range(int(input())):
        buff = input().split()
        if buff[0] == "insert":
            que.appendleft(buff[1])
        elif buff[0] == "delete":
            try:
                que.remove(buff[1])
            except ValueError:
                pass
        elif buff[0] == "deleteFirst":
            que.popleft()
        else:
            que.pop()

    print(" ".join(que))



Measured memory_bytes: 69732
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);
typedef long long LL;

LL func(string s){
	LL ret = 0;
	for(int i=1; i<s.size(); i++){
		if(s[i-1] == s[i]){
			ret++;
			i++;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	LL K;

	cin >> S;
	cin >> K;

	if(S.size() == 1){
		printf("%lld\n", K/2);
		return 0;
	}
	if(S.size() == 2){
		if(S[0] == S[1]){
			printf("%lld\n", K);
		}
		else{
			printf("0\n");
		}
		return 0;
	}

	LL ans = 0;

	string S1 = S;
	string S2 = S1 + S;
	string S3 = S2 + S;
	LL a1 = func(S1);
	LL a2 = func(S2);
	LL a3 = func(S3);
	LL d1 = a2 - a1;
	LL d2 = a3 - a2;
	if(d1 == d2){
		ans = a1 + (K-1)*d1;
	}
	else{
		ans = a1 + ((K-1)/2)*(d1+d2);
		if((K-1) % 2 == 1){
			ans += d1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3684
use proconio::{input, fastout};
const MODC: u64 = 1000000007;

fn powm (xx: u64, yy: u64) -> u64 {
    let mut x = xx;
    let mut y = yy;
    let mut result = 1;
    while y > 0 {
        if y & 1 != 0 {
            result *= x;
            result %= MODC;
        }
        x *= x;
        x %= MODC;
        y >>= 1;
    }
    result
}
struct Fact {
    mm: Vec<u32>,
    iv: Vec<u32>,
}
impl Fact {
    fn new() -> Fact {
        Fact {
            mm: vec![1],      // idx!
            iv: vec![1],     // 1 / idx!
        }

    }
    fn fact(&mut self, x: u64) -> u64 {
        if x < self.mm.len() as u64 { self.mm[x as usize] as u64 }
        else {
            let len = self.mm.len();
            let mut n = self.mm[len-1] as u64;
            for i in (len as u64)..(x + 1) {
                n = n * i % MODC;
                self.mm.push(n as u32);
            }
            n
        }
    } 
    fn facti(&mut self, x: u64) -> u64 {
        if x < self.iv.len() as u64 { self.iv[x as usize] as u64 }
        else {
            let len = self.iv.len();
            let mut n: u64 = 0;
            for i in (len as u64)..(x + 1) {
                n = powm(self.fact(i), MODC - 2);
                self.iv.push(n as u32);
            }
            n
        }
    } 
    fn combm (&mut self, n: u64, k: u64) -> u64 {
        let mut result = self.fact(n);
        result = result * self.facti(n - k) % MODC;
        result * self.facti(k) % MODC
    }
}

#[fastout]
fn main() {
    let mut f = Fact::new();
    input! {
        k: u64,
        s: String,
    }
    let n = s.len() as u64;
    let mut ans = 0;
    for i in 0..(k+1) {
        ans += powm(25, i) * powm(26, k - i) % MODC * f.combm(n + i - 1, n - 1) % MODC;
        if ans >= MODC {ans -= MODC};
    }
    println!("{}", ans);
}


Measured memory_bytes: 15796
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	string s;
	cin >> s;
	vector<char>c;
	for (int j = 97; j <= 122; j++) {
		if (count(s.begin(),s.end(),(char)j)==0)c.push_back((char)j);
	}
	sort(c.begin(), c.end());
	if (c.size() == 0)cout << "None" << endl;
	else cout << c[0] << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int num[105]={0};
int main()
{
    int n,cnt=0;
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d",&num[i]);
    for(int i = 1 ; i <= n ; i++)
      for(int j = n ; j >= 1; j--)
      {
          if(num[j]<num[j-1])
          {
              swap(num[j],num[j-1]);
              cnt++;
          }
      }
    for(int i = 1 ; i <= n ; i++)
    {
        printf("%d",num[i]);
        if(i<n)
          printf(" ");
    }
    printf("\n%d\n",cnt);
    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

vector<int> G[1<<17];
vector<int> dp(1<<17);

int dfs(int u,int v){
    int ret = 0;
    for(auto g:G[u]){
        if(g == v) continue;
        ret = max(ret, dfs(g, u));
    }
    return dp[u] = ret + 1;
}

int n;
int l = 3;

void dfs2(int u, int v, P x){
    vector<P> vv;
    for(auto g:G[u]){
        if(g == v){
            vv.pb(x);
        }
        else{
            vv.pb(mp(dp[g],g));
        }
    }
    sort(RALL(vv));
    for(auto g:G[u]){
        if(g == v) continue;
        if(vv[0].sc == g){
            if(vv.size() == 1) dfs2(g, u, mp(1, u));
            else dfs2(g, u, mp(vv[1].fs + 1, u));
        }
        else{
            dfs2(g, u, mp(vv[0].fs + 1, u));
        }
    }
    if(vv.size() >= 3){
        int a = vv[0].fs, b = vv[1].fs, c = vv[2].fs;
        for (int k = l; k < n; k++) {
            if(k > a + c) break;
            else if(a + c == k && k - b == k - c && (k - c) * 2 == k) break;
            l++;
        }
    }
    return;
}



int main(){
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    for (int i = 0; i < n-1; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(0,0);
    dfs2(0,0,mp(0,0));
    for (int i = 1; i <= 2; i++) {
        cout << 1;
    }
    for (int i = 3; i < l; i++) {
        cout << 0;
    }
    for (int i = l; i <= n; i++) {
        cout << 1;
    }
    cout << endl;
    return 0;
}





Measured memory_bytes: 28220
#include <iostream>
#include <iomanip>
#include <fstream>

#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>

#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>

#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N, M;
    cin >> N >> M;
    if(!cin) return;
    vector<int> A(M, 0);
    for (int i = 0; i < N; ++i) {
        int K;
        cin >> K;
        for (int k = 0; k < K; ++k) {
            int a;
            cin >> a;
            a--;
            A[a]++;
        } // end k
    } // end i
    int like = 0;
    for (auto &&a: A) {
        if(a == N) like++;
    } // end
    cout << like << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N,ans(0),sum(0);
  	scanf("%d",&N);
  	char isi[N];
  	scanf("%s",isi);
  	for(int i = 0 ; i < N ; i ++){
    	if(isi[i] == '.') ans ++;
    }
  	sum = ans;
  	for(int i = 0 ; i < N ; i ++){
      	if(isi[i] == '#') sum ++;
      	if(isi[i] == '.') sum --;
      	if(sum < ans) ans = sum;
    }
  	printf("%d",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)

int main() {
  int n, q;
  cin >> n >> q;
  vector<tuple<int, int, int>> t;
  rep(i, n) {
    int l, r, x;
    cin >> l >> r >> x;
    l -= x;
    r -= x;
    t.push_back(make_tuple(l, 1, x));
    t.push_back(make_tuple(r, 0, x));
  }
  rep(i, q) {
    int d;
    cin >> d;
    t.push_back(make_tuple(d, 2, 0));
  }
  sort(all(t));
  set<int> st;
  for(auto v : t) {
    int l, b, x;
    tie(l, b, x) = v;
    if(b == 2)
      cout << (st.empty() ? -1 : *st.begin()) << endl;
    else if(b == 1)
      st.insert(x);
    else
      st.erase(x);
  }
}


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

int main(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  rep(i,N)
    cin >> A.at(i);

  int m=0;
  rep(i,N){
    if(i==N-1){
      m = max(m,abs((K-A.at(i))+A.at(0)));
    }else{
      m = max(m,abs(A.at(i)-A.at(i+1)));
    }
  }
  cout << K-m << endl;
}


Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  /*
  if (A[0] == A.back()) {
    cout << 1 << endl;
    return 0;
  }
  */

  map<int,int> M;
  for (int i = 0; i < N; i++) {
    M[A[i]]++;
  }

  int cnt = 0;
  for(auto e : M) {
    if (e.second % 2 == 0) {
      cnt++;
    }
  }
  cout << M.size() - cnt % 2 << endl;
  return 0;
}

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

struct Point 
{
  double x, y;
  
  Point() {}
  
  Point(double x, double y) : x(x), y(y) {}
  
  void input() { scanf("%lf %lf", &x, &y); }
  void output() { printf("%.10f %.10f\n", x, y); }
  double abs() { return (sqrt(norm())); }
  double norm() { return (x * x + y * y); }
  
  Point operator + (Point d) { return (Point(x + d.x, y + d.y)); }
  Point operator - (Point d) { return (Point(x - d.x, y - d.y)); }
  Point operator - () { return (Point(-x, -y)); }
  Point operator * (double a) { return (Point(x * a, y * a)); }
  Point operator / (double a) { return (Point(x / a, y / a)); }
  
};

struct Segment
{
  Point p1, p2;
  
  Segment() {}
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}

  void input() { p1.input(); p2.input(); }
  
};

typedef Point Vector;
typedef vector < Point > Polygon;
typedef Segment Line;

double dot(Vector a, Vector b)
{
  return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
  return (a.x * b.y - a.y * b.x);
}

Point project(Line s, Point p)
{
  Vector base = s.p2 - s.p1;
  return (s.p1 + base * (dot(p - s.p1, base) / base.norm()));
}

Point reflect(Line s, Point p)
{
  return (-p + project(s, p) * 2);
}


main()
{
  int n;
  Line s;
  
  s.input();
  cin >> n;

  for(int i = 0; i < n; i++) {
    Point p;
    p.input();
    reflect(s, p).output();
  }
  
  
  return (0);
}

Measured memory_bytes: 3200