akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    int n;
    cin >> n;
    int max = 0;
    int now = 0;
    while(n--) {
        int a, b;
        cin >> a >> b;
        if(a == b) ++now;
        else now = 0;
        chmax(max, now);
    }
    cout << (max >= 3 ? "Yes" : "No") << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3612
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n;
vec<i32> w[100001];

i32 rec(i32 i) {
    multiset<i32> s;
    times(w[i].size(), j) {
        s.insert(-rec(w[i][j]));
    }
    i32 ret = 0;
    auto it = s.begin();
    times(s.size(), j) {
        ret = max(ret, (-*it)+j+1);
        it++;
    }
    return ret;
}

i32 main()
{
    cin >> n;
    upto(2, n, i) {
        i32 a; cin >> a;
        w[a].append(i);
    }
    cout << rec(1) << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>

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 INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

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

typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;

int main() {
	int x;
	cin >> x;
	if (x < 1200) puts("ABC");
	else puts("ARC");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX / 5
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

//各Q[i]を素因数分解した結果を２次元配列で返す。
//O(nlog(n)+Q.size()*log(Q[i]))
vector<vector<int>> multi_factolization(vector<int>Q) {
	vector<int>QQ = Q;
	sort(QQ);
	reverse(QQ);
	int n = QQ[0];
	vector<int> spf(n + 1);
	for (int i = 0; i <= n; i++) spf[i] = i;
	for (int i = 2; i * i <= n; i++) {
		if (spf[i] == i) {
			for (int j = i * i; j <= n; j += i) {
				if (spf[j] == j) {
					spf[j] = i;
				}
			}
		}
	}
	vector<vector<int>>ANS(Q.size());
	rep(i, Q.size()) {
		vector<int> ret;
		while (Q[i] != 1) {
			ret.push_back(spf[Q[i]]);
			Q[i] /= spf[Q[i]];
		}
		sort(ret);
		ANS[i] = ret;
	}
	return ANS;
}

//aとbの最大公約数を返す
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

//aとbの最小公倍数を返す
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<vector<int>>V = multi_factolization(A);
	int GCD = A[0];
	rep(i, N) {
		GCD = gcd(GCD, A[i]);
	}
	if (GCD != 1) {
		cout << "not coprime" << enld;
		return 0;
	}

	vector<set<int>>S(N);
	rep(i, N) {
		rep(j, V[i].size()) {
			S[i].insert(V[i][j]);
		}
	}
	set<int>SS;
	rep(i, N) {
		for (auto x : S[i]) {
			if (SS.count(x)) {
				cout << "setwise coprime" << endl;
				return 0;
			}
			SS.insert(x);
		}
	}
	cout << "pairwise coprime" << enld;
}

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

int main(){
  int N;
    cin>>N;
  vector <tuple<string,int,int>> rest(N); 
  for(int i=0;i<N;i++){
    cin >>get<0>(rest.at(i))>>get<1>(rest.at(i));
  	get<2>(rest.at(i))=i;
    get<1>(rest.at(i))*=-1;
  }
  sort(rest.begin(),rest.end());
  for(int i=0;i<N;i++)
  cout << get<2>(rest.at(i))+1<<endl;
}

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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

ll bc(ll x, int i) {
  ll p = pow(2ll, i + 1), ph = p / 2;
  return x / p * ph + max(0ll, x % p + 1 - ph);
}
int main() {
  ll a, b;
  cin >> a >> b;
  ll re = 0;
  repi(48) if ((bc(b, i) - bc(a - 1, i)) % 2 == 1) re |= 1ll << i;
  cout << re << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(name, start, stop) for (auto(name) = (start); (name) < (stop); (name)++)
using ll = long long;
using vi = vector<ll>;
constexpr ll N_MAX = 200001;
ll dp[N_MAX] = {0};

ll func(ll n) {
    if (n < 2)
        return 0;
    if (dp[n] > 0) {
        return dp[n];
    }
    dp[n] = n - 1 + func(n - 1);
    return dp[n];
}

int main(void) {
    ll n;
    cin >> n;
    map<ll, ll> freq;
    vi a(n);
    REP(i, 0, n) {
        cin >> a[i];
        freq[a[i]]++;
    }
    ll match_cnt = 0;
    for (const auto& p : freq) {
        ll c = p.second;
        match_cnt += func(c);
    }
    REP(i, 0, n) {
        ll ans = match_cnt;
        ll f = freq[a[i]];
        ans += func(f - 1) - func(f);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  string a;
  cin >> a;
  sort(a.begin(), a.end());
  if(a == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
(* abc138 b problem *)
open Scanf;;
open Array;;

let () = Scanf.scanf "%d"
           (fun n -> Array.init n (fun _ -> Scanf.scanf " %f" (fun a -> a)))
         |> Array.fold_left (fun x a -> x +. (1.0 /. a)) 0.0
         |> ((/.) 1.0)
         |> print_float
         |> print_newline;;

exit 0;;

Measured memory_bytes: 384
S = input()
alp = [chr(ord('a') + i) for i in range(26)]
L = [0]*26
def alp(n):
  return(ord(n)-97)
for i in range(len(S)):
  k = alp(S[i])
  L[k] += 1
ans = len(S)*(len(S)-1)//2+1
for i in range(26):
  ans -= L[i]*(L[i]-1)//2
print(ans)

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

class UnionFind {
  int _size;
  unique_ptr<int[]> _parent; // 親（親自身はー（マイナス）集合要素の個数）

 public:
  // n要素で生成
  explicit UnionFind(int n) : _size{n}, _parent{make_unique<int[]>(n)} {
    for (int i{}; i < n; ++i) {
      _parent[i] = -1;
    }
  }

  // 木の根を求める
  int find(int x) {
    if (x < 0 || x >= _size) {
      return x;
    }

    if (_parent[x] < 0) {
      return x;
    }

    return _parent[x] = find(_parent[x]);
  }

  // xとyの属する集合を併合する
  bool unite(int x, int y) {
    if (x < 0 || x >= _size || y < 0 || y >= _size) {
      return false;
    }

    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }

    if (size(x) > size(y)) {
      _parent[x] += _parent[y];
      _parent[y] = x;
    } else {
      _parent[y] += _parent[x];
      _parent[x] = y;
    }

    return true;
  }

  // xとyが同じ集合に属するか
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // xの属する集合の個数を求める
  int size(int x) {
    return -_parent[find(x)];
  }

  // 全体の個数を求める
  int size() {
    return _size;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  for (int i{}; i < M; ++i) {
    cin >> A[i] >> B[i];
    --A[i];
    --B[i];
  }

  UnionFind uni(N);

  vector<long long> ans(M);
  ans[M - 1] = (long long) N * (N - 1) / 2;

  for (int i{M - 1}; i >= 1; --i) {
    ans[i - 1] = ans[i];
    if (uni.find(A[i]) != uni.find(B[i])) {
      ans[i - 1] -= (long long) uni.size(A[i]) * uni.size(B[i]);
      uni.unite(A[i], B[i]);
    }
  }

  for (int i{}; i < M; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{

  int n, c = 0, j, x, y,k,i;
  cin >> n;
  int a[n + 3];
  int b[10];
  for (i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (i = 0; i < n - 2; i++)
  {
    for (j = i + 1; j < n - 1; j++)
    {
      for (k = j + 1; k < n; k++)
      {
        if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
        {
          b[0] = a[i]; b[1] = a[j]; b[2] = a[k];
          sort(b, b + 3);
          if (b[0] + b[1] > b[2])
          {
            c++;
          }
        }
      }
    }
  }

  cout<<c<<endl;
}

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

int main()
{
    long long i,a,sum=360;
    cin>>a;
    for(i=0;i<=110000000;i++)
   {
      if(sum%a==0)
      {
       cout<<sum/a<<endl;
       return 0;
      }
      else sum+=360;
    }
}


Measured memory_bytes: 3632
#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>;

ll INF = 1001001001;

ll dp[105][100005];

int main() {
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i,n) cin >> w[i] >> v[i];
    int v_max = 0; 
    rep(i,100005)rep(j,105) dp[j][i] = INF;

    for (int i = 1; i <= n; ++i) {
        v_max += v[i-1];
        for (int j = 1; j <= v_max; ++j) {
            if (j <= v[i-1]) dp[i][j] = min(dp[i-1][j], w[i-1]);
            else dp[i][j] = min(dp[i-1][j-v[i-1]]+w[i-1], dp[i-1][j]);
        }
    }
    ll ans;
    for (int i = v_max; i > 0; --i) {
        if (dp[n][i] <= W) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 82304
a, b = map(int, input().split())
import math
import fractions
n = fractions.gcd(a, b)
devide = 2
l1 = []
while devide <= math.sqrt(n):
    while n % devide == 0:
        n = n / devide
        l1.append(devide)
    devide += 1
l1.append(n)
l1 = list(set(l1))
if n == 1:
    print(int(len(l1)))
else:
    print(int(len(l1) + 1))

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> A(N, vector<char>(N)), B(M, vector<char>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B.at(i).at(j);
    }
  }
  
  bool E = false;
  for (int k = 0; k <= N - M; k++) {
    for (int l = 0; l <= N - M; l++) {
      int X = 0;
      for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
          if (A.at(i + k).at(j + l) == B.at(i).at(j)) X++;
        }
      }
      if (X == M * M) {
        E = true;
        break;
      }
    }
  }
  
  if (E) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    std::cin >> n;
    vec<u64> a(n);
    for (u64& x: a) std::cin >> x;
    u64 sum = std::accumulate(ALL(a), u64{0});

    usize q;
    std::cin >> q;
    while (q--) {
        usize i;
        u64 x;
        std::cin >> i >> x;
        i--;
        std::cout << sum - a.at(i) + x << '\n';
    }
}


Measured memory_bytes: 256
days=(31,29,31,30,31,30,31,31,30,31,30,31)
day=('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')
while True:
	total=0
	m,d=map(int,raw_input().split(" "))
	if m!=0:
		for i in range(m-1):
			total+=days[i]
		total+=d
		print day[(total+3)%7]
	else:
		break

Measured memory_bytes: 4220
# 入力
total_days = int(input())
days_normal_price = int(input())
normal_price = int(input())
discount_price = int(input())

# 処理
if total_days <= days_normal_price:
    answer =total_days * normal_price
    print(answer)
elif total_days > days_normal_price:
    first = normal_price * days_normal_price
    second = (total_days - days_normal_price) * discount_price
    answer = first + second
    print(answer)

Measured memory_bytes: 9108
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string s;
  int l[4], r[4], m[4];
  while(1){
    cin >> s;
    if(s=="0000") break;
    if(s[0]==s[1] && s[0]==s[2] && s[0]==s[3]){
      cout << "NA" << endl; continue;
    }
    m[0]=s[0]-'0', m[1]=s[1]-'0', m[2]=s[2]-'0', m[3]=s[3]-'0';
    for(int i=0; ; ++i){
      if(m[0]==6 && m[1]==1 && m[2]==7 && m[3]==4){
	cout << i << endl; break;
      }
      l[0]=m[0], l[1]=m[1], l[2]=m[2], l[3]=m[3];
      sort(l, l+4);
      r[0]=l[0], r[1]=l[1], r[2]=l[2], r[3]=l[3];
      reverse(r, r+4);
      int k = r[0]*1000 + r[1]*100 + r[2]*10 + r[3]
	- l[0]*1000 - l[1]*100 - l[2]*10 - l[3];
      m[0]=k/1000, k-=m[0]*1000;
      m[1]=k/100, k-=m[1]*100;
      m[2]=k/10, k-=m[2]*10;
      m[3]=k;
    }
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    vector<ll> dp(n + 200, 1e15);
    rep(i, n)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    rep(i, n)
    {
        for (int j = 1; j <= k; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<math.h>
#include<complex>
double PI=acos(-1);

template<typename T>
class FFT{
  private:
    using Complex = std::complex<long double>;
    std::vector<Complex> C;
    void DFT(std::vector<Complex> &F,int n,int sig=1){
        if(n==1) return;
        std::vector<Complex> f0(n/2),f1(n/2);
        for(int i=0;i<n/2;++i){
            f0[i]=F[2*i];
            f1[i]=F[2*i+1];
        }
        DFT(f0,n/2,sig);
        DFT(f1,n/2,sig);
        Complex z(cos(2.0*PI/n),sin(2.0*PI/n)*sig),zi=1;
        for(int i=0;i<n;++i){
            if(i<n/2) F[i]=f0[i]+zi*f1[i];
            else F[i]=f0[i-n/2]+zi*f1[i-n/2];
            zi*=z;
        }
        return;
    }
    void invDFT(std::vector<Complex> &f,int n){
        DFT(f,n,-1);
        for(int i=0;i<n;++i){
            f[i]/=n;
        }
        return;
    }
  public:
    FFT(const std::vector<T> &A,const std::vector<T> &B){
        int n=1;
        while(n<=A.size()+B.size()){
            n*=2;
        }
        std::vector<Complex> h(n,Complex(0)),g(n,Complex(0));
        for(int i=0;i<n;++i){
            if(i<A.size()) h[i]=Complex(A[i]);
            if(i<B.size()) g[i]=Complex(B[i]);
        }
        DFT(h,n);
        DFT(g,n);
        C.resize(n);
        for(int i=0;i<n;++i) C[i]=h[i]*g[i];
        invDFT(C,n);
        for(int i=0;i<n;++i) if(T(C[i].real())!=C[i].real()){
            C[i]=Complex(C[i].real()+0.5);
        }
    }
    T operator[](int k)const{return C[k].real();}
};

int main(){
    int N;
    long long M;
    std::cin>>N>>M;
    std::vector<int> A(N);
    int MAX_A=0;
    for(int i=0;i<N;++i){
        std::cin>>A[i];
        MAX_A=std::max(MAX_A,A[i]);
    }
    std::vector<long long> cnt(MAX_A+1);
    for(int i=0;i<N;++i){
        cnt[A[i]]++;
    }
    FFT<long long> C(cnt,cnt);
    long long ans=0;
    for(int i=2*MAX_A;i>=0;--i){
        if(M>=C[i]){
            ans+=i*C[i];
            M-=C[i];
        }else{
            ans+=i*M;
            break;
        }
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 44436
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}
ll prime[1000000];bool visprime[10000000];
void sieve(){ll k=0;for(ll i=2;i*i<=1000000;i++){for(ll j=i*i;j<=1000000;j+=i){visprime[j]=true;}}for(ll i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}


int main()
{

    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    double temp=0.0;

    for(int i=0;i<n;i++)
    {
        temp+=1.0/arr[i]*1.0;
    }
    temp=1.0/temp;
    printf("%.5f\n",temp);


}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int n, m, Q; cin >> n >> m >> Q;
    int l[m], r[m];
    rep(i, m){
        cin >> l[i] >> r[i];
    }

    int p[Q], q[Q];
    rep(i, Q){
        cin >> p[i] >> q[i];
    }

    int cnt[n+1][n+1];
    memset(cnt, 0, sizeof(cnt));

    rep(i, m){
        cnt[l[i]][r[i]]++;
    }

    reps(j, 1, n){
        cnt[j][j+1] += cnt[j][j] + cnt[j+1][j+1];
    }

    // cout << " " << endl;
    reps(i, 2, n){
        reps(j, 1, n+1-i){
            // cout << j << " " << j+i << endl;
            cnt[j][j+i] += cnt[j][j+i-1] + cnt[j+1][j+i] - cnt[j+1][j+i-1];
        }
    }

    rep(i, Q){
        cout << cnt[p[i]][q[i]] << endl;
    }

    return 0;
}

Measured memory_bytes: 4224
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    if(a<b)
        REP(i, b) cout << a;
    else if(a>b)
        REP(i, a) cout << b;
    else
        REP(i, min(a, b)) cout << b;
    
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

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

def dfs(v,d,dist):
    dist[v] = d
    for ve in edge[v]:
        if dist[ve] is None:
            dist = dfs(ve, d+1, dist)
    return dist
    
    
f_dist = dfs(0,0,[None]*n)
s_dist = dfs(n-1,0,[None]*n)

fget = sum(1 for f,s in zip(f_dist,s_dist) if f<=s)
print("Fennec" if fget*2>n else "Snuke")

Measured memory_bytes: 117296
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a + b + c <= 21) {
            System.out.println("win");
        } else {
            System.out.println("bust");
        }
    }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	double ans=0;
	for(int i=0;i<n;++i){
		double a; cin>>a;
		ans+=1/a;
	}
	cout<<1/ans<<"\n"s;
}


Measured memory_bytes: 3732
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

S = list(input())

for i, s in enumerate(S):
    if (i + 1) % 2 == 0:
        if s not in even:
            print('No')
            exit()
    else:
        if s not in odd:
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 2940
from collections import deque

X,Y,A,B,C = map(int, input().split())
A=[int(a) for a in input().split()]
B=[int(b) for b in input().split()]
C=[int(c) for c in input().split()]

A=sorted(A, reverse=True)[:X]
B=sorted(B, reverse=True)[:Y]
AB=deque(sorted(A+B))

for c in sorted(C, reverse=True):
  if c >= AB[0]:
    AB.popleft()
    AB.append(c)
  else:
    break

print(sum(AB))

Measured memory_bytes: 29776
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793




int main(){
  int n,a,b;
  cin >> n >> a >> b;
  VI p(n);
  rep(i,n)cin >> p.at(i);
  int x=0;
  int y=0;
  int z=0;
  rep(i,n){
      if(p.at(i)<=a)x++;
      else if(p.at(i)<=b)y++;
      else z++;
  }
  int ans=min(x,y);
  ans=min(ans,z);
  cout << ans << endl;
}

Measured memory_bytes: 3612
if __name__ == "__main__":
    total_occurence_num = 0
    word = input()
    while(True):
        input_str = input()
        if (input_str == "END_OF_TEXT"):
            break
        total_occurence_num += sum(map(lambda w: w == word, input_str.strip(".").lower().split()))
    print(f"{total_occurence_num}")



Measured memory_bytes: 5568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   int N, A,B;
   cin >> N >> A >> B;
   int a[N],b[N],c[N];
   int lowest[500][500];
   for(int i=0;i<500;i++){
      for (int j = 0; j < 500; j++)
      {
         lowest[i][j]=INT_MAX/2;
      }
   }
   lowest[0][0]=0;
   for (int i = 0; i < N; i++)
   {
      cin >> a[i] >> b[i] >> c[i];
      for(int x=499-a[i];x>=0;x--){
         for(int y=499-b[i];y>=0;y--){
            if(lowest[x][y]!=INT_MAX/2){
               lowest[x+a[i]][y+b[i]]=min(lowest[x+a[i]][y+b[i]], lowest[x][y]+c[i]);
            }     
         }
      }
   }
   int ans = INT_MAX/2;
   for(int i = 1 ; i < 500; i++){
      int X=A*i;
      int Y=B*i;
      if(X>400||Y>400){
         break;
      }
      ans = min(ans, lowest[X][Y]);
   }
   if(ans == INT_MAX/2) ans = -1;
   cout << ans << endl;
   
   return 0;
}


Measured memory_bytes: 4596
import heapq as hp
import sys
def input():
    return sys.stdin.readline()

n,m = map(int,input().split())
list = [[int(i) for i in input().split()] for i in range(n)]
temp = [0]
ans = 0
a = 0
j = 0
list = sorted(list)

for i in range(1,1+m):
  for j in range(a,len(list)):
    if list[j][0] == i:
      hp.heappush(temp,-list[j][1])
    else:
      a = j
      break
  if len(temp) > 0:
    ans -= hp.heappop(temp)
print(ans)

Measured memory_bytes: 25652
n = int(input())
li = list(map(int,input().split()))

ans = 1

for a in li:
  if a == 0:
    print(0)
    exit()

for a in li:
  ans = ans * a
  if ans > 1000000000000000000:
    print(-1)
    exit()
  
print(ans)

Measured memory_bytes: 84676
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  if(a>=13) ans = b;
  else if(a>= 6) ans = b/2;
  else ans = 0;

  cout << ans << endl;

}

Measured memory_bytes: 256
n = list(input())
ls = []
for i in range(3):
  ls.append(int(n[i]))
  
if ls[0] >= ls[1] and ls[0] >= ls[2]:
  for i in range(3):
    print(ls[0],end="")
else:
  for i in range(3):
    print(ls[0]+1,end="")

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

#define MOD 1000000007

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

	ll X = 1; // X = 10^N
	ll Y = 1; // Y = 8^N
	ll Z = 1; // Z = 9^N
	for(int i = 0; i < N; i++){
		X = (X * 10) % MOD;
		Y = (Y * 8) % MOD;
		Z = (Z * 9) % MOD;
	}
	Z = (Z * 2) % MOD;
	ll A = (X - Z + Y) % MOD;
	if(A < 0){
		A += MOD;
	}

	cout << A << endl;
	return(0);
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli L,R,N,M,K,sum=0,num=0;
   cin >> N >> K;
   sum=max((N-2),num+1)*max((K-2),num+1);
   if(N==2||K==2)sum=0;
   Out(sum);
}


Measured memory_bytes: 256
#include <cstdio>
#define MOD 1000000007
typedef long long ll;

ll n, a, b, ans, inv[200010];

ll qpow(ll x, ll y){				// 快速幂 
	ll t = 1;
	while(y){
		if(y & 1) t = t * x % MOD;
		x = x * x % MOD;
		y >>= 1;
	}
	return t;
}

ll solve(ll a, ll b){
	ll t = 1;
	// 以下部分即为 a! / (a - b)!，需要运行 b 次，考虑 b 很小，所以可以暴力算 
	for(ll i = a; i >= a - b + 1; i--)
		t = t * i % MOD;
	return t * inv[b] % MOD;
}

int main(){

	scanf("%lld%lld%lld", &n, &a, &b);
	inv[1] = 1;
	for(ll i = 2; i <= 200000; i++)			// 逆元预处理 
		inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
	for(ll i = 2; i <= 200000; i++)			// 递推变成阶乘的逆元 
		inv[i] = inv[i - 1] * inv[i] % MOD;
		
	ans = (qpow(2, n) - 1 + MOD) % MOD; 
	ans = (ans - solve(n, a) + MOD) % MOD;
	ans = (ans - solve(n, b) + MOD) % MOD;
	printf("%lld\n", ans); 

	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>




int main(){
  int n,a,b,m,j;
  int hai[100][100];
  int aa[100],bb[100];
  int t = 0;

  scanf("%d",&n);

  for(a = 0; a < n; a++){
    for(b = 0; b < n; b++){
      scanf("%d",&hai[a][b]);
    }
  }

  for(a = 0; a < n; a++){
    bb[a] = 0;
    aa[a] = 2000;
  }

  aa[0] = 0;

  for(a = 0; a < n; a++){
    m = 2000;
    for(b = 0; b < n; b++){
      if(aa[b] < m && bb[b] == 0){
	m = aa[b];
	j = b;
      }
    }

    bb[j] = 1;
    for(b = 0; b < n; b++){
      if(hai[j][b] != -1 && hai[j][b] < aa[b]  && bb[b] == 0){
	aa[b] = hai[j][b];
      }
    }
  }

  for(a = 0; a < n; a++){
    t += aa[a];
  }

  printf("%d\n",t);


  return 0;
}

  

  



Measured memory_bytes: 2108
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = min(A) + min(B)
for i in range(m):
    x, y, c = map(int, input().split())
    cost = A[x-1] + B[y-1] - c
    ans = min(ans, cost)
print(ans)

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

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (s == u) a--;
    else b--;
    cout << a << " " << b << endl;;
    return 0;
}

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

int main() {
  long long N,A,B,C,ans;
  cin >>A;
  ans=0;
  for(int i=1;i<=A;i++){
    if(i%3!=0&&i%5!=0){
      ans+=i;
    }
  }
  cout <<ans<< endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] var = new int[3];
	static char[] str;
	static int pos;

	public static void main(String[] arg) {
		while (true) {
			str = sc.next().toCharArray();
			if (str[0] == '.') break;
			pos = 0;
			Formula root = parse();
			int ans = 0;
			for (var[0] = 0; var[0] < 3; ++var[0]) {
				for (var[1] = 0; var[1] < 3; ++var[1]) {
					for (var[2] = 0; var[2] < 3; ++var[2]) {
						if (root.eval() == 2) ++ans;
					}
				}
			}
			System.out.println(ans);
		}
	}

	static Formula parse() {
		char c = str[pos++];
		if ('0' <= c && c <= '2') return new Constant(c - '0');
		if ('P' <= c && c <= 'R') return new Var(c);
		if (c == '-') return new Not(parse());
		Formula l = parse();
		char op = str[pos++];
		Formula r = parse();
		pos++;
		if (op == '*') {
			return new And(l, r);
		} else {
			return new Or(l, r);
		}
	}

	static abstract class Formula {
		abstract int eval();
	}

	static class Constant extends Formula {
		int v;

		Constant(int v) {
			this.v = v;
		}

		int eval() {
			return this.v;
		}
	}

	static class Var extends Formula {
		int p;

		Var(char name) {
			if (name == 'P') {
				this.p = 0;
			} else if (name == 'Q') {
				this.p = 1;
			} else {
				this.p = 2;
			}
		}

		int eval() {
			return var[p];
		}
	}

	static class Not extends Formula {
		Formula f;

		Not(Formula f) {
			this.f = f;
		}

		int eval() {
			int v = f.eval();
			return v == 1 ? v : 2 - v;
		}
	}

	static class And extends Formula {
		Formula left, right;

		And(Formula l, Formula r) {
			this.left = l;
			this.right = r;
		}

		int eval() {
			int vl = left.eval();
			int vr = right.eval();
			if (vl == 0 || vr == 0) return 0;
			if (vl == 1 || vr == 1) return 1;
			return 2;
		}
	}

	static class Or extends Formula {
		Formula left, right;

		Or(Formula l, Formula r) {
			this.left = l;
			this.right = r;
		}

		int eval() {
			int vl = left.eval();
			int vr = right.eval();
			if (vl == 2 || vr == 2) return 2;
			if (vl == 1 || vr == 1) return 1;
			return 0;
		}
	}

}

Measured memory_bytes: 18616
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{
	static int n = 12;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			char[][] m = new char[n][n];
			for(int i = 0; i < n; i++) {
				String s = sc.next();
				for(int j = 0; j < n; j++) {
					m[i][j] = s.charAt(j);
				}
			}

			DisjointSet ds = new DisjointSet(n * n);
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(i + 1 < n && m[i][j] == '1' && m[i + 1][j] == '1') {
						ds.unite(n * i + j, n * (i + 1) + j);
					}
					if(j + 1 < n && m[i][j] == '1' && m[i][j + 1] == '1') {
						ds.unite(n * i + j, n * i + j + 1);
					}
				}
			}
			Set<Integer> set = new HashSet<Integer>();
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(m[i][j] == '1') {
						set.add(ds.findSet(i * n + j));
					}
				}
			}
			System.out.println(set.size());
		}
		sc.close();
	}
	static class DisjointSet {
        int[] p;
        int[] rank;
        int[] size;
        DisjointSet(){}
        DisjointSet(int size){
            this.rank = new int[size];
            this.p = new int[size];
            this.size = new int[size];
            for(int i = 0; i < size; i++) {
                makeSet(i);
            }
        }
        void makeSet(int x) {
            p[x] = x;
            rank[x] = 0;
            size[x] = 1;
        }
        boolean same(int x, int y) {
            return findSet(x) == findSet(y);
        }
        void unite(int x, int y) {
            link(findSet(x), findSet(y));
        }
        void link(int x, int y) {
            if(rank[x]  > rank[y]) {
                p[y] = x;
                size[x] = size[x] + size[y];
            }else if(rank[x] < rank[y]){
                p[x] = y;
                size[y] = size[x] + size[y];
            }else if(x != y) {
            	p[y] = x;
            	rank[x]++;
            	size[x] = size[x] + size[y];
            }
        }
        int findSet(int x) {
            if(x != p[x]) {
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
        int size(int x) {
        	if(x != p[x]) {
        		size[x] = size(findSet(x));
        	}
        	return size[x];
        }
    }
}


Measured memory_bytes: 25764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using VI = vector<long>;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    int prev = -1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == prev) {
            prev = -1;
            cnt++;
        } else {
            prev = a;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
string a,b,s;
int A,B;
map<string,int>M;
main()
{
	while(cin>>s)
	{
		if(A<s.size())A=s.size(),a=s;
		if(B<++M[s])B=M[s],b=s;
	}
	cout<<b<<" "<<a<<endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
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; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    vector<int> data(100050,0);
    int n,a;
    cin >>n;
    for range(i,n){
        cin >> a;
        data[a+9]++;
        data[a+10]++;
        data[a+11]++;
    }
    cout << *max_element(all(data))<< endl;;
}

Measured memory_bytes: 768
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    res = 0
    a, b = map(int, r.split())
    if max(a,b) > 8:
        print(':(')
    else:
        print('Yay!')

if __name__ == '__main__':
    main()



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

const int nax = 1e6+1;
int phi[nax];
int isprime[nax];

ll mod = 998244353;

ll sum[nax];
ll g[nax];
ll a[200000];

ll inv(ll a) {
  ll r = 1, p = mod-2;
  while (p) {
    if (p&1) r = r*a%mod;
    a = a*a%mod;
    p >>= 1;
  }
  return r;
}

int main() {
  assert(inv(12345)*12345%mod == 1);

  ios::sync_with_stdio(0); cin.tie(0);

  int n;
  cin >> n;

  ll sum_a = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum_a += a[i];
    (sum[a[i]] += a[i]) %= mod;
  }

  fill_n(isprime+2, nax-2, 1);
  fill_n(phi, nax, 1);
  for (int i = 1; i < nax; i++) {
    if (!isprime[i]) continue;
    for (int j = i; j < nax; j += i)
      phi[j] *= -1, isprime[j] = 0;
    for (int j = (nax-1)/i; j; j--)
      (sum[j] += sum[j*i]) %= mod;
    ll sq = (ll)i*i;
    for (ll j = sq; j < nax; j += sq)
      phi[j] = 0;
  }

  /*for (int i = 1; i < 10; i++)
    cout << phi[i] << ' ';
    cout << endl;*/

  for (int i = 1; i < nax; i++)
    sum[i] = sum[i]*sum[i]%mod;

  ll ans = 0;
  for (int i = 1; i < nax; i++) {
    ll v = 0;
    for (int j = 1; j*i < nax; j++) {
      (v += phi[j]*sum[j*i]) %= mod;
    }
    (ans += v*inv(i)) %= mod;
  }
  (ans -= sum_a) %= mod;
  (ans *= inv(2)) %= mod;
  cout << (ans%mod+mod)%mod << endl;
}


Measured memory_bytes: 18688
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
#S,T = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]

#cnt = 0
#cnt += 1
d=""
dchar ="abcdefghijklmnopqrstuvwxyz"

while N > 0:
    N -= 1
    d += dchar[N%26]
    N//=26
    #print(N%26,N,d)
    
print(d[::-1])


#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)

Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <vector>

#define pb push_back

using namespace std;

typedef long long ll;

int main()
{
        int n;
        cin >> n;
        vector<int> a(3);
        int max;
        while(n--){
                for(int i=0; i<3; ++i) cin >> a[i];
                max = *max_element(a.begin(), a.end());
                if(max*max == a[0]*a[0] + a[1]*a[1] + a[2]*a[2] - max*max) cout << "YES" << endl;
                else cout << "NO" << endl;
        }

        return 0;
}


Measured memory_bytes: 3036
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.Bits ((.&.), xor)
import Data.List
import qualified Data.Vector.Storable as V
import qualified Data.ByteString.Char8 as B

main = do
    [a,b,c,d] <- unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
    case (a,b,c,d) of
        (a,_,c,d) | (abs (c-a) <= d) -> putStrLn "Yes"
        (a,b,c,d) | abs (c-b) <= d && abs(b-a) <= d -> putStrLn "Yes"
        _ -> putStrLn "No"

Measured memory_bytes: 380
/*
 * zyrch - Rupanshu Yadav
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 1e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
	a %= mo;
	if(a < 0) a+=mo;
	return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
	return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}

//=========================CODE STARTS HERE=============================//

int main() {
	
	str s;
	cin >> s;
	
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	}
	else cout << "No"; 
	
	return 0; 
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    bool[string] res;
    foreach (_; 0..N) {
        res[readln.chomp] = true;
    }
    writeln(res.length);
}

Measured memory_bytes: 23616
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int S[maxn], dp[210][maxn];

int N, X;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> N >> X;
	for (int i = 0; i < N; i++)
		cin >> S[i];
	sort(S, S + N);
	for (int t = 0; t < maxn; t++)
		dp[0][t] = t % S[0];
	for (int i = 1; i < N; i++) 
		for (int t = 0; t < maxn; t++) {
			dp[i][t] = 1LL * dp[i - 1][t] * i % MO;
			dp[i][t] = (dp[i][t] + dp[i - 1][t % S[i]]) % MO;
		}
	cout << dp[N - 1][X] << "\n";
}


Measured memory_bytes: 80128