akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	s := sc.Next()
	mp := map[byte]bool{}
	for _, v := range s {
		mp[byte(v)] = true
	}
	if len(mp) == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main(String[] args) {
    // たこ焼きのパラメータ取得用リスト
    List<Integer> takoyakiParam = new ArrayList<Integer>();
    
    // 回復量の合計
    int sum = 0;
    
    Scanner scanner = new Scanner(System.in);
    // 指定されたたこ焼きの個数を格納する
    int cnt = scanner.nextInt();
    
    // たこ焼きのパラメータをリストに格納する
    for (int i = 1; i <= cnt; i++){
      int num = scanner.nextInt();
      takoyakiParam.add(num);
    }
    
    // 体力の回復量の計算
    for (int x = 0; x < takoyakiParam.size(); x++){
      for (int y = 0; y < takoyakiParam.size(); y++){
        if(x >= y){
          continue;
        }
        sum += (takoyakiParam.get(x) * takoyakiParam.get(y));
      }
    }
    // 回復量の出力
  System.out.println(sum);
  }
}

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

int main() {
  ll n,d,ans = 0;
  cin >> n >> d;
  d *= d;
  rep(i,0,n){
    ll a,b;
    cin >> a >> b;
    if(d >= a*a+b*b) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include<map>
#include<stack>
#define T long long


int main(){
	std::string s;
	int k;
	std::cin >> k;
	std::cin.ignore();
	std::getline(std::cin,s);
	if(s.size()>k){
		for(int i=0;i<k;i++){
			std::cout << s[i];
		}
		std::cout <<"..."<< std::endl;
	}else{
		std::cout << s << std::endl;
	}
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int H;
void maxHeapify(int A[],int i)
{
    int l=2*i,r=2*i+1,largest=i;
    if(l<=H && A[i]<A[l])
        largest=l;
    if(r<=H && A[largest]<A[r])
        largest=r;
    int temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    if(largest!=i)
        maxHeapify(A,largest);
}
int main()
{
    int heap[500001];
    cin>>H;
    for(int i=1;i<=H;i++)
        cin>>heap[i];
    for(int i=H/2;i>0;i--)
        maxHeapify(heap,i);
    int isn=0;
    for(int i=1;i<=H;i++)
    {
        cout<<' ';
        cout<<heap[i];
    }
    cout<<endl;
    return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int mode = 0;
    int prev = A[0];
    int ans = 1;
    for (int i = 1; i < N; i++) {
        if (mode == 0) {
            if (prev < A[i]) mode = 1;
            if (prev > A[i]) mode = -1;
        } else if (prev < A[i] && mode == -1) {
            ans++;
            mode = 0;
        } else if (prev > A[i] && mode == 1) {
            ans++;
            mode = 0;
        }
        prev = A[i];
    }
    cout << ans << endl;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}


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


#define ll long long int 
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define PB push_back
#define F first
#define S second

ll value(vector<pair< ll , ll > > &v,ll w, ll n, ll index,vector< vector< ll > > &dp){
     if(index == n || w==0 ){
     	return 0;
     }

     if(dp[w][index]>-1) return dp[w][index];
     
     ll one = 0,two=0;
     
     if(v[index].first<=w){
       one = v[index].second +  value(v,w-v[index].first,n,index+1,dp);
     }

     two = value(v,w,n,index+1,dp);

     dp[w][index] = max(one,two);

     return dp[w][index];
}

int main(){
	 
	 ll n,w;

	 cin>>n>>w;

	 vector< pair< ll , ll > > v(n);
     

	 for(ll i=0;i<n;i++){
	 	cin>>v[i].first>>v[i].second;
	 } 

	 std::vector< std::vector<  ll > > dp(w+1,vector< ll > (n,-1));

	 for(int i=0;i<w+1;i++){
	 	for(int j=0;j<n;j++){
	 		dp[i][j]=-1;
	 	}
	 }

	 ll val = value(v,w,n,0,dp);

	 cout<<val<<endl;

	return 0;
}

Measured memory_bytes: 85244
h1, m1, h2, m2, k = map(int, input().split())
h_time = h2 - h1
if m1 > m2:
    h_time -= 1
    m_time = 60 - m1 + m2
else:
    m_time = m2 - m1

study_time = (h_time * 60 + m_time) - k
if study_time <= 0:
    print(0)
else:
    print(study_time)


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

int main(){
  static int n,k,a[200010];
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  
  for(int i=k;i<n;i++){
    if(a[i-k]<a[i])puts("Yes");
    else puts("No");
  }
}

Measured memory_bytes: 4540
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define bfo(i,v,u) for(int i=BB[v],u=B[i][1];i;u=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(b))
template<typename T> bool chkmin(T &a,const T &b) {return b<a?a=b,1:0;}
template<typename T> bool chkmax(T &a,const T &b) {return b>a?a=b,1:0;}
using namespace std;
typedef long long ll;
int read(){int n=0,p=1;char ch;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=2e5+5,mo=1e9+7;
int n,a[N],lst[N];
ll c[N],f[N];
int main()
{
	n=read();
	a[1]=read();
	f[1]=1;
	lst[a[1]]=1;
	fo(i,2,n)
	{
		a[i]=read();
		f[i]=f[i-1];
		if(a[i]!=a[i-1]) f[i]=(f[i]+f[lst[a[i]]])%mo;
		lst[a[i]]=i;
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

int S[100], top;

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}


int main() {
    int a, b;
    top = 0;
    char s[100];


    while (true) {
        cin >> s;
        if (cin.eof()) break;

        if (s[0] == '+') {
            b = pop();
            a = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            b = pop();
            a = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }

    }

    cout << pop() << endl;


}

Measured memory_bytes: 3092
#!/usr/bin/env python3
from bisect import bisect_left
from heapq import heappush

def cal_divisors(N):
    divisors = []
    i = 1
    while i*i <= N:
        if N % i == 0:
            divisors.append(i)
            if i != N // i:
                divisors.append(N//i)
        i += 1
    divisors.sort()
    return divisors

def main():
    N, M = map(int, input().split())
    ans = cal_divisors(M)
    # print(ans)
    i = bisect_left(ans,N)
    print(M//ans[i])

if __name__ == "__main__":
    main()

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

using namespace std;

int score[100];
int ans[100];
vector<int> rnk[301];

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

	for (int i = 0; i < (n*(n-1)/2); ++i) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		a--;b--;
		if (c > d) {
			score[a] += 3;
		} else if (d > c) {
			score[b] += 3;
		} else {
			score[a]++; score[b]++;
		}
	}

	for (int i = n - 1; i >= 0; --i) {
		rnk[score[i]].push_back(i);
	}

	int r = 1;

	for (int i = 300; i >= 0; --i) {
		int cnt = 0;
		while (rnk[i].size()) {
			ans[rnk[i].back()] = r;
			rnk[i].pop_back();
			cnt++;
		}
		r += cnt;
	}

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

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

int main() {
	int n, a[110], tmp, alice=0, bob=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else {
			bob += a[i];
		}
	}
	cout << alice - bob << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int count;
  
  for(int a=0;a<=A;a++){
    for(int b=0;b<=B;b++){
      for(int c=0;c<=C;c++){
        int total = 500*a+100*b+50*c;
        if(total==X) count++;
      }
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,d,x,a,chocolate=0;  cin>>n>>d>>x;
    for(int i=0;i<n;i++){
        cin>>a;
        chocolate+=(d-1)/a;
    }
    cout<<chocolate+x+n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  vector<string> nums;
  for (int i=0; i<s.length(); i++) nums.push_back(s.substr(i, 1));
 
  long res = 0;
  long tmp;
  long digit;
  long sum = 0;
  string ssum = "";
  for (int i=0; i< (1 << (nums.size() - 1)); i++) { // bit演算なので条件
    sum = 0;
    tmp = 0;
    digit = 1;
    ssum = nums[0];
    for (int k=0; k<nums.size()-1; k++) {
      if (i & (1 << k)) { // 見てるbitと現在見てる桁に+がついているとき
        sum +=  stol(ssum);
        ssum = "";
      }
      ssum += nums[k+1];
    }
    sum += stol(ssum);
    res += sum;
  }
 
  cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
minus = 0
mi = 10**10
ans = 0
for i in range(n):
    if a[i] < 0:minus+=1
    mi = min(mi,abs(a[i]))
    ans += abs(a[i])
if minus%2 == 0:
    print(ans)
else:
    print(ans-2*mi)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    if (A == B &&  B == C){
        if (A % 2 == 1){
            cout << 0 << endl;
        }
        else{
            cout << -1 << endl;
        }
    }
    else{
        ll count = 0;
        while(true){
            if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
                break;
            }
            else{
                ll P = (B + C) / 2;
                ll Q = (C + A) / 2;
                ll R = (A + B) / 2;
                A = P;
                B = Q;
                C = R;
                count++;
            }
        }
        cout << count << endl;
    }
}

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

vector<int> dp(3), new_dp(3);
int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		for(int j = 0, x; j < 3; ++j) {
			cin >> x;
			for(int c : {1, 2})
				new_dp[j] = max(new_dp[j], x + dp[(j + c) % 3]);
		}
		dp = new_dp;
	}
	cout << max(new_dp[0], max(new_dp[1], new_dp[2]));
	
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
long long N, A, B , C, D;
map<long long, long long> m;
long long dfs(long long a){
    if(a == 0) return m[0] = 0;
    if(a == 1) return m[a] = D;
    if(m.count(a)) return m[a];
    long long res = 1e18;
    if(a < res / D) res = a * D;
    long long l2 = a/2*2, r2 = (a + 1) / 2*2;
    long long l3 = a/3*3, r3 = (a + 2) / 3*3;
    long long l5 = a/5*5, r5 = (a + 4) / 5*5;
    res = min(res, min(llabs(a - l2) * D + A + dfs(l2 / 2), llabs(a - r2) * D + A + dfs(r2 / 2)));
    res = min(res, min(llabs(a - l3) * D + B + dfs(l3 / 3), llabs(a - r3) * D + B + dfs(r3 / 3)));
    res = min(res, min(llabs(a - l5) * D + C + dfs(l5 / 5), llabs(a - r5) * D + C + dfs(r5 / 5)));
    m[a] = res;
    return res;
}
int main(){
    long long T;
    cin >> T;
    for(int  i= 0; i < T; i++){
        cin >> N >> A >> B >> C >> D;
        m.clear();
        dfs(N);
        cout << m[N] << endl;
    }
}

Measured memory_bytes: 4332
#include <stdio.h>

int main(void)
{
    int n;
    int i , j;
    int u , k , v;
    scanf("%d" , &n);
    
    /*隣接行列*/
    int A[110][110];
    
    for(i = 0 ; i < n ; i++) {
        scanf("%d %d" , &u , &k);
        
        for(j = 1 ; j <= k ; j++) {
            scanf("%d" , &v);
            /*頂点1 なら配列0に入れたいので-1*/
            /*A[頂点][隣接点]*/
            A[u - 1][v - 1] = 1;
        }
    }
    
    for(i = 0 ; i < n ; i++) {
        for(j = 0 ; j <= n - 2 ; j++) {
            printf("%d " , A[i][j]);
        }
        printf("%d\n" , A[i][n - 1]);
    }
    
    return 0;
}



Measured memory_bytes: 2136
n = int(input())
a = list(map(int,input().split()))
a_list = [i for i in a if i%2==0]
flag = True
for i in a_list:
    if i%3==0 or i%5==0:
        flag = True
    else:
        flag = False
        break
if flag:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
//#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);

using Edges = std::vector<std::vector<int>>;

void dfs1(int i, const Edges& edges, std::vector<int>& ans, std::vector<bool>& memo) {
    memo[i] = true;
    for(auto v: edges[i]) {
        if(!memo[v]) dfs1(v, edges, ans, memo);
    }
    ans.push_back(i);
}

void dfs2(int i, const Edges& redges, std::vector<int>& ans, int cnt) {
    ans[i] = cnt;
    for(auto v: redges[i]) {
        if(ans[v] < 0) dfs2(v, redges, ans, cnt);
    }
}

int main() {
    int V, E;
    std::cin >> V >> E;
    Edges edges(V);
    Edges redges(V);
    while(E--){
        int s, t;
        std::cin >> s >> t;
        edges[s].push_back(t);
        redges[t].push_back(s);
    }
    std::vector<bool> memo(V, false);
    std::vector<int> topoSorted;
    topoSorted.reserve(V);
    for(int i = 0; i < V; ++i) {
        if(!memo[i])dfs1(i, edges, topoSorted, memo);
    }

    std::vector<int> ans(V, -1);
    int cnt = 0;
    for(auto itr = rbegin(topoSorted); itr != rend(topoSorted); ++itr) {
        if(ans[*itr] < 0) dfs2(*itr, redges, ans, cnt++);
    }

    int Q;
    std::cin >> Q;
    while(Q--) {
        int u, v;
        std::cin >> u >> v;
        std::cout << (ans[u] == ans[v]) << '\n';
    }
    std::cout << std::flush;

    return 0;
}



Measured memory_bytes: 4916
import sys
N = int(input())
S = input()
s1 = S[:N//2]
s2 = S[N//2:]
if N%2 == 1:
    print("No")
    sys.exit()
for i in range(N//2):
    if not s1[i] == s2[i]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class T>void sort(vector<T> &v){sort(v.begin(),v.end());}

int h,w;
int ptoi(int i,int j){return w*i+j;}

int main(){
	cin>>h>>w;
	vector<vector<char>> s(h,vector<char>(w));
	for(int i=0;i<h*w;i++)cin>>s[i/w][i%w];

	vector<vector<int>> cost(h*w,vector<int>(h*w, 100000000));
	for(int i=0;i<h*w;i++)cost[i][i]=0;
	
	for(int i=0;i<h;i++)for(int j=0;j<w;j++){
		if(s[i][j]=='#')continue;
		if(i-1>=0 && s[i-1][j]=='.')cost[ptoi(i,j)][ptoi(i-1,j)]=1;
		if(j-1>=0 && s[i][j-1]=='.')cost[ptoi(i,j)][ptoi(i,j-1)]=1;
		if(i+1< h && s[i+1][j]=='.')cost[ptoi(i,j)][ptoi(i+1,j)]=1;
		if(j+1< w && s[i][j+1]=='.')cost[ptoi(i,j)][ptoi(i,j+1)]=1;
	}
	
	set<int> road;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(s[i][j]=='.')road.insert(ptoi(i,j));

	for(int k=0;k<h*w;k++){if(road.count(k)==0)continue;
	for(int i=0;i<h*w;i++){if(road.count(i)==0)continue;
	for(int j=0;j<h*w;j++){if(road.count(j)==0)continue;
		cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
	}}}
	
		
	
	int ans=0;
	for(auto i:road)for(auto j:road)ans=max(ans,cost[i][j]);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 896
#include<stdio.h>

int main(void)
{
int n,d,i=0;

scanf("%d",&n);
scanf("%d",&d);


d = 1 + d * 2;

for(;;)
{
n = n-d;
i++;
if(n<=0) break;
}
printf("%d\n",i);
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
#define N 1005
#define M 30005
#define ll long long 
#define INF 0x3f3f3f3f
#define MOD 10000000
inline int rd()
{
	int f=1ll,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-f;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
int n;
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//ios::sync_with_stdio(false);
	n=rd();
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			if(i*j==n)
			{
				puts("Yes");
				return 0;
			}
	puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int gcd(int x, int y) {
  int M = (x > y) ? x : y;
  int m = (x <= y) ? x : y;
  if (m == 0)
    return M;
  return gcd(m, M%m);
}

int main() {
  int x, y;
  std::cin >> x >> y;
  std::cout << gcd(x, y) << std::endl;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n ,a ,b ,c ,d ,e;
long long ans,minn=1e18;
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d,&e);
	minn=min(a,min(b,min(c,min(d,e))));
    ans=(n-1)/minn+1 + 4;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  string Sa = "";
  string Sb = "";

  for(int i; i < b; i++) {
    Sa += to_string(a);
  }
  for(int i; i < a; i++) {
    Sb += to_string(b);
  }

  if (Sa >= Sb) {
    cout << Sb << endl;
  } else {
    cout << Sa << endl;
  }
  return 0;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(20000000)
from collections import defaultdict
n = int(input())

abc = []
edges = defaultdict(lambda: [])
for _ in range(n-1):
    a, b, c = map(int, input().split())
    edges[a].append([b, c])
    edges[b].append([a, c])

q, k = map(int, input().split())

# k からの距離を求める
dist = [-1 for _ in range(n+1)]
is_checked = [False for _ in range(n+1)]
def dfs(num, cur_dist):
    global dist, is_checked
    for next_num, d in edges[num]:
        if not is_checked[next_num]:
            is_checked[next_num] = True
            dist[next_num] = cur_dist + d
            dfs(next_num, cur_dist + d)
dist[k] = 0
is_checked[k] = True
dfs(k, 0)

ans = []
for _ in range(q):
    x, y = map(int, input().split())
    ans.append(str(dist[x] + dist[y]))
print("\n".join(ans))

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

void postorder(int pre[], int in[], int post[], int n)
{
    if(n<=0) return;
    post[n-1]=pre[0];
    int i;
    for(i=0; in[i]!=pre[0]; i++);
    postorder(pre+1, in, post, i);
    postorder(pre+i+1, in+i+1, post+i, n-i-1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int pre[40], in[40];
    int post[40]={};
    int n;
    cin>>n;
    for(int i=0; i<n; i++) cin>>pre[i];
    for(int i=0; i<n; i++) cin>>in[i];
    postorder(pre, in, post, n);
    cout<<post[0];
    for(int i=1; i<n; i++) cout<<' '<<post[i];
    cout<<'\n';
    return 0;
}

Measured memory_bytes: 1196
# coding:utf-8

import sys
from collections import Counter


input = sys.stdin.readline
INF = float('inf')


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


N = int(input())
A = inpl()

S = [0]
for i in range(N):
    S.append(S[-1] + A[i])

cnt_num = Counter(S)
ans = 0
for num in cnt_num.keys():
    cnt = cnt_num[num]
    if cnt < 2:
        continue
    ans += cnt * (cnt - 1) // 2

print(ans)


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,M;
    cin>>N>>M;
    vector<vector<pair<int,int>>> G(N);
    REP(i,M) {
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;c *= -1;
        G[a].pb(make_pair(b,c));
    }

    vector<ll> dist(N,INF);
    dist[0] = 0;

    REP(i,N-1) {
        REP(j,N) {
            REP(k,G[j].size()) {
                ll a = j , b = G[j][k].fi , c = G[j][k].se;
                if (dist[a] == INF) continue;
                if (dist[b] > dist[a] + c) {
                    dist[b] = dist[a] + c;
                }
            }
        }
    }

    ll ans = dist[N-1];

    vector<bool> nega(N,false);

    REP(i,N) {
        REP(j,N) {
            REP(k,G[j].size()) {
                ll a = j , b = G[j][k].fi , c = G[j][k].se;
                if (dist[a] == INF) continue;
                if (dist[b] > dist[a] + c) {
                    dist[b] = dist[a] + c;
                    nega[b] = true;
                }
                if (nega[a]) {
                    nega[b] = true;
                }
            }
        }
    }
    if (nega[N-1]) cout<<"inf"<<endl;
    else cout<<-ans<<endl;
    return 0;
}

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

#define ll long long

using namespace std;

int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;
    int ans = n*2;
    for(int i = 0;i < n;i++){
        if(s[i] == t[0]){
            bool flag = true;
            for(int j = 0;j < n - i;j++){
                if(s[i+j] != t[j]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                ans = i + n;
                break;
            }
        }        
    }

    cout << ans << endl;

	return 0;
}        


Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,k;
int arr[102];
int dp[2][100005];
int presum[100005];
int mod=1e9+7;
int32_t main() 
{
    IOS;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[n%2][0]=1;
    for(int pos=n-1;pos>=0;pos--)
    {
        for(int i=1;i<=k+1;i++)
            presum[i]=presum[i-1]+dp[(pos+1)%2][i-1];
        for(int left=0;left<=k;left++)
        {
            int ans=0;
            //sum from max(0,left-arr[pos]) to left
            // for(int i=0;i<=min(left,arr[pos]);i++)
            //     ans+=dp[(pos+1)%2][left-i];
            ans=presum[left+1]-presum[max(0ll,left-arr[pos])];
            dp[pos%2][left]=ans%mod;
        }
    }
    print(dp[0][k]);
}


Measured memory_bytes: 5968
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

typedef long long int ll;
int n;
string s;
int main(void){
	cin >> n;
	cin >> s;
	int cnt = 0;
	for(int i=0;i<s.size();i++){
		cnt += (s[i]=='R') ? 1 : -1;
	}
	cout << ((cnt>0) ? "Yes" : "No") << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
char hoge[3][3]={0},var[3]={0};
scanf("%s",hoge[0]);
scanf("%s",hoge[1]);
scanf("%s",hoge[2]);

var[0]=hoge[0][0];
var[1]=hoge[1][1];
var[2]=hoge[2][2];
printf("%s",var);
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
long double PI= 3.141592653589793238463;
const int N = 1e5+5;
const int MOD = 1e9+7;

ll a[100005];
ll dp[100005];
int n,k;

void D(int x)
{
    for(int i=x;i<n;i++){
        for(int j=1;j<=2;j++){
            dp[i]=min(abs(a[i]-a[i-j])+dp[i-j],dp[i]);
        }
    }
}

int main()
{
//int t; cin>>t;

//while(t--){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) {
        dp[i]=N*N;
    }
    dp[0]=0;
    dp[1]=(abs(a[0]-a[1]));
    D(2);
//for(int i=0;i<n;i++) {
//        cout<<dp[i]<<' ';
//    }
    cout<<dp[n-1];

//}


    return 0;
}



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

int main(){
  int K,T;
  cin >> K >> T;
  vector<pair<int,int> > vp(T);
  for(int i=0;i<T;i++){
    int a;
    cin >> a;
    vp.at(i)=make_pair(a,i);
  }
  sort(vp.begin(),vp.end(),greater<pair<int,int> >());
  int ans=0;
  int pre=vp.at(0).second;
  vp.at(0).first--;
  if(vp.at(0).first==0){
    vp.erase(vp.begin());
  }
  if(vp.empty()){
    cout << ans << endl;
    return 0;
  }
  for(int i=0;;i++){
    bool flag=false;
    if(vp.empty()){
      break;
    }
    for(int j=0;j<vp.size();j++){
      if(vp.at(j).second!=pre){
        vp.at(j).first--;
        pre=vp.at(j).second;
        flag=true;
        if(vp.at(j).first==0){
          vp.erase(vp.begin()+j);
        }
        break;
      }
    }
    if(!flag){
      ans+=vp.front().first;
      break;
    }
    sort(vp.begin(),vp.end(),greater<pair<int,int> >());
  }
  cout << ans << endl;
  return 0;
}


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

vector<ll> xs, ys;
vector<int> no_rails;

int main() {
    int n;
    cin >> n;
    ll powthree = 1;
    vector<ll> x(n), y(n), p(n);
    rep(i, n) {
        powthree *= 3;
        cin >> x[i] >> y[i] >> p[i];
    }
    vector<ll> ans(n + 1, 1e18);
    for (int i = 0; i < powthree; i++) {
        xs.clear();
        ys.clear();
        no_rails.clear();
        int info = i;
        for (int j = 0; j < n; j++) {
            if (info % 3 == 0) no_rails.push_back(j);
            if (info % 3 == 1) xs.push_back(x[j]);
            if (info % 3 == 2) ys.push_back(y[j]);
            info /= 3;
        }
        ll score = 0;
        for (int j : no_rails) {
            ll dist = min(abs(x[j]), abs(y[j]));
            for (ll xi : xs) dist = min(dist, abs(xi - x[j]));
            for (ll yi : ys) dist = min(dist, abs(yi - y[j]));
            score += p[j] * dist;
        }
        ans[xs.size() + ys.size()] = min(ans[xs.size() + ys.size()], score);
    }

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


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

#ifndef __SOULTCH
#define endl '\n'
#define debug(x) 
#else
#define debug(x) cout << " [+] " << #x << " = " << x << endl
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << pai.first << ' ' << pai.second;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> s) {
    for (T p : s) cout << p << ' ';
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> s) {
    for (auto p : s) cout << '(' << p << ") ";
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N, Q;
char str[200001];
pair<char, int> query[200001];
int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> Q >> str;
    rep(i, Q){
        char t[2];
        cin >> t; query[i].fi = t[0];
        cin >> t; query[i].se = (t[0]=='R'?1:-1);
    }

    int L, R;
    int l = -1, r = N-1;

    while(l < r) {
        int mid = (l+r+1)/2;
        debug(mp(l, r));
        bool f = true;
        int p = mid;
        rep(i, Q) {
            if (query[i].fi == str[p]) p += query[i].se;
            if (p >= N) break;
            if (p < 0) {f = false; break;}
        }

        if (f) r = mid-1;
        else l = mid;
    }
    L = l;
    debug(L);

    l = 0, r = N;
    while(l < r) {
        int mid = (l+r)/2;
        bool f = true;
        int p = mid;
        rep(i, Q) {
            if (query[i].fi == str[p]) p += query[i].se;
            if (p >= N) {f = false; break;}
            if (p < 0) break;
        }
        
        if (f) l = mid+1;
        else r = mid;
    }
    R = l;
    debug(R);
    
    cout << R-L-1 << endl;
}






Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;
#define mod 1000000007
lint fast_sikis(lint a, lint b){
    if(b==0)
        return 1;
    lint x = fast_sikis(a,b/2);
    x=x*x%mod;
    if(b&1) 
        x = x*a%mod;
    
    return x;

}
lint fak(lint a){
    lint sonuc = 1;
    for(lint i=1; i<=a; i++){
        sonuc = (sonuc*i) % mod;
    }
    return sonuc;
}
int main(){
    lint x,y;
    cin >> x >> y;
    if(x>2*y || y>2*x || (2*y-x) % 3 || (2*x-y) % 3){
        cout << "0";
        return 0;
    }

    lint b=2*y -x;
    lint a = 2*x -y;
    a/=3;
    b/=3;
    cout << fak(a+b) * fast_sikis(fak(a), mod-2) % mod * fast_sikis(fak(b), mod-2) % mod << endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  double l ; 
  cin >> l ;
  double ans = l/3 * l/3 * l/3;
  
 printf("%lf",ans );
    
    
  
  


}


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

int main() {
  int N;
  char c;
  cin >> N;
  bool flag = false;
  for (int i=0;i<N;i++){
    cin >> c;
    if(c=='Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main() {
  char x;
  cin >> x;
  
  cout << char(x+1) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int h = sc.nextInt();
		int w = sc.nextInt();

		char[][] a = new char[h][];
		for (int i = 0; i < h; i++) {
			a[i] = sc.next().toCharArray();
		}

		for (int i = 0; i < h + 2; i++) {
			StringBuilder sb = new StringBuilder();
			sb.append('#');
			if (i == 0 || i == h + 1) {
				for (int j = 0; j < w; j++) {
					sb.append('#');
				}
			} else {
				sb.append(a[i - 1]);
			}
			sb.append('#');

			pr.println(sb);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  ll N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    int x;
    cin >> x;
    ++a[x-1];
  }
  sort(all(a)); // a: frequencies in increasing order.

  vector<int> s(N+1); // s[i]: sum of [0, i). s[0] = 0.
  rep(i, N) {
    s[i+1] = s[i] + a[i];
  }

  ll ans = N, i = N;
  for (int k = 1; k <= N; ++k) {
    // We want to find the boundary of ok and ng.
    while (1) {
      bool ok = [&](int c) {
        while (i >= 0 && a[i-1] >= c) { --i; }
        int sum = c*(N-i) + s[i]; // (N-1)-(i-1) = N-i
        return sum >= c*k;
      }(ans);
      if (ok) { break; }
      --ans;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <list>

using namespace std;

typedef pair<int,int> P;
enum{IN,OUT};

int tosec(int h,int m,int s){
     int t=0;
     t+=s;
     t+=m*60;
     t+=h*60*60;
     return t;
}

int main(){
     int N;
     while(cin>>N,N){
	  list<P> hyou;
	  for(int i=0;i<N;i++){
	       int h1,h2,m1,m2,s1,s2;
	       scanf(" %d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
	       int temp1,temp2;
	       temp1=tosec(h1,m1,s1);temp2=tosec(h2,m2,s2);
	       //cout<<h2<<m2<<s2<<endl;
	       hyou.push_back(P(temp1,OUT));
	       hyou.push_back(P(temp2,IN));
	  }
	  hyou.sort();
	  int current=0,max_line=0;
	  list<P>::iterator itr=hyou.begin();
	  while(itr!=hyou.end()){
	       //cout<<itr->first<<" "<<itr->second<<endl;
	       switch(itr->second){
	       case OUT:
		    current++;
		    max_line=max(current,max_line);
		    break;
	       case IN:
		    current--;
		    break;
	       }
	       itr++;
	  }
	  cout<<max_line<<endl;
     }
}
    

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

vector<vector<int>> v;
int n,m,q;
int ans=0;

void find(vector<int> vv) {
  int tmp=0;
  for (vector<int> r : v) {
    if (vv[r[1]-1]-vv[r[0]-1] == r[2]) tmp+=r[3];
  }
  ans=max(ans, tmp);
}

int main() {
  cin >> n >> m >> q;
  v.resize(q, vector<int>(4));
  for (int i=0; i < q; i++)
    cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
  vector<int> in(n, 1);
  while (true) {
    find(in);
    in[n-1]++;
    if (in[n-1] <= m) continue;
    int id=n-1;
    for (; ~id && in[id]>=m; id--) {}
    if (id == -1) break;
    int s = in[id]+1;
    for (; id < n; id++) in[id] = s;
  }
  cout << ans;
  return 0;
}


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

const int MAXN = 1e5 + 10;
int N;
int cnt = 1, Head[MAXN], Next[MAXN << 1], To[MAXN << 1];
int d[MAXN];
int ans;

inline void add_edge(int x, int y) {
	Next[++cnt] = Head[x], To[cnt] = y, Head[x] = cnt;
}

inline void insert_edge(int x, int y) {
	add_edge(x, y), add_edge(y, x);
}

inline void Dfs(int x, int fa = 0) {
	register int i; int s = 0;
	for(i = Head[x]; i; i = Next[i])
		if(To[i] != fa) {
			Dfs(To[i], x);
			s += d[To[i]] ^ 1;
		}
	if(s == 1) d[x] = 1;
	else if(s > 1) ans = 1;
}

int main() {
	register int i;
	int x, y;
	scanf("%d", &N);
	for(i = 1; i < N; ++i)
		scanf("%d%d", &x, &y),
		insert_edge(x, y);
	Dfs(1); ans |= d[1] ^ 1;
	puts(ans ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  int n,h,w;
  cin>>n>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	var n, cnt int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n)

	if n < 3 {
		fmt.Println(0)
		return
	}

	l := make([]int, n)
	scanner.Scan()
	for i, v := range strings.Split(scanner.Text(), " ") {
		l[i], _ = strconv.Atoi(v)
	}

	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			for k := j + 1; k < n; k++ {
				if l[i] != l[j] && l[j] != l[k] && l[k] != l[i] {
					if l[i] > l[j] && l[i] > l[k] && l[i] < l[j]+l[k] {
						cnt++
					} else if l[j] > l[k] && l[j] > l[i] && l[j] < l[k]+l[i] {
						cnt++
					} else if l[k] > l[i] && l[k] > l[j] && l[k] < l[i]+l[j] {
						cnt++
					}
				}
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1884
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
    std::vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());
    std::cout << a[0] + a[1] << std::endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// sc = bufio.NewScanner(os.Stdin)
	// sc.Split(bufio.ScanWords)
	var s string
	fmt.Scan(&s)
	s = strings.Replace(s, "BC", "D", -1)
	ans := 0
	cntA := 0
	for _, r := range s {
		switch {
		case r == 'A':
			cntA++
		case r == 'D':
			ans += cntA
		default:
			cntA = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<ll> A(N),B(N),C(N);
	rep(i,N)cin>>A[i];
	rep(i,N)cin>>B[i];
	rep(i,N)cin>>C[i];
	sort(all(A));
	sort(all(B));
	sort(all(C));
	ll ans = 0;
	rep(i,N){
		ll a = lower_bound(all(A),B[i]) - A.begin();
		ll c = C.end() - upper_bound(all(C), B[i]);
		ans += a*c;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,j) for (int (i)=0;(i)<(int)(j);++(i))
#define put(i) cout << (i) << endl
using namespace std;
typedef long long ll;

int n, k;
int dis[10];

int count(int x) {
    int c = 0;
    string xs = to_string(x);
    rep(i,xs.size()) {
        c += dis[xs[i]-'0'];
    }
    return c;
}

int main() {
    cin >> n >> k;
    rep(i,k) {
        int t; cin >> t;
        dis[t]++;
    }

    int minc = 100000;
    int x = 0;
    for (int j = n; j < 100000; ++j) {
        int t = count(j);
        if (minc > t) {
            minc = t;
            x = j;
            if (t == 0) {
                cout << x << endl;
                return 0;
            }
        }
    }
    cout << x << endl;
}


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

class Program
{

    public static void Main( )
    {
        int N = int.Parse( Console.ReadLine( ) );
        var input = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        var count = input.GroupBy( x => x ).ToDictionary( x => x.Key, x => x.Count( ) );
        var resultMemo = new Dictionary<int, long>( );

        for ( int i = 0; i < N; i++ )
        {
            int exceptValue = input[ i ];
            if ( resultMemo.ContainsKey( count[ exceptValue ] ) )
            {
                Console.WriteLine( resultMemo[ count[ exceptValue ] ] );
                continue;
            }

            count[ exceptValue ] -= 1;
            long result = Calc( count );
            Console.WriteLine( result );
            count[ exceptValue ] += 1;
            resultMemo[ count[ exceptValue ] ] = result;
        }

    }

    public static long Calc( Dictionary<int, int> dict )
    {
        var choseWay = dict.Select( x => nCm( x.Value, 2 ) ).Sum( );
        return choseWay;
    }

    public static long nCm( int n, int m )
    {
        long numerator = 1;
        for ( int i = n; i > n - m; i-- ) numerator *= i;
        long denominator = 1;
        for ( int i = m; i >= 1; i-- ) denominator *= i;
        return numerator / denominator;
    }
}


Measured memory_bytes: 72632
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int k, s, ans;
  cin >> k >> s;

  for (int i = 0; i <= k; i++) { // x = i
    // condition: s - i = y + z (0 <= y, z <= k)
    for (int j = 0; j <= k; j++) {

      if (s - (i + j) <= k && s - (i + j) >= 0) ans++;
    }
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<utility>
#include<cstring>
using namespace std;
int main() {
    int H, A;
    cin >> H >> A;
    int ans = H / A;
    H = H % A;
    while(H > 0) {
        H -= A;
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;
ll dp[55][2];
ll s[55];
int n,p;
int main()
{
    dp[0][0]=1;
    cin>>n>>p;
    for(int i=1;i<=n;i++) cin>>s[i];
    for(int i=1;i<=n;i++){
    	dp[i][0]=dp[i-1][0];
		dp[i][1]=dp[i-1][1];
		if(s[i]%2==0){
    		dp[i][0]+=dp[i-1][0];
			dp[i][1]+=dp[i-1][1];	
    	}else{
    		dp[i][0]+=dp[i-1][1];
			dp[i][1]+=dp[i-1][0];
    	}
    }
    cout<<dp[n][p];
    return 0;
}


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

using namespace std;

int main() {
  int a[3];
  for (int i=0; i<3; ++i)
    scanf("%d", &a[i]);

  sort(a, a+3);

  printf("%s\n", (a[0]+a[1] == a[2])? "Yes":"No");
  return 0;
}
  


Measured memory_bytes: 128
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int helper(int arr[],int n,int dp[],int val)
{
int mi=0;
int i=0;
while (arr[i]<=val&&i<n)
{
    if(dp[val-arr[i]]==0)
    return 1;
    i++;
}
return 0;
}
void solve()
{
int n,k;
cin>>n>>k;
int dp[k+1]={0};
int arr[n];
for (int i = 0; i < n; i++)
{
    cin>>arr[i];
}
sort(arr,arr+n);
for (int i = 0; i < n; i++)
{
    dp[arr[i]]=1;
}
dp[0]=0;
for (int i = 1; i <=k; i++)
{
    if(dp[i]==0)
    {   
        dp[i]=helper(arr,n,dp,i);
    }
}
if(dp[k]==1)
cout<<"First"<<endl;
else
cout<<"Second"<<endl;
}
int main()
{
     #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
struct poi {
	double x;
	double y;
};
double th = M_PI*60/180.0;
int koch(int n,poi a, poi b){
	if(n == 0)return 0;
	poi s,t,u;
	s.x = (2*a.x + b.x)/3;
	s.y = (2*a.y + b.y)/3;
	t.x = (a.x + 2*b.x)/3;
	t.y = (a.y + 2*b.y)/3;
	u.x = (t.x -s.x)*cos(th) - (t.y -s.y)*sin(th) +s.x;
	u.y = (t.x -s.x)*sin(th) + (t.y -s.y)*cos(th) +s.y;
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,b);
}


int main(){
	int n;
	cin>>n;
	poi a,b;
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}


Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
P x[100000],y[100000];
int mypow(int a,int b,int c){
	if(b==0)return 1;
	else if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int n;
	string s;
	cin>>n>>s;
	if(n%2){
		puts("No");
		return 0;
	}
	f(i,n/2){
		if(s[i]!=s[i+n/2]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int X; cin >> X;
    int f[6]={100,101,102,103,104,105};
    bool dp[X+1000]={};
    dp[0]=true;
    for(int i=0;i<=X;i++){
        for(int j=0;j<6;j++){
            if(dp[i]) dp[i+f[j]]=true;
        }
    }
    if(dp[X]){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 384
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/

import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int x=0;
    
    for(int i=500;i<=n;i+=500)
        {
          x+=1000;
        }
        n=n%500;
        if(n!=0)
        {
          for(int i=5;i<=n;i=i+5)
          {
            x=x+5;
          }
        }
        System.out.println(x);
        }
        }
        


Measured memory_bytes: 21844
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count=0;
    boolean A=false;
    int Mountains[]=new int[N];
    for(int i=0;i<N;i++){
      Mountains[i]=sc.nextInt();
    }
    for(int i=1;i<N;i++){
      A=false;
      for(int j=0;j<i;j++){
        if(Mountains[i]<Mountains[j]){
          A=true;
          break;
        }
      }if(A==false){
        count++;
      }
      }
    System.out.println(count+1);
  }
}



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

int main(){
  ll A, B, C;
  cin >> A >> B >> C;
  rep(i, C){
    if (i % 2 == 0) {
      if (A%2 == 1) {
        A -= 1;
      }
      B += A/2;
      A /= 2;
    }else{
      if (B%2 == 1) {
        B -= 1;
      }
      A += B/2;
      B /= 2;
    }
  }
  cout << A << " " << B << endl;
}


Measured memory_bytes: 256