akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

/*
	int n, k;
	scanf("%d%d%*c", &n, &k);
	vector<bool> a(n);
	char tmp;
	rep(i, n) {
		scanf("%c", &tmp);
		a[i] = (tmp == '1');
	}
	vector<pair<int, int>> b;//0の範囲を保存する。末尾がi番目
	bool flag = false;
	int count = 0;
	rep(i, n) {
		if (flag) {
			if (a[i]) {
				b.pb(make_pair(count, i));
				count = 0;
				flag = false;
			}
			else {
				++count;
			}
		}
		else {

		}
	}
*/

int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a));
	int sum = accumulate(all(a), 0);
	for (int i = 0; sum % 10 == 0 && i < n; ++i) {
		if (i != 0)sum += a[i - 1];
		sum -= a[i];
	}
	printf("%d\n", (sum % 10 == 0 ? 0 : sum));

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int sec,h,m,s;
	cin >> sec;
    h = sec/3600;
    m = (sec - h*3600)/60;
    s = sec - h*3600 - m*60;
	cout << h << ":" << m << ":" << s << "\n";
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N;
    ll x;
    // 2000;
    cin >> N >> x;
    ll ans = 1e18;
    vector<ll> as(N);
    vector<ll> bs(N);
    rep(i, N){
        // cost;
        cin >> as[i];
        bs[i] = as[i];
    }

    rep(i, N){
        ll tmp = i * x;
        rep(j, N){
            int index = ((j - i) + N) % N;
            bs[j] = min(bs[j], as[index]);
            tmp += bs[j];
        }
        ans = min(tmp , ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)

int main() {
    int N;

    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N ;i ++) cin >> a[i];

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (i - 1 >= 0 && a[i] == a[i - 1]) {
            a[i] = - 1;
            ans ++;
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(),a.end());
  
  int a_sum = 0,b_sum = 0;
  for(int i = 0;i < n;i++){
    if(i % 2 == 0){
      a_sum += a.at(i);
    }
    else{
      b_sum += a.at(i);
    }
  }
  cout << a_sum - b_sum << endl;
}

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

const int K = 18, N = 55;

vector<int> vv[1<<K];

long long C[N][N];

void pre() {
    for (int i=0; i<N; i++) C[i][0] = 1;
    for (int i=1; i<N; i++)
        for (int j=1; j<N; j++)
            C[i][j] = C[i-1][j-1] + C[i-1][j];

    for (int i=0; i<N; i++)
        for (int j=1; j<N; j++)
            C[i][j] += C[i][j-1];
}

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


    int n, k, S, T;
    cin>>n>>k>>S>>T;

    vector<int> v(n);
    for (int i=0; i<n; i++) cin>>v[i];
    sort(v.begin(), v.end());

    if ( (S&T) != S) {
        cout<<0<<endl;
        return 0;
    }

    for (int i=0; i<n; i++) {
        int x = v[i];

        if ((x&S) != S) continue;
        if ((x&T) != x) continue;

        for (int mask = 0; mask < (1<<K); mask++) {
            if ((mask&S) != S) continue;
            if ((mask&T) != mask) continue;
            int ans = x & (~mask);
            vv[mask].push_back(ans);
        }
    }

    long long ans = 0;
    for (int mask = 0; mask < (1<<K); mask++) {
        if ((mask&S) != S) continue;
        if ((mask&T) != mask) continue;
        sort(vv[mask].begin(), vv[mask].end());

        long long ww = 0;
        while (vv[mask].size()) {
            int last = vv[mask].back();
            int cnt = 0;
            while (vv[mask].size() && vv[mask].back() == last)  cnt++, vv[mask].pop_back();

            ww += C[cnt][k]-1;
        }

        int bc = __builtin_popcount(mask);
        if (bc%2)   ans += ww;
        else        ans -= ww;
    }
    cout<<abs(ans)<<endl;
}


Measured memory_bytes: 81456
#include <iostream>

using namespace std;

#define MAX 15

int N;
int A[MAX];
int x[MAX][MAX];
int y[MAX][MAX];

int countbit(int bits) {
  int ct = 0;
  while(bits) {
    if(bits&1) ct ++;
    bits = bits >> 1;
  }
  return ct;
}

int main() {
  cin >> N;
  for(int i=0; i<N; i++) {
    cin >> A[i];
    for(int j=0; j<A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }

  int ans = 0;
  // 各正直，不親切の組を仮定して，1つでも不一致がないか調べる
  // 全て不正直は調べるまでもなく，成り立つ
  for(int bits = 1; bits < (1 << N); bits ++) {
    // ある仮定
    // その時に，全ての言明を調べる
    int ok = true;
    for(int i=0; i<N; i++) {
      // 不誠実の仮定のときは無視
      if(!((bits>>i)&1)) continue;
      
      for(int j=0; j<A[i]; j++) {
	int hito = x[i][j] - 1;
	if(((bits >> hito)&1) ^ y[i][j]) ok = false;
      }
    }
    if(ok) {
      ans = max(ans, countbit(bits));
    }
  }

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    array<int, 4> num;
    REP(i, 4){
        num[i] = N % 10;
        N /= 10;
    }
    if (num[1] == num[2] && (num[0] == num[1] || num[2] == num[3])){
        puts("Yes");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()
using namespace std;

int main(){
    int y[7];
    int x[6][6]={{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
    int a,b,c,d,q;
    rep(i,6)cin>>y[i+1];
    cin>>q;
    rep(i,q){
        cin>>a>>b;
        for(int j=1;j<=6;j++){
            if(a==y[j])c=j;
            if(b==y[j])d=j;
        }
        cout<<y[x[c-1][d-1]]<<endl;
    }
}


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

int main()
{
    ll N;
    cin >> N;
    cout << (N - 1) * N / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000003;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

vector<LL> fact;
vector<LL> inver(mod + 1);
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<mod;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[mod-1]=fpow(fact[mod-1],mod-2);
    for(int i=mod-2;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 

int main(){
    set_combi();
    int q;cin >> q;
    while(q--){
        LL x,d,n;cin >> x >> d >> n;
        if(d==0){
            cout << fpow(x, n) << endl;
            continue;
        }
        x = x * fpow(d, mod - 2) %mod;
        if(x + n - 1 >= mod) cout << 0 << endl;
        else cout << fact[x + n - 1] * inver[x - 1] %mod * fpow(d,n) %mod << endl;
    }
    return 0;
}


Measured memory_bytes: 18284
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

long long int do_m(const std::vector<long long int>& happiness, const std::vector<long long int>& sum, const int min, const long long int m) {
	long long int count = 0, count_just = 0;
	long long int sum_upper = 0;
	for (const auto a : happiness) {
		auto lower = std::lower_bound(happiness.begin(), happiness.end(), min - a);
		auto upper = std::upper_bound(happiness.begin(), happiness.end(), min - a);
		count_just += std::distance(lower, upper);
		count += std::distance(upper, happiness.end());
		sum_upper += (sum.back() - sum[std::distance(happiness.begin(), upper)]) + std::distance(upper, happiness.end()) * a;
	}
	return sum_upper + (m - count + 0LL) * min;
}
bool can_make(const std::vector<long long int>& happiness, const int min, const long long int m) {
	long long int count = 0;
	for (const auto a : happiness) {
		auto lower = std::lower_bound(happiness.begin(), happiness.end(), min - a);
		count += std::distance(lower, happiness.end());
	}
	return count >= m;
}
int main() {
	int n; long long int m; std::cin >> n >> m;
	std::vector<long long int> happiness(n), sum{ 0LL }; for (auto& a : happiness) std::cin >> a;
	std::sort(happiness.begin(), happiness.end());
	for (auto a : happiness) sum.push_back(sum.back() + a);
	long long int min = 0;
	long long int max = happiness.back() * 2 + 1;
	while (min < max) {
		const auto mid = (min + max) / 2;
		if (can_make(happiness, mid, m)) {
			min = mid + 1;
		}
		else {
			max = mid;
		}
	}
	std::cout << do_m(happiness, sum, max - 1, m) << std::endl;
}

Measured memory_bytes: 2168
#include <iostream>

using namespace std;

const int MAX_NUM = 100;
const int MAX_WEIGHT = 10000;

int main()
{
    int N, W, dp[MAX_WEIGHT] = {}, v[MAX_NUM], w[MAX_NUM], ans = -1;
    cin >> N >> W;
    for(int i=0;i<N;++i) cin >> v[i] >> w[i];
    
    for(int i=0;i<N;++i)
    {
        for(int j=0;j<W+1;++j)
        {
            if(j >= w[i])
            {
                dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
                ans = max(dp[j], ans);
                continue;
            }

        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3132
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
//Variables End


void solve(){
	string s;cin>>s;
	int n=s.length();
	reverse(all(s));
	vector<ll> val(2019,0);
	vector<int> po(n,0);
	po[0]=1;
	for(int i=1;i<n;i++)po[i]=(10*po[i-1])%2019;
	val[0]++;
	int mod=0;
	for(int i=0;i<n;i++){
		int new_mod=(mod+po[i]*(s[i]-'0'))%2019;
		val[new_mod]++;
		mod=new_mod;
	}
	ll ans=0;
	for(int i=0;i<2019;i++){
		//cout<<val[i]<<" ";
		ans += val[i]*(val[i]-1)/2;
	}
	
	cout<<ans<<endl;
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    for(int i=1;i<=ti;i++)
    {
		solve();        
    }
    return 0;
        
}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int,int> mii;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = b-1; i >= a; i--)
#define F0Rd(i,a) for (int i = a-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 1000000007;
double PI = 4*atan(1);

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int H,W; cin >> H >> W;
	char a[500][500], b[500][500], c[500][500];
	F0R(i,H) F0R(j,W) {
		cin >> a[j][i];
		b[j][i] = c[j][i] = a[j][i];
	}
	F0R(i,H) b[0][i] = c[W-1][i] = '#';
	F0R(i,H) {
		FOR(j,1,W-1)
			if (i % 2) b[j][i] = '#';
			else c[j][i] = '#';
	}
	F0R(i,H) {
		F0R(j,W) cout << b[j][i];
		cout << "\n";
	}
	cout << "\n";
	F0R(i,H) {
		F0R(j,W) cout << c[j][i];
		cout << "\n";
	}
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

signed main(){

	int N, M;
	P a[123456];
	cin >> N >> M;

	for (int i = 0; i < N; i++){
		cin >> a[i].first >> a[i].second;
	}
	a[N].first = INF; a[N].second = INF;
	sort(a, a + N, [](P &s, P &t){return s.first <t.first; });

	int ans = 0;
	int cnt = 0;
	int i = 0;
	while (cnt + a[i].second <= M){
		ans += a[i].second * a[i].first;
		cnt += a[i].second;
		i++;
	}
	ans += (M - cnt)*a[i].first;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int x=sqrt(N);
    cout << x*x << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
int dp[105][100005];
signed main() {
    int N,W;
    cin >> N >> W;
    for(int i = 0; i < 105; i++) {
        for(int j = 0; j < 100005; j++) {
            dp[i][j] = -INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= N; i++) {
        int w,v;
        cin >> w >> v;
        for(int j = 0; j <= W; j++) {
            if(dp[i-1][j] >= 0 && j+w <= W) {
                dp[i][j+w] = dp[i-1][j]+v;
            }
            if(dp[i-1][j] >= 0) {
                dp[i][j] = max(dp[i][j],dp[i-1][j]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= W; i++) {
        ans = max(ans,dp[N][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 85672
object Main extends App {
  val Array(n, a, b) = readLine.split(" ").map(_.toInt)
  
  val elements = for {
    e <- (0 to n).toList
    str = e.toString.split("").filter(_.nonEmpty)
    sum = str.map(_.toInt).sum
    if a <= sum
    if sum <= b
  } yield e
  
  println(elements.sum)
}

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

using namespace std;

int main()
{
    int d, n;
    int k;
    vector<int>vec;

    cin >> d >> n;

    int i = 1;
    while (vec.size() <= n) {
        int temp = i;
        int cnt = 0;
        while (temp % 100 == 0) {
            temp /= 100;
            cnt++;
        }

        if (cnt == d) {
            vec.push_back(i);
        }
        i++;
    }
        

    cout << vec[n - 1]  << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    }
    let mut adj = vec![vec![]; n];
    for (a, b) in ab {
        adj[b].push(a);
        adj[a].push(b);
    }
    for &m in &adj[0] {
        if adj[m].contains(&(n - 1)) {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}


Measured memory_bytes: 19776
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL fastpow(LL x,LL a)
{
	LL res=x,ret=1;
	while(a>0)
	{
		if((a&1)==1) ret=ret*res%MOD;
		a>>=1;
		res=res*res%MOD;
	}
	return ret;
}

LL n,a[10010],have[1000010],res=1,ans=0;
map <LL,LL> mp;

int main()
{
  cin>>n;
  rep(i,n) cin>>a[i];
  rep(i,n)
  {
    LL tmp=a[i];
    mp.clear();
    for(LL j=2;j*j<=a[i];j++)
    {
      while(tmp%j==0)
      {
        tmp/=j;
        mp[j]++;
      }
    }
    if(tmp>0) mp[tmp]++;
    for(map <LL,LL>::iterator it=mp.begin();it!=mp.end();it++) 
    have[it->fi]=max(have[it->fi],it->se);
  }
  repn(i,1000005) res=res*(LL)pow(i,have[i])%MOD;
  //cout<<res<<endl;
  rep(i,n) ans=(ans+res*fastpow(a[i],MOD-2)%MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

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

    long n;

    cin >> n;

    map<long, long> even, odd;
    V<pair<long, long> > evenV, oddV;
    pair<long, long> p0, p1;
    long v;
    long ans = LONG_MAX;
    long half = n / 2;
    bool found = false;

    long i, j, len, lenJ;

    repiin(i, n, 1) {
        cin >> v;

        if (i % 2 == 0) even[v]++;
        else odd[v]++;
    }

    repit(even) evenV.pb(mp(it->Y, it->X));
    repit(odd) oddV.pb(mp(it->Y, it->X));

    sort(All(evenV), std::greater<pair<long, long> >());
    sort(All(oddV), std::greater<pair<long, long> >());

    len = evenV.size();
    lenJ = oddV.size();
    rep(i, len) {
        p0 = evenV[i];

        rep(j, lenJ) {
            p1 = oddV[j];

            if (p0.Y != p1.Y) {
                Min(ans, half - p0.X + half - p1.X);
                found = true;

                break;
            }
        }

        if (found) break;
    }

    found = false;

    rep(j, lenJ) {
        p0 = oddV[j];

        rep(i, len) {
            p1 = evenV[i];

            if (p0.Y != p1.Y) {
                Min(ans, half - p0.X + half - p1.X);
                found = true;

                break;
            }
        }

        if (found) break;
    }

    if (ans == LONG_MAX) {
        Min(ans, half - evenV[0].X + half);
        Min(ans, half + half - oddV[0].X);
    }

    Out(ans);

    return 0;
}


Measured memory_bytes: 8824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;

	if (N < 1200) co("ABC");
	else co("ARC");

	Would you please return 0;
}

Measured memory_bytes: 256
var
  a,b,i:longint;
Function max(x,y:longint):longint;
begin
  if x>y then exit(x) else exit(y);
end;
begin
  read(a);
  for i:=a to 999 do
    begin
      if (i mod 10=i div 100)and(i div 100=i div 10 mod 10) then
        begin
          write(i);
          exit;
        end;
    end;
end.

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		long a=sc.nextLong();
		long b=sc.nextLong();
		int k=sc.nextInt();

		long aa;

		for(int i=0;i<k;++i){
			b=b+a/2;
			a=a/2;

			aa=b;
			b=a;
			a=aa;
		}

		if(k%2==0)System.out.println(a+" "+b);
		else System.out.println(b+" "+a);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,sum=0,ans=INT_MIN;
    long long int w;
    long long int a[105][2];
    long long int dp[105][100005];
    cin>>n>>w;
    for(i=1;i<=n;i++)
    {
    cin>>a[i][0]>>a[i][1];
    sum+=a[i][1];
    }
    for(i=0;i<=n;i++)
    {
    for(j=0;j<=sum;j++)
    dp[i][j]=LLONG_MAX-INT_MAX;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=sum;j++)
        {
            if(j<=a[i][1])
            {
                dp[i][j]=min(dp[i-1][j],a[i][0]);
            }
            else
            {
                if(dp[i-1][j-a[i][1]]==INT_MAX)
                dp[i][j]=LLONG_MAX-INT_MAX;
                else
                {
                dp[i][j]=min(dp[i-1][j],a[i][0]+dp[i-1][j-a[i][1]]);
                }
            }
            if(dp[i][j]<=w)
            ans=max(ans,j);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 81024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
#define SORT(a) sort(a.begin(), a.end())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

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

    if(a != 1 && b !=1)cout<<'1'<<endl;
    if(a != 2 && b !=2)cout<<'2'<<endl;
    if(a != 3 && b !=3)cout<<'3'<<endl;
}

Measured memory_bytes: 256
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    reads(s)
    int x[4]; fori (i, 0, 3) x[i] = (int)(s[i] - '0');

    int m = x[0]*10 + x[1];
    int y = x[2]*10 + x[3];

    if(m == 0)
    {
    	if(y >= 1 && y <= 12) print("YYMM")
    	else print("NA")
    }

    else if(y == 0)
    {
    	if(m >= 1 && m <= 12) print("MMYY")
    	else print("NA")
    }

	else if(m > 12 && y > 12) print("NA")

	else if(m <= 12 && y <= 12) print("AMBIGUOUS")

	else if(m <= 12) print("MMYY")
	else print("YYMM")

    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  dsu d(n);
  for(int i = 0; i < k; i++) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    d.merge(a,b);
  }
  int ans = d.groups().size();
  cout << ans -1 << endl;
}

Measured memory_bytes: 8916
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
    a,b=map(int,input().split())
    A[i]=a
    B[i]=b
A.sort()
B.sort()
if N%2:
    print(B[N//2]-A[N//2]+1)
else:
    a=A[N//2-1]+A[N//2]
    b=B[N//2-1]+B[N//2]
    print(b-a+1)

Measured memory_bytes: 25380
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

const int INF = 1e9;

int keta(long n){
    int cnt = 0;
    while(n > 0){
        cnt++;
        n /= 10;
    }
    return cnt;
}

int main(void) {
    long n;
    cin >> n;

    int ans = INF;
    for(long i = 1; i * i <= n; i++){
        if(n % i != 0){
            continue;
        }
        long a = i;
        long b = n / i;
        long c = max(a, b);
        ans = min(ans, keta(c));
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
struct Pos {
  int x, y;
};

int main() {
  string a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "EQUAL" << endl;
    return 0;
  }
  if (a.size() > b.size())
    cout << "GREATER" << endl;
  else if (a.size() < b.size())
    cout << "LESS" << endl;
  else
    cout << (a > b ? "GREATER" : "LESS") << endl;
}


Measured memory_bytes: 256
N = int(input())
s = [0 for _ in range(N)]
for i in range(N):
   s[i] = input()
M = int(input())
t = [0 for _ in range(M)]
for i in range(M):
   t[i] = input()

count = [0,]
for s_i in s:
   k = 0
   for i in range(N):
      if s_i == s[i]:
         k += 1
   for i in range(M):
      if s_i == t[i]:
         k -= 1
   count.append(k)


print(max(count))

   



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

#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 foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int N;

int main(){
  scanf("%d",&N);

  int s = N%2 ? N : N + 1;
  int M = N%2 ? (N-1)*(N-1)/2 : N*(N-2)/2;
  cout << M << endl;
  rep (i, N) {
    for (int j=i+1; j<N; ++j) {
      if (i+j+2 != s) {
        cout << (i+1) << " " << (j+1) << endl;
      }
    }
  }
  return 0;
}

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

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

    vector<int> p(n);
    vector<long long int> c(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
        p[i] -= 1;
    }
    for(int i=0; i<n; i++){
        cin >> c[i];
    }

    vector<vector<long long int>> x(n);
    for(int i=0; i<n; i++){
        int current = i;
        x[i].push_back(0);
        vector<bool> visited(n, false);

        while(visited[current] == false){
            //cout << current << " ";
            visited[current] = true;
            x[i].push_back(c[current]);

            int j = x[i].size() - 1;
            x[i][j] += x[i][j-1];

            current = p[current];
        }
        //cout << endl;
    }

    long long int ans = -1e18 - 1;
    for(int i=0; i<n; i++){
        long long int score = -1e18 - 1, rem = -1e18 - 1;
        int j = x[i].size() - 1;

        for(int l=1; l<=min(j,k); l++) score = max(score, x[i][l]);
        
        for(int l=1; l<=k%j; l++) rem = max(rem, x[i][l]);
        if(k >= j){
            score = max(score, x[i][j] * (k / j - 1) + score);
            score = max(score, x[i][j] * (k / j) + rem);
        }

        ans = max(ans, score);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 218960
class BIT
  attr_reader :original_size, :op, :array
  def initialize(original_size, unit, &op)
    @original_size = original_size
    @op = op
    @unit = unit
    @array = Array.new(original_size+1, unit)
  end

  def add(i, v)
    i += 1
    while i <= @original_size do
      @array[i] = @op.call(@array[i], v)
      i += i&(-i)
    end
  end

  def find(i)
    r = @unit
    i += 1
    while i > 0 do
      r = @op.call(r, @array[i])
      i = i & (i-1)
    end
    r
  end
end

N,K,*A = `dd`.split.map &:to_i
ss = [0]
A.each{ |a| ss << ss[-1] + a - K }
smap = {}
ss[1..-1].sort.each_with_index{ |s,i| smap[s] = i }

st = BIT.new(N, 0) { |a,b| a + b }
ans = 0
ct = {}
ss[1..-1].each{ |s|
  ans += 1 if s >= 0
  i = smap[s]
  ans += st.find(i)
  st.add(i, 1)
}
p ans


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w, k;
	cin >>h >>w >>k;
	vector<string> s(h);
	rep(i, h) cin >>s[i];
	vector<VI> ba(h, VI(w));
	rep(i,h) rep(j,w) ba[i][j] = s[i][j] -'0';
	int res = 1<<28;
	rep(i,1<<(h-1)){
		int tsu = 0;
		vector<int> cv(h); //sh;
		rep(j, h){ cv[j] = tsu; if((i>>j)& 1) tsu++; }
		if(tsu >= res) continue;
		vector<int> cdy(tsu+1,0);
		rep(x, w){
			bool addsw=false;
			vector<int> gdy(tsu+1,0);
			rep(y, h){
				gdy[cv[y]] += ba[y][x];
				if(gdy[cv[y]] > k) goto lastloop;
				cdy[cv[y]] += ba[y][x];
				if(cdy[cv[y]] > k){ addsw=true; break;}
			}
			if(addsw){
				tsu++;
				fill(all(cdy), 0);
				x--;
			}
		}
		res = min(res, tsu);
		lastloop: ;
	}
	cout << res <<"\n";
	return 0;
}


Measured memory_bytes: 384
n = int(input())
s = input()
c = s.count

# 文字列からR,G,Bをひとつずつを選んだときの組み合わせ総数をカウントする
ans = c("R")*c("G")*c("B")

for a in range(n-2):  # 基準
    for j in range((n-a+1)//2):  # 文字の距離
        # 全ての組み合わせから距離の等しい組み合わせを排除する
        # 距離の等しい組み合わせは、a,b,cの組み合わせのうち、
        # aを固定、a-bの距離をjで固定したとき,b=a+j, c=a+2*jと表せる
        if s[a] != s[a+j] and s[a+j] != s[a+2*j] and s[a+2*j] != s[a]:
            ans -= 1
print(ans)


Measured memory_bytes: 9156
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    total = sum(A)

    ans = 0
    for a in A:
        total -= a
        ans = (ans + a * total % MOD) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 110556
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# 早期終了

if len(set(A)) != len(A):
    print(0)
    exit()
if len(set(B)) != len(B):
    print(0)
    exit()

# 高速化のため事前ソート

A.sort(reverse=True)
B.sort(reverse=True)

n_A, n_B = 0, 0  # ある数よりも大きい要素数(単調増加)
# この問題は場合分けを思いつけるか、計算量を減らせるかにかかっている

# TLEでなくするには2つ工夫が必要
# 1. a in A等を工夫する
# 2. 与えられた集合の中にxょり大きい要素がいくつあるかという処理の高速化

# 1は簡単なので2についてだけ記録を残す
# これをn_Aとおくと、n_Aには単調増加性があることがすぐにわかる
# xをどんどん小さくしているからである。
# n_Aを逐一計算する代わりに、いままでの情報を使ってn_Aを求められると処理が高速化される
# A=[182, 181, 180, 179, 178, 176, 175, 169, 168, 167, 158, 151, 147, 129]とする(sorted)とすると、
# A[n_A]=xとなるn_Aがほしい。xが登場するまでのイテレーションでx_pre in Aとなる要素があるたび、その回数をカウントすればよい
#


def ret_n_given_x(x):
    global n_A, n_B
    flgA = False
    flgB = False
    # a in Aの代わり(こうしないとTLE)
    for a in A[n_A:]:
        if a == x:
            flgA = True
            break
    for a in B[n_B:]:
        if a == x:
            flgB = True
            break

    if flgA and flgB:
        n_A += 1  # 上記で解説した個数カウント
        n_B += 1  # xより大きな要素が何個あったかついでに記録できる
        return 1
    elif flgA:
        n_A += 1
        return n_B
    elif flgB:
        n_B += 1
        return n_A
    else:
        return (n_A * n_B)-(N*M-x)


MOD = 10**9 + 7
ans = 1
for x in range(N * M, 0, -1):
    ans *= ret_n_given_x(x)
    ans %= MOD
    # print(x, ans, ret_n_given_x(x))
    if ans == 0:
        break

print(int(ans))


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

#define sd(n) scanf("%d",&n) == 0
#define sl(n) scanf("%lld",&n) == 0

#define pl(x) printf("%lld\n", x)

#define rep(i, begin, end) for (decltype(begin) i = end - 1; i >= begin; i--)

using namespace std;

long long arr[100000];

int main() {
	int n;
	sd(n);
	rep(i, 0, n) {
		sl(arr[i]);
	}

	sort(arr, arr + n);

	long long last = -1;
	long long best = -1;
	rep(i, 0, n) {
		if (last == arr[i]) {
			if (best != -1) {
				pl(last * best);
				return 0;
			}
			best = arr[i];
			last = -1;
			continue;
		}
		last = arr[i];
	}

	pl((long long)0);

}

Measured memory_bytes: 1024
//At_coder
//Bismillahir Rahmanir Rahim
#include<iostream>
//#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,t,a,sum=0;
	string s,ss;
	cin>>s;

	for(int i=0;i<s.size();i++)
	{
		n=s[i]-48;
		sum+=n;
	}
	(sum%9==0)?cout<<"Yes"<<endl:cout<<"No"<<endl;
}

Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
int main(){
    LL x,y;
    bool true_flg = false;
    cin >> x >> y;
    for(int i = 0; i < x; i++) {
        if(y == (i*2) + ((x-i)*4)){
            true_flg = true;
        }else if(y == (i*4) + ((x-i)*2)){
            true_flg = true;            
        }
    }
    if(true_flg) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  int n;
  cin >> n;
  int a[n + 1];
  REP(i, n) cin >> a[i + 1];
  int cnt = 0, pos = 1;
  while(true) {
    if(pos == 2) break;
    if(a[pos] == -1) {
      cnt = -1;
      break;
    }
    cnt++;
    int new_pos = a[pos];
    a[pos] = -1;
    pos = new_pos;
    // cout << pos << endl;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a<=b && a<=c)
    {
        if(b<=c) cout<<a<<" "<<b<<" "<<c;
        else cout<<a<<" "<<c<<" "<<b;
    }
    else
    if(b<=a && b<=c)
    {
        if(a<=c) cout<<b<<" "<<a<<" "<<c;
        else cout<<b<<" "<<c<<" "<<a;
    }
    else
    if(c<=a && c<=b)
    {
        if(a<=b) cout<<c<<" "<<a<<" "<<b;
        else cout<<c<<" "<<b<<" "<<a;
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;

vector<bool> seen;
vector<int> root;
vector<int> mcount;
void dfs(const Graph &G,int v){
  mcount[root[v]]++;
  seen[v]=true;
  for(auto next_v:G[v]){ 
    if(seen[next_v]) continue;
    root[next_v]=root[v];
    dfs(G, next_v);
  }
}

int main() {
  int n,m,k;
  cin>>n>>m>>k;
  int vec[n]={0};
  Graph G(n);
  int a,b;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    a--;
    b--;
    vec[a]++;
    vec[b]++;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  seen.assign(n,false);
  mcount.assign(n,0);
  root.assign(n,0);
  for(int i=0;i<n;i++){
    if(!seen[i]){
      root[i]=i;
      dfs(G,i);
    }
  }
  for(int i=0;i<n;i++){
    mcount[i]=mcount[root[i]];
  }
  for(int i=0;i<k;i++){
    cin>>a>>b;
    a--;
    b--;
    if(root[a]==root[b]){
      mcount[a]--;
      mcount[b]--;
    }
  }
  for(int i=0;i<n;i++){
    cout<<mcount[i]-vec[i]-1<<" ";
  }
}

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

ll N, ans=0, ansv[2];
vector<int> v1, v2;

signed main(){
    vector<int> v;
    cin >> N;
    v1.resize(N);
    v2.resize(N);
    for(int i=1;i<=N;i++) v.push_back(i);
    for(int i=0;i<N;i++) cin >> v1[i];
    for(int i=0;i<N;i++) cin >> v2[i];
    do {
        ans++;
        int flag=0;
        for(int i=0; i<v.size(); i++) {
            if(v[i]==v1[i]) continue;
            flag=1;
        }
        if(flag==0) {
            ansv[0]=ans;
        }
        flag=0;
        for(int i=0; i<v.size(); i++) {
            if(v[i]==v2[i]) continue;
            flag=1;
        }
        if(flag==0) {
            ansv[1]=ans;
        }
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(ansv[1]-ansv[0]) << endl;
    return 0;
}

Measured memory_bytes: 3592
n = int(input())
s = ['' for _ in range(n)]
for i in range(n):
    s[i] = list(input())
    s[i].sort()
    s[i] = ''.join(s[i])
s.sort()
s.append('#')
res = 0
cnt = 1
for i in range(n):
    if s[i] != s[i+1]:
        res += cnt *(cnt-1)//2
        cnt = 1
    else:
        cnt += 1
print(res)

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

using namespace std;

int A[5];

int main()
{
    int k;
    scanf("%d %d %d %d %d %d",&A[0],&A[1],&A[2],&A[3],&A[4],&k);
    int ok = 1;
    for(int i = 0;i < 5;i++){
        for(int j = i+1;j < 5;j++){
            if(abs(A[i] - A[j]) > k){
                ok = 0;
            }
        }
    }
    if(ok) printf("Yay!\n");
    else printf(":(\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Graph{
	private:
	int V;
	vvi g,dp;
	vi res;
	void f(int v,int d,int c){
		if(dp[v][d]||d==-1) return;
		if(!res[v]) res[v]=c;
		for(int i=0;i<g[v].size();i++){
			f(g[v][i],d-1,c);
		}
		dp[v][d]=1;
	}
	public:
	Graph(int v){
		V=v;
		g=vvi(v);
	}
	void add_edge(int s,int t){
		g[s].push_back(t);
		g[t].push_back(s);
	}
	void solve(){
		int q;
		cin>>q;
		vi v,d,c;
		v=d=c=vi(q);
		res=vi(V);
		dp=vvi(V,vi(11));
		for(int i=0;i<q;i++) cin>>v[i]>>d[i]>>c[i];
		for(int i=q-1;i>=0;i--) f(v[i]-1,d[i],c[i]);
		for(int i=0;i<V;i++) cout<<res[i]<<endl;
	}
};

int n,m;

int main(){
	cin>>n>>m;
	Graph g(n);
	for(int i=0;i<m;i++){
		int s,t;
		cin>>s>>t;
		g.add_edge(s-1,t-1);
	}
	g.solve();
}

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

bool valid(int n,const vector<bool>& nr){
    while(n>0){
        //cout<<n<<" "<<nr[n%10]<<endl;
        if(nr[n%10]==true) return false;
        n =n/10;
    }
    return true;
}
int main(){
  int n,k;
  cin>>n>>k;
  vector<bool> notreq(k+1,false);
  for(int i=0;i<k;++i){
      int digit;
      cin>>digit;
      notreq[digit] = true;
  }
  //for(auto e: notreq) cout<<e<<" ";
  //cout<<endl;
  for(int i=n;;++i){
     if(valid(i,notreq)) {
         cout<<i<<endl;
         return 0;
     }
  }
}


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


int main() {

  int N=0;
  int Ans=0;
cin >> N;
vector<int>L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
     for(int k=j;k<N;k++){
       if(L.at(i)!=L.at(j)&&L.at(j)!=L.at(k)&&L.at(k)!=L.at(i)){
         if(L.at(i)+L.at(j)-L.at(k)>0&&L.at(j)+L.at(k)-L.at(i)>0&&L.at(k)+L.at(i)-L.at(j)>0){
           Ans++;
         }
       }
     }
    }
  }
  
cout << Ans;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>p(n);
    rep(i,n)cin >> p[i];
    sort(all(p));
    int ans = 0;
    rep(i,k)ans += p[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,m,ans=0;
  cin>>n>>m;
  vector<ll>v(n,0);
  for(ll i=0;i<n;i++){
    cin>>v[i];
    v[i]=v[i]/2;
  }
  ll t=v[0];
  ll tt=v[0];
  for(ll i=1;i<n;i++){
    t=lcm(t,v[i]);
    tt=gcd(tt,v[i]);
    if(m<t)break;
  }
  if(t/tt%2==0||m<t)cout<<0<<endl;
  else cout<<m/t/2+m/t%2<<endl;
}


Measured memory_bytes: 1024