akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
#define pii pair<lli,lli>
#define vi vector <lli>
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    lli x;
    lli ans=0;
    rep(i,n){
    	cin>>x;
    	if((i+1)%2!=0 && x%2!=0)
    	ans++;
	}
	cout<<ans;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int n = 0;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {
      n++;
    }
  }
  if (n > 0) {
    cout << "Bad" << endl;
  }
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	float n, a[1100], s = 0;
	int ans;
	float b,d = INF,e;
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		s += a[i];
	}
	b = s / n;
	REP(i, n) {
		if (a[i] > b) e = a[i] - b;
		else e = b - a[i];
		if (e < d) {
			d = e;
			ans = i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int r, x, y;
  scanf("%d%d",&x,&y);

  if(x > y) {
    r = x%y;
    while(r != 0) {
      x = y;
      y = r;
      r = x%y;
    }
    printf("%d\n", y);
  }

  else {
    r = y%x;
    while(r != 0) {
      y = x;
      x = r;
      r = y%x;
    }
     printf("%d\n",x);
  }
  
  return 0;
}

Measured memory_bytes: 592
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(a[K-1])


Measured memory_bytes: 2940
n, m = map(int, input().split())
ac = 0
wa = 0

ac_tf = [0] * n
wa_num = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac_tf[p] == 0:
            ac += 1
            wa += wa_num[p]
            ac_tf[p] = 1
    else:
        wa_num[p] += 1
            
print(ac, wa)


Measured memory_bytes: 4596
import Control.Monad
import qualified Data.Vector.Unboxed as UV

main=do
    [n,m]<-map read.words<$>getLine::IO[Int]
    as<-replicateM n $ tail.map read.words<$>getLine::IO[[Int]]
    print $ f n m as

f::Int->Int->[[Int]]->Int
f n m as = UV.length $ UV.filter (==n) $ sv m as
    where
        sv m = foldl ac (UV.replicate m 0)
        ac sv a0 = UV.accum (+) sv $ map (\a->(a-1,1)) a0


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

int calc(int n, int x) {
    return n * (100 + x) / 100;
}

int main() {
    int x, y ,s;
    while (cin >> x >> y >> s, x) {
	int ans =0;
	for (int a = 1; a <= s; a++) {
	    for (int b = 1; b <= s; b++) {
		if (calc(a, x) + calc(b, x) != s) continue;
		ans = max(ans, calc(a, y) + calc(b, y));
	    }
	}
	cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3072
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] B=new int[N-1];
		for(int i=0; i<N-1; i++) {
			B[i]=sc.nextInt();
		}
		long ans=B[0]+B[N-2];
		for(int i=0; i<N-2; i++) {
			ans+=Math.min(B[i], B[i+1]);
		}
		p(ans);
	}
	public static void p(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 21972
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

tmp = []
tmp.append(-1)
for i, x in enumerate(S):
	if x != "A" and x != "T" and x != "G" and x != "C":
		tmp.append(i)
tmp.append(len(S))
# print(tmp)
tmp2 = [tmp[i+1]-tmp[i] for i in range(len(tmp)-1)]
print(max(tmp2)-1)

Measured memory_bytes: 3896
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> A(N);
    for(int i = 1; i < N; ++i) A[i].se = i;
    for(int i = 0; i < N; ++i) cin >> A[i].fi;
    sort(all(A));
    for(int i = 0; i < N; ++i){
        if(i == N - 1){
            cout << A[i].se + 1 << endl;
            break;
        }
        cout << A[i].se + 1 << ' ';
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int cnt[26]={0};
	for(int i=0;i<s.size();i++){
		cnt[(s[i]-'A')]++;
	}
	sort(cnt,cnt+26);
	reverse(cnt,cnt+26);
	if(cnt[0]==cnt[1]&&cnt[0]==2){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int ans = 0, hozon;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            hozon = 0;
            if(i != j){
                hozon = abs(v[i] - v[j]);
                ans = max(ans, hozon);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<=(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

template<class T> inline bool chmax(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;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class DXXOR {
public:
    int N;
    ll K;
    ll A[ten(5)+1];
    int bit[41];
    int bit_K[41]{0};

    void solve(std::istream& in, std::ostream& out) {
        in >> N >> K;
        REP(i, N) in >> A[i];
        M0(bit);

        // O(1e6)
        ll mask = 0;
        int keta = -1;
        do {
            keta++;
            mask = 1ll << keta;
            REP(i, N) bit[keta] += ((A[i] & mask) > 0); // any better way?

            if (bit[keta] >= (N+1)/2) bit_K[keta] = 0;
            else bit_K[keta] = 1;
        } while (mask <= K);

        // herasu
        ll argmax = 0;
        for (int k = keta; k >= 0; k--) {
            if (bit_K[k] == 0) continue;
            else {
                ll tmp = argmax + (1ll << k);
                if (tmp <= K) argmax = tmp;
                else continue;
            }
        }

        OUT(f(argmax));
    }

    ll f(ll xi) {
        ll ans = 0;
        REP(i, N) {
            ans += A[i] ^ xi;
        }
        return ans;
    }
};

int main() {
    DXXOR solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

long long Calc(string S, int st, int ed) {
	int renzoku = 0;
	long long ans = 0;
	for (auto itr = S.begin() + st; itr != S.end() - ed - 1; itr++) {
		if (*itr == *(itr + 1)) renzoku++;
		else {
			ans += (renzoku + 1) / 2;
			renzoku = 0;
		}
	}
	ans += (renzoku + 1) / 2;
	return ans;
}

int main() {
	string S;
	int K;
	cin >> S >> K;
	long long ans = 0;
	if (S.front() != S.back()) cout << Calc(S, 0, 0) * K << endl;
	else {
		long long lrenzoku = 0, rrenzoku = 0;
		auto itr = S.begin();
		while (itr != S.end() && *itr == *S.begin()) {
			lrenzoku++;
			itr++;
		}
		itr = S.end() - 1;
		while (itr != S.begin() && *itr == *(S.end() - 1)) {
			rrenzoku++;
			itr--;
		}
		if (lrenzoku + rrenzoku < S.length()) {
			ans = lrenzoku / 2 + (lrenzoku + rrenzoku) / 2 * ((long long)K - 1) + rrenzoku / 2;
			cout << ans + Calc(S, lrenzoku, rrenzoku) * K << endl;
		}
		else cout << S.length() * K / 2 << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count1 = -1;
		int count2 = 0;
		while (n > 0) {
		    count2 += n % 2;
		    n >>= 1;
		    count1++;
		}
		System.out.println(Math.max(count1, count2));
	}
}



Measured memory_bytes: 26316
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using std::cerr;using std::max;using std::min;
#define N 705
#define ll long long
#define db double
#define dbg1(x) cerr<<#x<<"="<<x<<" "
#define dbg2(x) cerr<<#x<<"="<<x<<"\n"
int n,m,a,b,e[N][N],vis[N],mark[N],cnt0,cnt1,f[N],g[N],flag,ans=1e9;
void dfs(int x,int v)
{
	if(vis[x]) return;
	vis[x]=1,mark[x]=v;
	if(mark[x]) cnt1++;
	else cnt0++;
	for(int i=1;i<=n;i++)
		if(e[x][i])
		{
			if(vis[i]&&mark[i]==v) flag=1; 
			dfs(i,v^1);
		}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) if(i^j) e[i][j]=1;
	for(int i=1;i<=m;i++)
		scanf("%d%d",&a,&b),e[a][b]=e[b][a]=0;
	f[0]=1;
//	for(int i=1;i<=n;i++)
//		for(int j=i+1;j<=n;j++) if(e[i][j]) dbg1(i),dbg2(j);
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			cnt0=cnt1=0,dfs(i,0);
			if(flag) return puts("-1"),0;
//			dbg1(cnt0),dbg2(cnt1);
			for(int j=0;j<=n;j++) g[j]=f[j],f[j]=0;
			for(int j=0;j<=n;j++)
			{
				if(j>=cnt0&&g[j-cnt0]) f[j]=1;
				if(j>=cnt1&&g[j-cnt1]) f[j]=1;
			}
		}
	for(int i=1;i<=n;i++) if(f[i]) ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
	printf("%d\n",ans);
	return 0;
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n,m; cin >> n >> m;
    int g[n];
    rep(i,n) g[i] = 0;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        g[a-1]++;
        g[b-1]++;
    }
    bool ans = true;
    rep(i,n){
        if(g[i] % 2) ans = false;
    }
    if(ans){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

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

int main ()
{
/*int x,y;
cin>>x>>y;
if(y>x*4||y%2!=0)
    cout<<"No\n";
else
    cout<<"Yes\n";
    */
    int x,n;
cin>>x>>n;
int a[n];
unordered_map<int,int> m;
for(int i=0;i<n;i++)
{
    cin>>a[i];
    m[a[i]]=1;
}
int res=INT_MAX,ans;
for(int i=-101;i<=101;i++)
{
    if(!m[i])
    {
       if(res>abs(x-i))
       {
           ans=i;
           res=abs(x-i);
       }
    }
}
cout<<ans<<endl;
}


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

#define fi first
#define se second

const int N = 100100;

using namespace std;

int n;
bool used[N];
map < long long, int > d;
map < long long, long long > B;

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        int K = 3000;
        vector < int > p;
        for(int i = 2; i < K; i++){
                if(used[i]) continue;
                p.push_back(i);
                for(int j = i * i; j < K; j += i) used[j] = true;
        }

        cin >> n;
        int shit = 0;
        long long inf = 1e6;
        for(int i = 1; i <= n; i++){
                long long x;
                cin >> x;
                long long mask = 1, bad_mask = 1;
                for(auto y: p){
                        int cnt = 0;
                        while(x % y == 0){
                                x /= y;
                                cnt += 1;
                        }
                        cnt %= 3;
                        if(cnt == 0) continue;

                        if(cnt == 1){
                                mask *= y;
                                bad_mask *= y * y;
                        } else{
                                mask *= y * y;
                                bad_mask *= y;
                        }
                }
                if(x > 1){
                        long long y = sqrt(x);
                        while(y * y > x) y--;
                        while(y * y < x) y++;

                        if(y * y == x){
                                mask *= x;
                                bad_mask *= y;
                        } else{
                                mask *= x;

                                if(x <= inf){
                                        bad_mask *= x * x;
                                } else{
                                        bad_mask = 0;
                                }
                        }
                }

                if(mask == 1){
                        shit = 1;
                        continue;
                }
                d[mask] += 1;
                B[mask] = bad_mask;
        }
        int res = 0;
        for(auto p: d){
                res += max(d[B[p.fi]], p.se);
                d[p.fi] = d[B[p.fi]] = 0;
        }

        cout << res + shit << "\n";
}


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

using ll = long long;
#define mod 1000000007

struct DisjointSet
{
	ll n;
	vector<ll> parent;
	vector<ll> rank;
	DisjointSet(ll num)
	{
		n=num;
		for(ll i=0;i<n;i++)
		{
			parent.push_back(i);
			rank.push_back(1);
		}
	}
	ll find(ll x)
	{
		if(parent[x]==x)	return x;
		parent[x]=find(parent[x]);
		return parent[x];
	}
	void unionSet(ll a,ll b)
	{
		ll parent_a=find(a);
		ll parent_b=find(b);
		if(parent_a==parent_b)	return;
		if(rank[parent_a]>rank[parent_b])
		{
			parent[parent_b]=parent_a;
		}
		else if(rank[parent_a]<rank[parent_b])
		{
			parent[parent_a]=parent_b;
		}
		else
		{
			parent[parent_a]=parent_b;
			rank[parent_b]++;
		}
	}
};
int main() 
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll n,q;
    cin>>n>>q;
    DisjointSet s(n);
    while(q--)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	if(a==0)
    	{
    		s.unionSet(b,c);
    	}
    	else
    	{
    		if(s.find(b)==s.find(c))
    		{
    			cout<<1<<endl;
    		}
    		else
    		{
    			cout<<0<<endl;
    		}
    	}
    }
	return 0;
}

Measured memory_bytes: 6404
import sys
sys.setrecursionlimit(10**6)

a2e = [int(input()) for _ in range(5)]
k = int(input())

for i in a2e:
    for j in a2e:
        if abs(i-j) > k:
            print(':(')
            break
    else:
        continue
    break
else:
    print('Yay!')

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {

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

		String[] data = input.split("\\s");

		int a = Integer.parseInt(data[0]);
		int b = Integer.parseInt(data[1]);
		int c = Integer.parseInt(data[2]);
		if( a==(b+c) || b==(a+c) || c==(b+a)){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 9680
#include <stdio.h>
int main(void) {
    int num,quorum,m,i,j,temp;
    while (1) {
        scanf("%d %d",&num,&quorum);
        if (num==0&&quorum==0) break;
        int date[50][101]={{0}},last=0,max=0,day=0;
        for (i=0; i<num; i++) {
            scanf("%d",&m);
            for (j=0; j<m; j++) {
                scanf("%d",&temp);
                date[i][temp]++;
                if (temp>last) last=temp;
            }
        }
        for (i=1; i<=last; i++) {
            temp=0;
            for (j=0; j<num; j++) if (date[j][i]==1) temp++;
            if (temp>=quorum&&temp>max) {
                max=temp;
                day=i;
            }
        }
        printf("%d\n",day);
    }
    return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
char s[maxn];
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>s+1;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(s[i]!=s[i-1]) cnt++;
	}
	cout<<cnt;
	return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll A,B,N;cin>>N>>A>>B;vl X(N);rep(i,N)cin>>X[i];
  ll cnt=0;
  for(int i=0;i<N-1;i++){
    cnt+=min(B,A*(X[i+1]-X[i]));
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,w,k;cin>>h>>w>>k;
	int line_stra[h];
	memset(line_stra,0,sizeof(line_stra));
	char gra[h][w];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++){
			char t;cin>>t;
			gra[i][j]=t;
			if(t=='#')line_stra[i]++;
		}
	int disno=0;
	int take=0;
	int disgra[h][w];
	int idx=-1;
	for(int i=0;i<h;i++)if(line_stra[i]){
		idx=i;
		break;
	}
	assert(idx!=-1);
	for(int i=idx;i<h;i++){
		int col_take=0;
		
		if(!line_stra[i]){		
			for(int j=0;j<w;j++){
				disgra[i][j]=disgra[i-1][j];
			}
			continue;
		}else{
			disno++;
		}
		for(int j=0;j<w;j++){
			disgra[i][j]=disno;
			if(gra[i][j]=='#'){
				col_take++;
				take++;
				if(col_take<line_stra[i])disno++;
			}
		}
		
	}
	for(int i=idx-1;i>=0;i--){
		for(int j=0;j<w;j++)
		disgra[i][j]=disgra[i+1][j];
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(j)cout<<" ";
			cout<<disgra[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long c;
    cin>>c;
    long long x[n],v[n];
    long long cal1_l[n];//時計回りだけに進むときの差し引き栄養価
    long long cal1_r[n];//反時計回りだけに進むときの差し引き栄養価
    long long cal2_l[n];//時計回りに進み、初めの場所まで戻る時の差し引き栄養価
    long long cal2_r[n];//反時計回りに進み、初めの場所まで戻る時の差し引き栄養価
    long long wa_l[n];
    long long wa_r[n];
    int half=0;
    for(int i=0;i<n;i++)cin>>x[i]>>v[i];
    wa_l[0]=v[0];
    wa_r[0]=v[n-1];
    for(int i=1;i<n;i++){
        wa_l[i]=wa_l[i-1]+v[i];
        wa_r[i]=wa_r[i-1]+v[n-i-1];
    }
    for(int i=0;i<n;i++){
        cal1_l[i]=wa_l[i]-x[i];
        cal2_l[i]=wa_l[i]-x[i]*2;
        cal1_r[i]=wa_r[i]-(c-x[n-i-1]);
        cal2_r[i]=wa_r[i]-(c-x[n-i-1])*2;
    }
    long long lmax[n],rmax[n],lrmax[n],rlmax[n];
    lmax[0]=cal1_l[0];
    rmax[0]=cal1_r[0];
    lrmax[0]=cal2_l[0];
    rlmax[0]=cal2_r[0];
    for(int i=1;i<n;i++){
        lmax[i]=max(lmax[i-1],cal1_l[i]);
        rmax[i]=max(rmax[i-1],cal1_r[i]);
        lrmax[i]=max(lrmax[i-1],cal2_l[i]);
        rlmax[i]=max(rlmax[i-1],cal2_r[i]);
    }
    long long m=max({0ll,lmax[n-1],rmax[n-1]});
    for(int i=0;i<n-1;i++)m=max({m,lrmax[i]+rmax[n-i-2],rlmax[i]+lmax[n-i-2]});
    cout<<m<<endl;
    return 0;
}

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

using namespace std;

int main()
{
   string str;
   int n;
   cin>>str;
   n=str.size();
   if(str[n-1]=='s')
        cout<<str<<"es";
   else
        cout<<str<<"s";
   return 0;
}

Measured memory_bytes: 3628
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int m = 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);
const int maxm = 100001;

void solve()
{

    ll n;
    cin >> n;
    ll ar[n];
    ll suf[n];
    ms(suf,0);

    loop(i, 0, n)
    {
        cin >> ar[i];
    }

    bloop1(i, n - 2, 0)
    {
        suf[i] = ((suf[i + 1]) % m + (ar[i + 1]) % m) % m;
    }

    ll ans = 0;
    loop(i, 0, n)
    {
        ans = (ans % m + (suf[i] * ar[i]) % m) % m;
    }
    cout << ans << "\n";
}

int main()
{
    io;

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();

    return 0;
}


Measured memory_bytes: 6760
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debugg cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,i;
void fun(ll num,ll t,ll f,ll s)
{
    //cout<<num<<" "<<ans<<endl;
    if(num>n)
        return ;
       if(t&&f&&s)
            ans++;
   i--;
   fun(num*10+3,t+1,f,s);fun(num*10+5,t,f+1,s);fun(num*10+7,t,f,s+1);
   i++;
}
void solve()
{
    cin>>n;
    if(n<357)
    {debug(ans);return;}
    ll nn=n;
    while(nn)
    {
        nn/=10;
        i++;
    }
    fun(0,0,0,0);
    debug(ans);return;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define ff(i,a,b)  for(int i=a;i<=int(b);++i)
#define fr(i,a,b)  for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
const ll M  = 1e9+7 ;
//const int N = 111;
const int inf = 1<<30;
const double EPS = 1e-9;
//////////////////////    Hi    ^_^  hack me if you can :P
string ys = "YES\n";
string no = "NO\n" ;

int vis [1010];

int main()
{
    speed;
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    ff(i,a,b-1) vis[i] = 1;
    int ans = 0;
    ff(i,c,d-1) if (vis[i]) ++ans;
    cout << ans ;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Ans
{
	int w1;
	bool flag;
};
int main()
{
	Ans ans[100000];
	int m,n,i,a,c=0,w=0;
	string s;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		ans[i].flag=true;
		ans[i].w1=0;
	}
	for(i=0;i<m;i++)
	{	
		cin>>a;
		cin>>s;
		if(s=="WA"&&ans[a-1].flag)
			ans[a-1].w1++;
		else if(s=="AC"&&ans[a-1].flag)
		{
			c++;ans[a-1].flag=false;
			w+=ans[a-1].w1;
		}
	}
	cout<<c<<" "<<w<<endl;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
abc = [tuple(map(int, input().split())) for i in range(N)]

dp = [[-1]*3 for i in range(N)]

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1, N):
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1) % 3], dp[i-1][(j+2) % 3]) + abc[i][j]
print(max(dp[-1]))


Measured memory_bytes: 40256
#include <stdio.h>
#include <iostream>
#include <string>
#include <unordered_map>

int t1,t2,t3;

int n,s;

std::unordered_map<std::string,long long> memo;
long long getans(std::string a,std::string b,std::string c)
{
    //printf("AAA %s/%s/%s\n",a.c_str(),b.c_str(),c.c_str());
    if (!a.empty() && !c.empty()) {
        t1=0;
        while (t1<a.size() && t1<c.size() && a[t1]==c[c.size()-1-t1]) t1++;
        if (t1<a.size() && t1<c.size()) return 0;
        a=a.substr(t1);
        c=c.substr(0,c.size()-t1);
    }
    if (b.empty()) {
        if (a.empty() && c.empty()) return 1;
        return 0;
    }
    std::string key=a+"/"+b+"/"+c;
    //printf("BBB %s\n",key.c_str());
    if (memo.count(key)) return memo[key];
    // don't select first letter
    long long ans=getans(a+b[0],b.substr(1),c);
    // select first letter
    for (int i=1; i<b.size(); i++) {
        if (b[0]==b[i]) {
            ans+=getans(a,b.substr(1,i-1),b.substr(i+1)+c);
        }
    }
    // done
    //printf("what %s = %lld\n",key.c_str(),ans);
    return memo[key]=ans;
}

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    std::string zero,s;
    std::cin >> n >> s;
    std::cout << getans(zero,s,zero)*2;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  double c = (a * 1. + b * 1.) / 2;
  int d = (a + b) / 2;
  if (c - d > 0) {
    d = d + 1;
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
struct graph
{
	int v[200010];
	int t[200010];
	int h[100010];
	int n;
	graph()
	{
		n=0;
	}
	void add(int x,int y)
	{
		v[++n]=y;
		t[n]=h[x];
		h[x]=n;
	}
};
graph g1,g2,g;
int fa[100010];
int fb[100010];
int a1[100010];
int a2[100010];
int st[100010];
int top;
int b[100010];
int c[100010];
void dfs1(int x)
{
	int i;
	for(i=g1.h[x];i;i=g1.t[i])
		dfs1(g1.v[i]);
	if(a1[x])
		st[++top]=x;
	while(top>=2)
	{
		g.add(st[top],st[top-1]);
		g.add(st[top-1],st[top]);
		top-=2;
	}
}
void dfs2(int x)
{
	int i;
	for(i=g2.h[x];i;i=g2.t[i])
		dfs2(g2.v[i]);
	if(a2[x])
		st[++top]=x;
	while(top>=2)
	{
		g.add(st[top],st[top-1]);
		g.add(st[top-1],st[top]);
		top-=2;
	}
}
void dfs(int x,int v)
{
	c[x]=v;
	b[x]=1;
	int i;
	for(i=g.h[x];i;i=g.t[i])
		if(!b[g.v[i]])
			dfs(g.v[i],-v);
}
int main()
{
//	open("agc018f");
	int n;
	scanf("%d",&n);
	int i;
	int rt1,rt2;
	for(i=1;i<=n;i++)
		a1[i]=a2[i]=1;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&fa[i]);
		if(fa[i]==-1)
			rt1=i;
		else
		{
			g1.add(fa[i],i);
			a1[fa[i]]^=1;
		}
	}
	for(i=1;i<=n;i++)
	{
		scanf("%d",&fb[i]);
		if(fb[i]==-1)
			rt2=i;
		else
		{
			g2.add(fb[i],i);
			a2[fb[i]]^=1;
		}
	}
	for(i=1;i<=n;i++)
		if(a1[i]!=a2[i])
		{
			printf("IMPOSSIBLE\n");
			return 0;
		}
	printf("POSSIBLE\n");
	top=0;
	dfs1(rt1);
	top=0;
	dfs2(rt2);
	for(i=1;i<=n;i++)
		if(!b[i])
			dfs(i,1);
	for(i=1;i<=n;i++)
		if(!a1[i])
			printf("0 ");
		else
			printf("%d ",c[i]);
	return 0;
}

Measured memory_bytes: 10752
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"5 5 7"# => r#"YES"#,
r#"5 7 7"# => r#"NO"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        mut abc: [usize; 3],
    }
    abc.sort();

    if abc[0] == 5 && abc[0] == abc[1] && abc[2] == 7 {
        "YES"
    } else {
        "NO"
    }.to_string()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

namespace mapping{
	template<class t>
		auto collect(int n,t f){
			vector<decltype(f())> res(n);
			for(auto &i:res){
				i = f();
			}
			return res;
		}

	template<class t,class f>
		auto mapcar(t x,f func){
			int n = x.size();
			vector<typename t::value_type> res(n);
			auto itr = res.begin();
			for(auto &i:x){
				*itr = func(i);
				++itr;
			}
			return res;
		}
	template<class t,class f>
		void mapc(t x,f func){
			for(auto &i:x){
				func(i);
			}
		}
	template<class t,class u>
		auto sellect(t x,u f){
			vector<typename t::value_type> res;
			for(auto &i:x){
				if(f(i)){
					res.push_back(i);
				}
			}
			return res;
		}

}

using namespace mapping;

ll in(){
	ll res;
	scanf("%lld",&res);
	return res;
}


int main(){
	ll c = in();
	ll r = in();
	ll n = in();
	vector<pll> line;
	auto touch = [&](ll x, ll y){
		return x == 0 || x == c || y == 0 || y == r;
	};
	auto value = [&](ll x, ll y){
		if(y==0)return x;
		if(x==c)return c + y;
		if(y==r)return r + 2 * c - x;
		return 2*(r+c) - y;
	};
	rep(i, n){
		ll a = in();
		ll b = in();
		ll c = in();
		ll d = in();
		if(touch(a, b)&&touch(c, d)){
			line.emplace_back(value(a, b), i);
			line.emplace_back(value(c, d), i);
		}
	}
	sort(all(line));
	stack<int> st;
	foreach(i, line){
		if(st.size()&&st.top()==i.second){
			st.pop();
		}else{
			st.push(i.second);
		}
	}
	cout << (st.empty()?"YES":"NO") << endl;
	return 0;
}


Measured memory_bytes: 6512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef unordered_map<ll, ll> uii;
typedef unordered_map<ll, ll> uuii;
typedef unordered_map<ll, ll> uuuii;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
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; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    string S; cin >> S;
    ll ans = 0; rep(i, S.size()) if(S[i] == '1') ans++;
    
    cout << ans << endstr;
    
    return 0;
}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

string S;
vector<int> V;
int ans;

signed main(){

    in(S);
    int i=0;
    while(i<S.size()){
        if(S[i]=='A'){
            V.pb(1);
            i++;
        }else if(S.substr(i,2)=="BC"){
            V.pb(2);
            i+=2;
        }else{
            V.pb(-1);
            i++;
        }
    }
    show(V);
    int tmp=0;
    for(auto e:V){
        if(e==1){
            tmp++;
        }else if(e==2){
            ans+=tmp;
        }else{
            tmp=0;
        }
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;

int main(void){
    double a,b,sum =0,ans=0;
    cin >> a;
    for (int i = 0; i < a; i++) {
        cin >> b;
        sum += 1/b;
    }
    
    ans = 1/sum;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int x; cin >> x;
    int y = 0;
    int i;
    for(i=1; y<x; i++){
        y += i;
    }
    pr(i-1);
    return 0;}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a<=5){
        cout << "0" << endl;
    }else if(a>=6 && a<=12){
        cout << b/2 << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}


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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();

        int[] vArr = new int[n];
        int[] wArr = new int[n];
        for (int i = 0; i< n;i++) {
            vArr[i] = sc.nextInt();
            wArr[i] = sc.nextInt();
        }

        int[][] dp = new int[n + 1][w + 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= w; j++) {
                if (wArr[i] <= j) {
                    dp[i + 1][j] = Math.max(dp[i][j], dp[i + 1][j - wArr[i]] + vArr[i]);
                } else {
                    dp[i + 1][j] = dp[i][j];
                }
            }
        }

//        debug(dp);

        System.out.println(dp[n][w]);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



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


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

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

  rep(b,n) rep(a,b){
    int ab = L[a]+L[b];
    int r = lower_bound(L.begin(),L.end(),ab)-L.begin();
    int l=b+1;
    num += max(0,r-l);
  }


  cout << num << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
using u64 = std::uint_fast64_t;

public:
u64 a;

constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};

using mint = modint<1000000007>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> C(N);
    rep(i,N) cin >> C[i];

    unordered_map<int, int> dic;
    vector<mint> ans(N+1);
    ans[0] = 1;
    rep(i,N) {
        if (dic.count(C[i]) && i != dic[C[i]]) {
            ans[i+1] = ans[i] + ans[dic[C[i]]];
            dic[C[i]] = i+1;
        } else {
            dic[C[i]] = i+1;
            ans[i+1] = ans[i];
        }
    }

    cout << ans[N].a << endl;
}


Measured memory_bytes: 10824