akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int t[n+1], x[n+1], y[n+1];
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < n; i++) {
    int T = t[i+1] - t[i];
    int D = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (T < D || T%2 != D%2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
N,K = map(int, input().split())
As = [i for i in map(int, input().split())]
MOD = 10**9 + 7

count1 = 0
count2 = 0
for i,Ai in enumerate(As):
    for j,Aj in enumerate(As):
        if Ai > Aj:
            count2 += 1
        if i >= j:
            continue
        if Ai > Aj:
            count1 += 1
        
total = (count1*K + count2*K*(K-1)//2) % MOD
print(int(total % (10**9+7)))

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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x;
    ll ans=0;
    cin>>n>>x;
    ll a[n],num;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        if(i==1){
            num=a[0];
            if(num>x){
                ll maki=num-x;
                num-=maki;
                a[0]-=maki;
                ans+=maki;
            }
        }
        else{
            num-=a[i-2];
        }
        num+=a[i];
        if(num>x){
            ll maki=num-x;
            num-=maki;
            a[i]-=maki;
            ans+=maki;
        }
    }
    cout << ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
n=int(input())
#n,p=map(int,input().split())
hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
#素因数分解した結果を2次元配列にして返す
mx=hl[0]
ans="Yes"
for i in range(n):
    mx=max(mx,hl[i])
    if hl[i]>=mx-1:
        pass
    else:
        ans="No"
        break
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    vector<ll> ba(n);
    rep(i, n)
    {
        ll k = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ba[i] = k;
    }
    rep(i, n - 1)
    {
        ba[i + 1] += ba[i];
    }

    ll ans = 0;
    rep(i, n)
    {
        ll k = lower_bound(b.begin(), b.end(), c[i]) - b.begin();
        if (k > 0)
        {
            ans += ba[k - 1];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

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

		int n, t, min = 100000, c, l;

		n = sc.nextInt();
		t = sc.nextInt();

		for (int i = 0; i < n; ++i) {
			c = sc.nextInt();
			l = sc.nextInt();
			if (l <= t) {
				min = Math.min(min, c);
			}
		}

		if (min > 1000) {
			System.out.println("TLE");
		} else {
			System.out.println(min);
		}
		sc.close();
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> A >> B >> C;
	if (A*C <= B)cout << C << endl;
	else cout << B / A << endl;
}

Measured memory_bytes: 256
a = int(input())
max_count = 0
max_number = 1

for i in range(1,a+1):
    count = 0
    hold = i
    while i%2 == 0:
        count += 1
        i //= 2
    if count > max_count:
        max_count = count
        max_number = hold
        
print(max_number)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include<string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s[1]=='R') cout<<"ABC";
	else cout<<"ARC";
}

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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n,greater<int>());
    int sum = 0;
    for(int i=0;i<n;i++)
    {
        if(!(i%2))
            sum += a[i];
        else
            sum -= a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<ll, ll>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, T;
  cin >> N >> T;
  VI A(N);
  INPUT(A);
  int max_A = A[N-1];
  int max_pro = -1;
  int ans = 0;
  int pro;
  REPR(i, N-1)
  {
    if (A[i] > max_A)
    {
      max_A = A[i];
      continue;
    }
    pro = max_A - A[i];
    if (pro < max_pro) continue;
    else if (pro > max_pro)
    {
      ans = 1;
      max_pro = pro;
    }
    else if (pro == max_pro) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
def solve(s, k):
    n = len(s)
    if k >= n // 2:
        return n
    dpp = [[1] * (k + 1), [0] * (k + 1)]
    for r in range(1, n):
        dpc = [[0] * (k + 1) for _ in range(r + 2)]
        dpc[r] = [1] * (k + 1)
        for l in range(r - 1, -1, -1):
            dpl, dpl1 = dpc[l], dpp[l + 1]
            if s[l] == s[r]:
                dpc[l] = [c + 2 for c in dpl1]
            else:
                dppl, dpcl1 = dpp[l], dpc[l + 1]
                dpl[0] = max(dppl[0], dpcl1[0])
                for p in range(1, k + 1):
                    dpl[p] = max(dppl[p], dpcl1[p], dpl1[p - 1] + 2)
        dpp = dpc

    return dpp[0][k]


print(solve(input(), int(input())))


Measured memory_bytes: 3956
def is_OK(W, N):
    w = {W[0]}
    for i in range(0, N-1):
        if (W[i][-1] != W[i+1][0]) or (W[i+1] in w):
            return 'No'
        else:
            w.add(W[i+1])
    return 'Yes'

N = int(input())
W = []
for _ in range(N):
    W.append(input())

print(is_OK(W, N))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<cmath>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
	string ans;
	ll k,x;	cin >> k >> x;
	if(500*k >= x)ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;
const int MAX_N = 1 << 18;
int S[MAX_N];
bool used[MAX_N];

signed main()
{
  cin >> N;
  int M = 1 << N;
  REP(n,M) {
    cin >> S[n];
  }

  sort(S, S+M, greater<int>());

  used[0] = true;
  REP(n,N) {
    priority_queue<int> pq;
    REP(m,M) {
      if(used[m]) {
        pq.push(S[m]);
      }
    }
    REP(m,M) {
      if(pq.size() == 0) break;
      if(!used[m]) {
        if(pq.top() > S[m]) {
          used[m] = true;
          pq.pop();
        }
      }
    }
    if(pq.size() != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}


int main() {
    int a,b,c,k;
    cin >> a >> b>> c >> k;
    int ans = 0;
    int sa = 0;

    // 引ける数を引く
    if(a >= k) {
        sa = k;
    }else{
        sa = a;
    }
    k -= sa;
    ans += sa;

    if(b>= k){
        sa = k;
    }else{
        sa = b;
    }
    k -= sa;

    if(c>= k){
        sa = k;
    }else{
        sa = c;
    }
    ans -= sa;


    ct(ans);


}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X; cin >> X;
  int ans = 1;
  for(int i = 1; i*i <= X; i++){
    int tmp = i;
    for(int j = 2; j <= 10; j++){
      tmp *= i;
      if(tmp > X) break;
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}

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

#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int MAXN = 2e5+5;
const int MOD= 998244353;
int n,b[MAXN];
struct node{
    int x,y;
}a[MAXN];
bool cmp(node a,node b){
    return a.x<b.x;
}
ll dp[MAXN];
stack<pair<int,int> >st;
int main()
{
    scanf("%d",&n);
    rep(i,1,n){
        scanf("%d%d",&a[i].x,&a[i].y);
        a[i].y+=a[i].x-1;
    }
    sort(a+1,a+n+1,cmp);
    rep(i,1,n)b[i]=a[i].x;
    dp[n+1]=1;
    while(!st.empty())st.pop();
    per(i,n,1){
        int y=a[i].y;
        while(!st.empty()&&y>=a[st.top().first].x){
            y=max(y,st.top().second);
            st.pop();
        }
        if(st.empty())dp[i]=(dp[i+1]+dp[n+1])%MOD;
        else dp[i]=(dp[i+1]+dp[st.top().first])%MOD;
        st.push(make_pair(i,y));

    }
    printf("%lld\n",dp[1]);
}


Measured memory_bytes: 4992
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };



template<typename T, T MOD = 1000000007>
struct Mint {
	T v;

	Mint() : v(0) {}
	Mint(signed v) : v(v) {}
	Mint(ll t) { v = t % MOD; if (v < 0) v += MOD; }

	Mint pow(ll k) {
		Mint res(1), tmp(v);

		while (k) {
			
			if (k & 1) res *= tmp;

				tmp *= tmp;
				k >>= 1;
			}



		return res;
	}

	Mint inv() { return pow(MOD - 2); }

	Mint& operator=(Mint a) { if (a.v >= MOD) a.v %= MOD; v = a.v; return *this; }
	Mint& operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; }
	Mint& operator/=(Mint a) { return (*this) *= a.inv(); }
	Mint operator+(Mint a) const { return Mint(v) += a; }
	Mint operator-(Mint a) const { return Mint(v) -= a; }
	Mint operator*(Mint a) const { return Mint(v) *= a; }
	Mint operator/(Mint a) const { return Mint(v) /= a; }

	Mint operator-() { return v ? MOD - v : v; }
	bool operator==(const Mint a) const { return v == a.v; }
	bool operator!=(const Mint a) const { return v != a.v; }
	bool operator < (const Mint a) const { return a < a.v; }


};

using M = Mint<ll>;


M Fact[300005];

ll N, K;

int main() {
	M a;
	Fact[0] = 1;
	for(int i = 1; i <= 2 * 100000; i++){
		Fact[i] = M(i) * Fact[i - 1];
	}
	auto mcomb = [&](int a, int b) { return Fact[a] / (Fact[b] * Fact[a - b]); };
	

	cin >> N >> K;

	vector<ll> sosuu;

	sosuu.push_back(2);
	bool flag = true;
	for (int i = 3; i * i <= K; i++) {
		rep(j, sosuu.size()) {
			if (i % sosuu[j] == 0) {
				flag = false; break;
			}
		}

		if (flag == true) sosuu.push_back(i);
		flag = true;
	}

	vector<ll> cands;
	for (auto &a : sosuu) {
		while (K % a == 0) {
			K /= a;
			cands.push_back(a);
		}
	}
	
	if (K > 1) { cands.push_back(K); }

	M ans;

	ans = 1;
	cands.push_back(0);
	ll index = 1;
	rep(i, cands.size()-1) {

		if (cands[i] != cands[i + 1]) {
			ans *= mcomb(N - 1 + index, index);
			index = 1;
		}
		else {
			index += 1;
		}
	}
	
	cout << ans.v << endl;
	return 0;
}


Measured memory_bytes: 2688
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL maxn=1e4;
struct node{
  int p,l,r;
};
node T[maxn];
void preOrder(int n){
  if(n==-1) return;
  printf(" %d",n);
  preOrder(T[n].l);
  preOrder(T[n].r);
}
void inOrder(int n){
  if(n==-1) return;
  inOrder(T[n].l);
  printf(" %d",n);
  inOrder(T[n].r);
}
void PostOrder(int n){
  if(n==-1) return;
  PostOrder(T[n].l);
  PostOrder(T[n].r);
  printf(" %d",n);
}
int main()
{
  int N, v, l, r, root;
  scanf("%d",&N);
  for(int i = 0; i <= N; i++) T[i].p=-1;
  for(int i = 0; i < N; i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l, T[v].r = r;
    if(l!=-1) T[l].p = v;
    if(r!=-1) T[r].p = v;
  }
  for(int i = 0; i < N; i++)
    if(T[i].p==-1)//找到根节点
      root = i;
  printf("Preorder\n");
  preOrder(root);
  printf("\nInorder\n");
  inOrder(root);
  printf("\nPostorder\n");
  PostOrder(root);
  printf("\n");
  return 0;
}



Measured memory_bytes: 3196
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = input()
    L = len(S)
    for i in range(L):
        if S[i] == 'A':
            left = i
            break
    for i in range(L-1,0,-1):
        if S[i] == 'Z':
            right = i
            break
    print(right-left+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    ll k,a,b;
    cin>>k>>a>>b;
    if(b-a<=2){
        cout<<k+1;
        return 0;
    }
    ll dif=a-1;
    k-=dif;
    ll ans=a+((k/2)*(b-a));
    if(k&1)ans++;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("6");
            //30
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1000");
            //972926972
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int N = int.Parse(InputList[0]);

        Eratosthenes(N);

        int[] JyousuuArr = new int[SosuuArr.GetUpperBound(0) + 1];

        for (int I = 2; I <= N; I++) {
            int CopiedI = I;
            for (int J = 0; J <= SosuuArr.GetUpperBound(0); J++) {
                if (CopiedI % SosuuArr[J] == 0) {
                    do {
                        JyousuuArr[J]++;
                        CopiedI /= SosuuArr[J];
                    } while (CopiedI % SosuuArr[J] == 0);
                }
                if (CopiedI == 1) break;
            }
        }
        long Answer = 1;
        foreach (int EachInt in JyousuuArr) {
            if (EachInt == 0) continue;
            Answer = (Answer * (EachInt + 1)) % 1000000007;
        }
        Console.WriteLine(Answer);
    }

    static int[] SosuuArr;

    //エラトステネスの篩
    static void Eratosthenes(int pJyougen)
    {
        var IsSosuuArr = new System.Collections.BitArray(pJyougen + 1);

        for (int I = 2; I <= IsSosuuArr.Count - 1; I++) {
            IsSosuuArr[I] = true;
        }
        for (int I = 2; I <= IsSosuuArr.Count - 1; I++) {
            if (I != 2 && I % 2 == 0) continue;

            if (IsSosuuArr[I]) {
                for (int J = I * 2; J <= IsSosuuArr.Count - 1; J += I) {
                    IsSosuuArr[J] = false;
                }
            }
        }
        var SosuuList = new List<int>();
        for (int I = 2; I <= IsSosuuArr.Count - 1; I++)
            if (IsSosuuArr[I]) SosuuList.Add(I);

        SosuuArr = SosuuList.ToArray();
    }
}


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

int64_t	modpow(int64_t a, int64_t n, int64_t mod)
{
	int64_t	res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int	main()
{
	int	N, K;
	cin >> N >> K;
	const int64_t	mod = 1e+9 + 7;
	int64_t	sum = 0;
	int64_t	num_gcd;
	vector<int64_t>	num_gcd_vec(K);
	for (int k = K; k > 0; --k) {
		num_gcd = modpow(K / k, N, mod);
		for (int j = 2; j * k <= K; ++j) {
			num_gcd -= num_gcd_vec.at(j * k - 1);
			if (num_gcd < 0)
				num_gcd += mod;
		}
		num_gcd_vec.at(k - 1) = num_gcd;
		sum += num_gcd * k;
		sum %= mod;
	}
	cout << sum << endl;
}

			


Measured memory_bytes: 4048
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second 

using namespace std;

int n, a[200100];
map<int, ll> fr;

int main() {
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

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

    ll ans = 0;
    for (auto it : fr) {
        ll cnt = it.se;
        ans += cnt * (cnt - 1) / 2ll;
    }

    for (int i = 1; i <= n; i++) {
        ll cpy = ans;
        ll cnt = fr[a[i]];
        cpy -= cnt * (cnt - 1) / 2ll;
        cpy += (cnt - 1) * (cnt - 2) / 2ll;
        cout << cpy << '\n';
    }


    return 0;
}

Measured memory_bytes: 10368
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALDS1_5_A solver = new ALDS1_5_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALDS1_5_A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int n = in.Int();
            int[] A = in.Int(n);
            int q = in.Int();
            int[] m = in.Int(q);

            boolean[] b = new boolean[4001];
            int max = (int) Math.pow(2, n);
            for (int i = 1; i <= max; i++) {
                int sum = 0;
                for (int j = 0; j < n; j++) {
                    if (((i >> j) & 1) == 1) {
                        sum += A[j];
                        b[sum] = true;
                    }
                }
            }
            for (int i = 0; i < q; i++) {
                out.println(b[m[i]] ? "yes" : "no");
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}




Measured memory_bytes: 25204
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n,x;
	cin>>n>>x;
	vector<int> map(n);
	rep(i,n){
		int t;
		cin>>t;
		map[i] = t-x;
	}
	int ans = map[0];
	for(int i = 1; i<n; ++i){
		ans = __gcd(ans, map[i]);
	}
	cout<<abs(ans)<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;

int n, i, on1, on2, j;
int a[100005];
vector<ii> path;
vector<int> am;
int main(){
	cin >> n;
	for(i=0;i<n;i++)
		cin >> a[i];
	sort(a, a+n);
	int j=0;
	while(a[j]<0){
		am.push_back(a[j]);
		j++;
	}
	if(j==0){
		on2 = a[n-1];
		on1 = a[j];
		for(i=j+1;i<n-1;i++){
			path.push_back(ii(on1, a[i]));
			on1 -= a[i];
		}
		cout << on2 - on1 << "\n";
		for(i=0;i<path.size();i++)
			cout << path[i].first << " " << path[i].second << "\n";
		cout << on2 << " " << on1;
	}
	else if (j>0&&j<=n-1){
		on2 = a[n-1];
		on1 = a[j-1];
		for(i=0;i<am.size()-1;i++){
			path.push_back(ii(on2, am[i]));
			on2 -= am[i];
		}
		for(i=j;i<n-1;i++){
			path.push_back(ii(on1, a[i]));
			on1 -= a[i];
		}
		cout << on2 - on1 << "\n";
		for(i=0;i<path.size();i++)
			cout << path[i].first << " " << path[i].second << "\n";
		cout << on2 << " " << on1;
	}
	else{
		on2 = a[n-1];
		for(i=0;i<n-1;i++){
			path.push_back(ii(on2, a[i]));
			on2 -= a[i];
		}
		cout << on2 << "\n";
		for(i=0;i<path.size();i++)
			cout << path[i].first << " " << path[i].second << "\n";
	}
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
	cin >> n;
	while(n--){
		int h, w;
		cin >> h >> w;
		string field[20];
		for(int i = 0; i < h; ++i){ cin >> field[i]; }
		int x, y, dir;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				switch(field[i][j]){
					case '^': x = j; y = i; dir = 0; break;
					case 'v': x = j; y = i; dir = 1; break;
					case '<': x = j; y = i; dir = 2; break;
					case '>': x = j; y = i; dir = 3; break;
				}
			}
		}
		int m;
		string cmd;
		cin >> m >> cmd;
		for(int i = 0; i < m; ++i){
			switch(cmd[i]){
				case 'U':
					dir = 0;
					if(y > 0 && field[y - 1][x] == '.'){ field[y][x] = '.'; --y; }
					field[y][x] = '^';
					break;
				case 'D':
					dir = 1;
					if(y < h - 1 && field[y + 1][x] == '.'){ field[y][x] = '.'; ++y; }
					field[y][x] = 'v';
					break;
				case 'L':
					dir = 2;
					if(x > 0 && field[y][x - 1] == '.'){ field[y][x] = '.'; --x; }
					field[y][x] = '<';
					break;
				case 'R':
					dir = 3;
					if(x < w - 1 && field[y][x + 1] == '.'){ field[y][x] = '.'; ++x; }
					field[y][x] = '>';
					break;
				case 'S':
					if(dir == 0){
						int i = y - 1;
						for(; i >= 0; --i){ if(field[i][x] == '*' || field[i][x] == '#'){ break; } }
						if(i >= 0 && field[i][x] == '*'){ field[i][x] = '.'; }
					}else if(dir == 1){
						int i = y + 1;
						for(; i < h; ++i){ if(field[i][x] == '*' || field[i][x] == '#'){ break; } }
						if(i < h && field[i][x] == '*'){ field[i][x] = '.'; }
					}else if(dir == 2){
						int i = x - 1;
						for(; i >= 0; --i){ if(field[y][i] == '*' || field[y][i] == '#'){ break; } }
						if(i >= 0 && field[y][i] == '*'){ field[y][i] = '.'; }
					}else if(dir == 3){
						int i = x + 1;
						for(; i < w; ++i){ if(field[y][i] == '*' || field[y][i] == '#'){ break; } }
						if(i < w && field[y][i] == '*'){ field[y][i] = '.'; }
					}
					break;
			}
//			for(int j = 0; j < h; ++j){ cout << field[j] << endl; }
//			cout << endl;
		}
		for(int i = 0; i < h; ++i){ cout << field[i] << endl; }
		if(n != 0){ cout << endl; }
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize "O3"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define POP pop_back
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define X real()
#define Y imag()
#ifndef LOCAL
    #define endl "\n"
#endif

using namespace std;
using namespace chrono;
using namespace __gnu_pbds;

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef long long C;
typedef complex<C> P;

const int INF = 1e9;
const long long LLINF = 1e18;
const double PI = 3.14159265358979323;
const long long PRIME = (1ll << 31) - 1;
const long long PRIME2 = 269;
const long long MOD = 1e9 + 7;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using hash_set = gp_hash_table<T, null_type>;
template <class T, class U> using hash_map = gp_hash_table<T, U>;
template <class T, class U> ostream& operator<< (ostream &out, pair<T, U> p) { return out << "(" << p.F << ", " << p.S << ")"; }
template <class T> ostream& operator<< (ostream &out, vector<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, ordered_set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, ordered_map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> ostream& operator<< (ostream &out, hash_set<T> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T, class U> ostream& operator<< (ostream &out, hash_map<T, U> c) { for (auto it = c.begin(); it != c.end(); ++it) { if (it != c.begin()) out << " "; out << *it; } return out; }
template <class T> int sign (T x) { return (x > 0) - (x < 0); }
inline ll mod (ll a, ll b) { return a%b + (a < 0) * b; }
inline ll mod (ll a) { return mod(a, MOD); }
C dot (P a, P b) { return a.X * b.X + a.Y * b.Y; }
C cross (P a, P b) { return a.X * b.Y - b.X * a.Y; }

double startTime;
double currTime() { return duration_cast<nanoseconds>(system_clock::now().time_since_epoch()).count() / 1e9; }
double execTime() { return currTime() - startTime; }

int main() {
#ifndef LOCAL
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    srand(time(0));
    startTime = currTime();

    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}

Measured memory_bytes: 256
def aux(ss)
  p0=0
  p1=0
  while ss.length > 0
    s = ss.shift
    p = (s[0] <=> s[1])
    if p >0
      p0 += 3
    elsif p <0
      p1 += 3
    else
      p0 += 1
      p1 += 1
    end
  end

  [p0,p1]

end

def main
  fh=STDIN
  #fh=File.new("x.txt", "r")
  n = fh.gets.chomp.to_i
  l = []
  n.times {
    f = fh.gets.chomp.split
    l << f
  }
  #puts "l: #{l}"

  puts aux(l).map(&:to_s).join(' ')
end



if $0 == __FILE__ then
  main
end


Measured memory_bytes: 6856
import sys
import math


def get_iv():
    args = sys.stdin.readline()
    argv = args.split()
    iargv = [int(arg) for arg in argv]
    return iargv


def min_mod_prod(L, R):
    min_rem = 2019
    for i in range(L, R + 1):
        if min_rem == 0:
            break
        for j in range(i + 1, R + 1):
            if min_rem == 0:
                break
            tst = (i * j) % 2019
            if tst < min_rem:
                minij = [i, j]
                min_rem = tst

    minij.append(min_rem)
    return minij


def main():
    specs = get_iv()
    L = specs[0]
    R = specs[1]
    rv = min_mod_prod(L, R)
    # print(rv)
    print(rv[2])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}
 
int main() {
	FAST_IO();
	string S; cin >> S;
	if(S.compare("Sunny") == 0) cout << "Cloudy\n";
	else if(S.compare("Cloudy") == 0) cout << "Rainy\n";
	else if(S.compare("Rainy") == 0) cout << "Sunny\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int H=1,W=1;
while ((H!=0)&&(W!=0)){
	cin>>H>>W;
	if ((H==0)&&(W==0)){
		break;
	}
	for (int i=0;i<H;i++){
		for (int j=0;j<W;j++){
			cout<<'#';
		}
		cout<<endl;
		}
	cout<<endl;
	}
}


Measured memory_bytes: 3076
#include <iostream>
#include <map>
#include <algorithm>
using i64 = long long;

i64 a, b, c, d;
std::map<i64, i64> memo;

i64 rec(const i64 n) {
    if (n <= 1) return n * d;
    if (memo.find(n) != memo.end()) return memo[n];
    const i64 p = rec(n / 2) + a + n % 2 * d,
        q = n > 2 ? rec(n / 2 + 1) + a + (2 - n % 2) * d : p,
        r = rec(n / 3) + b + n % 3 * d,
        s = rec(n / 3 + 1) + b + (3 - n % 3) * d,
        t = rec(n / 5) + c + n % 5 * d,
        u = rec(n / 5 + 1) + c + (5 - n % 5) * d;
    i64 min = std::min({ p, q, r, s, t, u });
    if (n < min / d) min = n * d;
    return memo[n] = min;
}

int main() {
    int t;
    std::cin >> t;
    while (t--) {
        i64 n;
        std::cin >> n >> a >> b >> c >> d;
        std::cout << rec(n) << std::endl;
        memo.clear();
    }

    return 0;
}


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

using namespace std;

const int MAX = 159 * 80;

int n, m;
int a[80][80];
int dp[80][80][MAX + 1];

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

    cin >> n >> m;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> a[i][j];

    for (int i = 0; i < n; i++)
        for (int j = 0, x; j < m; j++)
            cin >> x, a[i][j] = abs(a[i][j] - x);

    dp[0][0][a[0][0]] = true;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            for (int k = 0; k <= MAX; k++) {
                if (!dp[i][j][k]) continue;

                if (i < n - 1) {
                    dp[i + 1][j][k + a[i + 1][j]] = true;
                    dp[i + 1][j][abs(k - a[i + 1][j])] = true;
                }

                if (j < m - 1) {
                    dp[i][j + 1][k + a[i][j + 1]] = true;
                    dp[i][j + 1][abs(k - a[i][j + 1])] = true;
                }
            }

    int res = 0;

    while (!dp[n - 1][m - 1][res]) res++;

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 316672
#include<bits/stdc++.h>
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
//const int N=2e5;
//int arr[N+1];

 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h,w,m;
	cin>>h>>w>>m;
	vector<int> rows(h,0);
	vector<int> cols(w,0);
	int x,y;
	map< pair<int,int> ,int>dict;
	fo(i,m){
		cin>>x>>y;
		x--;y--;
		rows[x]+=1;
		cols[y]+=1;
		dict[mp(x,y)]=1;	
	}
	vector< pair<int,int> > rc;
	fo(i,h){
		rc.pb(mp(rows[i],i));	
	}
	vector< pair<int,int> > cc;
	fo(i,w){
		cc.pb(mp(cols[i],i));
	}
	sort(rc.rbegin(),rc.rend());
	sort(cc.rbegin(),cc.rend());
	vector< pair<int,int> > rcp;
	vector< pair<int,int> > ccp;
	int rmax = rc[0].F;
	int cmax = cc[0].F;
	int k=0;
	while(k<(int)rc.size() && rc[k].F==rmax){
		rcp.pb(rc[k]);
		k++;	
	}
	k=0;
	while(k<(int)cc.size() && cc[k].F==cmax){
		ccp.pb(cc[k]);
		k++;	
	}
	int flag=1;
	fo(i,(int)rcp.size()){
		fo(j,(int)ccp.size()){
			if(dict[mp(rcp[i].S,ccp[j].S)]==0){
				flag=0;
				break;	
			}
		}	
	}
	cout<<rmax+cmax-flag<<endl;
	return 0;
}


Measured memory_bytes: 52376
#include<bits/stdc++.h>
#define foreach(c,itr) for(auto itr = c.begin(); itr!= c.end(); itr++)
#define pb push_back
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
   int X; cin >> X;

   double maxi = 1;
   for(double i = 1; i <= X; i++) {
      for(double j = 2; j <= X; j++) {
	 if(pow(i,j) <= X) {
	    maxi = max(maxi, pow(i,j));
	 }
      }
   }

   cout << maxi << endl;

   return 0;
}


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

    using namespace std;
    #define ll long long
    #define rep(i,a,n) for(int i=a;i<n;i++)
    #define pb push_back
    #define in insert
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db long double
    #define sc scanf
    #define pf printf
    const double pi=3.1415926535897;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
    bool valid(ll k){
    	ll a[10005]={0};
    	for(ll x=5;x<=100;x++){
    		for(ll i=5;i<=100;i++){
    			a[i*x]=1;
    		}
    	}
    	
    	if(a[k])return true;
    	else return false;
    	
    }
   
    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	if(s.size()<=n)cout<<s;
    	else{
    		string t=s.substr(0,n);
    		t+="...";
    		cout<<t;
    	}
    	
    
    	

    	return 0;
}


Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Numerics;

namespace ABC176
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
        }

        public static void c()
        {
            long n = long.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long hi = a[0];
            long sum = 0;
            for(int i = 1; i < a.Length; i++)
            {
                if(a[i] < hi)
                {
                    sum += hi - a[i];
                }
                else
                {
                    hi = a[i];
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 47304
import sys
li = ["dream","dreamer","erase","eraser"]
li = [s[::-1] for s in li]
sen = input()[::-1]
while 1:
  ju = 0
  for i in range(4):
    le = len(li[i])
    if sen[:le] == li[i]:
      if len(sen) == le:
        print("YES")
        sys.exit()
      else:
        sen = sen[le:]
        ju = 1
  if not ju:
    print("NO")
    sys.exit()
	


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int n; cin >> n;
    map<string, int> m;
    rep(i,n){
        string s;
        cin >> s;
        sort(ALL(s));
        m[s]++;
    }
    int ans = 0;
    for(auto p : m){
        ans += p.second * (p.second - 1) / 2;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define MANX MAXN
#define itn int
#define in(x); { for (auto &to : x) cin>>to;}
#define out(x); { for (auto &to : x) cout<<to<<" ";cout<<'\n'; }

const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
const int K = 20;
int f[K][K];
ll bin_pow(ll base,ll deg)
{
    if (deg==0)
        return 1;
    ll t=bin_pow(base,deg/2);
    if (deg&1)
        return t*t*base;
    else
        return t*t;
}
void add(int l,int r,int x)
{
    for (int i=l;i<K;i=(i|(i+1)))
    {
        for (int j=r;j<K;j=(j|(j+1)))
            f[i][j]+=x;
    }
}

int res(int l,int r)
{
    int sum=0;
    for (int i=l;i>=0;i=((i+1)&i)-1)
    {
        for (int j=r;j>=0;j=((j+1)&j)-1)
            sum+=f[i][j];
    }
    return sum;
}

int res(int l,int r,int l1,int r1)
{
    return res(l1,r1)+res(l-1,r-1)-res(l-1,r1)-res(l1,r-1);
}
ll ff(string &s)
{
    bool ok=false;
    string t;
    int cnt=0;
    for (auto to:s) {
        if (to == '.')
            ok = true;
        else {
            t +=to;
            if (ok)
                cnt++;
        }
    }
    ll ans=0;
    reverse(all(t));
    ll g=1;
    for (auto to:t)
        ans+=g*(to-'0'),g*=10;
    ans*=bin_pow(10,9-cnt);
    return ans;
}
void solve()
{
    int n;
    cin>>n;
    ll ans=0;
    for (int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        ll g=ff(s);
        int cnt1=0,cnt2=0;
        while (g%2==0)
            cnt1++,g/=2;
        while (g%5==0)
            cnt2++,g/=5;
        cnt1=min(cnt1,18);
        cnt2=min(cnt2,18);
        ans+=res(18-cnt1,18-cnt2,19,19);
        add(cnt1,cnt2,1);
    }
    cout<<ans<<'\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef Mip182
    freopen("a.in","r",stdin);
    #endif
    int _t;
//    cin>>_t;
    _t=1;
    while (_t--)
        solve();


    //n=1 ?
    //recursion - matrix exponential
    //linear algebra - just a joke
    //check ios_base, MAXN, mod1 before submit
    //if debug more than 15 minutes - write stress
    //compression
}

Measured memory_bytes: 3504
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int d = 0;
            int cnt = 1;
            for (int i = 0; i < n; i++) {
                int l = scanner.nextInt();
                d += l;
                if (d <= x) {
                    cnt++;
                } else {
                    break;
                }
            }
            System.out.println(cnt);
        }
    }

}


Measured memory_bytes: 25172
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const int INF = 1 << 25;

struct E {
  int from, to, cost;
};

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<E> edges;
    for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      --a;
      --b;
      edges.push_back(E{a, b, c});
    }
    vector<vector<int>> dist(N, vector<int>(N, INF));
    for (int i = 0; i < N; i++) dist[i][i] = 0;
    for (auto& e : edges) dist[e.from][e.to] = dist[e.to][e.from] = e.cost;
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
    int res = 0;
    for (auto& e : edges) {
      bool found = false;
      for (int s = 0; s < N; s++) {
        for (int t = 0; t < N; t++) {
          if (dist[s][e.from] + e.cost + dist[e.to][t] == dist[s][t]) {
            found = true;
          }
        }
      }
      if (!found) {
        ++res;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> X(N), Y(N), P(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> P[i];
  }
  vector<vector<int>> XS(1 << N, vector<int>(N, 1 << 28));
  vector<vector<int>> YS(1 << N, vector<int>(N, 1 << 28));
  for (int bit = 0; bit < (1 << N); bit++) {
    for (int i = 0; i < N; i++) {
      XS[bit][i] = min(XS[bit][i], abs(X[i]));
      YS[bit][i] = min(YS[bit][i], abs(Y[i]));
      if ((bit >> i) & 1) {
        for (int j = 0; j < N; j++) {
          XS[bit][j] = min(XS[bit][j], abs(X[i] - X[j]));
          YS[bit][j] = min(YS[bit][j], abs(Y[i] - Y[j]));
        }
      }
    }
  }
  vector<int64_t> res(N + 1, INT64_C(1) << 49);
  for (int bitx = 0; bitx < (1 << N); bitx++) {
    int mask = ((1 << N) - 1) ^ bitx;
    for (int bity = ((1 << N) - 1) & mask;; bity = (bity - 1) & mask) {
      int a = __builtin_popcount(bitx), b = __builtin_popcount(bity);
      int64_t r = 0;
      for (int i = 0; i < N; i++) {
        r += static_cast<int64_t>(P[i]) * min(XS[bitx][i], YS[bity][i]);
      }
      res[a + b] = min(res[a + b], r);
      if (bity == 0) break;
    }
  }
  for (int i = 0; i < N + 1; i++) {
    cout << res[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 9784
#include <bits/stdc++.h>
using i64 = long long;

i64 dp[200010][20];
i64 dp2[200010][20];
int n;

i64 get(i64 l, i64 x) {
    if (x < 15) return dp[l][x];
    return dp[l][15] + (x - 15) * (n - l);
}

i64 get2(i64 l, i64 x) {
    if (x < 15) return dp2[l][x];
    return dp2[l][15] + (x - 15) * (l + 1);
}

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

    for (int i = 0; i < 16; i++) {
        dp[n - 1][i] = i;
        dp2[0][i] = i;
    }

    for (int l = n - 2; l >= 0; l--) {
        i64 cc = a[l];
        i64 dd = a[l + 1];
        for (int x = 0; x < 16; x++) {
            if (x) cc *= 4;
            i64 i = 0;
            while (cc > dd * (1ll << (2 * i))) i++;
            dp[l][x] = x + get(l + 1, i);
        }
    }

    for (int l = 1; l < n; l++) {
        i64 cc = a[l];
        i64 dd = a[l - 1];
        for (int x = 0; x < 16; x++) {
            if (x) cc *= 4;
            i64 i = 0;
            while (cc > dd * (1ll << (2 * i))) i++;
            dp2[l][x] = x + get2(l - 1, i);
        }
    }

    auto ret = 2 * get(0, 0);
    for (int i = 0; i < n - 1; i++) {
        // [0, i] are all negative
        auto curr = i + 1 + 2 * get2(i, 0) + 2 * get(i + 1, 0);
        ret = std::min(ret, curr);
    }
    ret = std::min(ret, 2 * get2(n - 1, 0) + n - 1);

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 64256
#include <iostream>

int main(){
  int W, H, x, y, r;
  std::cin >> W >> H >> x >> y >> r;
  if ((x-r >= 0) && (x+r <= W) && (y-r >= 0) && (y+r <= H)) {
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3088