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

template<typename T>
inline bool make_triangle(T val1, T val2, T val3)
{
   return val1 + val2 > val3 && val1 + val3 > val2 && val2 + val3 > val1;
}

int main()
{
    int n;
	cin >> n;
    int* line = new int[n];
    for (int i = 0; i < n; ++i)
    {
        auto value = 0;
        cin >> value;
        line[i] = value;
    }
    
    auto len = n;
    auto count = 0;
    for (int i = 0; i < len-2; ++i)
    {
        for (int j = i + 1; j < len-1; ++j)
        {
            if (line[i] == line[j]) continue;
            
            for (int k = j + 1; k < len; ++k)
            {
                if (line[i] == line[k] || line[j] == line[k]) continue;
                if (line[i] + line[j] > line[k] && line[i] + line[k] > line[j] && line[j] + line[k] > line[i])
                    count++;
            }
        }
    }
    
    cout << count;
    
    delete[] line;

    return 0;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct node {
    double x,y,z;
}a[25];
int n,m;
vector<int> G;
int cnt(int x)
{
    G.clear();
    int ans=0;
    for(int i=0;i<n;i++) if(x&(1<<i)){
        ans++;
        G.push_back(i);
    }
    return ans;
}
inline double dis(int i,int j)
{
    return (a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z);
}
double solve()
{
    int sz = G.size();
    double ans=0;
    for(int i=0;i<sz;i++) {
        for(int j=i+1;j<sz;j++) {
                ans+=dis(G[i],G[j]);
        }
    }
    //cout<<ans<<endl;
    return ans;
}
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) {
        scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].z);
    }
    int ALL=(1<<n);
    double ans = 0;
    for(int i =0;i<ALL;i++) {
        if(cnt(i)!=m) continue;
        ans=max(ans,solve());
    }
    printf("%.9lf\n",ans);
    return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <string>
#include <stack>
using namespace std;
struct P{
	int num, lev;
};

int n;
string s[30];

int main() {

	while (true) {

		cin >> n;
		if (!n)break;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}

		stack<char> ch;
		stack<P> num;
		for (int i = 0; i <= n; i++) {

			//cout << "i:" << i << endl;
			if (n == i && ch.size() == 0)break;

			if (ch.size() >= s[i].size() || n == i) {//レベルが低かったら
				//cout << "a" << endl;
				int x;

				char ope = ch.top();
				if (ope == '+')x = 0;
				else x = 1;

				while (!num.empty()) {
					P p = num.top();
					if (p.lev < ch.size())break;
					num.pop();

					if (ope == '+') {
						x += p.num;
					}
					else {
						x *= p.num;
					}
				}

				ch.pop();
				num.push(P{ x, (int)ch.size() });
				i--;
				//cout << "  x:" << x << endl;
			}
			else {//同じか高い場合
				//cout << "b" << endl;
				if (s[i][s[i].size() - 1] == '+' || s[i][s[i].size() - 1] == '*') {//演算子の場合
					ch.push(s[i][s[i].size() - 1]);
				}
				else {//数値の場合
					num.push(P{ (int)(s[i][s[i].size() - 1] - '0'), (int)ch.size() });
				}
			}
		}

		cout << num.top().num << endl;
	}
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>

int main()
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int A,B;
  int ans = 0;
  std::cin >> A >> B;
  std::string S;
  for(int i = A;i <= B;i++)
  {
    S = std::to_string(i);
    if ((S[0]==S[4]) and (S[1]==S[3])) ans += 1;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())

if d < c:
    tmp = c
    c = d
    d = tmp

common = lcm(c, d)

div_c = b//c - (a-1)//c
div_d = b//d - (a-1)//d
div_common = b//common - (a-1)//common
print((b - a) + 1 - div_c - div_d + div_common)


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){

    bool flag=false;

    ll ans=0,sum=0;
    
    int n;
    cin >>n;

    vector<int> l(n),g(n),s(n);
    //vector<int> s;

    for (int i = 0; i < n; i++){
        cin >>l[i];
        g[i]=l[i];
        s[i]=l[i];
    }

    sort(all(s));
    sort(all(g),greater<int>());

    for (int i = 0; i < n-2; i++){
        for (int j = i+1; j < n-1; j++){
            int add=0;
            add =(n-j-1) - (upper_bound(all(s),g[i]-g[j]) - s.begin());
            
            if(add < 0)continue;

            ans += add;
            //cout << "g[j]:"<<g[j]<<" "<< add << " ";
        }
        //puts("\n");
    }

    /*for (int i = 0; i < n; i++){
        int add = s.end() - upper_bound(all(s),g[i]);
        ans += add;
    }*/
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 384
/*
 * Codeforces Contest
 * Au: Lost_Deviation
 */
#ifndef open_dbg_func
#define err(args...)
#endif
#include <bits/stdc++.h>
using namespace std;
#define ll long long
static auto XxXOxO = []() {
    std::ios::sync_with_stdio(false); // turn off sync
    cin.tie(nullptr);                 // untie in/out streams
    return 0;
}();
struct T {
    int x, y;
};
int cmp(const T &a, const T &b) {
    if (a.x != b.x)
        return (a.x < b.x);
    else
        return (a.y < b.y);
}
const double esp = 1e-8;
char a[20];
void work(int i, int n, char s) {
    if (i == n + 1) {
        for (int j = 1; j <= n; j++)
            cout << a[j];
        cout << endl;
        return;
    }
    // if (i == 1) {
    //     cout << 'a';
    //     work(i + 1, n, s);
    // }
    for (int j = 0; j < i; j++)
        if ((char) (j + 'a') <= s + 1) {
            a[i] = (char) (j + 'a');
            work(i + 1, n, max((char) (j + 'a'), s));
        }
}
int main(void) {
    int n;
    cin >> n;
    char s = 'a';
    work(1, n, s);
    return 0;
}


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

int main()
{
    long long A, B, K;
    cin >> A >> B >> K;
    if (A < K)
    {
        K -= A;
        A = 0;
        if (B < K)
        {
            B = 0;
        }
        else
        {
            B -= K;
        }
    }
    else
    {
        A -= K;
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    int s[m];
    int c[m];
    rep(i, m) {
        cin >> s[i] >> c[i];

        // 0から始まる
        if (n != 1 && s[i] == 1 && c[i] == 0) {
            cout << "-1" << endl;
            return 0;
        }

        // ある桁に2つ指定がある。
        if (i > 0) {
            rep(j, i) {
                if (s[j] == s[i] && c[j] != c[i]) {
                    cout << "-1" << endl;
                    return 0;
                }
            }
        }
    }

    rep(i, n) {
        int keta = i + 1;

        int found = 0;
        rep(j, m) {
            if (keta == s[j]) {
                cout << c[j];
                found = 1;
                break;
            }
        }

        if (found == 0) {
            if (keta == 1 && n != 1) {
                cout << "1";
            } else {
                cout << "0";
            }
        }
    }

    cout << endl;
}


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

template<class T>
struct line{
	T a,b;
	T get(T x){
		return a*x+b;
	}
};
template<class T>
struct CHT{
	deque<line<T>>que;
	bool check(line<T>a,line<T>b,line<T>c){
		double A[]{a.a,b.a,c.a},B[]{a.b,b.b,c.b};
		return (B[1]-B[2])*(A[1]-A[0])<=(B[0]-B[1])*(A[2]-A[1]);
	}
	void add(line<T>l){
		while(que.size()>1&&check(que[que.size()-2],que.back(),l))que.pop_back();
		que.push_back(l);
	}
	double get(double x){
		if(que.empty())return INFINITY;
		while(que.size()>1&&que[0].get(x)>=que[1].get(x))que.pop_front();
		return que[0].get(x);
	}
};

ll h[300000];
ll a[300000],b[300000];
ll dp[300000];

int main(){
	int n;ll C;cin>>n>>C;
	rep(i,n)scanf("%lld",&h[i]);
	CHT<ll>cht;
	dp[0]=0;
	cht.add({-2*h[0],h[0]*h[0]+C});
	for(int i=1;i<n;i++){
		dp[i]=cht.get(h[i])+h[i]*h[i];
		cht.add({-2*h[i],dp[i]+h[i]*h[i]+C});
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 6400
/*Hey, What's up?*/
 
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
multiset<long long>st;
multiset<long long>::iterator it;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        if(st.size()==0)st.insert(a);
        else{
            it=st.lower_bound(a);
            if(it==st.begin()){
                st.insert(a);
            }
            else{
                it--;
                st.erase(it);
                st.insert(a);
            }
        }
    }
    cout<<st.size();
 
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <stack>
#define sz size()
#define pb push_back
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll exp(ll t,ll x){if(x==0) return 1;if(x==1) return t;if(x%2==1) return (t*exp((t*t)%mod,x/2))%mod;if(x%2==0) return exp((t*t)%mod,x/2);} 
ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){return u<b?u:bsum(u/b,b)+u%b;}
ll prival(ll u,ll p){int cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
bool isprime(ll x){for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
void YAY(void){cout<<"YES"<<endl;}
void NAY(void){cout<<"NO"<<endl;}
ll cur;
int n;
ll a[111111];
ll b[111111];

ll val(ll U, ll V)
{
	ll x=U%V;
	if(x==0)
	{
		return 0;
	}
	else
	{
		return V-x;
	}
}
int main(void)
{
	int i, j;
	cin>>n;
	for(i=1 ; i<=n ; i++)
	{
		scanf("%lld %lld",&a[i],&b[i]);
	}
	for(i=n ; i>=1 ; i--)
	{
		cur+=val(a[i]+cur,b[i]);	
	}	
	cout<<cur<<endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, A;
    cin >> X >> A;
    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    map <int,int> mp;
    map <int,bool> done;

    int n , m , k;
    cin >> n >> m;
    string s;
    int ans = 0 , ac = 0;
    while (m--){
        cin >> k >> s;
        if (done[k])
            continue;
        if (s == "WA")
            mp[k]++;
        else {
            ans += mp[k];
            ++ac;
            done[k] = true;
        }
    }

    cout << ac << ' ' << ans;
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 12948
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

sys.setrecursionlimit(1000000)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline().rstrip())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N, M = LI()
    A = LI()
    s = sum(A)

    print("Yes" if len(list(filter(lambda x: 4 * M * x >= s, A))) >= M else "No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 77152
#include <iostream>
#include<math.h>
#include<algorithm>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long

#define MAX 600000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
	int n1=mid-left;
	int n2=right-mid;
	//?????????????????????LR?????\??????
	REP(i, n1)L[i] = A[left + i];
	REP(i, n2)R[i] = A[mid + i];
	L[n1]=R[n2]=SENTINEL;
	int i=0,j=0;
	
	//??????????????????????°?????????????A???????????¶????????????
	FOR(k, left, right) {
		cnt++;
		L[i] <= R[j] ? A[k] = L[i++] : A[k] = R[j++];
	}
}

void mergeSort(int A[], int n, int left, int right) {
	//????´???°???1??????????????§???????????????????????°
	if (left + 1 < right) {
		int mid=(left+right)/2;
		//?????°???????????????????????????????????????
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		//??????????????????2?????????????????????
		merge(A,n,left,mid,right);
	}
}

int main() {
	int A[MAX],n,i;
	cnt=0;
	
	cin>>n;
	REP(i,n)cin>>A[i];
	mergeSort(A,n,0,n);
	REP(i, n) {
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout<<endl<<cnt<<endl;
	
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    vector<int> data(6);
    for (int i = 0; i < 6; i++) {
        cin >> data[i];
    }
    
    if (data[4] - data[0] > data[5]) {
        std::cout << ":(" << std::endl;
    } else {
        std::cout << "Yay!" << std::endl;
    }

    return 0;
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=1e5+50;
int n,m,s[N];
int main() {
	n=rd(), m=rd();
	for(int i=1;i<=m;i++) {
		int x=rd(), y=rd();
		if(x>y) swap(x,y);
		++s[x]; --s[y];
	}
	for(int i=1;i<=n;i++) if((s[i]+=s[i-1])&1) return puts("NO"),0;
	puts("YES");
}

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

int main() {
	int n, m, p, ac[1000000] = { 0 }, ac_num = 0, wa_num = 0, wa[1000000] = { 0 };
	string s;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> p >> s;
		if (ac[p - 1] == 0) {
			if (s == "AC") {
				ac_num++;
				ac[p - 1] = 1;
				wa_num += wa[p - 1];
			}
			else {
				wa[p - 1]++;
			}
		}
	}
	
	cout << ac_num << " " << wa_num << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;
//const int MOD=1e9+7;

int main(){
	int N,A,B;
	cin>>N>>A>>B;
	int num[3]={};
	rep(i,N){
		int P;
		cin>>P;
		if(P<=A)num[0]++;
		else if(P<=B)num[1]++;
		else num[2]++;
	}
	int ans=min(num[0],num[1]);
	ans=min(ans,num[2]);
	cout<<ans;
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1e9+7
#define FOR(a,c)   for ( int (a)=0; (a)<(c); (a)++)
#define FORL(a,b,c)  for ( int (a)=(b); (a)<=(c); (a)++)
#define FORR(a,b,c)  for (  int (a)=(b); (a)>=(c); (a)--)
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define POB pop_back
#define MP make_pair

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

ll N;
cin>>N;
string s;
set<string>st;
FOR(i,N)
{
    cin>>s;
    st.insert(s);
}
cout<<st.size();


}

Measured memory_bytes: 19244
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    ll w, h, x, y; cin >> w >> h >> x >> y;
    printf("%lf %d\n", double(w)*double(h) / 2, x + x == w&& y + y == h);
}


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

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

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

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

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	ll n,m;
	cin >> n >> m;

	ll ans=0LL;

	{
		ll cnt=min(n,m/2);
		m-=2LL*cnt;
		ans+=cnt;
	}

	ans+=m/4LL;

	cout << ans << endl;

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int A =0;
  
  for(int i=0;i < 3;i++){
    if(s[i] == '7'){
      A++;
    }
  }
  
  if(A >0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 3604
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        int n;
        String s;
        int[] maxV=new int[101];
        int max=0;
        int count=0;
        Scanner sc = new Scanner(System.in);


        n = sc.nextInt();


        s = sc.next();


        String[] abc={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        if(2<=n&n<=100){
           for (int index = 1; index < s.length(); index ++) {
             count=0;
          String x = s.substring(0,index);
          String y = s.substring(index);
            for(int roop =0; roop<=25; roop ++){
              if(x.contains(abc[roop])&y.contains(abc[roop])){
                count++;
              }

            }
            maxV[index]=count;
             max = Math.max(max,maxV[index]);
        }


        System.out.println(max);

        }


    }
}

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

class dice {
    public:
        int top, front, right, left, back, bottom;
        dice(int a, int b, int c, int d, int e, int f) {
            top = a; front = b;
            right = c; left = d;
            back = e; bottom = f;
        }
        int tp() {
            return top;
        }
        void E() {
            int tmp = top;
            top = left;
            left = bottom;
            bottom = right;
            right = tmp;
        }
        void N() {
            int tmp = top;
            top = front;
            front = bottom;
            bottom = back;
            back = tmp;
        }
        void S() {
            int tmp = top;
            top = back;
            back = bottom;
            bottom = front;
            front = tmp;
        }
        void W() {
            int tmp = top;
            top = right;
            right = bottom;
            bottom = left;
            left = tmp;
        }
};

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    dice di(a, b, c, d, e, f);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (di.right == y || di.left == y)
            di.E();
        while (di.front != y)
            di.N();
        while (di.top != x)
            di.E();
        cout << di.right << '\n';
    }
    return 0;
}


Measured memory_bytes: 3052
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans = 0;
        for (int i = 1; i <= N; i++) {
            if (i%3 == 0 && i%5 == 0) {
                // 
            } else if (i%3 == 0) {
                //
            } else if (i%5 == 0) {
                //
            } else {
                ans += i;
            }
        }

        System.out.println(ans);
    }
}


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

int main(){
    
    string s,p;
    cin >> s >> p;
    s=s+s;
    if (s.find(p)!=-1) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
    return 0;
}




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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;cin>>s;
  int n=s.size();
  bool ok=true;
  int i;
  if(n%2!=0)cout<<"No"<<endl;
 else{
  for(i=0;i<n;i+=2)
  {
    if(s[i]!='h'||s[i+1]!='i')ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  string a;
  int sum = 0;
  cin >> a;
  int b = a.size();
  for(int i = 0;i<b;i++){
    for(int j = 0;j<b;j++){
      if(a.at(i)==a.at(j))sum++;
    }
    if(sum%2==1){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;
    int p[8], q[8];
    rep(i, n){
        cin >> p[i];
    }
    rep(i, n){
        cin >> q[i];
    }
    
    vector<int> v;
    rep(i, n){
        v.push_back(i+1);
    }
    int s = 1;
    int a = 0, b = 0;
    do {
        s++;
        bool ok_p = true;
        bool ok_q = true;
        rep(i, n){
            if(v[i] != p[i]){
                ok_p = false;
            }
            if(v[i] != q[i]){
                ok_q = false;
            }
        }
        if(ok_p){
            a = s;
        }
        if(ok_q){
            b = s;
        }
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;

    return 0;
}

Measured memory_bytes: 256
import math
a,b,C=map(int,input().split())
t=math.radians(C)
S=a*b*math.sin(t)/2
c=math.sqrt(a*a+b*b-2*a*b*math.cos(t))
L=a+b+c
h=2*S/a
print(f'{S:.8f}')
print(f'{L:.8f}')
print(f'{h:.8f}')


Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n;
	cin >> n;
	int a[2][n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[0][i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> a[1][i];
	}
	int max = 0;
	for (int i = 0; i < n; ++i)
	{
		int tmp = 0;
		for (int j = 0; j <= i; ++j)
		{
			tmp += a[0][j];
		}
		for (int j = i; j < n; ++j)
		{
			tmp+=a[1][j];
		}
		max = std::max(max,tmp);
	}
	cout << max << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let mut hash: HashMap<String, i32> = HashMap::new();
    for _ in 0..n {
        let s: String = read();
        if !hash.contains_key(&s) {
            hash.insert(s, 1);
        } else {
            let new_v = hash.get(&s).unwrap() + 1;
            hash.insert(s, new_v);
        }
    }
    let mut max = 0;
    for (_, v) in hash.iter() {
        if max < *v {
            max = *v;
        }
    }
    let mut words = vec![];
    for (k, v) in hash.iter() {
        if *v == max {
            words.push(k.clone());
        }
    }
    words.sort();
    for word in words.iter() {
        println!("{}", word);
    }
}


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

const int MAX_N = 1e5 + 10;

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

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

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	a -= b;
	c -= a;
	if (c < 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << c << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;



int partition(int *a, int p, int r){

  int x = a[r];
  int i = p-1;

  for(int j=p;j<r;j++){
    if(a[j] <= x){
      i = i+1;
      swap(a[i],a[j]);
    }

  }
  swap(a[i+1], a[r]);

  return i+1;
}

int main(){


  
  int n;
  cin >> n;
  int *a = new int[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  int ai = partition(a, 0, n-1);
  // cout << ai <<endl;
  
  for(int i=0;i<n;i++){
    if(i!=0)cout<<" ";
    if(i==ai){
      cout << "[";
    }
    cout << a[i];
    if(i==ai){
      cout<< "]";
    }
  }
  cout << endl;
  
  
}

Measured memory_bytes: 1572
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S, R;

    REP(i, H) {
        string si;
        cin >> si;
        S.push_back(si);
    }

    REP(i, H) {
        R.push_back(S[i]);
        REP(j, W) {
            int count = 0;
            if (S[i][j] == '.') {
                for (int h = i - 1; h <= i + 1; h++) {
                    for (int w = j - 1; w <= j + 1; w++) {
                        if (h >= 0 && h < H && w >= 0 && w < W && S[h][w] == '#')
                            count++;
                    }
                }
                R[i][j] = '0' + count;
            }
        }
    }

    REP(i, H)
        cout << R[i] << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
H,W=map(int, input().split())
A="".join(input() for _ in range(H))
C=Counter(A)
R=[0]*5
for v in C.values():
    R[4]+=v//4
    v-=v//4*4
    R[2]+=v//2
    v-=v//2*2
    R[1]+=v
R[4]-=(H//2)*(W//2)
x2=(H&1)*(W//2)+(W&1)*(H//2)
if R[4]>=0:
    R[2]+=R[4]*2
    R[4]=0
R[2]-=x2
b=R[4]==0 and R[2]==0 and R[1]==(H&1 and W&1)
print("YNeos"[not b::2])

Measured memory_bytes: 3316
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    d = defaultdict(lambda : 0)
    ans = 0
    for i,ai in enumerate(a):
        ans += d[-ai+i]
        d[ai+i] += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 130220
h,w=[int(i)for i in input().split()]
n=int(input())
a=[int(i)for i in input().split()]
arr=[]

count=0
for i in a:
    count+=1
    for j in range(i):
        arr.append(count)
        
for y in range(h):
    for x in range(w):
        if y%2==0:print(arr[y*w+x],end=" ")
        else:print(arr[(y+1)*w-1-x],end=" ")
    print("")

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(200010);


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    mint ans = 0;
    rep(j,61){
        ll cnt = 0;
        rep(i,N){
            if((A[i] >> j) & 1LL){
                cnt++;
            }
        }
        ans += mint(cnt*(N-cnt))*mint((1LL << j));
    }
    cout << ans << endl;
}


Measured memory_bytes: 8748
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll;
#define N 400102
const int p=1e9+7;
struct edge{int to,nxxt;}e[N];
int head[N],cnt=1,n,g[N],dp[5002][5002][2],siz[N],t[5002][2];
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void dfs(int te,int la)
{dp[te][1][0]=1;siz[te]=1;
    for(int i=head[te];i;i=e[i].nxxt)
    {
        int j=e[i].to;if(j==la)continue;dfs(j,te);
        for(int ii=0;ii<=siz[te]+siz[j];ii++)t[ii][0]=t[ii][1]=0;
        for(int ii=0;ii<=siz[te];ii++)for(int jj=0;jj<=siz[j];jj++)
        {
            t[ii][0]=(t[ii][0]+1ll*dp[te][ii][0]*dp[j][jj][1]%p*g[jj]%p)%p;
            t[ii][0]=(t[ii][0]+1ll*dp[te][ii][1]*dp[j][jj][0]%p*g[jj]%p)%p;
            t[ii][1]=(t[ii][1]+1ll*dp[te][ii][0]*dp[j][jj][0]%p*g[jj]%p)%p;
            t[ii][1]=(t[ii][1]+1ll*dp[te][ii][1]*dp[j][jj][1]%p*g[jj]%p)%p;
            t[ii+jj][0]=(1ll*t[ii+jj][0]+1ll*dp[te][ii][0]*dp[j][jj][0]%p+
            1ll*dp[te][ii][1]*dp[j][jj][1]%p)%p;
            t[ii+jj][1]=(1ll*t[ii+jj][1]+1ll*dp[te][ii][0]*dp[j][jj][1]%p+
            1ll*dp[te][ii][1]*dp[j][jj][0]%p)%p;
        }
        for(int ii=0;ii<=siz[te]+siz[j];ii++)dp[te][ii][0]=t[ii][0],dp[te][ii][1]=t[ii][1];
        siz[te]+=siz[j];
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        ins(x,y),ins(y,x);
    }
    g[2]=1;for(int i=4;i<=n;i+=2)g[i]=1ll*g[i-2]*(i-1)%p;
    dfs(1,1);int ans=0;
    for(int ii=2;ii<=n;ii+=2)ans=(ans+1ll*(dp[1][ii][0]-dp[1][ii][1]+p)*g[ii]%p)%p;
    printf("%d\n",ans);
}


Measured memory_bytes: 92576
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int a[100],m,n;
  int sm;
  string s[100],t[1000];
  while(cin>>n>>m&&n+m){
    for(i=0;i<n;i++)
      cin>>s[i]>>a[i];
    for(i=0;i<m;i++)
      cin>>t[i];
    sm=0;
    for(j=0;j<m;j++){
      for(i=0;i<n;i++){
	for(k=0;k<8;k++){
	  if(s[i][k]!='*'&&s[i][k]!=t[j][k])
	    break;
	}
	if(k==8){
	  sm+=a[i];
	  break;
	}
      }
    }
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 960
public class Main {
 public static void main(String...args) {
  final java.util.Scanner sc = new java.util.Scanner(System.in);
   final int num = sc.nextInt();
   String ans = "Christmas";
   for(int i=0;i<25-num;i++){
     ans+=" Eve";
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 19796
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        long[] arrAll = new long[1000000];
        arrAll = arrAll.Select(v => v = 0).ToArray();
        long n = long.Parse(Console.ReadLine());
        long[] arr = Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        var list = new List<long>();
        long sum = arr.Sum();
        foreach (long ele in arr) arrAll[ele]++;
        long q = long.Parse(Console.ReadLine());
        for(long i = 1; i <= q; i++)
        {
            long[] qArr = Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
            long b = qArr[0];
            long c = qArr[1];
            long count = arrAll[b];
            sum = sum - count * b + count * c;
            arrAll[b] = 0;
            arrAll[c] = arrAll[c] + count;
            list.Add(sum);
        }
        foreach (long ele in list) Console.WriteLine(ele);



    }

    

}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    cout<<a*b-d*a-c*b+c*d<<endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,K;
int P[5050];
long C[5050];
bool vis[5050];
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		cin>>P[i];
		P[i]--;
	}
	for(int i=0;i<N;i++)cin>>C[i];
	long ans=-9e18;
	for(int i=0;i<N;i++)if(!vis[i])
	{
		vector<long>Cs;
		int now=i;
		long all=0;
		do{
			Cs.push_back(C[now]);
			all+=C[now];
			vis[now]=true;
			now=P[now];
		}while(now!=i);
		vector<long>cumsum(Cs.size()*3+1);
		for(int j=0;j<3*Cs.size();j++)
		{
			cumsum[j+1]=cumsum[j]+Cs[j%Cs.size()];
		}
		for(int j=0;j<2;j++)
		{
			long t=0;
			int rest=K;
			bool iz=false;
			if(j==0)
			{
				if(rest>2*Cs.size())rest=2*Cs.size();
			}
			else
			{
				int l=K/Cs.size();
				if(l<=1)
				{
					continue;
				}
				t=(l-1)*all;
				rest=K%Cs.size()+Cs.size();
				iz=true;
			}
			priority_queue<pair<long,int> >P;
			for(int i=0;i<rest;i++)P.push(make_pair(-cumsum[i],i));
			for(int i=rest;i<cumsum.size();i++)
			{
				if(iz)
				{
					P.push(make_pair(-cumsum[i],i));
				}
				if(!P.empty())ans=max(ans,t+cumsum[i]+P.top().first);
				while(!P.empty()&&P.top().second+rest<=i)P.pop();
				if(!iz)
				{
					P.push(make_pair(-cumsum[i],i));
				}
			}
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  int N;
  cin >> N;
  map<int, int> count;
  for(int i=0;i<N;i++) {
    int a;
    cin >> a;
    count[a]++;
  }

  int total = 0;

  for(auto it=count.begin();it!=count.end();it++) {
    if(it->second == 0) continue;
    if(it->first < it->second) total += it->second - it->first;
    else if(it->first > it->second) total += it->second;
  }

  cout << total << endl;
}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

int solve(){
    int n;
    cin >> n;
    if(n==0) return 1;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int i=0;i<n;i++){
        int m = s[i].size();
        for(int j=0;j<m-1;j++){
            if(s[i][j] != '.') break;
            if(isalpha(s[i][j+1])){
                s[i][j] = '+';
                break;
            }
            else s[i][j] = ' '; 
        }
    }
    for(int i=0;i<n;i++){
        int j = 0;
        while(s[i][j] == ' ' || s[i][j] == '|') j++;
        if(s[i][j] != '+') continue;
        int ni = i+1;
        while(ni<n && j<s[ni].size() && isblank(s[ni][j])) ni++;
        if(ni<n && j<s[ni].size() && s[ni][j] == '+'){
            for(int k=i+1;k<ni;k++){
                s[k][j] = '|';
            }
        }   
    }
    for(int i=0;i<n;i++){
        cout << s[i] << endl;
    }
    return 0;
}

int main(){
    while(solve()==0);
    // solve();
    return 0;
}



Measured memory_bytes: 3744
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
map<ll, ll>mp;

ll fact(ll m, ll n){
    if(n == 0){
        return 1LL;
    }else if(n==1LL){
        return m;
    }
    ll next_n = floor(sqrt(n));
    ll now;

    if(mp[next_n]==0LL){
        now = fact(m, next_n);
        mp[next_n] = now;
    }else{
        now = mp[next_n];
    }

    ll rest;
    if(mp[n-next_n*2]==0LL) {
        rest = fact(m, n-next_n*2);
        mp[n-next_n*2] = rest;
    }else{
        rest = mp[n-next_n*2];
    }
    return ((now*now)%MOD)*rest%MOD;
}


int main() {
    ll n, m; cin >> m >> n;
    cout << fact(m, n) << endl;
    return 0;
}


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

int main()
{
    int N;

    cin >> N;

    vector<string> list(N);

    for(int i = 0; i < N; i++)
    {
        cin >> list.at(i);
    }

    for(int i = 0; i < N; i++)
    {
        sort(list.at(i).begin(), list.at(i).end());
    }

    map<string,int> str_map;

    for(int i = 0; i < N; i++)
    {
        str_map[list.at(i)]++;      
    }

    long long total = 0;

    for(auto p : str_map)
    {
        int sum = p.second;
        total += (long long)sum*(sum-1)/2;
    }

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 18176
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  lint k; cin >> k;
  lint ans = 0;


  // 全文字一緒の場合
  bool allSame = true;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] != s[i - 1]) allSame = false;
  }

  if (allSame) {
    cout << s.size() * k / 2 << endl;
    return 0;
  }

  lint cnt = 0;
  char cur = '*';
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == cur) cnt++;
    else {
      ans += cnt / 2;
      cur = s[i];
      cnt = 1;
    }
  }
  ans += cnt / 2;
  cerr << ans << endl;
  ans *= k;

  if (s[0] == s[s.size() - 1]) {
    char c = s[0];
    lint a = 0;
    lint b = 0;
    for (int i = 0; s[i] == c; i++) {
      a++;
    }
    for (int i = s.size() - 1; s[i] == c; i--) {
      b++;
    }
    
    cerr << ans << " " << a << " " << b << endl;
    ans -= (a / 2 + b / 2 - (a + b) / 2) * (k - 1);
  }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b, x;

int main()
{
    cin >> a >> b >> x;
    if(a <= x && x <= a + b) puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 256