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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;++i)
    {
        if(i%d==0)
        {
            ++ans;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        String t = sc.next();
        char[] s_array = s.toCharArray();
        char[] t_array = t.toCharArray();
        StringBuilder answer = new StringBuilder();
        for (int i = 0; i < n; i++) {
            answer.append(s_array[i]);
            answer.append(t_array[i]);
        }
        System.out.println(answer);
        sc.close();
    }
}


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

using namespace std;

void solve(){
	int a, b, c, k; cin>>a>>b>>c>>k;
	while(b <= a && k > 0){
		b*=2;
		k--;
	}
	while(c <= b && k > 0){
		c*=2;
		k--;
	}
	cout << ((c > b && b > a)?"Yes\n":"No\n");
}

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;//cin>>t;
	while(t--){
		//cout << "run\n";
		solve();
		//cout << "\n";
	}
	return 0;
}


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


int main() {long N, x;
cin >> N >> x;
vector<long> a(N + 1);
erep(i, N) cin >> a.at(i);
long ans = 0;

erep(i, N - 1){
  if(a.at(i) + a.at(i + 1) > x){
    ans += a.at(i) + a.at(i + 1) - x;
    if(a.at(i) + a.at(i + 1) - x > a.at(i + 1)) a.at(i + 1) = 0;
    else a.at(i + 1) -= a.at(i) + a.at(i + 1) - x;
  }
}


// cout << a.at(2) << endl;

cout << ans << endl;
  return 0;
 
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll n;
    cin>>n;
    ld a[n];
    ld ans=0;
    loop(i,0,n){
        cin>>a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    ld div = 2;
    loop(i,0,n){
        ans += a[i]/div;
        div=div*(ld)2;
    }
    // print(ans<<" "<<div)<<endl;
    div/=(ld)2;
    ans -= a[n-1]/div;
    div/=(ld)2;
    ans += a[n-1]/div;
    printPrec(ans);
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	long long a,b,min,x,y;
	while(cin>>a>>b){
        if(a>b){
            x=a;
            y=b;
        }else{
            x=b;
            y=a;
        }
			while(x%y!=0){
				min=x;
				x=y;
				y=min%y;
				}
			
		cout<<y<<" "<<(a*b/y)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define endl    '\n'
using namespace std;

typedef long long ll;

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

    int n;
    int ma, en, ja, avg;
    char cls;

    cin >> n;

    while (n != 0) {
        for (int i = 0; i < n; ++i) {
            cin >> ma >> en >> ja;
            avg = (ma + en + ja) / 3;

            if (ma == 100 || en == 100 || ja == 100 || (ma + en) / 2 >= 90 || avg >= 80) {
                cls = 'A';
            } else if (avg >= 70 || avg >= 50 && (ma >= 80 || en >= 80)) {
                cls = 'B';
            } else {
                cls = 'C';
            }

            cout << cls << endl;
        }

        cin >> n;
    }

    return 0;
}




Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
const int N=200000;
int Root[N],Rank[N],Size[N];
int find(int x){
    if(Root[x]==x)return x;
    else return Root[x]=find(Root[x]);
}
void unite(int x,int y){
    int X=find(x);
    int Y=find(y);
    if(X==Y)return;
    if(Rank[X]<Rank[Y]){
        Root[X]=Y;
        Size[Y]+=Size[X];
    }
    else{
        Root[Y]=X;
        Size[X]+=Size[Y];
        if(Rank[X]==Rank[Y])Rank[X]++;
    }
    return;
}
int main(){
    int n;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++)Root[i]=i,Rank[i]=0,Size[i]=1,s.insert(i);
    pair<int,int>point[n];
    int num[n];
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        point[i]={x-1,y-1};
        num[y-1]=i;
    }
    sort(point,point+n);
    vector<int>v(n);
    for(int i=0;i<n;i++)v[i]=point[i].second;
    int used[n]={};
    for(int i=0;i<n;i++){
        s.erase(v[i]);
        if(used[v[i]])continue;
        bool b=0;
        for(auto itr=s.upper_bound(v[i]);itr!=s.end();itr++){
            if(used[*itr])b=1;
            used[*itr]=1;
            unite(num[v[i]],num[*itr]);
            if(b)break;
        }
    }
    for(int i=0;i<n;i++)cout<<Size[find(i)]<<endl;
    return 0;
}


Measured memory_bytes: 18752
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        print((a+(n-1)*b)-((n-1)*a+b)+1)
resolve()

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

int main() {
  int N, K, l[60];
  cin >> N >>K;
  
  for (int i=0; i<N; i++) cin >> l[i];
  
  sort(l, l+N, greater<int>());
  
  int t=0;
  for (int i=0; i<K; i++){
  t+=l[i];
  }
    
  cout << t <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
namespace path {
	vector<ll> dijkstra(int s, vector<vector<edge>>* G, ll INF = LLONG_MAX) {
		int V = (*G).size();
		vector<ll> d(V);
		fill(d.begin(), d.end(), INF);
		priority_queue<P, vector<P >, greater<P > > que;
		d[s] = 0;
		que.push(P(d[s], s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			for (edge e : (*G)[v]) {
				if (e.to < V && d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(P(d[e.to], e.to));
				}
			}
		}
		return d;
	}

	vector<vector<ll>> warshall_floyd(vector<vector<edge>>* G, ll INF = LLONG_MAX) {
		int V = (*G).size();
		vector<vector<ll>> d(V, vector<ll>(V, INF));
		for (int i = 0; i < V; i++) {
			d[i][i] = 0;
			for (edge e : (*G)[i]) {
				if (e.to < V) {
					d[i][e.to] = e.cost;
				}
			}
		}
		for (int k = 0; k < V; k++) {
			for (int i = 0; i < V; i++) {
				if (d[i][k] == INF)continue;
				for (int j = 0; j < V; j++) {
					if (d[k][j] == INF)continue;
					// 頂点iから頂点jへ行きたい。
					//   (頂点i, jの他には)頂点0～kのみを使える場合
					//     もしも頂点kを使わない場合は、頂点0～(k-1)のみを使える場合と同コスト
					//     頂点kを使う場合は、頂点iから頂点kまで頂点0～(k-1)以外を使わずに行くコストと、頂点kから頂点jまで頂点0～(k-1)以外を使わずに行くコストの和
					//   補足: 負の閉路がある <=> d[i][i]<0となるiが存在する
					//   　　: (負の閉路が存在しないならば)同じ頂点を２度通る必要はない
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		return d;
	}
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int H, W;
	cin >> H >> W;
	vector<vector<edge>> G(10);
	rep(i, 10)rep(j, 10) {
		int c;
		cin >> c;
		G[j].push_back({ i,c });
	}
	vector<ll> a = path::dijkstra(1, &G);
	ll ans = 0;
	rep(i, H)rep(j, W) {
		int A;
		cin >> A;
		if (A != -1) {
			ans += a[A];
		}
	}
	cout << ans << endl;
}

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

#define ll long long int

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);	cout.tie(0);
	int n;
	cin >> n;
	cout << fixed << setprecision(17)<< ceil(n*1.0/2)*1.0/n << '\n';		


	return 0;
}

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

constexpr long long mod = 998244353;

// zero-based numbering
template<class T> struct Fenwick {
    vector<T> bit; int N;
    Fenwick(int n) : N(n) { bit.assign(n+1, 0); }
    // add w to a
    void add(int a, T w) {
        for (int x = ++a; x <= N; x += x & -x) bit[x] = (bit[x] + w + mod) % mod;
    }
    // sum [0, a)
    T sum(int a) {
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) ret = (ret + bit[x] + mod) % mod;
        return ret;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    vector<int> W(N+2, 0);
    for (int i = 0; i < K; i++) {
        int L, R; cin >> L >> R;
        W[L]++, W[R+1]--;
    }
    for (int i = 1; i <= N; i++) {
        W[i+1] += W[i];
    }
    vector<pair<int, int>> V;
    int con = 0;
    for (int i = 0; i <= N+1; i++) {
        if (W[i]) con++;
        else {
            if (con) V.emplace_back(i-con, i);
            con = 0;
        }
    }

    Fenwick<long long> DP(N+2);
    DP.add(1, 1);
    DP.add(2, mod - 1);
    for (int i = 1; i < N; i++) {
        long long Cur = DP.sum(i+1);
        for (auto &[l, r]: V) {
            if (i+l > N) continue;
            DP.add(i+l, Cur);
            DP.add(min(N+1, i+r), mod-Cur);
        }
    }
    long long Ans = DP.sum(N+1);
    cout << Ans << "\n";
    return 0;
}

Measured memory_bytes: 5572
def main():
    S = input()
    if len(S) >= 26:
        for i in range(24, -1, -1):
            if S[i] < S[i+1]:
                m = 'z'
                for j in S[i+1:]:
                    if j > S[i] and j < m:
                        m = j
                print(S[:i]+m)
                return
        print(-1)
    else:
        for i in range(ord('a'), ord('z')+1):
            flag = True
            for j in S:
                if j == chr(i):
                    flag = False
                    break
            if flag:
                print(S+chr(i))
                return


if __name__ == '__main__':
    main()


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

namespace ABC142C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var inputInt = int.Parse(Console.ReadLine());

            int[] ans = new int[inputArr.Length];
            for (int i = 0; i < inputArr.Length; i++)
            {
                ans[inputArr[i] - 1] = i + 1;
            }

            //int ans = 0;
            //string ans = "";

            Console.WriteLine(string.Join(" ", ans));
            Console.ReadKey();
        }
    }
}


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

def main():
    X, N = map(int, readline().split())
    P = list(map(int, readline().split()))
    diff = 1000
    ans = 0
    for i in range(102):
        if not i in P:
            if abs(X-i)<diff:
                ans = i
                diff = abs(X-i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc144/abc144_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N;
  cin >> N;
  int sqn = sqrt(N) + 1;
  bool ok = false;
  ll a = 0, b = 0;
  ll ans = LINF;
  repi(i, 2, sqn) {
    b = N / i;
    if (i * b == N) {
      a = i;
      ans = min(ans, a + b - 2);
      ok = true;
    }
  }

  if (!ok) {
    // 素数
    ans = N - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by Hideaki Imamura on 2020-03-17.
//
# include <bits/stdc++.h>

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

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
const ll mod = 1000000007;
ll N, K;
ll fact[10000], invfact[10000];

inline ll take_mod(ll a) {
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b) {
    return take_mod(a + b);
}

inline ll sub(ll a, ll b) {
    return take_mod(a - b);
}

inline ll mul(ll a, ll b) {
    return take_mod(a * b);
}

inline ll mod_pow(ll x, ll n) {
    ll res = 1LL;
    while (n > 0) {
        if (n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x) {
    return mod_pow(x, mod - 2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

int main() {
    cin >> N >> K;
    make_fact(5000);
    make_invfact(5000);

    for (int i = 1; i <= K; ++i) {
        ll ans = 1;
        if (N - K + 1 >= i) {
            ans = comb(N - K + 1, i);
        } else {
            ans = 0;
        }
        ans = mul(ans, comb(K - 1, i - 1));
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int a,b,zero=0,cnt=0;
    cin>>a>>b;
    if(b==1)
    {
    	cout<<0<<"\n";
    	return 0;
    }
    while(zero<b)
    {
    	zero+=a;
    	++cnt;
    	if(zero<b)
    		--zero;
    }
    cout<<cnt<<"\n";

}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;
    
    vector<int> a(3);
    a[0] = P;
    a[1] = Q;
    a[2] = R;
    
    int ans = INT_MAX;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(i == j)    continue;
            
            ans = min(ans, a[i] + a[j]);
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
int main() {
	int r;
	cin >> r;
	if(r < 1200) {
		cout << "ABC" << endl;
	}
	else if (1200 <= r && r < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = str(input())

ans = 0
for i in range(N):
    same = 0
    S_a = S[0:i+1]
    S_b = S[i+1:N]
    for alphabet in "abcdefghijklmnopqrstuvwxyz":
        if S_a.count(alphabet) >0 and S_b.count(alphabet):
            same +=1
    if same > ans:
        ans = same
print(ans)


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

int n;
int main() {
  scanf("%d", &n);
  if (__builtin_popcount(n) == 1) return puts("No"), 0;
  printf("Yes\n1 2\n2 3\n3 %d\n%d %d\n%d %d\n", n + 1, n + 1, n + 2, n + 2, n + 3);
  for (int i = 5; i <= n; i += 2) {
    printf("1 %d\n%d %d\n1 %d\n%d %d\n", i - 1, i - 1, i + n, i, i, i - 1 + n);
  }
  if (!(n & 1)) {
    int x = n & -n;
    printf("%d %d\n%d %d\n", n, x, n + n, x ^ n ^ 1);
  }
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;
    cin >> S;
  	int max_length = 0;
  	int tmp_length = 0;
  	//四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対
  	for(int i = 0; i< S.length();i++)
    {
      if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
      {
        tmp_length++;
      }else
      {
        tmp_length = 0;
      }
      if(max_length < tmp_length) max_length = tmp_length;
    }
  
  	cout << max_length << endl;
    
    return 0;
}


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

int main() {
  int N, K, num;
  cin >> N;
  cin >> K;
  num = 1;
  for (int i = 0; i < N; i++) {
    num = min(num * 2, num + K);
  }
  cout << num << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

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

	if(a==b&&a!=c || a==c&&a!=b || b==c&&a!=b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    int N;
    int dig = 0;
    int sum = 0;

    scanf("%d", &N);

    int x = N;
    while (N)
    {
        dig = N % 10;
        sum = sum + dig;
        N = N / 10;
    }

    if (x % sum == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
A = LIST()

a = [A[i] - (i+1) for i in range(N)]
a.sort()

b = a[len(a)//2]

print(sum([abs(x-b) for x in a]))

Measured memory_bytes: 28932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  ll ans=0;
  for (int i=0; i <= n;i++){
    for (int j=0; j <= n;j++){
      if (n-r*i-g*j == 0 ) {
        ans++;
        //printf("(%d %d 0)\n",i,j);
      }
      else if (n-r*i-g*j < 0 ) continue;
      else if ((n-r*i-g*j)%b==0 ) {
                 ans++;
                 //printf("(%d %d %d)\n",i,j,(n-r*i-g*j)/b);
      }
      else continue;
      }
    }
  cout << ans <<endl;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// as[i]: the number of nodes which is at the level i and is leaf
vector<int> as;
// bs[i]: the maximum number of nodes which is at the level i and is not leaf
vector<ll> bs;

ll solve(const int N) {
    ll ans = 0;

    ll cur_vs = 0;
    for (int cur_l = N; cur_l > 0; cur_l--) {
        const ll next_max = bs[cur_l - 1];

        cur_vs += as[cur_l];
        ans += cur_vs;
        // printf("cur_l: %d, next_max: %d, cur_vs: %d, ans: %lld\n", cur_l, next_max, cur_vs, ans);
        if (cur_vs > next_max) {
            if (cur_vs > 2 * next_max) {
                return -1;
            }
            cur_vs = next_max;
        }
    }

    ans += 1;
    return ans;
}

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

    as.resize(N + 1);
    for (int i = 0; i <= N; i++) {
        cin >> as[i];
    }

    if (N == 0) {
        if (as[0] == 1) {
            cout << 1 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }

    bs.resize(N + 1);
    bs[0] = 1 - as[0];
    bs[N] = 0;
    for (int i = 1; i < N; i++) {
        bs[i] = min(LONG_LONG_MAX / 2, bs[i - 1] * 2 - as[i]);
    }
    for (int i = 0; i < N; i++) {
        // printf("bs[%d]: %lld\n", i, bs[i]);
        if (bs[i] <= 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 4544
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int a, b, c, x;
    cin >> c >> b >> a >> x;
    x/=50;
    vector<int> dp(x+1, 0);
    dp[0] = 1;
    // 10, 2, 1
    for(int w = x; w >= 1; w--) {
        for(int i = 1; i <= a; i++) {
            if (w-i >= 0)
                dp[w] += dp[w-i];
        }
    }
    for(int w = x; w >= 1; w--) {
        for(int i = 1; i <= b; i++) {
            if (w-i*2 >= 0)
                dp[w] += dp[w-i*2];
        }
    }
    for(int w = x; w >= 1; w--) {
        for(int i = 1; i <= c; i++) {
            if (w-i*10 >= 0)
                dp[w] += dp[w-i*10];
        }
    }

    cout << dp[x] << endl;
    return 0;
}




Measured memory_bytes: 256
# 幅優先探索, BFS
from collections import deque

n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]

neighbor = [[] for _ in range(n)]
for edge in edges:
    neighbor[edge[0]-1].append(edge[1]-1)  # 1- → 0-index
    neighbor[edge[1]-1].append(edge[0]-1)


visited = [-1] * n
ans = 1
for idx in range(n):
    if visited[idx] == -1:
        queue = deque()
        queue.append(idx)
        group_population = 1
        visited[idx] = 0
        while len(queue) > 0:
            vertex = queue.popleft()
            for nei in neighbor[vertex]:
                if visited[nei] == -1:
                    visited[nei] = 0
                    queue.append(nei)
                    group_population += 1
    
    ans = max(ans, group_population)
        
print(ans)


Measured memory_bytes: 80976
#include <bits/stdc++.h>
#define INF 1e9
#define MOD 1000000007
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T>
class FastFactorize
{
private:
    // smallest prime factor
    vector<T> spf;
    int N;

public:
    FastFactorize()
    {
    }

    void init(T N)
    {
        this->N = N;
        spf.resize(N + 1);
        iota(spf.begin(), spf.end(), 0);
        for (T i = 2; i * i <= N; i++)
        {
            if (spf[i] == i)
            {
                for (T j = i * i; j <= N; j += i)
                {
                    if (spf[j] == j)
                    {
                        spf[j] = i;
                    }
                }
            }
        }
    }

    void check()
    {
        for (int i = 0; i < N + 1; i++)
        {
            cout << "spf[" << i << "] = " << spf[i] << endl;
        }
    }

    map<T, int> factorize(T num)
    {
        map<T, int> result;
        if (num > N)
        {
            // Out of range
            return result;
        }

        while (num != 1)
        {
            result[spf[num]]++;
            num /= spf[num];
        }
        return result;
    }
};

int main(void)
{
    int N;
    cin >> N;
    FastFactorize<int> ff;
    ff.init(1e6);

    ll ans = 0;

    for (int i = 1; i < N; i++)
    {
        ll comb = 1;
        map<int, int> prims = ff.factorize(i);

        for (auto const &elem : prims)
        {
            comb *= (elem.second+1);
        }
        ans += comb;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7220
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> a >> b >> c >> d;
	while(a>=0&&c>=0){
		a-=d;
		c-=b;
		if(c<=0){
			cout << "Yes" << endl;
			return 0;
		}
		if(a<=0){
			cout << "No" << endl;
			return 0;
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  int a[100010] = {};

  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int c = 0;
  for(int i = 0; i < n; i++){
    if(a[i] % 2 != 0){
      c++;
    }
  }

  if(c % 2 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n;

int tot,go[2*maxn],nxt[2*maxn],f1[maxn];
void ins(int x,int y)
{
	go[++tot]=y;
	nxt[tot]=f1[x];
	f1[x]=tot;
}

int dis[maxn],d[maxn];
int bfs(int x)
{
	memset(dis,0,sizeof(dis));
	d[1]=x;
	dis[x]=1;
	for(int i=1, j=1; i<=j; i++)
	{
		for(int p=f1[d[i]]; p; p=nxt[p]) if (!dis[go[p]])
		{
			dis[go[p]]=dis[d[i]]+1;
			d[++j]=go[p];
		}
	}
	
	int re=0;
	fo(i,1,n) if (dis[i]>dis[re]) re=i;
	return re;
}

int main()
{
	scanf("%d",&n);
	fo(i,1,n-1)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		ins(x,y), ins(y,x);
	}
	
	int x=bfs(1), y=bfs(x), ds=dis[y]-2;
	
	puts((ds>=0 && ds%3==0) ?"Second" :"First" );
}

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

int main(void) {
  string S;
  ll N, K;
  cin >> S >> K;
  N = S.length();

  ll dp[N][N][K + 1];
  REP(l, 0, N) REP(r, l, N) REP(k, 0, K + 1) dp[l][r][k] = 0;
  REP(l, 0, N) REP(k, 0, K + 1) dp[l][l][k] = 1;
  REP(l, 0, N - 1) REP(k, 0, K + 1) dp[l][l + 1][k] = S[l] == S[l + 1] || k > 0 ? 2 : 0;
  REP(s, 0, N) REP(l, 0, N - s) {
    ll r = l + s;
    REP(k, 0, K + 1) {
      if(l + 1 <= r - 1 && S[l] == S[r]) dp[l][r][k] = max(dp[l][r][k], dp[l + 1][r - 1][k] + 2);
      if(l + 1 <= r) dp[l][r][k] = max(dp[l][r][k], dp[l + 1][r][k]);
      if(l <= r - 1) dp[l][r][k] = max(dp[l][r][k], dp[l][r - 1][k]);
      if(k > 0 && l + 1 <= r - 1) dp[l][r][k] = max(dp[l][r][k], dp[l + 1][r - 1][k - 1] + 2);
      if(k > 0) dp[l][r][k] = max(dp[l][r][k], dp[l][r][k - 1]);
    }
  }
  cout << dp[0][N - 1][K] << endl;
}


Measured memory_bytes: 211328
# -*- coding: utf-8 -*-
from heapq import heappush, heappop

N = int(input())
INF = float("inf")
adj = []
for _ in range(N):
    inp = tuple(map(int, input().split()))
    adj.append(tuple(zip(inp[2::2], inp[3::2])))

checked = [False for _ in range(N)]
d = [float("inf") for _ in range(N)]
d[0] = 0

heap = [[0, 0]] # cost, vec

while heap:
    c, u = heappop(heap)
    if d[u] < c or checked[u]:
        continue
    for nu, nc in adj[u]:
        new_d = d[u] + nc
        if new_d < d[nu]:
            d[nu] = new_d
            heappush(heap, [d[nu], nu])
    checked[u] = True

for n in range(N):
    print("{} {}".format(n, d[n]))

Measured memory_bytes: 8248
#include<bits/stdc++.h>
using namespace std;
map<pair<long long,long long>,long long> dp;
long long rec(long long w[],long long v[],long long wt,long long n,long long** dp){

	if(n<1 || wt<0)
		return 0;
	if(dp[n][wt]>-1)
		return dp[n][wt];
    if(w[n-1]>wt){
        return dp[n][wt]=rec(w,v,wt,n-1,dp);
    }
	return dp[n][wt]=max(v[n-1]+rec(w,v,wt-w[n-1],n-1,dp),rec(w,v,wt,n-1,dp));
}
int main() {
	long long n,wt;
	cin>>n>>wt;
	long long w[n],v[n];
	for(int i=0;i<n;i++)
		cin>>w[i]>>v[i];
    long long** dp; 
    dp = new long long*[n+1]; 
    for (int i = 0; i <= n; i++)  
        dp[i] = new long long[wt + 1];     
    for (int i = 0; i <= n; i++)  
        for (int j = 0; j < wt + 1; j++)  
            dp[i][j] = -1; 
	rec(w,v,wt,n,dp);
	cout<<dp[n][wt]<<endl;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int a, b, c, d; cin >> a >> b >> c >> d;
  int ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
import collections
import heapq
import operator
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, k = ril()
ls = rils(n)
ls.sort(key=operator.itemgetter(1), reverse=True)
counter0 = collections.Counter()
counter1 = collections.Counter()
ls0 = []
ls1 = []
base = 0
for i, (t, d) in enumerate(ls):
    if i < k:
        if counter0[t] > 0:
            heapq.heappush(ls0, (d, t))
        counter0[t] += 1
        base += d
    else:
        if t not in counter0 and t not in counter1:
            heapq.heappush(ls1, (-d, t))
            counter1[t] += 1

m = len(counter0)
res = base + m**2

for _ in range(k):
    if len(ls0) == 0 or len(ls1) == 0:
        break
    d, _ = heapq.heappop(ls0)
    base -= d
    d, _ = heapq.heappop(ls1)
    base += -d
    m += 1
    res = max(res, base + m**2)
print(res)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) (sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)),arg)
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>void reg(vector<T> &ary,const T &elem){ary.emplace_back(elem);}
template<class T>bool chmin(T &a, const T &b) {return (b<a)?(a=b,1):0;}
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}

using R=long double; // __float128
const R EPS = 1E-12; // [-1000:1000]->EPS=1e-8 [-10000:10000]->EPS=1e-7
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

using P=complex<R>;
using VP=vector<P>;
using C=struct{P c;R r;};
using VC=vector<C>;

constexpr P O = P(0,0);
istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

namespace std{
	bool operator <  (const P& a,const P& b){ return sgn(real(a-b))?real(a-b)<0:sgn(imag(a-b))<0;}
	bool operator == (const P& a,const P& b){ return sgn(real(a-b))==0 && sgn(imag(a-b))==0;}
}

enum RCC{OUT=1,ON_OUT=2,ISC=4,ON_IN=8,IN=16,ONS=10};
int rcc(C a,C b){ R d=abs(a.c-b.c);return bit(2+sgn(a.r+b.r-d)+sgn(abs(a.r-b.r)-d));}

VP contact(C a,C b){
	VP ret; R d=abs(a.c-b.c); int r=rcc(a,b);
	rep(i,2) if(r<=8-6*i) rep(j,2){
		R r=a.r+(2*i-1)*b.r;
		reg(ret,a.c+(r+P(0,2*j-1)*sq(norm(d)-norm(r)))*a.r*(b.c-a.c)/norm(d));
	}
	return uniq(ret);
}

int main(void){
	C c1,c2;
	cin >> c1.c >> c1.r >> c2.c >> c2.r;
	VP res=contact(c1,c2);
	cout.precision(20);
	for(auto &p:res) cout << fixed << p << endl;
	return 0;
}

Measured memory_bytes: 3336
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N, K, X[Nmax], Y[Nmax], C[Nmax];

int main(){
    cin >> N >> K;
    vector<vector<int> > v(2*K, vector<int>(2*K));
    for(int i=0; i<N; i++){
        ll x, y;
        char c;
        cin >> x >> y >> c;
        if(c=='B') y+=K;
        x = x%(2*K);
        y = y%(2*K);
        v[x][y] += 1;
        v[(x+K)%(2*K)][(y+K)%(2*K)] += 1;
    }
    vector<vector<int> > cum(2*K+1, vector<int>(2*K+1));
    for(int i=0; i<2*K; i++){
        for(int j=0; j<2*K; j++){
            cum[i+1][j+1] = v[i][j]+cum[i][j+1]+cum[i+1][j]-cum[i][j];
            // cout << i << " " << j << " " << v[i][j] << " " << cum[i][j] << endl;
            // cout << v[i][j] << " ";
        }
        // cout << endl;
    }

    int ans = 0;
    for(int i=0; i<=K; i++){
        for(int j=0; j<=K; j++){
            int s = cum[i+K][j+K]-cum[i][j+K]-cum[i+K][j]+cum[i][j];
            // cout << s << endl;
            ans = max(ans, s);
            ans = max(ans, N-s);
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
	// your code goes here
	int a[10]={2,10,3,9,4,8,6,12},b[10]={6,2,10,3,9,4,8,12},n,i;
	cin >> n;
	if(n==3){
		cout << "2 5 63" << endl;
	} else if(n%2==0){
		for(i=0;i<n;i++){
			cout << a[i%8]+12*(i-i%8)/8;
			if(i==n-1) cout << endl;
			else cout << " ";
		}
	} else {
		for(i=0;i<n;i++){
			cout << b[(i)%8]+12*((i)-(i)%8)/8;
			if(i==n-1) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream> 
#include <cmath>
using namespace std;
int main() {
	int n, t;
	cin >> n >> t;
	int ans = 0, k = 1;
	while (k < t) {
		k -= 1;
		k += n;
		ans++;
	}
	cout << ans;
  return 0;
}

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

typedef long long ll;

const int N = 1e7 + 100;
int mod = 998244353;


namespace Combi {
    int fact[N], inv[N];

    int bm(int b, int p, int m) {
        if(p == 0) return 1%m;
        int t = bm(b,p/2,m);
        t = (1ll*t*t)%m;
        if(p&1) return 1ll*t*b%m;
        return t;
    }

    int C(int n, int r) {
        if(n < 0 or r < 0 or r > n) return 0;
        int ret = 1ll*fact[n]*inv[r]%mod;
        ret = 1ll*ret*inv[n-r]%mod;
        return ret;
    }
    // X1 + X2 + ... + Xvar = Sum
    int no_of_eqns(int var, int sum) {
        return C(sum+var-1,var-1); // Xi >= 0
        // return C(sum-1,var-1); // Xi > 0
    }
    void init() {
        fact[0] = 1;
        for(int i = 1; i < N; i++) {
            fact[i] = 1ll*fact[i-1]*i%mod;
        }
        inv[N-1] = bm(fact[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--) {
            inv[i] = 1ll*inv[i+1]*(i+1)%mod;
        }
    }
}

int pw2[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    Combi::init();
    int n;
    cin >> n;
    int ways = 1;
    pw2[0] = 1;
    for(int i = 1; i <= n; i++) {
        ways = 1ll*3*ways%mod;
        pw2[i] = 1ll*2*pw2[i-1]%mod;
    }
    for(int i = n/2 + 1; i <= n; i++) {
        int bad_ways = 1ll*Combi::C(n, i)*pw2[n-i+1]%mod;
        ways = (ways - bad_ways + mod)%mod;
    }
    cout << ways << endl;
    return 0;
}



Measured memory_bytes: 117504
import copy
N,M=map(int,input().split())
linked=[set() for i in range(N)]
for i in range(M):
  s,t=map(int,input().split())
  linked[s-1].add(t-1)
def dp(link):
  dp=[0]*N
  for i in range(N-1):
    k=N-2-i
    size=len(link[k])
    if size==0:
      continue
    p=1/size
    v=0
    for t in link[k]:
      v=v+p*(dp[t]+1)
    dp[k]=v
  return dp
all_dp=dp(linked)
ans=all_dp[0]
for i in range(N-1):
  if len(linked[i])<2:
    continue
  cut=0
  v=0
  for t in linked[i]:
    if v<all_dp[t]:
      cut=t
      v=all_dp[t]
  linked[i].remove(cut)
  d=dp(linked)
  ans=min(ans,d[0])
  linked[i].add(cut)
print(ans)

Measured memory_bytes: 65980
#include <bits/stdc++.h>
#define IT map<pair<int,int> , int>::iterator
using namespace std;

typedef long long ll;
map<pair<int,int> , int>val_map;
int main(int argc, char const *argv[])
{
	int n;
	double a;
	scanf("%d",&n);
	for(register int i = 0;i < n;i++)
	{
		scanf("%lf",&a);
		ll denominator = 1000000000;
		ll numerator = (ll)(a * denominator + 0.1);
		ll gcd = __gcd(denominator,numerator);
		denominator /= gcd;
		numerator /= gcd;
		int two = 0,five = 0;
		while(denominator % 2 == 0) two--,denominator /= 2;
		while(denominator % 5 == 0) five--,denominator /= 5;
		while(numerator % 2 == 0) two++,numerator /= 2;
		while(numerator % 5 == 0) five++,numerator /= 5;
		val_map[make_pair(two,five)]++;
	}
	ll ans = 0;

	for(IT it1 = val_map.begin();it1 != val_map.end();it1++)
		for(IT it2 = val_map.begin();it2 != val_map.end();it2++)
			if(it1->first.first + it2->first.first >= 0 && it1->first.second + it2->first.second >= 0)
			{
				if(it1->first == it2->first)
					ans += 1ll * it1->second * (it1->second - 1) / 2;
				else if(it1->first < it2->first)
					ans += 1ll * it1->second * it2->second;
			}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
    string s,t;
    cin>>s>>t;
    int flag = 0;
    int n1=s.length();
    int n2 = t.length();
    if(n2 = n1 + 1){
    for(int i=0;i<n1;i++)
    {
        if(s[i]!=t[i])
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    cout<<"No"<<"\n";
    else
    cout<<"Yes"<<"\n";
    
    }
    else
    cout<<"No"<<"\n";
	return 0;
}

Measured memory_bytes: 3644
n = int(input())
t, a = map(int,input().split())
ls = list(map(int,input().split()))
#ls = [list(map(int,input().split()))[1:] for i in range(n)]
#ls = [int(input()) for i in range(n)]

p = []
for i in ls:
  p.append(abs(a - (t - i * 0.006)))

print(p.index(min(p)) + 1)

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    ll count = 0;
    FOR(i, 0, N-2){
        vector<ll> B;
        B.push_back(A[i]);
        B.push_back(A[i+1]);
        B.push_back(A[i+2]);
        sort(ALL(B));
        if(A[i+1] == B[1]) count++;
    }
    p(count);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
    VECCIN(head);
    VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
    seco[head]=IN();
    VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
    CIN(n);
    VC1(n,a);
    int num = 0;
    REP(i,n){
        while(a[i]%2==0){
            a[i]/=2;
            ++num;
        }
    }
    COUT(num);

    


    return 0;
}

Measured memory_bytes: 384
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2];
	min(C, B / A).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }

  int cnt = 0;
  for (int i = 1; i < n - 1; ++i) {
    int mn = min({p[i-1], p[i], p[i+1]});
    int mx = max({p[i-1], p[i], p[i+1]});
    if (p[i] != mn and p[i] != mx) ++cnt;
  }
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int sum = 0;
    for( int i=0; i<n.length(); i++){
        sum += (int)n[i]-48;
    }

    if(sum%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3740
#include<iostream>
#include<assert.h>
//#include<vector>
#include<math.h>

#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define write freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); 
#define ll long long

using namespace std;
//assert(x==i);
void solve()
{
ll n,d,cnt=0;
ll x,y;
cin>>n>>d;
//vector<int> x(n),y(n);
for(int i=0;i<n;++i)
{
cin>>x>>y;
if(sqrt(pow(x,2)+pow(y,2))<=d)
cnt++;
}
cout<<cnt<<"\n";
}
int main() 
{
ios;
//write;
int tc=1;
//cin>>tc;
for(int i=1;i<=tc;i++)
{
//cout<<"Case #"<<i<<": ";
solve();
}
return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

int main(){
    int i,n,j;
    scanf("%d",&n);
    for(i=1;i<=9;i++){
        if(n%i==0){
            j=n/i;
        }
    }
    if(j>=1 && j<=9 ){
        printf("Yes");
    }
    else{
        printf("No");
    }

return 0;
}


Measured memory_bytes: 128