akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		long[]a= {gInt(),gInt(),gInt()};
		Arrays.sort(a);
		for(int i:rep(gInt()))
			a[2]*=2;
		System.out.println(a[0]+a[1]+a[2]);
	}
	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


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

ll dp[3005][3005];

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  rep(i,n+5)dp[i][i]=a[i];

  rep(j,n)rep(i,n){
    if (i+j>=n)continue;
    else{
      dp[i][i+j]=max(a[i+j]-dp[i][i+j-1],a[i]-dp[i+1][i+j]);
  //    cout<<a[j]-dp[i][j-1]<<" "<<a[i]-dp[i+1][j]<<endl;
    //  cout<<dp[i][i+j]<<"i"<<i<<"j"<<(i+j)<<endl;
    //  dp[i][j]=max(dp[i][j],);
    }
  }
  cout<<dp[0][n-1];
}


Measured memory_bytes: 49768
#include<stdio.h>
void change(int *, int *);
int main(){
  int a, b, c, n;
  scanf("%d", &n);

  for(; n > 0; n--){
    scanf("%d %d %d", &a, &b, &c);
    change(&a, &c);
    change(&b, &c);
    if(a * a + b * b == c * c){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

void change(int *x, int *y){
  int tmp;
  if(*x > *y){
    tmp = *x;
    *x = *y;
    *y = tmp;
  }
}

Measured memory_bytes: 580
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def ceil(n, m):
    return -(-n//m)


def main():
    n = II()
    T = [II() for _ in range(5)]

    return 4 + ceil(n, min(T))


print(main())


Measured memory_bytes: 3064
using System;
using System.Linq;
namespace Answer {
  class Program {
    public static void Main(string[] args) {
      var N = int.Parse(Console.ReadLine());
      var H = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
      
      if (N == 1) { 
        Console.WriteLine("Yes");
      }
      else {
        Console.WriteLine(Answer(H, N));
      }
    }
    
    public static string Answer(int[] H, int N) {
      for (var i = 0; i < N-1; i++) {
        var prev = H[i];
        var next = H[i + 1];
       	if (next > prev) H[i + 1]--;
       	if (next == prev) continue;
      	if (next < prev) {
          return "No";
     	}
      }
      return "Yes";
    }
  }
}
        
        
        
      


Measured memory_bytes: 28124
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  long long int X;
  long long int a = 100;
  long long int sum = 0;
  cin>>X;
  while(a < X){
    a += (a/100);
    sum += 1;
  }
  cout<<sum<<'\n'; 
}

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

struct data_t {
    int num;
    string str;
  int res;

    // 最後のconstを忘れると"instantiated from here"というエラーが出てコンパイルできないので注意
    bool operator<( const data_t& right ) const {
        return str == right.str ? num > right.num : str < right.str;
    }
};

int main(){
  int N;
  cin >> N;
    vector<data_t> data_array(N);

    for(int i = 0;i < N;i++){
      cin >> data_array[i].str >> data_array[i].num;
      data_array[i].res = i + 1;
    }

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

    for(int i = 0;i < N;i++){
      cout << data_array[i].res << endl;
    }
    return 0;
}

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

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

using namespace std;

const LL MOD=1e9+7;

int n,a[200010],b[200010],z[2][400010];
vector <int> s;

void calcZ(int w)
{
	int lb=0,ub=0;
	repn(i,s.size()-1)
	{
		if(s[i]!=s[0]) continue;
		if(i>ub)
		{
			int p=i;
			while(p<s.size()&&s[p]==s[p-i]) p++;
			lb=i;
			ub=p-1;
			z[w][i]=p-i;
		}
		else
		{
			int j=i-lb;
			if(j+z[w][j]-1<ub-lb) z[w][i]=z[w][j];
			else
			{
				int p=ub+1;
				while(p<s.size()&&s[p]==s[p-i]) p++;
				z[w][i]=p-i;
				lb=i;
				ub=p-1;
			}
		}
	}
}

int main()
{
	cin>>n;
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);
	rep(i,n-1) s.pb(b[i]^b[i+1]);
	rep(i,n-1) s.pb(a[i]^a[i+1]);
	calcZ(0);
	s.clear();
	rep(i,n-1) s.pb(a[i]^a[i+1]);
	rep(i,n-1) s.pb(b[i]^b[i+1]);
	calcZ(1);
	rep(i,n)
	{
		//cout<<z[0][n-1+i]<<' '<<z[1][n-1+n-i]<<'p'<<endl;
		if(z[0][n-1+i]>=n-i-1&&z[1][n-1+n-i]>=i-1&&(a[i]^b[0])==(a[0]^b[(n-i)%n])) cout<<i<<' '<<(a[i]^b[0])<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }

#define pb push_back
#define mp make_pair

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

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

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

    ll x, y;

    cin >> x >> y;

    ll a = 1;
    ll b = 0;
    ll _x = x + 1;

    while (x <= y) {
        x *= 2;

        if (y < x) break;

        a++;
    }

    if (x < y) b = 1;

    if (b != 0) {
        while (_x <= y) {
            _x *= 2;

            if (y < _x) break;

            b++;
        }
    }

    cout << max(a, b) << '\n';

    return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}
using namespace std;

long long f(long long n){
    if(n&1LL){
        return (3LL*n+1LL);
    }
    else{
        return (n/2LL);
    }
}

int main(){
    IOS
    //freopen("output.txt","w",stdout);
    long long s;
    cin>>s;
    int i=1;
    map<long long , int>mp;
    mp[s]=i;
    i++;
    //cout<<f(1)<<endl<<endl;
    while(true){
        ll ans = f(s);
        mp[ans]++;
        if (mp[ans]>1){
            cout<<i;
            return 0;
        }
        mp[ans]--;
        if(!mp[ans])mp[ans]=i;
        i++;
        s=ans;


        //cout<<s<<endl;
    }

}


Measured memory_bytes: 256
program main
    use iso_fortran_env
    implicit none
    integer(int32) :: n, m, k
    integer(int32), allocatable :: a(:), b(:)
    integer(int64), allocatable :: bt(:)
    integer(int64), allocatable :: at, tmp
    integer(int32) :: i, j, jmax, ans

    read *, n, m, k
    allocate(a(n))
    allocate(b(m))
    allocate(bt(0:m))
    bt = 0

    read *, (a(i), i = 1, n)
    read *, (b(i), i = 1, m)

    do i = 1, m
        bt(i) = bt(i-1) + b(i)
    enddo

    i = 0
    ans = 0
    at = 0
    jmax = m
    do while( ( k - at ) >= 0 )
        tmp = k - at
        do j = jmax, 0, -1
            if ( bt(j) <= tmp ) exit
        enddo

        if ( ans < (i+j) ) ans = i + j
        i = i + 1
        jmax = j
        at = at + a(i)
        if ( i > n ) exit
    enddo

    print *, ans

end program main

Measured memory_bytes: 6216
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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 mp make_pair
#define fi first
#define sc second
ll sx,sy,tx,ty;
int main(){
	cin >> sx >> sy >> tx >> ty;

	REP(i,tx - sx) {
		cout << "R";
	}
	REP(i,ty - sy) {
		cout << "U";
	}
	REP(i,tx - sx) {
		cout << "L";
	}
	REP(i,ty - sy + 1) {
		cout << "D";
	}
	REP(i,tx - sx + 1) {
		cout << "R";
	}
	REP(i,ty - sy + 1) {
		cout << "U";
	}
	cout << "LU";
	REP(i,tx - sx + 1) {
		cout << "L";
	}
	REP(i,ty - sy + 1) {
		cout << "D";
	}
	cout << "R" << endl;
	return 0;
}


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 int ll;
typedef pair<int, int> P;
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; }

const ll INF = 1e10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m), a_sum(n+2, 0), b_sum(m+2, 0);
    rep(i,n){
        cin >> a[i];
        a_sum[i+1] += a_sum[i] + a[i];
    }
    a.push_back(INF);
    a_sum[n+1] += INF;
    rep(j,m){
        cin >> b[j];
        b_sum[j+1] += b_sum[j] + b[j];
    }
    b.push_back(INF);
    b_sum[m+1] += INF;
    ll ans = 0;
    rep(i,n+1){
        ll cost = a_sum[i];
        if(cost > k) continue;
        auto idx = lower_bound(b_sum.begin(), b_sum.end(), k - cost+1);
        idx--;
        ll cmp = i + (idx - b_sum.begin());
        //cout << i << " " << cost << " " << cmp << endl;
        chmax(ans, cmp);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	string s;
	cin >> s;
	if (s.length() >= 4 && s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I') cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;

struct Edge {
	int to, cost, e;
	Edge(){}
	Edge(int to, int cost, int e): to(to), cost(cost), e(e){}
};

struct State {
	int pos, l, sum;
	State(){}
	State(int pos, int l, int sum): pos(pos), l(l), sum(sum){}
	bool operator < (const State &t) const {
		return sum > t.sum;
	}
};

vector<Edge> g[100];
int dist[100][101];

int n, m, L;

int solve()
{
	fill_n(*dist, 100 * 101, INF);
	dist[0][L] = 0;
	
	priority_queue<State> pq;
	pq.push(State(0, L, 0));
	while (pq.size()){
		State st = pq.top(); pq.pop();
		if (dist[st.pos][st.l] < st.sum) continue;
		for (auto &e : g[st.pos]){
			if (dist[e.to][st.l] > st.sum + e.e){
				dist[e.to][st.l] = st.sum + e.e;
				pq.push(State(e.to, st.l, st.sum + e.e));
			}
			if (st.l >= e.cost && 
			    dist[e.to][st.l - e.cost] > st.sum){
				dist[e.to][st.l - e.cost] = st.sum;
				pq.push(State(e.to, st.l - e.cost, st.sum));
			}
		}
	}
	
	int res = INF;
	for (int i = 0; i <= 100; i++){
		res = min(res, dist[n - 1][i]);
	}
	
	return res;
}

int main()
{
	while (scanf("%d %d %d", &n, &m, &L), n){
		for (int i = 0; i < n; i++){
			g[i].clear();
		}
		
		for (int i = 0; i < m; i++){
			int a, b, d, e;
			scanf("%d %d %d %d", &a, &b, &d, &e);
			a--; b--;
			g[a].push_back(Edge(b, d, e));
			g[b].push_back(Edge(a, d, e));
		}
		
		printf("%d\n", solve());
	}
}

Measured memory_bytes: 1708
while True:
  m,f,r = map(int,input().split())
  if m==f==r==-1:
    break
  elif m==-1 or f==-1:
    print("F")
  else:
    if m+f>=80:
      print("A")
    elif 80>m+f>=65:
      print("B")
    elif 65>m+f>=50:
      print("C")
    elif 50>m+f>=30:
      if r>=50:
        print("C")
      else:
        print("D")
    else:
      print("F")


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long int x[4];
    x[0] = a * c;
    x[1] = a * d;
    x[2] = b * c;
    x[3] = b * d;
    sort(x,x+4);
    cout << x[3];
}


Measured memory_bytes: 3600
#include<stdio.h>
main()
{
	  long long int i,n, s=0;
	  scanf("%lld", &n);
	  i=n;
	  while(i)
	  {
		s=s+i%10;
		i=i/10;
	  }
	  if(n%s==0)
	  printf("Yes");
	  else
	  printf("No");
	return 0;
}

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

int left(int a) {
    while (a >= 10) {
        a /= 10;
    }
    return a;
}
int right(int a) {
    return a%10;
}

int main() {
    int n; cin >> n;
    vector<vector<int>> digLR(10);
    rep(i,10) digLR[i].resize(10);
    for (int i = 1; i <= n; i++) {
        digLR[left(i)][right(i)]++;
    }
    ll ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            int a = digLR[i][j];
            int b = digLR[j][i];
            ans += a*b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

for i in range(1, max(n+1, 11)):
    if (n/i)%1 == 0:
        if 1 <= n//i <= 9 and 1 <= i <= 9:
            print("Yes")
            break
else:
    print("No")

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

int main()
{
	int N;
	scanf("%d", &N);
	
	set<string> uniqueItems;
	for(int i = 0; i < N; i++)
	{
		char item[15];
		scanf("%s", item);
		
		string itemToAdd = "";
		for(int j = 0; j < 15; j++)
		{
			if(item[j] == '\0')
				break;
				
			itemToAdd += item[j];
		}
		
		uniqueItems.insert(itemToAdd);
	}
	
	printf("%d", (int)(uniqueItems.size()) );
}


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

#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=1e5+5,L=17;
int a[N],f[N][L];

int main()
{
//	freopen("1.in","r",stdin);
	int n;
	cin>>n;
	rep(i,1,n)scanf("%d",a+i);
	int l;
	cin>>l;
	rep(j,0,L-1)f[n][j]=n;
	int now=n;
	per(i,n-1,1)
	{
		while(a[now]-a[i]>l)--now;
		f[i][0]=now;
		rep(j,1,L-1)f[i][j]=f[f[i][j-1]][j-1];
	}
	int m;
	cin>>m;
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		int ans=0;
		per(j,L-1,0)
		if(f[x][j]<y)
		{
			ans+=1<<j;
			x=f[x][j];
		}
		printf("%d\n",ans+1);	
	}
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long 
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+9;
const ll MOD=998244353;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
ll cnt[MAX];
int main() 
{

	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int n;
    cin>>n;
    ll arr[n+1];
    ll ans[n+1];
    ll x=0;
    for(int i=1;i<=n;i++){
      cin>>arr[i];
      x=x^arr[i];
    }
    for(int i=1;i<=n;i++){
      cout<<(arr[i]^x)<<" ";
    }


}

Measured memory_bytes: 5144
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int N = sc.nextInt();
		int[] arr = new int[N];
		int[] pos = new int[N];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = sc.nextInt() - 1;
			pos[arr[i]] = i;
		}
		int ans = 0;
		int cur = 1;
		for (int i = 0; i + 1 < N; i++) {
			if (pos[i] < pos[i + 1]) {
				cur++;
				ans = Math.max(ans, cur);
			} else {
				cur = 1;
			}
		}
		ans = Math.max(ans, cur);
		System.out.println(N - ans);
	}
}


Measured memory_bytes: 82788
from operator import mul
from functools import reduce
from collections import Counter
# from itertools import combinations as comb
# from itertools import permutations as perm
# from copy import copy
# 配列二分法アルゴリズム
# https://docs.python.jp/3/library/bisect.html
# import bisect
# 桁数指定
# print('{:.3f}'.format(X))
# from collections import defaultdict
# dic = defaultdict(lambda: ...)
# 値で辞書をソート
# sorted(dic.items(), key=lambda x:x[1])
# ヒープキュー
# https://docs.python.org/ja/3/library/heapq.html
# import heapq
# 正規表現(regular expression)のためのモジュール
# import re

import sys

sys.setrecursionlimit(2000)


def inpl():
    return list(map(int, input().split()))


# 重複組み合わせは nHr = (n + r - 1)Cn
def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


N = int(input())
A = inpl()
ans = 0
for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i + 1] = -1
        ans += 1

print(ans)


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

#define ll              long long
#define mod             1000000007
#define inf             1e18

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n;
    cin>>n;

    int a[n], b[n], c[n];
    for(int i=0; i<n; i++)  cin>>a[i]>>b[i]>>c[i];

    int dp[3];

    dp[0] = a[0], dp[1] = b[0], dp[2] = c[0];

    int m[3] = {0};
    for(int i=1; i<n; i++){
        for(int i=0; i<3; i++)  m[i] = 0;
            
        m[0] = max(a[i] + dp[1], a[i] + dp[2] );
        m[1] = max(b[i] + dp[0], b[i] + dp[2] );
        m[2] = max(c[i] + dp[0], c[i] + dp[1] ); 
        
        for(int i=0; i<3; i++)  dp[i] = m[i];
    }

    sort(dp, dp+3);
    cout<<dp[2]<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long int lint;
typedef unsigned long long int ulint;
list <lint> graph[100020];
lint hesap(lint a,bool b,lint ata);
lint n,k,dp[3020][3020];
char s[3020];
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lint a,b,i,j,l,il;
    cin>>n;
    for(i=0;i<n-1;i++) cin>>s[i];
    dp[1][1]=1;
    for(i=2;i<=n;i++){
        lint pref=0;
        if(s[i-2]=='<'){
            for(j=1;j<=i;j++){
                dp[i][j]=pref;
                pref+=dp[i-1][j];
                pref%=mods;
                }
            
            }else{
                for(j=i;j>=1;j--){
                    pref+=dp[i-1][j];
                    pref%=mods;
                    dp[i][j]=pref;
                    }
            }
        }
        
    lint cev=0;
    for(i=1;i<=n;i++) cev+=dp[n][i], cev%=mods;
    //for(i=1;i<=n;i++){for(j=1;j<=n;j++) cout<<dp[i][j]<<" "; cout<<endl;}
    cout<<cev;
    
    }

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

int checkPrime(int num)
{
	int i, j, current, count = 0;
	bool check = true;
	for (i = 0; i < num; i++)
	{
		cin >> current;
		if (current % 2 == 0 && current != 2) check = false;
		else
		{
			for (j = 3; j <= sqrt(current); j += 2)
			{
				if (current % j == 0)
				{
					check = false;
					break;
				}
			}
		}
		if (check) count++;
		check = true;
	}
	return count;
}

int main()
{
	int num, count;
	cin >> num;
	count = checkPrime(num);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<string.h>

const int MAXN = 1000000000;
const int MOD = 1000000007;

int ext_gcd(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	else {
		int r = ext_gcd(b, a %b, y, x);
		y -= (a / b) * x;
		return r;
	}
}

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	int x, y;
	ext_gcd(a, b, x, y);
	printf("%d %d\n", x, y);

	return 0;
}


Measured memory_bytes: 2752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF INT_MAX
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll
#define P pair<int,int>


signed main(){
  string s; cin>>s;
  
  s=" "+s;
  int cnt_p=0;
  int won=0;
  for(int i=1; i<s.size(); i++){
    if(cnt_p+1>i-cnt_p-1){
      if(s[i]=='p') won--;
      continue;
    }
    cnt_p++;
    if(s[i]=='g'){
      won++;
    }
  }
  cout<<won<<en;
}


Measured memory_bytes: 512
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5 + 15;
const int OFFSET = 1e5 + 5;
int arr[N + 5], bit[N + 5];

void update(int x) {
	for( ; x <= N; x += (x & -x)) bit[x]++;
}

int query(int x) {
	int total = 0;
	for( ; x ; x -= (x & -x)) total += bit[x];
	return total;
}

void hora(int tc) {
	ll n;
	cin>>n;
	for(int i = 0;i < n;i++) cin>>arr[i];
	int lo = 0;
	int hi = 1e9;
	int res = 0;
	ll ways = n * (n + 1) / 2;
	while(lo <= hi) {
		memset(bit, 0, sizeof bit);
		int mid = (lo + hi) / 2;
		int cur = 0;
		int ptr = 0;
		ll total = 0;
		for(int i = 0;i < n;i++) {
			if(arr[i] < mid) {
				ptr++;
				update(cur + OFFSET);
				cur++;
				total += (i + 1) - query(ptr - 1 + OFFSET);
			} else {
				ptr--;
				update(cur + OFFSET);
				cur--;
				total += (i + 1) - query(ptr - 1 + OFFSET);
			}
		}
		if(total * 2 >= ways) {
			res = mid;
			lo = mid + 1;
		} else hi = mid - 1;
	}
	cout<<res<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


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

using namespace std;

/*
const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;*/

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

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void printV(vi v) {
    for (int i = 0; i<v.size(); ++i) cout << v.at(i) << " ";
    cout << "\n";
}

//g++ -std=c++11 -O2 -Wall c.cpp

void solve() {
    int x; cin >> x;
    cout << 1-x << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        solve();


    /**
     * ALGORITHME DE TRI ET EN LEVER LES DUPLICATES
     * set<int> s( v.begin(), v.end() );
     * v.assign( s.begin(), s.end() );
     * */
}


Measured memory_bytes: 3608
function Main(input){
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
	var result = xs.reduce(function (previous, current, index, array) {
    return previous + current;
    });
    console.log(Math.ceil(result/xs.length)); 
}
Main(require('fs').readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
s = list(input())

n = len(s)
ans = [0] * n

for i in range(2):
    cnt = 0
    for j in range(n):
        if s[j] == 'R':
            cnt += 1
        else:
            ans[j] += int(cnt/2)
            ans[j-1] += int((cnt+1)/2)
            cnt = 0
    ans.reverse()
    s.reverse()
    for j in range(n):
        if s[j] == 'L':
            s[j] = 'R'
        else:
            s[j] = 'L'

print(' '.join(map(str, ans)))

Measured memory_bytes: 11180
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int Euclidean(int a, int b){
    // b = a * q + r
    if(a > b) swap(a, b);
    int r = b % a;
    if (r == 0) return a;
    else return Euclidean(a, r);
}

int main(){
    int64_t A, B;
    cin >> A >> B;
    int64_t C = Euclidean(A, B);
    cout << A / C * B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    
    int A[N];
    map<int,int> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]]++;
        if(mp[A[i]] != 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 14336
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

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

    int ans = 0;
    int i = 0;
    while(i < n) {
        int cnt = 0;
        int j = i;
        while(a[i] == a[j] && j < n) {
            cnt++;
            j++;
        }
        ans += cnt / 2;
        i = j;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<int> vec;
  vec.push_back(a+c);
  vec.push_back(a+d);
  vec.push_back(b+c);
  vec.push_back(b+d);
  printf("%d\n",*min_element(vec.begin(),vec.end()));
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
vector<int> par; //oya
vector<int> rnk; //ki no hu ka sa
// n要素で初期化
void init(int n){
    par.resize(n);rnk.resize(n);
    FOR(i, 0, n){par[i] = i;rnk[i] = 0;}
}
//木の根を求める
int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}
//xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);y = find(y);
    if(x == y) return;
    if(rnk[x] < rnk[y])par[x] = y;
    else{par[y] = x;if(rnk[x] == rnk[y]) rnk[x]++;}
    return;
}
bool isSame(int x, int y){return find(x) == find(y);}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q; cin >> n >> q;
  init(n);
  FOR(i,0,q) {
    int s;
    int x, y;
    cin >> s >> x >> y;
    if(s == 0) {
      unite(x, y);
    } else {
      cout << (isSame(x, y) ? 1 : 0) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3284
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string a;
int n,m,f[10000000],flag1=0,cnt;

void dfs(int x){
	if(x==0){
		flag1=1;
		for(int i=cnt-1;i>=0;i--){
			if(i!=cnt-1) cout<<" ";
			cout<<f[i];
		}
		
		return;
	}
	for(int i=m;i>0;i--){
		if(x-i>=0&&a[x-i]=='0'){
			f[cnt++]=i;
			dfs(x-i);
			return;
		}
	}
}	
int main(){
   cin>>n>>m;
   cin>>a;
   dfs(n);
   if(!flag1) {
   	cout<<"-1";
   	return 0;
   }
   return 0;
} 

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			char[] c = {s.charAt(i), t.charAt(i)};
			sb.append(c);
		}

		System.out.println(sb.toString());

		sc.close();
	}
}


Measured memory_bytes: 21204
import sys
import copy
 
def main():
    ABCD = list(map(str, input()))
    b_digit = len(ABCD)-1
 
    for i in range(2 ** b_digit):
        signs = ["+"] * b_digit
        for j in range(b_digit):
            if ((i >> j ) & 1):
                signs[b_digit - 1 - j] = "-"
 
        ABCD_tmp = copy.deepcopy(ABCD)
        for k in range(len(signs)):
            ABCD_tmp.insert(1+k*2,signs[k])
        if(eval("".join(ABCD_tmp))==7):
            print("{}=7".format("".join(ABCD_tmp)))
            sys.exit()
 
main()

Measured memory_bytes: 3444
#pragma region template
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define pb push_back
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vstr = vector<string>;
const string Yes = "Yes\n";
const string No = "No\n";
static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}
#pragma endregion template

void solve(ll A, ll B, ll C, ll D) {
  bool turn = 0;
  while(A > 0 && C > 0) {
    if (turn) {
      A -= D;
    } else {
      C -= B;
    }
    turn ^= 1;
  }
  Yes(turn);
}

int main() {
  ll A;
  ignore_ret(scanf("%lld",&A));
  ll B;
  ignore_ret(scanf("%lld",&B));
  ll C;
  ignore_ret(scanf("%lld",&C));
  ll D;
  ignore_ret(scanf("%lld",&D));
  solve(A, B, C, D);
  return 0;
}


Measured memory_bytes: 3688
#include <cstdio>

bool a[105050][41],k[41];

inline void Compose(bool b[],long long n)
{
	register int dig=0;
	while(n)
	{
		b[++dig]=n&1;
		n>>=1;
	}
}

int main()
{
	int N;scanf("%d",&N);
	long long K;scanf("%lld",&K);
	for(register int i=1;i<=N;i++)
	{
		long long A;scanf("%lld",&A);
		Compose(a[i],A);
	}
	long long nK=0,ans=0,base=1;
	for(register int dig=1;dig<=40;dig++)
		base<<=1;
	for(register int dig=40;dig>=1;dig--)
	{
		base>>=1;
		register int z=0,o=0;
		for(register int i=1;i<=N;i++)
			z+=(a[i][dig]==0),o+=(a[i][dig]==1);
		//printf("%d: z %d o %d %lld<=%lld\n",dig,z,o,nK,K);
		if(z>o && (nK+base)<=K)
		{
			nK+=base;
			ans+=base*z;
		}
		else if(nK<=K)
			ans+=base*o;
		else
			break;
	}
	printf("%lld\n",ans);
	return 0;
}

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

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000;

ll a, b, n;

int main() {
	cin >> n >> a >> b;
	if (a > b || (n == 1 && a != b)) { print(0); return 0; }
	ll ans = (b*(n - 1) + a) - (a*(n - 1) + b) + 1;
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
using namespace std;
int n,h,amax,a,kazu;
vector<int> b(100001);
int main(){
  cin>>n>>h;
  for(int i=0;i<n;i++){
    cin>>a>>b[i];
    if(amax<a)amax=a;
  }
  sort(b.begin(),b.begin()+n);
  for(int i=n-1;i>=0;i--){
    if(amax<=b[i]){
      h-=b[i];kazu++;
      if(h<=0)break;
    }else break;
  }
  if(h>0)kazu+=(h+amax-1)/amax;
  cout<<kazu<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s,x;
    cin>>s;
    x=s;
    reverse(x.begin(),x.end());
    if(x==s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int s1 = 0, s2 = 0;
  vector<int> w(n);
  rep(i, 0, n) {
    cin >> w[i];
    s2 += w[i];
  }
  int ans = s2;
  rep(i, 0, n) {
    s2 -= w[i];
    s1 += w[i];
    ans = min(ans, abs(s1 - s2));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
N, K = map(int, input().split())

# Kの偶奇で場合分け
# 偶数の場合は、abcすべてがKの倍数。もしくはabcすべてがKの倍数+1/2K
if K % 2 == 0:
  x = N // (K // 2)
  y = N // K
  print((x-y)**3 + y**3)
# 奇数の場合はabcすべたがKの倍数
else:
  x = N // K
  print(x**3)

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

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    
    int X, Y, A;    
    int resultX = 0;
    int resultY = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> X >> Y >> A;
        
        if (A == 1) {
            //X領域小
            resultX = max(resultX, X);
        }else if(A == 2) {
            //X領域大
            W = min(W, X);
        }else if(A == 3) {
            //Y領域小
            resultY = max(resultY, Y);
        }else if(A == 4) {
            //Y領域大
            H = min(H, Y);
        }
    }
    
    cout << (max(W-resultX, 0) * max(H-resultY, 0)) << endl;
    
    return 0;   
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	ll cnt[27] = {};
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		cnt[S[0] - 'A']++;
	}
	string s = "MARCH";
	ll ans = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += cnt[s[i] - 'A'] * cnt[s[j] - 'A'] * cnt[s[k] - 'A'];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int count = 0;
    int max_r, max_g, max_b;
    max_r = N / R;
    max_g = N / G;
    max_b = N / B;

    for (int i = 0; i < max_r + 1; i++){
        for (int j = 0; j < max_g + 1; j++){
            if ((N - (R * i + G * j)) % B == 0 and N - (R * i + G * j) >= 0)
                count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import fractions
s = input().split()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])
def lcm(c, d):
  return (c*d)//fractions.gcd(c, d)
count = 0
C_value = B//C -(A-1)//C
D_value = B//D -(A-1)//D
value = B//(lcm(C, D)) - (A-1)//(lcm(C, D))
print(B-(A-1)-(C_value + D_value - value))

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

const int N = 100001;

struct Proc {
  string name;
  int time;
};

class Queue {
  int head, tail;
  Proc Q[N];

public:
  Queue() {
    head = 0;
    tail = 0;
  }
  
  void push(Proc p) {    
    Q[tail++] = p;
    tail = tail % N;
  }

  Proc pop() {
    int head_old = head;
    head++;
    head = head % N;
    return Q[head_old];
  }

  bool empty() {
    return (head == tail);
  }
};

int main() {
  int i, n, q, time, current;
  string name;
  Proc p;
  Queue queue;

  cin >> n >> q;
  for (i = 0; i < n; i++) {
    cin >> name >> time;
    p.name = name;
    p.time = time;
    queue.push(p);
  }

  current = 0;
  while (!queue.empty()) {
    p = queue.pop();
    if (p.time <= q) {
      current += p.time;
      cout << p.name << " " << current << endl;
    } else {
      current += q;
      p.time -= q;
      queue.push(p);
    }
  }

  return 0;
}



Measured memory_bytes: 7040
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
 
import bisect
 
 
N, H = mi()
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = mi()
 
B = sorted(B)
a = max(A)
m = bisect.bisect_right(B, a)
'''
s = 1
e = N
m = (s+e)//2
pre_m = 0
while True:
    m = (s+e)//2
    if B[m-1] > a:
        e = m
    elif B[m-1] <= a:
        s = m
    if s==e:
        m -= 1
        break
    #else:
        #break
    if e-s==1 and pre_m==m:
        break
    pre_m = m
'''
rem = H - sum(B[m:])
if rem > 0:
    print((N-m)+rem//a+(rem%a!=0))
else:
    for i in range(m, N):
        rem += B[i]
        if rem>0:
            print(N-i)
            exit()

Measured memory_bytes: 12080
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <time.h>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define int long long
struct EDGE {
	int x, y, z;
	inline int operator<(const EDGE &e2) const {
		return x < e2.x;
	};
} e[100005];
int n, m;
long long v[400005], lazy[400005];
void pushd(int nown) {
	lazy[nown << 1]= min(lazy[nown << 1], lazy[nown]);
	lazy[nown << 1 | 1]= min(lazy[nown << 1 | 1], lazy[nown]);
	v[nown << 1]= min(v[nown << 1], lazy[nown]);
	v[nown << 1 | 1]= min(v[nown << 1 | 1], lazy[nown]);
	lazy[nown]= 1000000000000000LL;
	return;
}
void update(int nown, int l, int r, int ml, int mr, long long c) {
	if(ml <= l && r <= mr) {
		lazy[nown]= min(lazy[nown], c);
		v[nown]= min(v[nown], c);
		return;
	}
	if(lazy[nown] != 1000000000000000LL) pushd(nown);
	int mid= (l + r) >> 1;
	if(mid >= ml) update(nown << 1, l, mid, ml, mr, c);
	if(mid < mr) update(nown << 1 | 1, mid + 1, r, ml, mr, c);
	return;
}
long long query(int nown, int l, int r, int mlr) {
	if(l == r) return v[nown];
	if(lazy[nown] != 1000000000000000LL) pushd(nown);
	int mid= (l + r) >> 1;
	if(mid >= mlr) return query(nown << 1, l, mid, mlr);
	return query(nown << 1 | 1, mid + 1, r, mlr);
}
signed main() {
	for(int i= 1; i <= 400000; i++) v[i]= lazy[i]= 1000000000000000LL;
	cin >> n >> m;
	for(int i= 1; i <= m; i++) {
		cin >> e[i].x >> e[i].y >> e[i].z;
	}
	update(1, 1, n, 1, 1, 0);
	sort(e + 1, e + m + 1);
	for(int i= 1; i <= m; i++) {
		update(1, 1, n, e[i].x, e[i].y, query(1, 1, n, e[i].x) + e[i].z);
	}
	int res= query(1, 1, n, n);
	if(res == 1000000000000000LL) res= -1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 8832
import copy


def main():
    target = input()

    num_list = []

    def function(n):
        if n == 0:
            num_list.append([(target[0], )])
        else:
            ans = []
            for i in num_list[n-1]:
                m = list(copy.copy(i))
                m.pop()
                m.append(i[-1] + target[n])
                ans.append(m)
                m = list(copy.copy(i))
                m.append(target[n])
                ans.append(m)
            ans = tuple(ans)
            num_list.append(ans)
    for x in range(len(target)):
        function(x)
    # print(num_list[-1])
    answer = 0
    for x in num_list[-1]:
        for y in x:
            answer += int(y)
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 71632
#include <stdio.h>

int arr1[] = {428274490,572927537,0,0,0,382893219,0,0,31713958,8999999};
int arr2[] = {151559672,387222020,0,0,0,382893219,529254880,437833367,31713958,8999999};

char ch[20];

void puti(int i){
    if(i>=10) {
        puti(i/10);
        i %= 10;
    }
    fputc(i + '0' ,stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 10, stdin);
    int res = 1;
    if (ch[1] == ' '){
        if (ch[4] == '3'){
            if (ch[6] == '4'){
                res = 65;
            } else if (ch[5] == '0'){
                if(ch[9] == '3') {
                    res = 823951039;
                }
            }
        } else if (ch[2] != ch[4]){
            res = 3;
        }
    } else if (ch[0] < '3'){
        res = arr1[ch[1]-'0'];
    }else{
        res = arr2[ch[1]-'0'];
        if(ch[2]=='8')res = 632611002;
    }
    puti(res);
    fputc('\n' ,stdout);
    return 0;
}

Measured memory_bytes: 1472
#C
X = int(input())
while True:
    root_X = X ** 0.5
    found_prime = True
    for i in range(2, int(root_X)+1):
        if X % i == 0:
            X += 1
            found_prime = False
            break
    if found_prime == True:
        print(X)
        break

Measured memory_bytes: 3060
A = []
for _ in range(3):
    A.append(list(map(int, input().split())))

B = set()
for _ in range(int(input())):
    B.add(int(input()))


checkList = list()
for i in range(3):
    checkList.append(set(A[i]))
for j in range(3):
    checkList.append(set([A[0][j], A[1][j], A[2][j]]))
checkList.append(set([A[0][0], A[1][1], A[2][2]]))
checkList.append(set([A[0][2], A[1][1], A[2][0]]))

flag = False
for s in checkList:
    if len(s - B) == 0:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
//#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
int main()
{
    Hello
    int n;
    cin >> n;
    long double sum = 1, arr[n + 5];
    ll N = 1e18;
    bool ok = true, zero = false;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        sum *= arr[i];
        if(sum > N)
            ok = false;
        if(arr[i] == 0)
            zero = true;
    }
    if(zero)
        cout << 0;
    else if(ok)
        cout << (ll)sum;
    else
        cout << -1;
    return 0;
}


Measured memory_bytes: 5292
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
int n;
const int M = 1e5 ;
int a[M][3]; 
int dp[M][3];
int main ()
{   
    scanf("%d" , &n );
    for (int i=0 ; i < n ;i++)
    {
        scanf ("%d%d%d" ,a[i] , a[i]+1, a[i]+2); 
    }
    for (int j =0 ; j < 3 ;j++)
    dp[0][j] = a[0][j]; 
    for (int i = 1; i < n ;i++)
    {
        for (int j =0 ; j< 3 ;j++)
        dp[i][j] = max (dp[i][j] , a[i][j] + max (  dp[i-1][ (j-1+3)%3 ] , dp[i-1][(j+1)%3]  ));
    }
    printf ("%d\n" , max ({dp[n-1][0] , dp[n-1][1] , dp[n-1][2]}));
}

Measured memory_bytes: 2560