akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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




vector<lli> G[100001];
lli colors[100001];

lli is_bipartite(lli target, lli color) {
    colors[target] = color;
    REP(i, 0, G[target].size()) {
        lli next = G[target][i];
        if (colors[next] == -color) {
            // 別の色で既に塗られている。それが塗られたときは二部グラフだったはずで、
            // ここで target を塗ったとしても矛盾するわけではないのでスキップ
            continue;
        }
        else if (colors[next] == color) {
            // 同一色で既に塗られているのでアウト
            return false;
        }
        else if (!is_bipartite(next, -color)) {
            // まだ塗られていないので、next 以降にゆだねている
            return false;
        }
    }
    return true;
}

int main() {
    lli n, m;
    cin >> n >> m;
    REP(i, 0, m) {
        lli a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if (is_bipartite(1, 1)) {
        lli black = 0, white = 0;
        REPE(i, 1, n) {
            if (colors[i] == 1)
                black++;
            else
                white++;
        }
        cout << black * white - m  << endl;
    }
    else {
        cout << n * (n-1) / 2 - m << endl;
    }
}


Measured memory_bytes: 7424
#include<stdio.h>

int main(void)
{
  int a = 0;
  int b = 0;
  scanf("%d %d",&a,&b);
  
  if(a*b % 2 == 0){
    printf("Even");
  }
  else{
    printf("Odd");
  }
    
  return 0;
}

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

int main() 
{
    int n,k,y,i,j;
    cin>>n>>k;
    int arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    
    int dp[n];
    for(i=0;i<n;i++) dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
        for(j=max(i-k,0);j<=i;j++)
        {
            dp[i]=min(dp[i],dp[j]+ abs(arr[j]-arr[i]));
        }
    }
    cout<<dp[n-1];
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N, W;
	cin >> N >> W;
	vector<long long int> A;
	for (int i = 0; i < W + 1; i++)
	{
		A.push_back(0);
	}
	for (int i = 0; i < N; i++)
	{
		long long int w, v;
		cin >> w >> v;
		vector<long long int> B;
		for (int j = 0; j < W+1; j++)
		{
			B.push_back(0);
		}
		for (int j = 0; j < W + 1; j++)
		{
			if (A[j] != 0)
			{
				if (j + w <= W)
				{
					B[j + w] = A[j] + v;
				}
			}
		}
		if (v > B[w])
		{
			B[w] = v;
		}
		for (int j = 0; j < W + 1; j++)
		{
			A[j] = (A[j] > B[j]) ? A[j] : B[j];
		}
	}
	long long int max = -1;
	for (int i = 0; i < W+1; i++)
	{
		if (max < A[i])
		{
			max = A[i];
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 2892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	if(2*x==w and 2*y==h)
		cout<<fixed<<setprecision(6)<<(w*h)/2.0<<" "<<1;
	else
		cout<<fixed<<setprecision(6)<<(w*h)/2.0<<" "<<0;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3760
import java.util.*;

class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner (System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    long ans = 0;
    long array[][] = new long[N][2];
    for (int i=0;i<N;i++){
      array[i][0] = sc.nextLong();
      array[i][1] = sc.nextLong();
    }
    Arrays.sort(array,(x,y)->Long.compare(x[0], y[0]));
    for (int i=0;i<N;i++){
      if (M>=array[i][1]){
        //買占め
        ans += array[i][0]*array[i][1];
        M -= array[i][1];
      }else{
        ans += array[i][0]*M;
        break;
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int main() {
    string line;
    while(cin >> line) {
        int arr[10] = {0};
        for(int i = 0; i < 10; ++i) arr[i] = line[i]-'0';
        for(int i = 0; i < 9; ++i) {
            for(int j = 0; j < 10-i-1; ++j) {
                arr[j] = (arr[j]+arr[j+1]) % 10;
            }
        }
        cout << arr[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import sys
def side(p1, p2, p3):
  y1,x1=p1
  y2,x2=p2
  y3,x3=p3
  return (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)>0
while 1:
  n=input()
  if n==0:break
  D=sorted([list(input()) for i in range(n)])
  p1=D[0]
  D1=D[:]
  while True:
    c=0
    for p2 in D1:
      if p1==p2:continue
      f=[0,0]
      for p3 in D:
        if p1==p3 or p2==p3: continue
        f[side(p1,p2,p3)]+=1
      if f[0]==0:break
    p1=p2
    D1.remove(p2)
    if p2==D[0]:break
  print len(D1)

Measured memory_bytes: 4284
"use strict";
const main = arg => {
  const input = arg.trim().split('\n');
  const arr = input[0].split(" ").map(Number);
  
  let tLife = arr[0];
  const tPower = arr[1];
  let aLife = arr[2];
  const aPower = arr[3];
  
  let cnt = 0;
  
  while(!(tLife <= 0) && !(aLife <= 0)){
        
        if((cnt % 2) === 0){
    		aLife -= tPower;
        }else{
          	tLife -= aPower;
        }
	cnt++;
  }
  
  if(tLife <= 0){
    console.log("No");
  }else{
    console.log("Yes");
  }
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
a, b = gets.split.map(&:to_i)

ans = a.upto(b).count do |n|
  xa = n / 10_000 % 10
  xb = n % 10

  ya = n / 10 % 10
  yb = n / 1_000 % 10

  xa == xb && ya == yb
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
   #define pb push_back
   #define ff first
   #define ss second
   #define sz(x) (int)x.size()
   #define all(x) begin(x),end(x)
   #define oo(i,a) for (int i = 0; i < (a); i++)
   using namespace std;
   typedef long long ll;
   typedef pair<int, int> pii;
   const char newl = 10;
   const int MOD = 998244353;
   const int N = 100005;
   // set N | watch out for overflow | n == 1 |
   void run(){
      ll x, y, a, b, c;
      cin >> x >> y;
      cin >> a >> b >> c;
      vector<ll> p(a),q(b),r(c);
      for (int i = 0; i < a; i++){
         cin >> p[i];
      }
      for (int i = 0; i < b; i++){
         cin >> q[i];
      }
      for (int i = 0; i < c; i++){
         cin >> r[i];
      }
      sort(all(p)); reverse(all(p));
      sort(all(q)); reverse(all(q));
      sort(all(r)); reverse(all(r));
      vector<int> d;
      for (int i = 0; i < x; i++) d.pb(p[i]);
      for (int i = 0; i < y; i++) d.pb(q[i]);
      for (int i = 0; i < c; i++) d.pb(r[i]);
      sort(all(d)); reverse(all(d));
      ll ans = 0;
      for (int i = 0; i < (x + y); i++){
         ans += d[i];
      }
      cout << ans << newl;
      return ;
   }
   int main(){
      ios_base::sync_with_stdio(0);
      cout.tie(0);cin.tie(0);
      int t = 1;
      // cin >> t;
      for (int tc = 1; tc <= t; tc++) {
         // cout << "Case #" << tc << ": ";
         run();
      }
      return 0;
   }

Measured memory_bytes: 4852
//0064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
	const int N = 80;
	char str[N+1];
	int count = 0;
	while(scanf("%s", str) == 1)
	{
		const char* p = str;
		while( (p = strpbrk(p, "0123456789")) != 0)
		{
			char* nextp;
			int next;
			count += (next = strtol(p, &nextp, 10));
			if(next == 0)
				break;
			p = nextp;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val aList = (1..n).map { readLine()!!.toInt() }
  val sortedAList = aList.sortedDescending()

  for (i in 0 until n) {
    val a = aList[i]
    println(if (a == sortedAList[0]) sortedAList[1] else sortedAList[0])
  }
}



Measured memory_bytes: 61880
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-05-04 00:24
# @url:https://atcoder.jp/contests/abc165/tasks/abc165_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    abn=list(map(int,input().split()))
    a,b,n=abn[0],abn[1],abn[2]
    # print (a,b,n)
    mn=min(b-1,n)
    print (a*mn//b-a*(mn//b))
if __name__ == "__main__":
    main()

Measured memory_bytes: 68460
h,w = map(int,input().split())
a = [input() for _ in range(h)]
ans = 0
queue = []
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            queue.append([i,j])
from collections import deque
queue = deque(queue)
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
dp = [[10**4]*w for _ in range(h)]
for i,j in queue:
    dp[i][j] = 0
while len(queue):
    y,x = queue.popleft()
    d = dp[y][x]
    for dx,dy in dxy:
        nx, ny = x+dx, y+dy
        if not 0<=nx<=w-1:
            continue
        elif not 0<=ny<=h-1:
            continue
        elif dp[ny][nx]<=d+1:
            continue
        dp[ny][nx] = d+1
        queue.append((ny,nx))
print(max([max(dp[row]) for row in range(h)]))

Measured memory_bytes: 150508
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, M, tmp, tmp2;
    cin >> N >> M;
    vector<int> xS(N), yS(N), xG(M), yG(M), ans(N);

    for(int i=0; i<N; i++){
	cin >> xS[i] >> yS[i];
    }
    for(int i=0; i<M; i++){
	cin >> xG[i] >> yG[i];
    }

    for(int i=0; i<N; i++){
	tmp = 2e9;
	for(int j=0; j<M; j++){
	    if(tmp > abs(xS[i]-xG[j])+abs(yS[i]-yG[j])){
		tmp = abs(xS[i]-xG[j])+abs(yS[i]-yG[j]);
		tmp2=j;
	    }
	}
	ans[i] = tmp2;
    }

    for(int i=0; i<N; i++){
	cout << ++ans[i]<< endl;
    }

}


Measured memory_bytes: 256
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    a,b = cin()
    cnt = 0
    for _ in range(a):
        x,y = cin()
        ans = (x**2 + y**2)**(0.5)
        if ans <= b:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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

n = int(input())
S = input().strip().split()

q = int(input())
T = input().strip().split()
count = 0
for i in range(len(T)):
    S.append(T[i])
    j = 0
    while S[j] != T[i]:
            j += 1
    if j != len(S[:-1]):
        count += 1
    S = S[:-1]
print(count)


Measured memory_bytes: 6320
h,w=map(int,input().split())
L=[list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if L[i][j]=='#':
            if L[i][max(j-1,0)]!='#' and L[i][min(j+1,w-1)]!='#' and L[max(i-1,0)][j]!='#' and L[min(i+1,h-1)][j]!='#':
                print('No')
                exit()
print('Yes')

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

using namespace std;

int main() {
    string S;
    cin >> S;

    for (int m = (S.length() - 1) / 2; m >= 1; m--) {
        bool same = true;
        for (int i = 0; i < m; i++) {
            if (S[i] != S[i + m]) {
                same = false;
                break;
            }
        }
        if (same) {
            cout << m * 2 << endl;
            return 0;
        }
    }

    return 1;
}


Measured memory_bytes: 256
import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n,m=map(int,input().split())
F=[0]*(10**5+1)
F[0]=1
for i in range(1,10**5+1):
  F[i]=(F[i-1]*i)%mod

if abs(n-m)>1:
  print(0)
else:
  ans=(F[n]*F[m])%mod
  if n==m:
    ans=(ans*2)%mod
  print(ans)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int N,i;
    cin>>N>>i;
    
    int ans=N-i+1;
    
    cout<<ans<<endl;
  
   
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=20,M=(1<<16)+5,mod=1e9+7;
int pw(int x,int k)
{int ret=1;while(k){if(k&1)ret=(ll)ret*x%mod;x=(ll)x*x%mod;k>>=1;}return ret;}

int n,m,a[N],jc[M],jcn[M],bin[N],f[N][M],ct[M];
bool cmp(int a,int b){return a>b?a:b;}
int C(int n,int m)
{
  if(n<0||m<0||n<m)return 0;
  return (ll)jc[n]*jcn[m]%mod*jcn[n-m]%mod;
}
void init()
{
  bin[0]=1;for(int i=1;i<=16;i++)bin[i]=bin[i-1]<<1;
  int lm=bin[n];
  jc[0]=1;for(int i=1;i<=lm;i++)jc[i]=(ll)jc[i-1]*i%mod;
  jcn[lm]=pw(jc[lm],mod-2);
  for(int i=lm-1;i>=0;i--)jcn[i]=(ll)jcn[i+1]*(i+1)%mod;
  for(int s=1;s<bin[n];s++)
    ct[s]=ct[s^(s&-s)]+1;
  for(int s=0;s<bin[n];s++)ct[s]=(ct[s]&1)?mod-1:1;
}
int main()
{
  scanf("%d%d",&n,&m); init();
  for(int i=1;i<=m;i++)scanf("%d",&a[i]);
  sort(a+1,a+m+1,cmp);
  f[0][0]=1; int lm=bin[n];
  for(int i=1;i<=m;i++)
    for(int s=0;s<bin[n];s++)
      {
	f[i][s]=f[i-1][s];
	for(int j=0;j<n;j++)
	  if(s&bin[j])
	    {
	      int t=s^bin[j];
	      int ml=(ll)f[i-1][t]*C(lm-a[i]-t,bin[j]-1)%mod;
	      f[i][s]=(f[i][s]+(ll)ml*jc[bin[j]])%mod;
	    }
      }
  int ans=0;
  for(int s=0,U=bin[n]-1;s<bin[n];s++)
    {
      ans=(ans+(ll)ct[s]*f[m][s]%mod*jc[U^s])%mod;
    }
  printf("%lld\n",(ll)ans*lm%mod);
  return 0;
}


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

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

	vector<int> r;
	vector<int> g;
	vector<int> b;
	for( int i = 0; i < N; i++ ) {
		if( S[i] == 'R' ) r.push_back( i );
		else if( S[i] == 'G' ) g.push_back( i );
		else if( S[i] == 'B' ) b.push_back( i );
	}
	long long ans1 = 0;
	auto f = [&ans1]( vector<int> &r, vector<int> &g, vector<int> &b )
	{
		for( int i = 0; i < r.size(); i++ ) {
			int j = upper_bound( g.begin(), g.end(), r[i] ) - g.begin();
			for( ; j < g.size(); j++ ) {
				auto it = lower_bound( b.begin(), b.end(), g[j] * 2 - r[i] );
				if( it != b.end() && g[j] - r[i] == *it - g[j] ) ans1++;
			}
		}
	};
	f( r, g, b );
	f( r, b, g );
	f( g, b, r );
	f( g, r, b );
	f( b, r, g );
	f( b, g, r );
	long long ans = r.size() * g.size() * b.size() - ans1;


	cout << ans << endl;
}


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

int main() {
  vector<int> t(3);
  for (int i = 0; i < 3; i++) {
    cin >> t[i];
  }
  cout << accumulate(t.begin(), t.end(), 0) - *max_element(t.begin(), t.end()) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
	
	int m[3];
	long long res = 1000000000000000000LL;
	
	scanf("%d %d %d", &m[0], &m[1], &m[2]);

	for (int i = 0; i < 3; i++) {
		if (m[i] % 2 == 0) {
			res = 0;
		}
		else {
			long long vol = 1;
			for (int j = 0; j < 3; j++) {
				if (j != i) {
					vol *= m[j];
				}
			}
			res = min(res, vol);
		}
	}
	
	printf("%lld\n", res);
	
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int m,d;
    cin >> m >> d;
    int count=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int d_10=j/10;
            int d_1=j%10;
          //  cout<<d_10<<" "<<d_1<<endl;
            if(i==(d_10*d_1)&&d_10>=2&&d_1>=2){
                count++;
               // cout<<"あった"<<endl;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int l[N];
  for(int i=0; i<N; i++){
    cin >> l[i];
  }
  sort(l,l+N);
  int ans = 0;
  for(int i=N-1; i>=2; i--){
    for(int j=i-1; j>=1; j--){
      for(int k=j-1; k>=0; k--){
        if(l[i]>=l[j]+l[k]) break;
        else ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define MAXN 210
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ps push_back
#define SZ(v) int(v.size())
#define FORINT(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) FORINT(i,0,n)
#define INF INT_MAX;
#define ms(v,x) memset(v,x,sizeof(v))
#define gcd(a,b) __gcd(a,b)
using namespace std;

int pd[MAXN][MAXN];
int n,t;
ll soma;

int resp(int a, int b){
	if(~pd[a][b]) return pd[a][b];
	return pd[a][b] = gcd(a,b);
}

int main(){_
	ms(pd,-1);
	cin >> n;
	FORINT(i,1,n+1){
		FORINT(j,1,n+1){
			FORINT(k,1,n+1){
				int a1 = resp(i,j);
				soma+=resp(a1,k);
			}
		}	
	}
	cout << soma << endl;

	return 0;
}

Measured memory_bytes: 3812
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String strDate = sc.next();

    String[] dates = strDate.split("/");
    int month = Integer.parseInt(dates[1]);

    if (month > 4) {
      System.out.println("TBD");
    } else {
      System.out.println("Heisei");
    }
  }
}


Measured memory_bytes: 20692
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[210];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=1000;
	for(int i=0;i<n;i++){
		int cnt=0;
		while(true){
			if(a[i]%2==0){
				a[i]/=2;
				cnt++;
			}
			else break;
		}
		if(ans>cnt)ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  
  string s;
  cin >> s;

  int N = SZ(s);

  int num_b = 0;
  LL ans = 0;

  for (char ch : s) {
    if (ch == 'B')
      ++num_b;
    else
      ans += num_b;
  }
  cout << ans << "\n";
}



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

const int oo = 0x3f3f3f3f;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int mx = -2e9, mn = a[0];
  for (int i = 1; i < n; i++) {
    mx = max(mx, a[i] - mn);
    mn = min(mn, a[i]);
  }
  cout << mx << '\n';
  return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pair;
const int Nmax = 140 * 3, Mod = 1e9 + 7;

int dp[Nmax][Nmax], S[Nmax][Nmax], A[Nmax], B[Nmax];
int N, n, t, i, j, reuniune[Nmax][Nmax];


bool found(int x, int pos)
{
    for(; pos; --pos) if(A[pos] == x) return 1;
    return 0;
}

void compute_sum()
{
    int i, j;
    ll sum = 0;
    memset(S, 0, sizeof(S));

    for(i=N; i; --i)
    {
        sum = 0;
        for(j=N; j;  --j)
            sum += dp[i][j], S[i][j] = (S[i+1][j] + sum) % Mod;
    }
}

int main()
{
 //   freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> N; n = N / 3;
    for(i=1; i<=N; ++i) cin >> A[i];
    for(j=1; j<=N; ++j) cin >> B[j];
    for(i=1; i<=N; ++i) reuniune[i][0] = reuniune[0][i] = i;

    for(i=1; i<=N; ++i)
        for(j=1; j<=N; ++j)
            reuniune[i][j] = reuniune[i][j-1] + !found(B[j], i); /// reuniunea A1, A2, ..., Ai cu B1, B2, ..., Bj

    for(i=1; i<=N+1; ++i)
        for(j=1; j<=N+1; ++j)
            S[i][j] = 1;

    for(t=n; t; --t)
    {
        for(i=1; i<=N; ++i)
            for(j=1; j<=N; ++j)
            {
                if(reuniune[i][j] == reuniune[i-1][j] || reuniune[i][j] == reuniune[i][j-1])
                {
                    /// nu indeplineste conditia 2
                    dp[i][j] = 0;
                    continue;
                }

                dp[i][j] = (ll) (3 * t - reuniune[i][j]) * S[i+1][j+1] % Mod;
            }

        compute_sum();
    }

    ll G = 1;
    for(i=0; i<n; ++i)
        G = G * (3*i + 1) * (3*i + 2) % Mod;

    cout << dp[1][1] * G % Mod << '\n';

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

char A[1010][1010];

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

int main(){
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin>>A[i][j];

  queue<pair<int,pair<int,int>>> Q;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(A[i][j]=='#') Q.push(make_pair(0,make_pair(i,j)));
    }
  }

  int ans=0;
  while(!Q.empty()){
    auto f=Q.front();
    Q.pop();

    int cnt=f.first;
    ans=cnt;
    int x=f.second.first;
    int y=f.second.second;
    for(int i=0;i<4;i++){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(nx<0||ny<0||nx>=H||ny>=W) continue;
      if(A[nx][ny]=='#') continue;
      Q.push(make_pair(cnt+1,make_pair(nx,ny)));
      A[nx][ny]='#';
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 13328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int main()
{
  int i,x;
    rep0(i,5){
      cin>>x;
      if(x!=i+1)break;
    }
    cout << i+1 << endl;
    return 0;
}

Measured memory_bytes: 3452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace abc_061
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = new int[n[0]];
            for (int i = 0; i < n[1]; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a[x[0] - 1]++;
                a[x[1] - 1]++;
            }
            for (int i = 0; i < n[0]; i++)
            {
                Console.WriteLine(a[i]);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13396
/*___________Bismillahir Rahmanir Rahim__________*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define uni(a)           a.erase(unique(a.begin(),a.end()),a.end())
#define vsum(a)          accumulate(a.begin(),a.end(),0)
#define vmax(a)          *max_element(a.begin(),a.end())
#define vmin(a)          *min_element(a.begin(),a.end())
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define yes              cout<<"YES"<<endl
#define no               cout<<"NO"<<endl
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    ll x=(s[0]=='R');
    ll y=(s[1]=='R');
    ll z=(s[2]=='R');
    if(x && y && z) cout<<3<<endl;
    else if((x && y) || (y && z)) cout<<2<<endl;
    else if(x || y || z) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}
/*_________________Alhamdulillah_________________*/


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
bool compare_by(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int x=in();
    if(N*500>=x){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int gcd(int a, int b) {
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    int A, B, C; cin >> A >> B >> C;
    int x;
    
    x = gcd(A, B);
    if (C % x == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

long long int isPrime(long long int num){
    long long int lim, i;
    lim = sqrt(num);
    for(i=2;i<=lim;i++){
        if(num%i == 0)return 0;
    }
    return 1;
}
int main(){
    long long int n, count, number;

    scanf("%lld", &n);
    count = 0;
    while(n--){
        scanf("%lld", &number);
        if(isPrime(number))count++;
    }
    printf("%lld\n", count);

return 0;
}



Measured memory_bytes: 2056
import java.io.*;

class Main{
public static void main(String args[]){
       
       int x;
       String buf;

       try{

       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       buf=br.readLine();

       
       x=Integer.parseInt(buf);
       System.out.println(x*x*x);
       }catch(Exception e){
             
       }
}
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T,class U>istream&operator>>(istream&is,pair<T,U>&P){is>>P.fst;is>>P.snd;return is;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}"<<endl;return o;}
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}

bool solve() {
  int n = read<int>();
  int m = read<int>();
  vector<string> A(n);
  rep(i, n) A[i] = read<string>();

  vector<string> B(m);
  rep(i, m) B[i] = read<string>();

  int d = n - m;
  rep(dy, d+1) {
    rep(dx, d+1) {
      bool ok = 1;
      rep(y, m) {
        int ay = y + dy;
        rep(x, m) {
          int ax = x + dx;
          if (A[ay][ax] != B[y][x]) {
            ok = 0;
            break;
          }
        }
        if (!ok) break;
      }
      if (ok) {
        return true;
      }
    }
  }
  return false;
}

void Main() {
  cout << (solve() ? "Yes" : "No") << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 256
//	@Author : Gaurang_Kothiya

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;
const int MOD2= 998244353;

bool mp[1000007]={0};
m(int,bool) vis;

void Solve()
{
	int n;
	cin>>n;
	int a[n];
	s(int) st;
	
	bool f=true;
	
	f(i,0,n-1)
	{
		cin>>a[i];
		int num=a[i];
		if(!f) continue;
		if(mp[num]==false)
		{
			if(vis[num]) f=false;
			else
			{
				vis[num]=true;
			}
		}
		else
		{
			f(i,2,sqrt(num))
			{
				if(num%i ==0)
				{
					if(vis[i])
					{
						f=false;
						break;
					}
					else
					{
						vis[i]=true;
						while(num%i ==0) num /=i;
						if(num!=1)
						{
							if(vis[num])
							{
								f=false;
								break;
							}
							else
							{
								vis[num]=true;
							}
						}
					}
				}
			}
		}
	}
	
	if(f) cout<<"pairwise coprime";
	else
	{
		int gs=a[0];
		f(i,1,n-1) gs=gcd(gs,a[i]);
		if(gs==1) cout<<"setwise coprime";
		else cout<<"not coprime";
	}
}
 
signed main() 
{
	speed		

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

	mp[1]=true;
	
	f(i,2,1000000)
	{
		if(mp[i]==false)
		{
			for(int j=2*i;j<=1000000;j+=i)
			{
				mp[j]=true;
			}
		}
	}

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 12368
#include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
		int K, N;
		cin >> K >> N;

		int A[200005];
		for (int i=0; i<N; i++){
				cin >> A[i];
		}

		vector<int> distance(N);
		for (int i=0; i<N-1; i++){
				distance[i] = A[i+1] - A[i];
		}
		distance[N-1] = K - A[N-1] + A[0];

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

		cout << K - distance[N-1] << endl;

}


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

int main(){
  int N;
  cin >> N;
  vector<double> v(N);
  int loop;
  for(loop=0;loop<N;loop++){
    cin >> v[loop];
  }
  sort(v.begin(),v.end());
  for(loop=0;loop<N-1;loop++){
    v[loop+1]=(v[loop]+v[loop+1])/2;
  }
  cout << v[N-1] << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder_b_085
{
    class _02
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] d = new int[N];
            int answer = 1;

            for(int i = 0; i<N; i++)
            {
                d[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(d);
            int Step = d[0];

            for (int i = 1; i<N; i++)
            {
                if (d[i] > Step)
                {
                    answer++;
                    Step = d[i];
                }
            }

            Console.WriteLine(answer.ToString());

        }
    }
}


Measured memory_bytes: 11092
// 1_5_A
#include<stdio.h>

int main(void)
{
	int height, width, H, W;
	scanf("%d %d", &H, &W);
	if(H == 0 && W == 0){
		return 0;
	}

	for(height = 0; height < H; height++){
		for(width = 0; width <W; width++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");

	main();
}

Measured memory_bytes: 572
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	boolean f1 = true,f2 = true;
	int indexC = -1,indexF = -2;
	for ( int i = 0; i < S.length(); i++ ) {
	    if (f1 && S.charAt(i) == 'C') {
		indexC = i;
		f1 = false;
	    } else if ( !f1 && S.charAt(i) == 'F' ) {
		indexF = i;
		f2 = false;
	    }
	}
	if ( !f1 && !f2 && indexC < indexF ) System.out.println("Yes");
	else System.out.println("No");
    }
}


Measured memory_bytes: 23764
n = int(input())
dp = [n] * (n+1)
dp[0] = 0
# 貰うdp -- dp[i] に遷移を集める
for i in range(1,n+1):
    pow6 = 1
    while pow6 <= i: # i円を実現できるか、を回す
        dp[i] = min(dp[i],dp[i-pow6] + 1)
        pow6 *= 6
    pow9 = 1
    while pow9 <= i:
        dp[i] = min(dp[i], dp[i-pow9] + 1)
        pow9 *= 9
print(dp[n])


Measured memory_bytes: 42220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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;}

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    int a,K;
    ll sum=0;
    priority_queue<int> ABC;
    rep(i,3){
        cin>>a;
        ABC.push(a);
    }
    cin>>K;
    rep(i,K){
        a=ABC.top()*2;
        ABC.pop();
        ABC.push(a);
    }
    rep(i,3){
        sum+=ABC.top();
        ABC.pop();
    }
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        for (int i = L; i <= R; i++) {
            if (i%d == 0) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35680
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

unordered_map<int, int> prime(int n) {
    unordered_map<int, int> ans;
    for (int x = 2; x * x <= n; x++) {
        int cnt = 0;
        while (1) {
            if (n % x == 0) {
                n /= x;
                cnt++;
            }
            else {
                if (cnt > 0) {
                    ans[x] = cnt;
                }
                break;
            }
        }
    }
    if(n > 1)
        ans[n]++;
    return ans;
}

int calc(vint& nums, int a, int b) {
    int ans = 0;
    rep(i, nums.size()) {
        rep(j, nums.size()) {
            if (i == j) continue;
            if (nums[i] + 1 >= a && nums[j] + 1 >= b) ans++;
        }
    }
    return ans;
}

int calc(vint& nums, int a) {
    int ans = 0;
    rep(i, nums.size()) {
        if (nums[i] + 1 >= a) ans++;
    }
    return ans;
}

int calc2(vint& nums, int a, int b, int c) {
    int ans = 0;
    rep(i, nums.size()) {
        REP(j, i + 1, nums.size()) {
            if (i == j) continue;
            rep(k, nums.size()) {
                if (i == k) continue;
                if (j == k) continue;
                if (nums[i] + 1 >= a && nums[j] + 1 >= b && nums[k] + 1 >= c) ans++;
            }
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    unordered_map<int, int> pmap;
    REP(x, 2, N + 1) {
        auto pmap_tmp = prime(x);
        for (auto& p : pmap_tmp) {
            pmap[p.first] += p.second;
        }
    }
    vint nums(pmap.size());
    int i = 0;
    for(auto &p : pmap) {
        nums[i] = p.second;
        i++;
    }
    ll ans = 0;
    ans += calc(nums, 75);
    ans += calc(nums, 25, 3);
    ans += calc(nums, 15, 5);
    ans += calc2(nums, 5, 5, 3);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int N;

long long int B[105];
long long int A[105];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N - 1; i++) {
		cin >> B[i];
	}

	A[1] = B[1];

	for (int i = 2; i <= N - 1; i++) {
		A[i] = min(B[i], B[i - 1]);
	}

	A[N] = B[N - 1];

	long long int ans = 0;

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

	/*for (int i = 1; i <= N; i++) {
		cout << A[i] << endl;
	}*/

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;

int main() {
    int n; cin >> n;
    long long a, b; cin >> a >> b;
    vector<int> x(n);
    for (auto &xi: x) cin >> xi;
    min_heap<int> pq;
    for (int i = 1; i < n; i++) pq.emplace(x[i] - x[i - 1]);
    long long sum = 0;
    long long mi = b * (n - 1) + a * sum;
    for (int k = n - 2; k >= 0; k--) {
        sum += pq.top(); pq.pop();
        mi = min(mi, b * k + a * sum);
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return x < p.x;
    }
    int x, h;
};

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

    int n, d, a;
    cin >> n >> d >> a;

    d = min(d * 2 + 1, 1 << 30);

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int x, h;
        cin >> x >> h;
        p[i] = { x, (h + a - 1) / a };
    }
    sort(p.begin(), p.end());

    vector<int> s(n + 1, 0);
    int t = 0;
    int j = 0;
    ll r = 0;
    for (int i = 0; i < n; i++) {
        t -= s[i];
        int h = p[i].h - t;
        if (h <= 0) continue;

        while (j < n && p[j].x < p[i].x + d) j++;
        s[j] += h;
        t += h;
        r += h;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

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

  string s;
  cin >> s;

  if(s.substr(0, n/2) == s.substr(n/2, n/2) && n > 1 && n % 2 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

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

long long gcd(long long x, long long y){
    if(x < y) swap(x, y);
    if(y == 0)return x;
    return gcd(x%y, y);
}

int main(){
    long long N;
    cin >> N;

    vector<long long> A(N);
    for(long long i = 0; i < N; i++){
        cin >> A[i];
    }

    vector<long long> L(N);
    for(long long i = 0; i < N; i++){
        if(i == 0){
            L[i] = A[i];
        }else{
            L[i] = gcd(L[i-1], A[i]);
        }
    }
    vector<long long> R(N);
    for(long long i = N-1; i >= 0; i--){
        if(i == N-1){
            R[i] = A[i];
        }else{
            R[i] = gcd(A[i], R[i+1]);
        }
    }

    long long maxv = 0;
    long long cur = 0;
    for(long long i = 0; i < N; i++){
        if(i == 0){
            cur = R[1];
        }else if(i == N-1){
            cur = L[N-2];
        }else{
            cur = gcd(L[i-1], R[i+1]);
        }
        maxv = max(maxv, cur);
    }
    
    cout << maxv << endl;

    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int s , n;

int main()
{
    _FastIO;
    cin >> n;
    int m = n;
    while(n){
        s += (n % 10);
        n /= 10;
    }
    if(m % s == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
using namespace std;

int main() {

	int a[5];
	for(int i=0; i<5; i++){
		cin >> a[i];
	}
	int time = 0;
	int over = 99;
	for(int i=0; i<5; i++){
		int cur = a[i];
		while(cur%10 != 0){
			cur += 1;
		}
		a[i] = a[i] - a[i]/10*10;
		if(a[i] != 0){
			over = min(over, a[i]);
		}
		time += cur;
	}
	if(over != 99){
		time = time-10+over;
	}
	cout << time;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
    int n;
    cin >> n;
    string s, pre = "", post = "";
    cin >> s;
    int tmp = 0;
    rep(n){
        if(s[i] == '('){
            tmp++;
        }else{
            if(tmp > 0){
                tmp--;
            }else{
                pre += '(';
            }
        }
    }
    while(tmp > 0){
        post += ')';
        tmp--;
    }
    cout << pre << s << post;
}


Measured memory_bytes: 256
Q, H, S, D = map(int, input().split())
N = int(input())
ans = 0
if N % 2 == 0:
    ans = min(4*N*Q, 2*N*H, N*S, N*D//2)
else:
    ans += min(4*(N-1)*Q, 2*(N-1)*H, (N-1)*S, (N-1)*D//2)
    ans += min(4*Q, 2*H, S)

print(ans)

Measured memory_bytes: 38384
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val ans = IntArray(n) { -1 }

    for (i in 1..m) {
        val (s, c) = readLine()!!.split(' ').map(String::toInt)
        if ((n > 1 && s == 1 && c == 0) || (ans[s - 1] != -1 && ans[s - 1] != c)) {
            println(-1)
            return
        }
        ans[s - 1] = c
    }
    if (ans[0] == -1 && n > 1) ans[0] = 1
    if (ans[0] == -1 && n == 1) ans[0] = 0
    for (i in 1 until n)
        if (ans[i] == -1) ans[i] = 0
    println(ans.joinToString(""))
}

Measured memory_bytes: 38256