akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second

signed main(){
    int a,b,c,x,y,p,q;
    cin>>a>>b>>c>>x>>y;
    int base=a*x+b*y;
    int m=min(x,y);
    int n=max(x,y);
    if(a+b>c*2){
        if(x<y)p=c*2*m+b*(n-m);
        else p=c*2*m+a*(n-m);
        q=c*2*n;
        int ans=min(p,q);
        cout<<ans<<endl;
    }
    else cout<<base<<endl;
    return 0;
}


Measured memory_bytes: 256
#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];
    vector<long long> acc(n+1);
    for (int i = 0; i<n+1; i++) acc[i] = 0;
    for (int i = 0; i<n; i++) acc[i+1] = acc[i] + a[i];
    //一個目の右端
    int left = 1;
    //三個目の右端
    int right = 3;
    long long ans = 1'000'000'000'000'000;
    //二個目の右端を全探索
    for (int i = 2; i<n-1; i++){
        while (abs(2*acc[left+1] - acc[i]) < abs(2*acc[left] - acc[i])) left++;
        while (abs(2*acc[right+1] - acc[i] - acc.back()) < abs(2*acc[right] - acc[i] - acc.back())) right++;
        ans = min(ans, max({acc[left], acc[i] - acc[left], acc[right] - acc[i], acc.back() - acc[right]}) - min({acc[left], acc[i] - acc[left], acc[right] - acc[i], acc.back() - acc[right]}));
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 2560
program sqrt_inequality
  integer(8) :: a, b, c
  read(*,*) a, b, c
  if (c-a-b < 0) then
    write(*,'(a)') "No"
    stop
  end if
  if (a*b*4 < (c-a-b)*(c-a-b)) then
    write(*,'(a)') "Yes"
  else
    write(*,'(a)') "No"
  end if
end program sqrt_inequality

Measured memory_bytes: 640
//その２：メモ化再帰

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX_N 100
#define MAX_W 10000
using namespace std;
int dp[MAX_N][MAX_W];
int n, W;
struct Item {
    int weight;
    int value;
};
typedef struct Item Item;
Item data[MAX_N];

//pos番目の荷物から、重さj以下になるように選んで行く
int knapsack(int pos, int j) {
    if(pos >= n) return(0);
    if(dp[pos][j] != -1) return(dp[pos][j]);
    else if(j < data[pos].weight) return(knapsack(pos + 1, j));
    else {
        return(dp[pos][j] = max(knapsack(pos + 1, j), knapsack(pos + 1, j - data[pos].weight) + data[pos].value));
    }
}

void solve() {
    memset(dp, -1, sizeof(dp));
    cout << knapsack(0, W) << endl;
}

int main(void) {
    cin >> n >> W;
    
    for(int r = 0; r < n; r++) cin >> data[r].value >> data[r].weight;
    solve();
    return(0);
}

Measured memory_bytes: 5080
N, K = map(int, input().split())
res = []
for n in range(1, N + 1):
    # 1/n * 0.5**
    t = 0
    s = n
    while s < K:
        s *= 2
        t += 1
    res.append((1 / N) * (1 / 2 ** t))
print(sum(res))

Measured memory_bytes: 6296
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
    String[]str={"a","b","c"};
    boolean[]b={false,false,false};
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String []s=line.split("");
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(str[i].equals(s[j])){
                    b[i]=true;
                }
            }
        }
        if(b[0]&&b[1]&&b[2])
        System.out.println("Yes");
        else
        System.out.println("No");
        
    }
}

Measured memory_bytes: 21844
grid = [[-1] * 4 for i in range(4)]
for i in range(1,4):
    grid[i][1],grid[i][2],grid[i][3] = map(int,input().split())
    grid[i][0] = min(grid[i][1],grid[i][2],grid[i][3])
#print('----------')
#for i in range(4):
#    print(grid[i])

isOK = False
for i in range(grid[1][0]+1):
    grid[0][0] = i
    grid[0][1] = grid[1][1]-i
    grid[0][2] = grid[1][2]-i
    grid[0][3] = grid[1][3]-i
#    print('----------')
#    for j in range(4):
#        print(grid[j])
    if grid[2][1]-grid[0][1] == grid[2][2]-grid[0][2] and grid[2][2]-grid[0][2] == grid[2][3]-grid[0][3]:
        if grid[3][1]-grid[0][1] == grid[3][2]-grid[0][2] and grid[3][2]-grid[0][2] == grid[3][3]-grid[0][3]:
            isOK = True
            break
if isOK:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9220
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  ll N;
  cin >> N;
  ll res = N;
  for (ll i = 1; i <= (ll)(sqrt(N)); ++i) {
    ll j = (ll)(N / i);
    if (j * i == N) {
      res = min(res, j - 1 + i - 1);
    }
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007


 ll ar[MAX]={0};
int main()
{
 //O_O ;
   ll n;
   cin>>n;
for(ll i=1;i<n;i++)
{
    ll temp;cin>>temp;
    ar[temp]++;
}
for(ll i=1;i<=n;i++)
{
    cout<<ar[i]<<nn;
}
//cout<<nn;


    return 0;
}


Measured memory_bytes: 5192
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    s=input()
    A=[0]*n # A[i]: i番目までのWの数
    count=0
    for i in range(n):
        if s[i]=='W': count+=1
        A[i]=count
    ans=INF
    for i in range(n):
        if i==0:
            ans=min(ans,n-1-(A[n-1]-A[0]))
        elif i==n-1:
            ans=min(ans,A[n-2])
        else:
            ans=min(ans,A[i-1]+n-i-1-(A[n-1]-A[i]))
    print(ans)
resolve()

Measured memory_bytes: 43120
//
// Created by yamunaku on 2019/08/04.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    string s;
    cin >> s;
    int ans=0;
    for(int i=1;i<s.length();i+=2){
        ans=ans*100+9;
    }
    if(s.length()%2){
        int x=stoi(s);
        int a=1;
        while(x>=a) a*=10;
        a/=10;
        ans+=x-a+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
 
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
 
long long gcd(long long x, long long y) {
	long long r;
	if (x < y) swap(x, y);
 
	while (y > 0) {
		r = x%y;
		x = y;
		y = r;
	}
	return x;
}
 
long long lcm(long long x, long long y) {
	return x / gcd(x, y)*y;
}
 
int main() {
	int N;
	long long T[102];
	cin >> N;
	
	REP(i, N) {
		cin >> T[i];
	}
	
	long long ans;
	ans = 1;
	for (int i = 0;i < N;i++) {
		ans = lcm(T[i], ans);
	}
 
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

int partition(vector<int> &v,int p,int r){
    int x=v[r];
    int i=p-1;
    for(int j=p;j<r;j++){
        if(v[j]<=x){
            i++;
            swap(v[i],v[j]);
        }
    }
    swap(v[i+1],v[r]);
    return i+1;
}

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 itr = partition(a,0,n-1);
    for(int i=0;i<n;i++){
        cout << (i==itr?"[":"") << a[i] << (i==itr?"]":"") << (i!=n-1?" ":"\n");
    }
}



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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    unsigned long x{accumulate(A.begin(), A.end(), 0UL, bit_xor<>())};
    for(auto& i : A)i &= ~x;
    unsigned long a{0};
    for(unsigned long i = 1UL << 60; i; i >>= 1){
        if(partition(A.begin(), A.end(), [&i](auto a){return ~a & i;}) == A.end())continue;
        auto t = A.back();
        A.pop_back();
        if(a < (a ^ t))a ^= t;
        if(A.empty())break;
        for(auto& j : A)if(j & i)j ^= t;
    }
    cout << x + (a * 2) << endl;
    return 0;
}

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

int main()
{
    long long n,maxi,x,y,ans=0,aux;
    cin>>n>>maxi;
    maxi*=maxi;
    while(n--)
    {
        cin>>x>>y;
        aux = (x*x) + (y*y);
        if(aux<=maxi)
        {
            ans++;
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define p pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<d;
#define OUTL(d) cout<<d; BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))
 
ll gcd(ll x, ll y){
    if(y == 0) return x;
    return gcd(y, x%y);
}

ll lcm(ll x, ll y){
    return x * (y / gcd(x, y));
}

signed main(){ INIT;
    VAR(string, str);
    reverse(ALL(str));
    OUTL(str);
RET;}

Measured memory_bytes: 3220
import collections
a=collections.deque()
for _ in range(int(input())):
    b=input()
    if b[0]=='i':a.appendleft(b[7:])
    elif b[6]==' ':
        try:a.remove(b[7:])
        except:pass
    elif len(b)>10:a.popleft()
    elif len(b)>6:a.pop()
print(*a)



Measured memory_bytes: 69736
#include <cstdio>

using namespace std;
int main (){
    int n;
    scanf("%d",&n);
    long long int a[n];
    long long int sum=0;
    for (int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    sum-=n;
    printf("%lld",sum);
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	class C implements Comparable<C>{
		int r,h;

		public C(int r, int h) {
			super();
			this.r = r;
			this.h = h;
		}

		@Override
		public int compareTo(C a) {
			if(this.h < a.h) return -1;
			if(this.h > a.h) return 1;
			return 0;
		}
		
	}

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if ( n == 0) break;
			ArrayList<C> data = new ArrayList<C>();
			
			for(int i = 0; i < n; i++){
				int h = sc.nextInt();
				int r = sc.nextInt();
				data.add(new C(r,h));
			}
			int m = sc.nextInt();
			for(int i=0; i < m; i++){
				int h = sc.nextInt();
				int r = sc.nextInt();
				data.add(new C(r,h));
			}
			Collections.sort(data);
			int len = n + m;
			int [] [] dp = new int [len + 2][len + 2];
			int ans = 0;
			for(int i= 1; i <= len; i++){
				dp[1][i] = data.get(i -1 ).h;
				dp[0][i] = data.get(i - 1).r;
				for(int j = i - 1; j >= 0; j--){
					int h = dp[1][j];
					int r = dp[0][j];
					if(dp[1][i] > h && dp[0][i] > r){
						
						int temp =  dp[2][j] + 1;
						dp[2][i] = Math.max(temp, dp[2][i]);
						// debug
						//System.out.println( i + " " + j + " " +dp[2][i]);
						ans = Math.max(ans,	 dp[2][i]);
						
					}
				}
			}
			//System.out.print("Answer = ");
			System.out.println(ans);
		}
		
		
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}

}

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

using namespace std;

bool Cat(string str, int p){
  if(str.size() == 0) return true;
  if(str[0] == 'm' && str[(int)str.size()-1] == 'w'){
    int m = 0, w = 0;
    for(int i=1;i<str.size()-1;i++){
      if(str[i] == 'm') m++;
      if(str[i] == 'w') w++;
      if(str[i] == 'e' && m == w && Cat(str.substr(1, i-1), p+1) && Cat(str.substr(i+1, (int)str.size()-i-2), p+1)) return true;
    }
  }
  return false;
}

main(){
  string str;
  cin >> str;
  cout << (Cat(str, 0) ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i, j;
	cin >> n;
	int v[n], c[n];
	fo(i, 0, n)
	cin >> v[i];
	fo(i, 0, n)
	cin >> c[i];
	int ans = -INT_MAX;
	fo(i, 0, (1 << n)){
		int s1 = 0, s2 = 0;
		fo(j, 0, n){
			if((i & (1 << j))){
				s1 += v[j], s2 += c[j];
			}
		}
		ans = max(ans, s1 - s2);
	}
	cout << ans;
}


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

#define DEBUG(x) cerr << #x << ": " << (double)x << endl;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    const double noudo = ((double)e / (100.0+e));

    vector<int> water;
    vector<int> suger;
    for (int i = 0; i <= f; i++) {
        for (int j = 0; j <= f; j++) {
            int w= (a * 100 * i) + (b * 100 * j);
            int s= (c * i) + (d * j);
            if (w <= f && w != 0) {
                water.push_back(w);
            }
            if (s <= f) {
                suger.push_back(s);
            }
        }
    }

    int l1 = water.size();
    int l2 = suger.size();
    double maxNoudo = -1.0;
    int maxSw = 0;
    int maxS = 0;
    for (int i = 0; i < l1; i++) {
        for (int j = 0; j < l2; j++) {
            int w = water[i];
            int s = suger[j];
            int sw = w + s;
            double curNoudo = ((double)s / sw);
            if ( (sw <= f) && (curNoudo <= noudo) ) {
                if ( maxNoudo < curNoudo ) {
                    maxNoudo = curNoudo;
                    maxSw = sw;
                    maxS = s;
                }
            }
        }
    }

    cout << maxSw << " " << maxS << endl;


    return 0;
}

Measured memory_bytes: 1400
package main

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

func main() {
	N := ReadInt()
	ans := 1 << 61
	for i := 1; i <= N-1; i++ {
		j := N - i
		v := sum(i) + sum(j)
		if ans > v {
			ans = v
		}
	}
	fmt.Println(ans)
}

func sum(a int) int {
	v := 0
	for a > 0 {
		v += a % 10
		a /= 10
	}
	return v
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
def insection_sort(lst):
    lens=len(lst)
    ans=0
    for i in xrange(lens):
        mn=i
        for j in xrange(i+1,lens):
            if(lst[j]<lst[mn]):
                mn=j
        if(mn!=i):
            tmp=lst[i]
            lst[i]=lst[mn]
            lst[mn]=tmp
            ans+=1
    return ans
num=int(raw_input().strip())
arr=map(int,raw_input().strip().split())
ans=insection_sort(arr)
print " ".join(str(pp) for pp in arr)
print ans



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

int main(){
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;

}




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

int main() {
    string o,e;
    cin >> o >> e;
    if(o.size()==e.size()){
        for(int i=0;i<o.size();i++){
            cout << o.at(i) << e.at(i);
        }
        cout << endl;
    }
    else{
        for(int i=0;i<e.size();i++){
            cout << o.at(i) << e.at(i);
        }
        cout << o.at(o.size()-1) << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

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

int main(){
    
    int a,b;
    cin >> a >> b;

    int tmp = 0;
    int res[6] = {0};
    int cnt =0;

    for(int i=a;i<=b;i++){
            tmp = i;
            res[6] = {0};
        for(int j=1;j<=5;j++){
            res[j] = tmp%10;
            tmp /= 10;
        }
        if(res[1]==res[5] && res[2]==res[4]) cnt ++;
    }
    cout << cnt << endl;
    

    return 0;
};



Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  ll a,b,n,cnt=0;
  std::cin >> n >> a >> b;

  if(a<=b) cnt=b*(n-2)-a*(n-2)+1;
  if(n==1 && a!=b) cnt=0;
  std::cout << cnt << '\n';
  return 0;
}


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

bool m[1000010];
void sieve()
{
    m[0]=false;
    m[1]=false;
    for(int i=2;i<1000010;i++)
        {
            m[i]=true;
        }
    for(int i=2;i*i<1000010;i++)
    {
        if(m[i]==true)
        {
            for(int j=i*i;j<1000010;j+=i)
            {
                m[j]=false;
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;
    sieve();
    for(int i=n;;i++)
    {
        if(m[i])
        {
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 1280
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = False

n, t = MAP()
a = LIST()
b = [0 for _ in range(n)]
b[0] = a[0]
for i in range(1, n):
    if b[i - 1] > a[i]:
        b[i] = a[i]
    else:
        b[i] = b[i - 1]
debug(b)
c = [0 for _ in range(n)]
for i in range(n):
    c[i] = a[i] - b[i]
debug(c)
print(c.count(max(c)))

Measured memory_bytes: 85996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using indexed_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template <class c
#define ris return *this
#define dor > debug& operator<<
#define eni(x)                                                                 \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(   \
              c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mem(a, s) memset(a, s, sizeof(a))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for (int i = a; i >= b; --i)

typedef vector<int> vi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};

const int mod = 1e6 + 7;

void solve();
void pre();

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int t = 1;
    // cin >> t;
    rep(i, 1, t) {
        // cout << "Case # " << i << ": ";
        solve();
    }
    return 0;
}

void pre() {}

void solve() {
    int n;
    cin >> n;
    vi v(n), cost(n);
    rep(i, 0, n - 1) cin >> v[i];
    rep(i, 0, n - 1) cin >> cost[i];
    int ans = 0;
    rep(i, 0, (1 << n) - 1) {
        vi x, co;
        rep(j, 0, n - 1) {
            if (i & (1 << j)) {
                x.pb(v[j]);
                co.pb(cost[j]);
            }
        }
        int y = 0;
        rep(i, 0, sz(x) - 1) { y += x[i] - co[i]; }
        ans = max(ans, y);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3660
#include <stdio.h>
int main(void)
{
  int a,b,area,circumference; //area:面積 circumference:周囲
  scanf("%d %d",&a,&b); //キーボード入力
  if(1<=a&&b<=100)
  {
    area=a*b;
    circumference=2*a+2*b;
    printf("%d %d\n", area,circumference);
  }
  else
  {
    printf("再度、条件を満たす入力をしてください。\n");
  }
	return 0;
}



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

bool dfs(vector<int>& state, vector<vector<int>>& adjlist, const int& u){
    if(state[u] == 1) return true;
    state[u] = 1;
    for(int i = 0; i < adjlist[u].size(); i++){
        if(state[adjlist[u][i]] != 2){
            bool hasCycle = dfs(state, adjlist, adjlist[u][i]);
            if(hasCycle) return true;
        }
    }
    state[u] = 2;
    return false;
}
int main(){
    int v, e, s, t;
    cin >> v >> e;
    vector<int> state(v, 0);
    vector<vector<int>> adjlist(v);
    for(int i = 0; i < e; i++){
        cin >> s >> t;
        adjlist[s].push_back(t);
    }
    for(int i = 0; i < v; i++){
        if(state[i] != 2){
            bool hasCycle = dfs(state, adjlist, i);
            if(hasCycle){
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3172
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    long mod = 998244353;
    ModInt ans = new ModInt(0, mod);
    ModInt color = new ModInt(m, mod);
    ModIntCombinationCache cCache = new ModIntCombinationCache(200005, mod).calc();
    for (int x = n - 1; x >= 0; x--) {
      ModInt now = color.multiplicity(cCache.get(n - 1, x));
      if (x <= k) {
        ans = ans.add(now);
      }
      color = color.multiplicity(m - 1);
    }
    pw.println(ans);
  }

  static class ModInt {

    final long mod;
    long x;

    ModInt(long x, long mod) {
      this.x = x;
      this.mod = mod;
    }

    ModInt(ModInt m) {
      this.x = m.x;
      this.mod = m.mod;
    }

    ModInt add(long m) {
      ModInt n = new ModInt(this);
      n.x += m;
      n.x %= mod;
      return n;
    }

    ModInt add(ModInt m) {
      return this.add(m.x);
    }

    ModInt minus(long m) {
      ModInt n = new ModInt(this);
      if ((n.x += (mod - m)) >= mod) {
        n.x -= mod;
      }
      return n;
    }

    ModInt minus(ModInt m) {
      return this.minus(m.x);
    }

    ModInt multiplicity(long m) {
      ModInt n = new ModInt(this);
      n.x *= m;
      n.x %= mod;
      return n;
    }

    ModInt multiplicity(ModInt m) {
      return multiplicity(m.x);
    }

    ModInt pow(long p) {
      if (p == 0) {
        return new ModInt(1, mod);
      }
      ModInt a = pow(p >> 1);
      a = a.multiplicity(a.x);
      if ((p & 1) == 1) {
        a = a.multiplicity(x);
      }
      return a;
    }

    ModInt inv() {
      return pow(mod - 2);
    }

    ModInt divide(ModInt d) {
      ModInt n = new ModInt(this);
      n = n.multiplicity(d.inv().x);
      return n;
    }

    @Override
    public String toString() {
      return String.valueOf(x);
    }
  }

  static class ModIntCombinationCache {

    ModInt[] fact;
    ModInt[] ifact;
    int n;
    long mod;

    public ModIntCombinationCache(int n, long mod) {
      assert n < mod;
      this.fact = new ModInt[n + 1];
      this.ifact = new ModInt[n + 1];
      this.n = n;
      this.mod = mod;
    }

    ModIntCombinationCache calc() {
      fact[0] = new ModInt(1, mod);
      for (int i = 1; i <= n; i++) {
        fact[i] = fact[i - 1].multiplicity(i);
      }
      ifact[n] = fact[n].inv();
      for (int i = n; i >= 1; i--) {
        ifact[i - 1] = ifact[i].multiplicity(i);
      }
      return this;
    }

    ModInt get(int n, int k) {
      if (k < 0 || k > n) {
        return new ModInt(0, mod);
      }
      return fact[n].multiplicity(ifact[k]).multiplicity(ifact[n - k]);
    }
  }
}


Measured memory_bytes: 68476
import java.util.*;

public class Main {
	private long[] trarray = new long[3];
	private long minDiv;

	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();

		Main soln = new Main();
		soln.minDiv = Math.min(m,n);
		long[] temp = new long[3];
		for(int i=1; i<=m/2; i++) {
			temp[0] = (long)i*n;
			soln.digR(temp, m-i, n);
			soln.digC(temp, m-i, n);
		}
		for(int i=1; i<=n/2; i++) {
			temp[0] = (long)i*m;
			soln.digR(temp, m, n-i);
			soln.digC(temp, m, n-i);
		}
		System.out.println(soln.minDiv);
	}

	private void digR(long[] temp, int m, int n) {
		int j = m/2;
		temp[1] = (long)j*n;
		temp[2] = (long)(m-j)*n;
		this.calcMinDiv(temp);
	}

	private void digC(long[] temp, int m, int n) {
		int j = n/2;
		temp[1] = (long)j*m;
		temp[2] = (long)(n-j)*m;
		this.calcMinDiv(temp);
	}

	private void calcMinDiv(long[] temp) {
		this.trarray = Arrays.copyOf(temp, temp.length);
		Arrays.sort(this.trarray);
		long div = this.trarray[2] - this.trarray[0];
		this.minDiv = (div<this.minDiv)? div:minDiv;
	}
}

Measured memory_bytes: 29012
#include <cstdio>

const int SIZE = 200005;
typedef long long int lli;
lli comb1[SIZE];	//H-A+B-1 C i
lli comb2[SIZE];	//W-B+A-1 C i
lli inv[SIZE];
int N;
//p = p / n * n + p % n
//inv(n) = -inv(p%n) * (p/n)

int main(){
	int H, W, A, B;
	lli ans=0, p=1e9+7;
	scanf("%d %d %d %d", &H, &W, &A, &B);
	inv[1] = 1;
	N = H + W;
	for(int i=2; i<=N; ++i)
		inv[i] = (p*p - inv[p%i] * (p/i)) % p;
	comb1[0] = comb2[0] = 1;
	for(int i=0; i<N; ++i){
		comb1[i+1] = (comb1[i] * inv[i+1]) % p;
		comb1[i+1] = (comb1[i+1] * (H-A+B-1-i)) % p;
		comb2[i+1] = (comb2[i] * inv[i+1]) % p;
		comb2[i+1] = (comb2[i+1] * (W-B+A-1-i)) % p;
	}
	for(int i=0; i<H-A; ++i){
		ans = (ans + comb1[i] * comb2[H-1-i]) % p;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 4864
#include <stdio.h>
 
int main(){
	int a, b, c, d, n, tw[2048] = {0};
	long long th[4096] = {0};
	for(a = 0;a <= 1000;a++) 
		for(b = 0;b <= 1000;b++) 
			tw[a+b]++;
			
	for(a = 0;a <= 2000;a++) 
		for(b = 0;b <= 2000;b++) 
			th[a+b] += tw[a]*tw[b];
 
	while(scanf(" %d", &n) != EOF)
    	printf("%lld\n", th[n]);
  	
  	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
int main() {
	int a,b,m;
	cin >> a >> b >> m;
	vector<int> heat(a), cool(b);
	rep(i,a) cin >> heat[i];
	rep(i,b) cin >> cool[i];
	int minHeat = *min_element(heat.begin(), heat.end());
	int minCool = *min_element(cool.begin(), cool.end());
	int ans = minHeat + minCool;
	rep(i, m) {
		int x, y, c;
		cin >> x >> y >> c;
		ans = min(ans, heat[x-1]+cool[y-1]-c);
	}
	cout << ans << endl;
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var KX = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var start = KX[1] - KX[0] + 1;
            var end = KX[1] + KX[0] - 1;

            var ans = new List<int>();
            for (var i = start; i <= end; i++)
                ans.Add(i);
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P; 
const ll mod = 1000000007;
/*141421 35623*/ 
int main()
{
	ll n,k;
	cin>>n>>k;
	ll le = k;
	ll ri = n+1;
	ll sum = 0;
	for(ll i=le;i<=ri;i++)
	{
		ll plus = (ri-1+ri-i)*i/2;
		ll minu = (i-1)*i/2;
		sum+=(plus-minu)%mod+1;
		sum%=mod;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main()
{
    int x,y;
    cin>>x>>y;
    int a,b,c;
    a=x+y;
    b=x*y;
    c=x-y;
    int maxx;
    maxx=max(a,max(b,c));
    cout<<maxx<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const ll LIM = 1e13;
int main(){
    ll n;
    cin >> n;
    ll h[n];
    ll i,j;
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    for(i=n-2;i>=0;i--){
        if(h[i+1]>=h[i]){}
        else {
            h[i]--;
            if(h[i+1]<h[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
input()
n=sorted(list(map(int,input().split())))
m=n[0]
a=set()
for x in range(1,int(m**.5)+1):
    if m%x==0:a|={x,m//x}
for c in sorted(list(a)):
    for k in n[1:]:
        if k%c:break
    else:print(c)


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

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

    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(auto& i : a){
        std::cin >> i;
    }
    for(int i=n-1; i>=0; --i){
        std::cout << a[i] << ((i!=0)?" ":"\n");
    }
    return 0;
}

Measured memory_bytes: 3184
# include <stdio.h>
#include <stdlib.h>
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == 5 && b == 5 && c == 7)
	{
		printf("YES\n");
	}
	else 
	{
		if (a == 5 && b == 7 && c == 5)
		{
			printf("YES\n");
		}
		else 
		{
			if (a == 7 && b == 5 && c == 5)
			{
				printf("YES\n");
			}
			else 
			{ 
				printf("NO\n");
			}
		}
	}
	system("pause");
}


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

int main(void){

  int H,W;
  while(cin >> H >> W){
    if(H == 0 && W == 0) break;
    int i,j;
    for(j=0; j<H; j++){
      for(i=0; i<W; i++){
	if(j == 0 || j == H-1){
	  cout << "#";
	}else if(i == 0 || i == W-1){
	  cout << "#";
	}else{
	  cout << ".";
	}
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#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-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    // 文字列の順番を逆にする
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int main() {
	ll N, K;
	cin >> N >> K;
	string res = Itoa(N, K);

	cout << res.size() << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <set>

using namespace std;

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < n; ++i)

const int MAX = 2e5+10;

int N;
ll B[MAX];

int main() {

  cin >> N;
  REP (i, N) {
    int a;
    cin >> a;
    B[a-1] = i+1;
  }

  set<int> right, left;
  left.insert(0);
  right.insert(N+1);

  ll ans = 0;
  REP (i, N) {
    int k = B[i];
    int l = *(prev(left.lower_bound(k),1));
    int r = *right.upper_bound(k)-1;
    ans += (i+1)*(k-l)*(r-k+1);
    right.insert(k);
    left.insert(k);
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
main(){
	double d,t,s;
	while(cin>>d>>t>>s){
		double time=d/s;
		puts(time<=t?"Yes":"No");
	}
}


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

int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0) break;
    vector<int> road[1000];
    lp(i,n){
      road[i].clear();
    }
    lp(i,m){
      int a,b;
      cin>>a>>b;
      a--;
      b--;
      road[a].push_back(b);
      road[b].push_back(a);
    }
    int ans[1000],anscount=0;
    lp(i,1000){
      ans[i]=0;
    }
    lp(i,n){
      int a[1000];
      lp(j,n){
	a[j]=0;
      }
      int result=0,act;
      a[i]=1;
      while(1){
	act=0;
	for(int j=0;j<n;j++){
	  if(a[j]==1){
	    for(int k=0;k<road[j].size();k++){
	      if(a[road[j][k]]==0){
		a[road[j][k]]=2;
		act=1;
	      }
	    }
	  }
	  if(a[j]==2){
	    for(int k=0;k<road[j].size();k++){
	      if(a[road[j][k]]==0){
		a[road[j][k]]=1;
		act=1;
	      }
	    }
	  }
	}
	if(act==0) break;
      }
      lp(i,n){
	for(int j=0;j<road[i].size();j++){
	  if(a[i]==a[road[i][j]]){
	    result=-1;
	    break;
	  }
	}
	if(result==-1) break;
      }
      if(result==0){
	int count=0;
	lp(i,n){
	  if(a[i]==1) count++;
	}
	if(count%2==0){
	  if(ans[count/2]==0){
	    ans[count/2]=1;
	    anscount++;
	  }
	}
      }
    }
    cout<<anscount<<endl;
    lp(i,500){
      if(ans[i]==1) cout<<i<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 998244353
#define MOD 1000000007
signed main()
{
    SPEED;
    int n;
    cin>>n;
    string str;
    cin>>str;
    int cnt[n+1][3],res=0;
    memset(cnt,0,sizeof(cnt));
    for(int i=1;i<=n;i++)
    {
        if(str[i-1]=='R')
        {
            cnt[i][0]+=1;
        }
        if(str[i-1]=='G')
        {
            cnt[i][1]+=1;
        }
        if(str[i-1]=='B')
        {
            cnt[i][2]+=1;
        }
        cnt[i][0]+=cnt[i-1][0];
        cnt[i][1]+=cnt[i-1][1];
        cnt[i][2]+=cnt[i-1][2];
    }
    for(int i=n;i>=3;i--)
    {
        for(int j=i-1;j>=2;j--)
        {
            if(str[j-1]!=str[i-1])
            {
                if(str[i-1]=='R' && str[j-1]=='G')
                {
                    res+=cnt[j][2];
                    if(j-(i-j)-1>=0 && str[j-(i-j)-1]=='B')
                    {
                        res--;
                    }
                }
                else if(str[i-1]=='R' && str[j-1]=='B')
                {
                    res+=cnt[j][1];
                    if(j-(i-j)-1>=0 && str[j-(i-j)-1]=='G')
                    {
                        res--;
                    }
                }
                else if(str[i-1]=='B' && str[j-1]=='G')
                {
                    res+=cnt[j][0];
                    if(j-(i-j)-1>=0 && str[j-(i-j)-1]=='R')
                    {
                        res--;
                    }
                }
                else if(str[i-1]=='G' && str[j-1]=='R')
                {
                    res+=cnt[j][2];
                    if(j-(i-j)-1>=0 && str[j-(i-j)-1]=='B')
                    {
                        res--;
                    }
                }
                else if(str[i-1]=='B' && str[j-1]=='R')
                {
                    res+=cnt[j][1];
                    if(j-(i-j)-1>=0 && str[j-(i-j)-1]=='G')
                    {
                        res--;
                    }
                }
                else if(str[i-1]=='G' && str[j-1]=='B')
                {
                    res+=cnt[j][0];
                    if(j-(i-j)-1>=0 && str[j-(i-j)-1]=='R')
                    {
                        res--;
                    }
                }
            }
        }
    }
    cout<<res;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
long long modinv(long long a,long long mod)//extgcdの方がいいらしい
{
  return modpow(a,mod-2,mod);
}
vector<int>inv;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,x;
  int mod=1e9+7;
  cin>>n>>x;
  vector<int>s(n);
  rep(i,n)cin>>s[i];
  sort(all(s),greater<int>());
  inv.resize(n+1);
  repi(i,1,n+1)inv[i]=modinv(i,mod);
  vector<vector<int>>dp(2,vector<int>(x+1,0));
  dp[0][x]=1;
  rep(i,n)
  {
    int no=i&1,ne=1-no;
    fill(all(dp[ne]),0);
    rep(j,x+1)
    {
      if(dp[no][j]==0)continue;
      int t=(ll)dp[no][j]*inv[n-i]%mod;
      int jsi=j%s[i];
      dp[ne][jsi]+=t;
      dp[ne][j]+=(ll)t*(n-i-1)%mod;
      if(dp[ne][jsi]>mod)dp[ne][jsi]-=mod;
      if(dp[ne][j]>mod)dp[ne][jsi]-=mod;
    }
  }
  int  res=0;
  int kai=1;
  rep(i,n)kai=(ll)kai*(i+1)%mod;
  rep(i,x+1)
  {
    res+=(ll)kai*dp[n&1][i]%mod*i%mod;
    if(res>mod)res-=mod;
  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 1408
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	string s;
  	cin >> s;
  	vector<string> data = {"Sunny", "Cloudy", "Rainy", "Sunny"};
 	rep(i,3) {
      	if(s==data[i]) {
      		cout << data[i+1] << endl;
    		return;
    	}
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n int
		a int
		b int
	)
	fmt.Scanf("%d %d %d", &n, &a, &b)
	var bus = a * n
	var taxi = b

	var result = bus
	if bus > taxi {
		result = taxi
	}

	fmt.Println(result)

}


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

//using namespace __gnu_pbds;
using namespace std;

typedef  long long ll;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define endl "\n"
#define ioss ios::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define eb emplace_back



double startTime;
double gct()//get_current_time
{
    return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}

void suraj();

int main()
{
    startTime=(double)clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt,"w",stdout);
    //ioss
    //int t;cin>>t;while(t--)
    suraj();
    //suraj2();
    //suraj3();
    //suraj4();
    return 0;
}

































//int dp[100005];//dp[i] is the maximmmum value if exactly weight i has been chosen.


void suraj(){
    vector<ll>v;v.pb(0ll);
ll n,w;cin>>n>>w;
vector<ll>dp(w+1);
for(ll i=0;i<=w;i++)dp[i]=0;
for(ll i=1;i<=n;i++){//we have assumed that for all the weight combinations that are not possible we assume its value to be 0.This will help us cz our dp is made such a way that dp[i] corresponds to the minimum value for a weight of exact i weight ..but actually we need the maximum value that we can get within the maximum weight limit of W.so this assumption helps us overall.
    ll wei,val;cin>>wei>>val;
    for(int j=w-wei;j>=0;j--){
        dp[j+wei]=max(dp[j+wei],dp[j]+val);
    }
//for(int i=0;i<=w;i++)cout<<dp[i]<<" ";cout<<endl;
}
ll ans=0;
for(int i=0;i<=w;i++){ans=max(ans,dp[i]);}
cout<<ans<<endl;
}













Measured memory_bytes: 4036
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;



int main() {
	int n, m;
	cin >> n >> m;
	cout << (n + m) % 24 << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 *  I wish I could travel by the road that crosses baby's mind,
 *  and out beyond all bounds;
 *  Where messengers run errands for no cause
 *  between the kingdoms of kings of no history;
 *  Where Reason makes kites of her laws and flies them,
 *  and Truth sets Fact free from its fetters.
 *                                           Rabindranath Tagore
 */

#include <bits/stdc++.h>
using namespace std;

#ifndef ORZ_EVERYBODY_BUT_ME
#define ORZ_EVERYBODY_BUT_ME
#endif

#ifndef SOCIALISM
#define SOCIALISM
#endif

unsigned long long operator "" _love(unsigned long long literal) {
    return literal;
}

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) return puts("+"), 0;
    if (a * b == 15) return puts("*"), 0;
    return puts("x"), 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
double PI = 3.1415926;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R;
    cin >> R;
    print(2*R*PI);
    

}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,x,y,ans,tmp,hoge,fuga,piyo;

string s,str;
char ch;
int main(){
  cin>>x>>y>>a>>b>>c;
  ll p[100100],q[100100],r[100100];
  ll pa[x],qa[y],ra[x+y];
  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(p,p+a, [](auto const& lhs, auto const& rhs) {
    return lhs > rhs;
  });
  sort(q,q+b,[](auto const& lhs, auto const& rhs) {
    return lhs > rhs;
  });
  sort(r,r+c,[](auto const& lhs, auto const& rhs) {
    return lhs > rhs;
  });
  for(int i=0;i<x;i++){
    pa[i]=p[i];
    ra[i]=p[i];
  }
  for(int i=0;i<y;i++){
    ra[x+i]=q[i];
    qa[i]=q[i];
  }
  for(int i=0;i<c;i++){
    ra[x+y+i]=r[i];
  }
  sort(ra,ra+(x+y+c),[](auto const& lhs, auto const& rhs) {
    return lhs > rhs;
  });
  for(int i=0;i<x+y;i++){
    ans+=ra[i];
  }
  cout<<ans;
  return 0;
}

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

int main()
{
  int debt=100000;
  double interest=1.05;
  int week=0;

  cin>>week;

  for(int i=0;i<week;i++){
    debt*=interest;
    if(debt%1000!=0){
      debt-=debt%1000;
      debt+=1000;
    }
  }

  cout<<debt<<endl;

  return 0;
}



Measured memory_bytes: 3064