akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
using ll = long long;

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x.at(i); }

int main() {

    CIN(int, N);
    CIN(int, M);

    vector<pair<ll, ll>> list(N);

    for (int i = 0; i < N; i++) {
        CIN(int, a);
        CIN(int, b);
        list[i] = make_pair(a, b);
    }

    sort(list.begin(), list.end());

    long long sum = 0;
    int num = 0;

    for (int i = 0; i < N; i++) {
        if ( list[i].second + num <= M ) {
            sum += list[i].first * list[i].second;
            num += list[i].second;
        } else {
            sum += list[i].first * (M - num);
            break;
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
long long int a[100005];
long long int b[100005][3];
vector<long long int> v1,v2;
int main(){
	long long int n,m=0,s=0;
	long long int i,j,k;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>m){
			b[i][0]=a[i]-m;
			m=a[i];
			v1.push_back(a[i]);
			v2.push_back(i);
		}
	}
	auto itr=v1.begin();
	for(i=0;i<n;i++){
		itr=lower_bound(v1.begin(),v1.end(),a[i]);
		j=(long long int)(itr-v1.begin());
		if(j==0){
			b[0][2]+=a[i];
		}else{
			b[v2[j]-1][1]++;
			b[v2[j]][2]+=a[i]-(a[v2[j]]-b[v2[j]][0]);
		}
	}
	for(i=n-1;i>=0;i--){
		b[i][1]+=b[i+1][1];
	}
	for(i=0;i<n;i++){
		m=b[i][1]*b[i][0]+b[i][2];
		cout<<m<<endl;
	}
	return 0;
}
	


Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)1e9+7
#define INF 1e15
typedef pair<int, int> P;
int a[5];
signed main() {
	int n;
	cin >> n;
	rep(i, 5)cin >> a[i];
	for (int i = 1; i < 5; i++)a[i] = min(a[i], a[i - 1]);
	cout << 4 + (n - 1) / a[4] + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------

ll dp[301][301][301]; //番目,消してない最後の番目,消した数 = いまのコスト
//--MAIN-----------------------------------
void Main() {
    int N,K;
    cin >>N>>K;
    ll H[N+1];
    H[0]=0;
    rep(i,N){
        cin>>H[i+1];
    }

    rep(i,301){
        rep(j,301){
            rep(k,301){
                dp[i][j][k]=INF2;
            }
        }
    }

    dp[0][0][0]=0;

    rep(i,N){ // i番目
        rep(j,i+1){ // 消してない最後
            rep(k,K+1){ //消した数
                mini(dp[i+1][j][k+1],dp[i][j][k]); //消す
                mini(dp[i+1][i+1][k],dp[i][j][k]+max(0LL,H[i+1]-H[j]));//消さない
            }
        }
    }

    ll ans=INF2;

    rep(i,N+1){
        rep(j,K+1){
            mini(ans,dp[N][i][j]);
        }
    }

    cout<< ans<<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

Measured memory_bytes: 3604
#include <stdio.h>

#define INF 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NIL -1

int n;
int A[128][128];

void dijkstra(int);
void printresult(int *);

void init(){
        int i, j;
        for(i = 0 ; i < n ; i++){
                for(j = 0 ; j < n ; j++){
                        A[i][j] = NIL;
                }
        }
}

int main(){
        int i, j, numto, k, num, weight;

        scanf("%d", &n);
        init();
        for(i = 0 ; i < n ; i++){
                scanf("%d %d", &num, &k);
                for(j = 0 ; j < k ; j++){
                        scanf("%d %d", &numto, &weight);
                        A[num][numto] = weight;
                }
        }

        dijkstra(0);

        return 0;
}

void dijkstra(int s){
        int i, u;
        int d[128], p[128], color[128];
        for(i = 0 ; i < n ; i++){
                d[i] = INF;
                p[i] = NIL;
                color[i] = WHITE;
        }

        d[0] = 0;

        int mincost, v;
        while(1){
                mincost = INF;
                for(i = 0 ; i < n ; i++){
                        if(color[i] != BLACK && d[i] < mincost){
                                mincost = d[i];
                                u = i;
                        }
                }

                if(mincost == INF)break;

                color[u] = BLACK;

                for(v = 0 ; v < n ; v++){
                        if(color[v] != BLACK && A[u][v] != NIL){
                                if(d[u] + A[u][v] < d[v]){
                                        d[v] = A[u][v] + d[u];
                                        p[v] = u;
                                        color[v] = GRAY;
                                }
                        }
                }
        }
                printresult(d);
}

void printresult(int *d){
        int i;

        for(i = 0 ; i < n ; i++){
                printf("%d %d\n", i, d[i]);
        }
}



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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin>>S;
    if (S == "SSS")
        cout << 0;
    else if (S == "RRS" || S == "SRR")
        cout << 2;
    else if (S == "RRR")
        cout << 3;
    else
        cout << 1;
}

Measured memory_bytes: 3620
n = int(input())
s = []
cnt = {}
ans = 0
for i in range(n):
  s_ = list(str(input()))
  s_.sort()
  s_ = "".join(s_)
  if s_ in cnt:
    ans += cnt[s_]
    cnt[s_] += 1
  else:
    cnt[s_] = 1

print(ans)

Measured memory_bytes: 17800
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
 
const int INF = 1001001001;
int dist[100005][3];
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
  }
  int sv, tv;
  cin >> sv >> tv;
  --sv; --tv;
  rep(i,n)rep(j,3) dist[i][j] = INF;
  queue<P> q;
  q.push(P(sv,0));
  dist[sv][0] = 0;
  while (!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for (int u : to[v]) {
      int nl = (l+1)%3;
      if (dist[u][nl] != INF) continue;
      dist[u][nl] = dist[v][l]+1;
      q.push(P(u,nl));
    }
  }
  int ans = dist[tv][0];
  if (ans == INF) ans = -1;
  else ans /= 3;
  cout << ans << endl;
  return 0;
}

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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var N = int.Parse(buffer[0]);
            var K = int.Parse(buffer[1]);

            buffer = Console.ReadLine().Split();
            var list = new List<int>();
            foreach (var v in buffer)
                list.Add(int.Parse(v));

            list.Sort();
            int ans = 0;
            for (int i = 0; i < K; i++)
                ans += list[i];

            Console.WriteLine(ans);
        }
    }
}


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

main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if(abs(c-a)<=d)cout <<"Yes";
  else if(abs(b-a) <= d && abs(c -b) <=d){
    cout <<"Yes";
  }
  else{cout <<"No";}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(int  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

int main()
{
  
   Ezio
   ll t,m,n,x,a,b;
   string s;
   
   cin>>t;
   
   cout<<t+t*t+t*t*t<<endl;
   return 0;
}
    

Measured memory_bytes: 3652
/************************************************************
	> File Name: b.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 19 Jan 2020 08:15:15 PM CST
************************************************************/

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
int main(void){
	int a, b;
	cin >> a >> b;
	if(a > b)
		swap(a,b);
	for(int i = 1;i <= b;i++)
		cout << a;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define de(x) cerr<<#x<<"="<<x<<endl;

vector<int> vec;

int n,k;

int main(void){
    cin>>n>>k;
    if((n-1)/2+1>=k)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<vector<int> > ki(n);
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }

    vector<int> visit(n,0);
    queue<int> next;
    int ans=n;
    rep(i,n){
        int uni=0;
        if(visit[i]) continue;
        visit[i]++;
        next.push(i);
        while(!next.empty()){
            int now=next.front();
            next.pop();
            rep(j,ki[now].size()){
                int ne=ki[now][j];
                if(!visit[ne]){
                    next.push(ne);
                    visit[ne]++;
                    uni++;
                }
            }
        }
        ans-=uni;
    }
    cout << ans << endl;
return 0;
}


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


int main(){
    
        int target, rahul;
        cin>>target>>rahul;
        int arr[rahul];
        
        for (int i = 0; i < rahul; i++) {
            /* code */
            cin>>arr[i];
        }
        int count=0;
        
        for (int i = 0; i < rahul; i++) {
            /* code */
            target-=arr[i];
            
            
        }
        if(target<=0){
                cout<<"Yes"<<endl;
                count=1;
            }
        else{
             cout<<"No"<<endl;
        }
       
}

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

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


  int R;
  cin >> R;

  if (R<1200) {
    cout << "ABC" << endl;
  }

  else if (R<2800) {
    cout << "ARC" << endl;
  }

  else if (R>=2800) {
    cout << "AGC" << endl;
  } 
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
  int n,no=0;
  cin>>n;
  set<string> s;
  rep(i,n)
  {
    int a;
    cin>>a;
    if(a<400) s.insert("gray");
    else if(a<800) s.insert("brown");
    else if(a<1200) s.insert("green");
    else if(a<1600) s.insert("lblue");
    else if(a<2000) s.insert("blue");
    else if(a<2400) s.insert("yellow");
    else if(a<2800) s.insert("orange");
    else if(a<3200) s.insert("red");
    else no++;
  }
  int size=s.size();
  cout<<max(size,1)<<" "<<size+no<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	int N;
	cin >> N;
	map<ll, int> m;
	rep(i, N) {
		ll a;
		cin >> a;
		m[a] += 1;
	}

	vector<ll> rect(N, 0);
	vector<ll> square(N, 0);

	for(auto itr: m) {
		if (itr.second < 2) continue;

		if (itr.second >= 4) {
			square.push_back(itr.first);
		}

		rect.push_back(itr.first);
	}

	sort(rect.begin(), rect.end(), greater<ll>());
	ll rect1 = rect[0];
	ll rect2 = rect[1];

	ll sq_max = *max_element(square.begin(), square.end());

	cout << (max({rect1*rect2, sq_max*sq_max})) << endl;
  return 0;
}


Measured memory_bytes: 8832
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
         try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int H = sc.nextInt(), W = sc.nextInt();
                                if (H == 0 && W == 0) {
                                        break;
                                }
                                for (int i = 0; i < H; i++) {
                                        for (int j = 0; j < W; j++) {
                                                if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
                                                        System.out.print("#");
                                                } else {
                                                        System.out.print(".");
                                                }
                                        }
                                        System.out.println("");
                                }
                                System.out.println("");
                        }
                }
    }
    
}



Measured memory_bytes: 32500
n = int(input())
num_lists = list(map(int, input().split()))

odds = []
evens = []
for i in num_lists:
    if i%2 == 0:
        evens.append(i)
    else:
        odds.append(i)

odds_sum = 0
for i in odds:
    odds_sum += i

if odds_sum%2 == 0:
    ans = 'YES'
else:
    ans = 'NO'

print(ans)

Measured memory_bytes: 20108
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n%M) * (f(n - 1) % M);
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N; cin >> N;
	vector<ll> A(N + 1); for (int i = 1; i <= N; i++)cin >> A[i];

	map<ll, ll> sum;
	for (int i = 1; i <= N;i++) {
		sum[i - A[i]]++;
	}

	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += sum[i + A[i]];
	}

	cout << ans << endl;
	//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
}


Measured memory_bytes: 35464
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::string C = "CODEFESTIVAL2016";
	std::cin >> S;
	int result = 0;
	for (int i = 0; i < S.size(); ++i)
		if (S[i] != C[i])
			++result;
	std::cout << result << "\n";
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<iomanip>
#include<cmath>
#define ll long long
using namespace std;
int gcd(int, int);
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);


	int a, b, flag = 0;
	cin >> a >> b;

	for (int i = 0; i <= a; i++)
	{
		if (i * 2 + 4 * (a - i) == b)
		{
			flag = 1;
			break;
		}
	}

	if (flag == 1)
		cout << "Yes";
	else cout << "No";





	return 0;
}
int gcd(int m, int n)
{
	return n == 0 ? m : gcd(n, m % n);
}

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

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

    static class BProductMax {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long[] a = in.nextLongArray(2);
            long[] b = in.nextLongArray(2);
            long max = Long.MIN_VALUE;
            for (int i = 0; i < 2; ++i) {
                for (int j = 0; j < 2; ++j) {
                    max = Math.max(a[i] * b[j], max);
                }
            }
            out.println(max);
        }

    }

    static class FastScanner {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public FastScanner(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream), 32768);
            tokenizer = null;
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

    }
}



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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)


void solve()
{
    int n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
void read(pp& x){ read(x.first); read(x.second); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int R, C, n;

vector<pp> bord;

int ind(pp a){
	int ret=0;
	if(a.x == 0) return ret+a.y;
	ret += C;
	if(a.y == C) return ret+a.x;
	ret += R;
	if(a.x == R) return ret+(C-a.y);
	ret += C;
	if(a.y == 0) return ret+(R-a.x);
	return -1;
}

bool e[100010];

void no(){
	puts("NO");
	exit(0);
}

int main()
{
	read(R, C, n);
	for(int i=1; i<=n; ++i){
		pp p1, p2;
		read(p1, p2);
		int i1=ind(p1), i2=ind(p2);
		if(i1>=0 && i2>=0){
			bord.eb(i1, i);
			bord.eb(i2, i);
		}
	}
	sort(all(bord));
	stack<int> s;
	for(auto tmp:bord){
		int x=tmp.second;
		if(e[x]){
			if(s.empty() || s.top() != x) no();
			s.pop();
			e[x]=0;
		} else {
			e[x]=1;
			s.push(x);
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 2548
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll f[100010];

void calc() {
    f[0] = 1;
    rep(i, 1, 100010) {
        f[i] = f[i - 1] * i;
        f[i] %= mod;
    }
}

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }
    calc();

    
    ll ans = 0;
    
    vector<ll> S(N);
    S[0] = 1;
    rep(i, 1, N) {
        S[i] = S[i - 1] + inv_mod(i + 1, mod);
        S[i] %= mod;
    }
    
    rep(i, N) {
        ll tmp = A[i] * ((S[i] + S[N - i - 1] - 1) % mod);
        ans += tmp;
        ans %= mod;
    }
    ans *= f[N];
    ans %= mod;
    ans += mod;
    ans %= mod;
    output(ans);
    

    
    

    
    
    return 0;
}


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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int a, b, c;

bool read() {
    if (!(cin >> a >> b >> c))
        return false;

    return true;
}

void solve() {
    cout << min({ a + b, a + c, b + c }) << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define RG register
#define gi getint()
#define gc getchar()
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef int it;
#define int long long
IL int getint()
{
    RG int xi=0;
    RG char ch=gc;
    bool f=0;
    while(ch<'0'|ch>'9')ch=='-'?f=1:f,ch=gc;
    while(ch>='0'&ch<='9')xi=(xi<<1)+(xi<<3)+ch-48,ch=gc;
    return f?-xi:xi;
}
IL void pi(int k,char ch=0)
{
    if(k<0)k=-k,putchar('-');
    if(k>=10)pi(k/10,0);
    putchar(k%10+'0');
    if(ch)putchar(ch);
}
IL unsigned int LOG2(unsigned int x)
{
    unsigned int ret;
    __asm__ __volatile__ ("bsrl %1, %%eax":"=a"(ret):"m"(x));
    return ret;
}
inline int gcd(int a,int b){while(a)a^=b^=a^=b%=a;return b;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
string a,b;
bool check()
{
	int aa=lcm(a.size(),b.size())/a.size(),bb=lcm(a.size(),b.size())/b.size();
	int lc=lcm(a.size(),b.size());
	int i=0,j=0;
	for(i=0;i<a.size();i++)
	{
		while(j*bb<i*aa&&j<b.size())j++;
		if(j>=b.size())break;
		if(j*bb==i*aa&&a[i]!=b[j])return false;
	}
	return true;
}
it main(void)
{
	int n=gi,m=gi;
	cin>>a>>b;
	pi(check()?lcm(a.size(),b.size()):-1,'\n');
    return 0;
}

Measured memory_bytes: 512
from operator import itemgetter

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

AB = sorted(AB, key=itemgetter(0), reverse=True)
CD = sorted(CD, key=itemgetter(1))
is_pair = [False for _ in range(N)]

count = 0

for a, b in AB:
    for i, cd in enumerate(CD):
        c, d = cd
        if is_pair[i]:
            continue
        if a < c and b < d:
            is_pair[i] = True
            count += 1
            break

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  
  cout << ((b-a)*(b-a-1))/2 -a << "\n";
  
  //cout << fixed << setprecision(10) << n << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dummy (int)1e8
using namespace std;

struct data {
  int num, lef, righ, par;
};

int t;
string s;
vector<data> v;
vector<int> pre, in, pos;

void insert(int x);
void print();
void rec(int p);
bool find(int x);
void del(int x);

int main() {
  cin >> t;
  v.push_back({dummy, dummy, dummy, dummy});
  while(t--) {
    cin >> s;
    if(s == "print")
      print();
    else if(s == "find") {
      int x;
      cin >> x;
      if(find(x))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    else if(s == "delete") {
      int x;
      cin >> x;
      del(x);
    }
    else {
      int x;
      cin >> x;
      insert(x);
    }
  }
  return 0;
}

void insert(int x) {
  int id = 0;
  while(!v.empty() && v[id].num != dummy) {
    int nownum = v[id].num;
    if(nownum > x) {
      if(v[id].lef == dummy) {
        v[id].lef = v.size();
        v.push_back({dummy, dummy, dummy, id});
      }
      else
        id = v[id].lef;
    }
    else if(nownum < x) {
      if(v[id].righ == dummy) {
        v[id].righ = v.size();
        v.push_back({dummy, dummy, dummy, id});
      }
      else
        id = v[id].righ;
    }
  }
  v[id].num = x;
}

void print() {
  pre.clear();
  in.clear();
  pos.clear();
  rec(0);
  for(int i = 0; i < pos.size(); ++i) cout << " " << in[i];
  cout << endl;
  for(int i = 0; i < pre.size(); ++i) cout << " " << pre[i];
  cout << endl;
}

void rec(int p) {
  pre.push_back(v[p].num);
  if(v[p].lef != dummy) rec(v[p].lef);
  in.push_back(v[p].num);
  if(v[p].righ != dummy) rec(v[p].righ);
  pos.push_back(v[p].num);
}

bool find(int x) {
  int id = 0;
  while(id != dummy && v[id].num != dummy) {
    if(v[id].num == x) return 1;
    if(v[id].num > x)
      id = v[id].lef;
    else if(v[id].num < x)
      id = v[id].righ;
  }
  return 0;
}

void del(int x) {
  int id = 0;
  while(id != dummy && v[id].num != dummy) {
    if(v[id].num == x) {
      int par = v[id].par;
      if(v[id].lef == v[id].righ && v[id].lef == dummy) {
        v[id].num = dummy;
        if(v[par].lef == id)
          v[par].lef = dummy;
        else
          v[par].righ = dummy;
      }
      else if(v[id].lef == dummy) {
        int chil = v[id].righ;
        v[chil].par = par;
        if(v[par].lef == id)
          v[par].lef = chil;
        else
          v[par].righ = chil;
        v[id].num = dummy;
      }
      else if(v[id].righ == dummy) {
        int chil = v[id].lef;
        v[chil].par = par;
        if(v[par].lef == id)
          v[par].lef = chil;
        else
          v[par].righ = chil;
        v[id].num = dummy;
      }
      else {
        int chil = v[id].lef, num;
        num = v[chil].num;
        del(v[chil].num);
        v[id].num = num;
      }
    }
    if(v[id].num > x)
      id = v[id].lef;
    else if(v[id].num < x)
      id = v[id].righ;
  }
  return;
}


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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    map<string, int> S;
    rep(i, N){
        string beet;
        cin >> beet;
        S[beet]++;
    }
    int mx = 0;
    for(auto p: S) mx = max(mx, p.second);
    for(auto p: S){
        if(p.second != mx){
            continue;
        }else{
            cout << p.first << endl;
        }
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 26624
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;

bool Sosuu(int r){
  for(int i = 2;i <= sqrt(r);i++){
    if(r%i == 0)
      return false;
  }
  return true;
}


vector <int> Ehurui;
void Etenesu(int y){
  bool f[y+1] = {0};
  for(int i = 2;i <= sqrt(y);i++ ){
    if(f[i] == false){
      Ehurui.push_back(i);
      f[i] = true;
      for(int j = i;j <= y;j = j+i){
	f[j] = true;
      }
    }
  }
  for(int i = 2;i <= y;i++){
    if(!f[i])
      Ehurui.push_back(i);
  }
}


int main(){
  Etenesu(55555);
  int n;
  cin >> n;

  vector <int> a;
  REP(i,Ehurui.size()){
    ll s = Ehurui[i];
    ll t = s%10;
      if(t == 1)
	a.pb(s);
    
  }
  //cout << a.size();
  REP(i,n){
    cout << a[i] << " " ;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(b<=a){
        cout<<"delicious"<<endl;
    }
    else if(b<=a+x){
        cout<<"safe"<<endl;
    }
    else{
        cout<<"dangerous"<<endl;
    }

    
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<ll> vll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(s, e) for(int i=s; i<e; ++i)
#define pb push_back
#define INF 1000000000

int main(){
	IO
	int n;
	cin >> n;
	ll ans = 0LL;
	for(int i=1; i<=n; ++i){
		if(i%3 && i%5){
			//cout << i << endl;
			ans+=i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n[]={0,1,2,1,3,1,3,1,1,3,1,3,1};
main(){
	int a,b,c;
	cin>>a>>b;
	if(a+b>9)cout<<"error"<<endl;
	else cout<<a+b<<endl;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
if b < c or d < a:
    print(0)
elif d < b:
    if c < a:
        print(d-a)
    else:
        print(d-c)
else:
    if c < a:
        print(b-a)
    else:
        print(b-c)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
int A[MAXN];
long long ans, cnt;

int main() {
	register int i;
	scanf( "%d", &N );
	for( i = 1; i <= N; ++i ) scanf( "%d", A + i ), A[i] ? (cnt += A[i]) : (ans += cnt / 2, cnt = 0); ans += cnt / 2;
	printf( "%lld\n", ans );
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int main() {

    long long int a;
    cin >> a;
    string s;
    cin >> s;

    if ( a >= 3200 ) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;

}


Measured memory_bytes: 256
# include<bits/stdc++.h>
# define ll long long
# define fo(i,n)for(int i=0;i<n;i++)
# define fo1(i,n)for(int i=1;i<=n;i++)
# define pb push_back
# define endl "\n"
# define mod 1000000007ll
# define pi  3.1415926535897932384626
using namespace std;

vector<vector<long long>>adj(100005);
vector<long long >vis(100005,0);

void bfs(int i)
{
  queue<int>q;
  q.push(i);

  if(!vis[i])
  {
    vis[i]=1;
    while(!q.empty())
   {
      int u=q.front();
      q.pop();
     for(auto a:adj[u])
     {
       if(!vis[a])
       {
         vis[a]=1;
         q.push(a);
       }
     }
   }
  }
}
void solve()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int cnt=0;
   for(int i=1;i<=n;i++)
   {
     if(!vis[i])
     {
       cnt++;
       bfs(i);
     }
   }
   cout<<cnt-1;
}
int main()
{
 # ifndef ONLINE_JUDGE
   freopen("input1.txt","r",stdin);
   freopen("output1.txt","w",stdout);
 #endif
    ios::sync_with_stdio(0);
    cin.tie(0);

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


Measured memory_bytes: 10056
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;
#include <algorithm>
#include <stack>
#include <vector>
#include <array>

int search(vector<int> v,int e){
  int hantei=0;
  int val = 0;
  for(int i=0 ;i<v.size(); i++){
    val = v.back();
    v.pop_back();
    if(val==e){
      hantei=1;
      break;
    }
  }
  return hantei;
}

int search2(vector<int> v,int e){
  int hantei=0;
  int val = 0;
  for(int i: v){
    if(i==e){
      hantei=1;
      break;
    }
  }
  return hantei;
}

int main(){

    //stack<int> s;
  int N;
  int Q;
  cin >> N >>Q;
  vector<vector<int> > v(N);
  vector<int> p(N,0);

  for(int i=0;i<N-1;i++){
    int a,b; cin >>a>>b;
    v[a-1].push_back(b-1);
    v[b-1].push_back(a-1);
    //printf("v[%d]=%d\n",a-1,b-1);
    //printf("v[%d]=%d\n",b-1,a-1);
  }
  for(int i=0;i<Q;i++){
    int p_,x;
    cin >>p_>>x;
    p[p_-1]+=x;
  }

  vector <int> sta(N);
  vector <int> root(N,0);
  vector <int> ans(N,0);
  sta.push_back(0);
  int size_ = sta.size();
  int t=0;
  int val = 0;
  int time=0;
  int e = 0;
  ans[0]=p[0];
  while(sta.size()>0){
    time += 1;
    //printf("%dtime\n",time );
    t=sta.back();
    val = ans[t];
    //cout << val<<endl;
    //cout << 2;
    root.push_back(t);
    root[t]=1;
    sta.pop_back();
    //cout << 1;
    for(int e:v[t]){
      e=v[t].back();
      v[t].pop_back();

      if(root[e]==0){
        //printf("push[%d]\n",e+1);
        sta.push_back(e);
        root[e]=1;
        ans[e]=val+p[e];
      }
    }

  }

  for(int i=0;i<N;i++){
    printf("%d\n",ans[i]);
  }



  //初期化 std::vector<型名> 変数名(要素数,値);



  return 0;
}


Measured memory_bytes: 19668
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  ll ans=0;
  vector<ll> p(n);   
  
  rep(i,n){
    cin>>p[i];
  }
  
  rep(i,n){
    if(p[p[i]-1]-1==i) ans++;
  }

  cout << ans/2 << endl;
  
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

constexpr char kBlack = '#';
constexpr char kWhite = '.';

int main() {
  int N; std::cin >> N;
  std::string S; std::cin >> S;

  int white = 0;
  for (char c : S) {
    if (c == kWhite) ++white;
  }

  int min_cnt = white;
  int black = 0;
  for (char c : S) {
    if (c == kWhite) --white;
    else             ++black;

    min_cnt = std::min(white + black, min_cnt);
  }

  std::cout << min_cnt << std::endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;

int main()
{
  string AIDU = "AIDUNYAN";
  sort(AIDU);
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.size(); i++){
    string ss = s.substr(i, 8);
    sort(ss);
    if (AIDU == ss){
      cout << "AIZUNYAN";
      i += 7;
    }
    else cout << s[i];
  }
  cout << endl;

  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n , a, b ,x, ans =0;
	cin >> n >> a >> b;
	ans+= (n/(a+b))*a;
	n %= a+b;
	if(n < a) { 
		ans += n;
	}
	else {
		ans+= a;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = sc.nextInt();
	static int M = sc.nextInt();
	static int[] A = new int[N+1];
	static int[] B = new int[M+1];
	static final int MOD = 1_000_000_007;
	public static void main(String[] args) {
		A[0] = -1;
		B[0] = -1;
		for (int i = 1; i <= N; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 1; i <= M; i++) {
			B[i] = sc.nextInt();
		}
		if (Arrays.stream(A).distinct().count() < A.length || Arrays.stream(B).distinct().count() < B.length) {
			System.out.println(0);
			return;
		}
		Arrays.sort(A);
		Arrays.sort(B);
		long ans = 1;
		int a_placed = 0;
		int b_placed = 0;
		for (int num = N*M; num > 0; num--) {
			if (A[N - a_placed] == num && B[M - b_placed] == num) {
				a_placed++;
				b_placed++;
			} else if (A[N - a_placed] == num) {
				a_placed++;
				ans = mul(ans, b_placed);
			} else if (B[M - b_placed] == num) {
				b_placed++;
				ans = mul(ans, a_placed);
			} else {
				ans = mul(ans, a_placed*b_placed - (N*M-num));
			}
			if (ans == 0) {
				break;
			}
		}
		System.out.println(ans);
	}
	static long mul(long x, long y) {
		return x*y%MOD;
	}
}

Measured memory_bytes: 30980
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=55;
int n,A,a[N],ans,dp[N][N][N*N];
signed main(){
	scanf("%lld%lld",&n,&A);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	dp[0][0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=n;j++)
			for (int k=0;k<=n*50;k++){
				dp[i][j][k]+=dp[i-1][j][k];
				if (j&&k>=a[i])dp[i][j][k]+=dp[i-1][j-1][k-a[i]];
			}
	for (int i=1;i<=n;i++)ans+=dp[n][i][i*A];
	printf("%lld\n",ans);
}

Measured memory_bytes: 66560
import collections
N,K,L = map(int, input().split())
p = []
q = []
for i in range(K):#h:高さ
    pi, qi = map(int, input().split())
    p.append(pi)
    q.append(qi)
r = []
s = []
for i in range(L):#h:高さ
    ri, si = map(int, input().split())
    r.append(ri)
    s.append(si)

class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n + 1)

    # 検索
    # 根ならその番号を返す
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

        # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
        # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

u = UnionFind(N)
for i in range(K):
    u.union(p[i],q[i])


u2 = UnionFind(N)
for i in range(L):
    u2.union(r[i],s[i])

li = [None]*(N)
liw = [None]*(N)
for i in range(N):
    li[i] = (u.find(i + 1), u2.find(i + 1), i + 1)
    liw[i] = (u.find(i + 1), u2.find(i + 1))
#li.sort(key=lambda x:(x[0], x[1]))

liws = collections.Counter(liw)

ansli = [0]*(N+1)
for i in range(N):
    ansli[i + 1] = liws[(li[i][0], li[i][1])]

for i in range(1, N + 1):
    print(ansli[i], "", end="")

Measured memory_bytes: 111000