akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
//ll min(ll a, ll b){
//    if(a>b){
//        return b;
//    }
//    return a;
//}
// 
//ll max(ll a, ll b){
//    if(a>b){
//        return a;
//    }
//    return b;
//}
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 

ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);

int main()
{
	int n;
	cin>>n;
	int arr[n];
	forl(i,0,n)cin>>arr[i];
	int num=1;
	int val=0;
	forl(i,0,n)
	{
		if(arr[i]==num)
		{
			num++;
			continue;
		}else val++;
	}
	if(num==1) cout<<-1<<endl;
	else cout<<val<<endl;
}

Measured memory_bytes: 1024
import sys
from collections import Counter
s=list(input())
ls = list("ATGC")
a=[]
for i in range(len(s)):
  if s[i] in ls:
    a.append(i)
if a == []:
  print(0)
  sys.exit()
for i in range(len(a)):
  a[i] -= i+1
c=Counter(a)
print(c.most_common(1)[0][1])

Measured memory_bytes: 3316
import sys
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())

shop = []

for i in range(N):
    a,b = map(int, input().split())
    shop.append((a, b))

shop.sort()

cnt = 0
ans = 0
for i in range(N):
    cost, count = shop[i]
    if cnt == M:
        break
    if cnt < M:
        if cnt + count <= M:
            cnt += count
            ans += cost * count
        else:
            ex = M - cnt
            cnt = M
            ans += cost * ex 
print(ans)

Measured memory_bytes: 48476
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    res = defaultdict(int)
    for i in range(1, n + 1):
        cnt = 0
        k = i
        while k % 2 == 0:
            k //= 2
            cnt += 1
        res[i] = cnt

    ma = 0
    ans = 1
    for k, v in res.items():
        if ma < v:
            ans = k
            ma = v

    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3316
import itertools
n=int(input())
sm=0
l=["3","5","7"]
for i in range(3,len(str(n))+1):
  b=list(itertools.product(l, repeat=i))
  for m in b:
    s="".join(m)
    if int(s)<=n and "7" in s and "3" in s and "5" in s:sm+=1
       
print(sm)

Measured memory_bytes: 12120
#include <stdio.h>
#include <math.h>
#define N_MAX 10000
 
int isPrime(int x)
{
  int i;
  if (x <= 3) {
    return 1;
  } else if (x % 2 == 0) {
    return 0;
  } else {
    for (i = 3; i <= sqrt(x); i = i + 2) {
      if (x % i == 0) {
        return 0;
      }
    }
    return 1;
  }
}
 
int main(int argc, char *argv[])
{
  int i, j, n, x;
  int answer = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    answer = answer + isPrime(x);
  }
  printf("%d\n", answer);
  return 0;
}



Measured memory_bytes: 2096
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,ans=0;
	string s;
	cin>>s;
	n=s.size();
	for (int i=0;i<n;i++) if (s[i]=='x') ans++;
	if (15-ans>=8) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
module mod_two_dim_merge_sort
  implicit none
  integer, private, parameter :: intkind = 4
contains
  logical function less(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b(:)
    res = a(1) > b(1) .or. (a(1) == b(1) .and. a(2) >= b(2))
  end
  subroutine merge_sort(a)
    integer(intkind), intent(inout) :: a(:, :)
    integer :: n, m, l, i, u
    n = size(a, 1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m / 2
        u = min(2 * i * l, n)
        call merger(a(2 * (i - 1) * l + 1:(2 * i - 1) * l, :), &
        a((2 * i - 1) * l + 1:u, :))
      end do
      l = 2 * l
      m = (m + 1) / 2
    end do
  end
  subroutine merger(a1, a2)
    integer(intkind), intent(inout) :: a1(:, :), a2(:, :)
    integer(intkind) :: a(size(a1, 1) + size(a2, 1), size(a1, 2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(a1,1)
    n2 = size(a2,1)
    do while (i1 <= n1 .and. i2 <= n2)
      if (less(a1(i1, :), a2(i2, :))) then
        a(i1 + i2 - 1, :) = a1(i1, :)
        i1 = i1 + 1
      else
        a(i1 + i2 - 1, :) = a2(i2, :)
        i2 = i2 + 1
       end if
    end do
    if (i1 <= n1) then
      a(i1 + i2 - 1:n1 + n2, :) = a1(i1:n1, :)
    else
      a(i1 + i2 - 1:n1 + n2, :) = a2(i2:n2, :)
    end if
    a1 = a(1:n1, :)
    a2 = a(n1 + 1:n1 + n2, :)
  end
end module mod_two_dim_merge_sort
program sum_of_large_numbers
  use mod_two_dim_merge_sort
  implicit none
  integer :: n, a(2000, 2) = 0, i, j
  integer(8) :: dp(0:2000, 0:2000) = 0, x = 0
  read(*,*) n
  read(*,*) a(1:n, 1)
  a(1:n, 2) = [(i, i = 1, n)]
  call merge_sort(a(1:n, :))
  do i = 0, n
    do j = 0, n - i
      if (i > 0) then
        dp(i, j) = max(dp(i, j), &
        dp(i - 1, j) + int(a(i + j, 1), 8) * abs(a(i + j, 2) - i))
      end if
      if (j > 0) then
        dp(i, j) = max(dp(i, j), &
        dp(i, j - 1) + int(a(i + j, 1), 8) * abs(a(i + j, 2) - (n - j + 1)))
      end if
    end do
  end do
  do i = 0, n
    x = max(x, dp(i, n - i))
  end do
  write(*,'(i0)') x
end program sum_of_large_numbers

Measured memory_bytes: 25444
package main

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

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	a := scanInts(n)
	b := scanInts(n)
	c := scanInts(n)

	sort.Ints(a)
	sort.Ints(b)
	sort.Ints(c)

	ans := 0
	
	for i := 0; i < n; i++ {
		v1 := upperBound(b[i]-1, a)
		v2 := upperBound(b[i], c)
		ans += v1*(n-v2)
	}

	fmt.Println(ans)
}

func upperBound(x int, arr []int) int {
	l,r := -1, len(arr)
	for l+1 < r {
		mid := (l+r)/2
		if arr[mid] > x {
			r = mid
		} else {
			l = mid
		}
	}
	return r
}


Measured memory_bytes: 5888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int a, b; cin >> a >> b;
    a--; b--;
    int o_lines = (a+50-1)/50, x_lines = (b+50-1)/50;

    print(2*o_lines+2*x_lines+2, 100);

    for (int i = 0; i < 100; i++) cout << '#';
    cout << '\n';
    for (int i = 0; i < o_lines; i++) {
        if (i == o_lines-1) {
            for (int j = 0; j < a*2; j+=2) {
                cout << '#' << '.';
            }
            for (int j = a*2; j < 100; j++) cout << '#';
            cout << '\n';
        }
        else {
            for (int j = 0; j < 100; j+=2) {
                cout << '#' << '.';
            }
            cout << '\n';
            a -= 50;
        }
        for (int i = 0; i < 100; i++) cout << '#';
        cout << '\n';
    }

    for (int i = 0; i < x_lines; i++) {
        for (int i = 0; i < 100; i++) cout << '.';
        cout << '\n';
        if (i == x_lines-1) {
            for (int j = 0; j < b*2; j+=2) {
                cout << '.' << '#';
            }
            for (int j = b*2; j < 100; j++) cout << '.';
            cout << '\n';
        }
        else {
            for (int j = 0; j < 100; j+=2) {
                cout << '.' << '#';
            }
            cout << '\n';
            b -= 50;
        }
    }
    for (int i = 0; i < 100; i++) cout << '.';
    cout << '\n';

}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
int main()
{
#ifdef DEBUG
	freopen("in", "r", stdin);
//	freopen("out", "w", stdout);
#endif
	int n;
	scanf("%d", &n);
	int _min=1000000;
	int _max=-_min;
	ll sum=0;
	int x=-1;
	while(n--){
		scanf("%d", &x);
		_min=min(x,_min);
		_max=max(x,_max);
		sum+=x;
	}
	printf("%d %d %lld\n", _min, _max, sum);
	
	//insert code
	return 0;
}
//aog1_4_d.cc

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> read() {
	int n;
	scanf("%d", &n);
	unordered_map<int, int> cnt;
	while (n --) {
		int x;
		scanf("%d", &x);
		cnt[x] ++;
	}
	return cnt;
}
int main() {
	unordered_map<int, int> c1 = read(), c2 = read();
	bool gg = 0;
	for (auto t : c2) gg |= t.second > c1[t.first];
	puts(gg ? "NO" : "YES");
}


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

int main() {
    string o, e;
    cin >> o >> e;
    deque<char> O(o.begin(), o.end()), E(e.begin(), e.end());
    string ans;
    rep(i, 0, o.size() + e.size()) {
        if (i % 2) {
            ans += E.front(); E.pop_front();
        } else {
            ans += O.front(); O.pop_front();
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <sstream>
#include <algorithm>
#define fastio() ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long 
#define MOD 1000000007
#define inf 9223372036854775807ll
using namespace std;

int main(){
	int n; cin >> n;
	int height[100002];
	for(int i = 0; i < n; i++){
		cin >> height[i];
	}
	ll prev_state2 = 0, prev_state1 = abs(height[1] - height[0]), ans = prev_state1;

	for(int i = 2; i < n ; i++){
		ans = min((ll)abs(height[i] - height[i - 1]) + prev_state1, (ll)abs(height[i] - height[i - 2]) + prev_state2);
		prev_state2 = prev_state1;
		prev_state1 = ans;
	}

	cout << ans;

	return 0;
}

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

using namespace std;

#define int long long
#define N 100005

int a[2][N];

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

    for(int i=0;i<n;i++)
    {
        cin>>a[0][i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>a[1][i];
    }

    for(int i=1;i<n;i++)
    {
        a[0][i]+=a[0][i-1];
    }
    
    for(int i=n-2;i>=0;i--)
    {
        a[1][i]+=a[1][i+1];
    }

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

    return 0;

}

Measured memory_bytes: 256
// Created by SAMAN on ۷/۳۱/۲۰۲۰ م..

#include <iostream>
#include <algorithm>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <fstream>
#include <cstdlib>
#include <iterator>
#include <cmath>
#include <ctime>
#include <iomanip>

#define lint long long int
#define kill(x) return cout<<x<<'\n', 0;
#define debug(x) cout << #x << " : " << x << '\n'
#define pb push_back
#define ppb pop_back

using namespace std;
const int oo = 1000*1000*1000;
int n;
const int maxn = 1000*1000;
int a[maxn],b[maxn],c[maxn];
int dp[3][maxn]; // at
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); 
    cin >> n;
    for(int i = 1;i<=n;i++)
        cin >> a[i] >> b[i] >> c[i];
    dp[0][1] = a[1];
    dp[1][1] = b[1];
    dp[2][1] = c[1];
    for(int i = 2;i<=n;i++){
        dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]); 
        dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1],dp[1][i-1]);
    }
    cout<<max(dp[2][n] , max (dp[0][n] , dp[1][n]));  
}

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

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

    vector<int> vecA(n);
    for(int i=0; i<n; i++)  cin >> vecA.at(i);

    priority_queue<int> qA;
    for(int i=0; i<n; i++)
        qA.push(vecA[i]);

    vector<int> vecAns;
    for(int i=0; i<n; i++){
        if(qA.top() == vecA[i]){
            int a = qA.top();
            qA.pop();
            vecAns.push_back(qA.top());
            qA.push(a);
            continue;
        }

        vecAns.push_back(qA.top());
    }

    for(int i=0; i<vecAns.size(); i++)
        cout << vecAns[i] << endl;

    return 0;
}

Measured memory_bytes: 4084
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        int n = sc.nextInt();
        int ans = 0;

        for(int i=1;i<=n;i++) {
            if((i+"").length() % 2 == 1) ans++;
        }


        pw.println(ans);
        pw.close();
    }
}


Measured memory_bytes: 32596
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<pair<int,int>,int>a,pair<pair<int,int>,int>b)
{
    if(a.first.first<b.first.first)
        return true;
    else if(a.first.first==b.first.first)
    {
        if(a.first.second<=b.first.second)
            return true;

    }
    return false;
}
int main()
{
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
}


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

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	string ans = "";
	//ans += "0";
	long long n;
	cin >> n;

	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	else if(n == 1){
		cout << 1 << endl;
		return 0;
	}

	vector<pair<long long, long long>> mp;
	mp.push_back(make_pair(1, 0));
	long long digits = 1;
	for (;; ++digits) {
		long long val;
		val = pow(-2ll, digits);
		long long maxVal = val;
		long long minVal = val;
		for (int j = 0; j < mp.size(); ++j) {
			maxVal = max(val + mp[j].first, maxVal);
			minVal = min(minVal, val + mp[j].second);
		}
		if (minVal <= n && n <= maxVal) {
			ans += "1";
			break;
		}
		else {
			//ans += "0";
		}

		mp.push_back(make_pair(maxVal, minVal));
	}

	long long val = pow(-2ll, digits);
	for (long long j = digits - 1; 0 <= j; --j) {
		long long buf = val + pow(-2ll, j);
		//cout << val << "\t" << val + mp[j].second << "\t" << n << "\t" << val + mp[j].first << endl;
		if (val == n) {
			ans += "0";
		}
		else if (val + mp[j].second <= n && n <= val + mp[j].first) {
			ans += "1";
			val += pow(-2ll, j);
		}
		else {
			ans += "0";
		}
	}
	cout << ans << endl;

	/*val = 0;
	int dit = 0;
	int j = 0;
	for (int i = ans.length() - 1; 0 <= i; --i) {
		dit = (ans[i] - 0x30);
		val += pow(-2ll, j) * dit;
		++j;
	}
	cout << val << endl;*/

	return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long X, long long Y, long long Z) {
    swap(X, Y);
    swap(X, Z);
    cout << X << " " << Y << " " << Z << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    long long Z;
    scanf("%lld", &Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

char S[15];

void solve() {
	int n = strlen(S);

	 if (S[0] != 'A') {
    	puts("WA");
    	return;
    }

    int l = 0;
    REP(i, 0, n) if (islower(S[i])) l++;
    if (l != n-2) {
    	puts("WA");
    	return;
    }

    int C = 0;
    REP(i, 2, n-1) if (S[i] == 'C') C++;
    if (C != 1) {
    	puts("WA");
    	return;
    }

    puts("AC");

}

int main(void) {
    scanf("%s", S);

    solve();

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()
	A = inputList()

	katamuki = []
	for i,val in enumerate(A):
		if i == 0:
			continue
		if val < A[i-1]:
			katamuki.append("down")
		elif val > A[i-1]:
			katamuki.append("up")
		else:
			katamuki.append("to")

	ans = 1000
	for i,val in enumerate(A):
		if i == len(A)-1:
			break
		if val <= ans:
			if katamuki[i] == "up":
				tmp = ans // val
				ans = ans - (val * tmp)
				ans = ans + (tmp * A[i+1])

	print(ans)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


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

using namespace std;

#define size(x) ((int) x.size())

const int MAXN = 1e5 + 5;

int n, u, v;

bool ans, mark[MAXN];

vector<int> adj[MAXN];

void dfs(int v, int par = 0) {
	for (auto u : adj[v]) {
		if (u != par) {
			dfs(u, v);
			if (!mark[u]) {
				if (!mark[v]) 
					mark[v] = mark[u] = true;
				else
					ans = true;
			}
		} 
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(0);
//	cout << ans << " " << mark[0] << endl;
	if (ans || !mark[0])
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int solve(int a[],int v[])
{
	int sum=accumulate(a,a+10,0);
	int s=0;
	rep(i,10){
		s+=a[i];
		if(v[1]*s>=v[0]*(sum-s))
			return i+1;
	}
	return 10;
}

int main()
{
	for(int a[10],v[2];cin>>a[0];){
		repi(i,1,10)
			scanf(",%d",a+i);
		rep(i,2)
			scanf(",%d",v+i);
		cout<<solve(a,v)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import numpy as np

n = int(input())
a_list = []
b_list = []
for i in range(n):
    a, b = [int(i) for i in input().split()]
    a_list.append(a)
    b_list.append(b)

b_sort_index = np.argsort(b_list)
time = 0
for i in b_sort_index:
    time += a_list[i]
    if time > b_list[i]:
        print('No')
        exit(0)
print('Yes')

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

int main() {
    int n, k, m=1, sum=0, ans=0;
    cin >> n >> k;
    while(n>=m){
        ans++;
        sum += m;
        n -= m;
        m = (sum-1)/k+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
    int n;
    long long ans = 0;
    string s;
    map <string,int> m;
    cin >> n;


    for(int i = 0; i < n; i++)
    {
        cin >> s;
        sort(s.begin(), s.end());
        if(m.find(s) != m.end())
        {
            ans += m[s];
            m[s]++;
        }else
        {
            m.insert({s,1});
        }
    }


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


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




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


    int k;
    cin >> k;

    int h[n+100];

    rep(i,n){
        cin>>h[i];
    }

    ll dp[n+100];

    for(int i=0;i<n;i++){
        dp[i]=inf;
    }

    dp[0]=0;
    dp[1]= abs(h[0]-h[1]);

    for(int i=0;i<n;i++){
        for(int j=1;j<=min(n-i-1,k);j++){
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
            
        }
    }

    cout << dp[n-1] <<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
	int m[100], f[100], r[100], i=0;
	char ans[100];
	do{
		cin >> m[i] >> f[i] >> r[i];
		if ((m[i] != -1 || f[i] != -1) || r[i] != -1){
			if (m[i] == -1 || f[i] == -1)
				ans[i] = 'F';
			else{
				if (m[i] + f[i] >= 80)
					ans[i] = 'A';
				else if (m[i] + f[i] >= 65)
					ans[i] = 'B';
				else if (m[i] + f[i] >= 50)
					ans[i] = 'C';
				else if (m[i] + f[i] >= 30){
					if (r[i] >= 50) ans[i] = 'C';
					else			ans[i] = 'D';
				}
				else ans[i] = 'F';
			}
		}
		i++;
	} while ((m[i-1] != -1 || f[i-1] != -1) || r[i-1] != -1);
	for (int j = 0; j < i - 1; j++){
		printf("%c\n", ans[j]);
	}
}

Measured memory_bytes: 1144
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  1 20:52:24 2020

@author: H_Hoshigi
"""

A_list = []
for i in range(3):
    A_list += list(map(int, input().split()))

N = int(input())

b_list = []
for i in range(N):
    b_list.append(int(input()))

bingo_line_list =[
    [0,1,2],
    [3,4,5],
    [6,7,8],
    [0,3,6],
    [1,4,7],
    [2,5,8],
    [0,4,8],
    [2,4,6]
    ]
at_least_one_bingo = False
for i in bingo_line_list:
    get_bingo = True
    for j in i:
        if A_list[j] not in b_list:
            get_bingo = False
            break
    if get_bingo:
        at_least_one_bingo = True
        break
if at_least_one_bingo:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
n,k = map(int,input().split())
a=list(map(int,input().split()))
#input

from collections import defaultdict
counter=defaultdict(int)
#桁ごとに１の数を数える辞書型

def makebit(a):
    return bin(a)[2:]
#数値型から２進数の文字列型を返す関数

def count(a):
    l=len(a)
    for i in range(1,l+1):
        if a[-i]=='1':
            counter[i]+=1
    return
#２進数の文字列型から、１の場所と数を数える関数

for i in range(len(a)):
    count(makebit(a[i]))
#inputしたデータをcounterに整理する

kbit=makebit(k)
#kの2進数表記
onetime=kbit.count('1')
#kに何回１が出現するか(後述)
if len(counter)>0:
    maxlenth=max(counter)
elif len(counter)==0:
    maxlenth=0
#Aiの最も大きい桁


#２の階乗のリスト

for i in range(1,1+max(maxlenth,len(kbit))):
    if counter[i]==0:
        counter[i]=0

if maxlenth>len(kbit):
    kbit='0'*(maxlenth-len(kbit))+kbit
elif maxlenth<len(kbit):
    maxlenth=len(kbit)
    
kaijo=[]
for i in range(maxlenth+1):
    kaijo.append(2**i)
#maxlenthまでで登録されていないkeyを登録

#メインとなるループ関数
def search(kbit,default,ans,before,counter):
    if kbit.count('1')==0:
        dlenth=len(kbit)
        for keta in counter:
            if keta>before:continue
            elif keta<=dlenth:
                default+=counter[keta]*kaijo[keta-1]
        if default>ans:ans=default
        return ans
    dlenth=len(kbit)-kbit.index('1')
    now=default
    newcounter=counter.copy()
    for keta in counter:
        if keta>before:continue
        elif keta>dlenth:
            default+=counter[keta]*kaijo[keta-1]
            now+=counter[keta]*kaijo[keta-1]
            newcounter.pop(keta)
        elif keta==dlenth:
            default+=(n-counter[keta])*kaijo[keta-1]
            now+=counter[keta]*kaijo[keta-1]
            newcounter.pop(keta)
        elif keta<dlenth:now+=max(n-counter[keta],counter[keta])*kaijo[keta-1]
    if kbit.index('1')==len(kbit)-1:
        now=default-(n-counter[1])
        now+=max(n-counter[1],counter[1])
        if now>ans:ans=now
        return ans
    if now>ans:ans=now
    idx=kbit.index('1')
    kbit=kbit[idx+1:]
    return search(kbit,default,ans,dlenth,newcounter)
print(search(kbit,0,0,maxlenth+1,counter))

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    char t[200000], d[200000];
    for(int i=0;i<q;i++) cin >> t[i] >> d[i];

    int lfall=-1, lrem=n;
    while(lrem-lfall>1){
        int mid = (lfall+lrem)/2;
        int pos = mid;
        for(int i=0;i<q;i++){
            if(s[pos]==t[i]){
                if(d[i]=='L') pos--;
                else pos++;
            }
            if(pos<0 || pos>=n) break;
        }
        if(pos<0) lfall = mid;
        else lrem = mid;
    }

    int rfall=n, rrem=-1;
    while(rfall-rrem>1){
        int mid=(rfall+rrem)/2;
        int pos=mid;
        for(int i=0;i<q;i++){
            if(s[pos]==t[i]){
                if(d[i]=='L') pos--;
                else pos++;
            }
            if(pos<0 || pos>=n) break;
        }
        if(pos>=n) rfall = mid;
        else rrem = mid;
    }

    int fall = (lfall+1)+(n-rfall);
    cout << n-fall << endl;
    
    return 0;
}

Measured memory_bytes: 976
#include <stdio.h>
int main(void){
    int x,a,b,ans;
    scanf("%d",&x);
    // 500円玉で両替
    a = x / 500;
    x -= a * 500;
    // 5円玉で両替
    b = x / 5;
    // 嬉しさ
    ans = a*1000 + b*5;
    printf("%d",ans);
}


Measured memory_bytes: 128
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 4e5+10;
PII d[SIZE];
int dn;
LL dp[100][SIZE];
int main(){
    int N,K;
    R(N,K);
    int now=1;
    while(now<=N){
        int v=N/now;
        int nxt=N/v+1;
        d[dn++]=MP(now,nxt-1);
        now=nxt;
    }
    REP(i,dn)dp[0][i]=d[i].S;
    REPP(i,1,K){
        REP(j,dn){
            dp[i][j]=dp[i-1][dn-1-j]*(d[j].S-d[j].F+1LL);
        }
        REPP(j,1,dn)ADD(dp[i][j],dp[i][j-1]);
    }
    W(dp[K-1][dn-1]);
    return 0;
}


Measured memory_bytes: 256768
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
f = a[0] - 1
ans = b[f]
for i in range(1, n):
    nf = a[i] - 1
    ans += b[nf] 
    if f + 1 == nf:
        ans += c[f]
    f = nf
print(ans)

Measured memory_bytes: 3064
import sys
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            count=0
            if i>0:
                if s[i-1][j]=="#":
                    count+=1
            if i<h-1:
                if s[i+1][j]=="#":
                    count+=1
            if j>0:
                if s[i][j-1]=="#":
                    count+=1
            if j<w-1:
                if s[i][j+1]=="#":
                    count+=1
            if count==0:
                break
    else:
        continue
    break
else:
    print("Yes")
    sys.exit()
print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    }else {
        printf("a == b\n");
    }
    
    return 0;
}



Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int mx = max({ A,B,C });
	int ans = A + B + C - mx + mx * pow(2, K);
	cout << ans;
}

Measured memory_bytes: 512
#include <cstdio>

#define N	9

int main()
{
	for(int i = 1; i <= N; i ++)
	{
		for(int j = 1; j <= N; j ++)
		{
			::printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	return(0);
}

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

int main(){
  vector<int> a(60000);
  for(int x=1;x<=100;x++){
    for(int y=x;y<=100;y++){
      for(int z=y;z<=100;z++){
        int k=x*x+y*y+z*z+x*y+y*z+z*x-1;
        if(x==y&&y==z) a[k]++;
        else if(x!=y&&y!=z&&z!=x) a[k]+=6;
        else a[k]+=3;
      }
    }
  }
  
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 3620
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,m = I()
s = v()
t = v()
l = lcm(n,m)
g = math.gcd(n,m)

for i in range(g):
    if s[n//g*i] != t[m//g*i]:
        print(-1)
        sys.exit()

print(l)


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 110;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void generate_table(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

struct BinaryIndexedTree {
private:
    int n,b;
    vector<int> bit;
public:
    BinaryIndexedTree(int n_) {
        n = n_+10;
        b = 1;
        while (b < n) b <<= 1;
        b >>= 1;
        bit = vector<int>(n,0);
    }

    void add(int a,int w) {
        for (int x = a;x < n;x += x&-x) bit[x] += w;
    }

    int sum(int a) {
        int ret = 0;
        for (int x = a;x > 0;x -= x&-x) ret += bit[x];
        return ret;
    }

    void update(int a,int w) {
        int v = w-sum(a)+sum(a-1);
        add(a,v);
    }

    int lower_bound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = b;k > 0;k /= 2) {
            if (x+k < n && bit[x+k] < w) {
                w -= bit[x+k];
                x += k;
            }
        }
        return x+1;
    }
};

int main() {
    generate_table(100);
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    BinaryIndexedTree bita(n),bitb(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) cin >> b[i];
    int x = 1,y = 1;
    for (int i = 0;i < n;++i) {
        bita.add(a[i],1);
        x += (a[i]-bita.sum(a[i]))*fact[n-i-1];
    }
    for (int i = 0;i < n;++i) {
        bitb.add(b[i],1);
        y += (b[i]-bitb.sum(b[i]))*fact[n-i-1];
    }
    cout << abs(x-y) << endl;
}


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

const ll N_MAX = 1e5 + 10;

ll N, M;
ll A[N_MAX], B[N_MAX];

void solve(){
  
  unordered_map<ll, ll> x;
  for(ll i = 0; i <= N; i++){
    x[B[i]]++;
  }

  ll ans = 0;

  for(auto p : x){
    ans += (p.second * (p.second - 1)) / 2;
  }

  cout << ans << endl;
}


int main() {

  cin >> N >> M;
  B[0] = 0;
  for(ll i = 0; i < N; i++){
    cin >> A[i];
    B[i+1] = B[i] + A[i];
    B[i+1] %= M;
  }

  solve();
}

Measured memory_bytes: 5260
import itertools

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

acc = [0] + list(itertools.accumulate(A))

B = [ai % M for ai in acc]
B.sort()
B.append(-1)

result = 0
count = 1

for i in range(N + 1):
    if B[i + 1] == B[i]:
        count += 1
    else:
        result += count * (count - 1) // 2
        count = 1
print(result)


Measured memory_bytes: 16324
fun main(args: Array<String>) {
    abc139c()
}

fun abc139c() {
    val n = readLine()!!.toInt()
    val hList = readLine()!!.split(" ").map { it.toInt() }

    var answer = 0
    var consecutiveMove = 0
    for (i in 0 until n - 1) {
        val currentHeight = hList[i]
        val nextHeight = hList[i + 1]
        if (currentHeight >= nextHeight) {
            consecutiveMove++
            if (consecutiveMove > answer) answer = consecutiveMove
        } else {
            consecutiveMove = 0
        }
    }

    println(answer)
}


Measured memory_bytes: 59704
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int main(){
    int n;scanf("%d %s",&n,s+1);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(s[i]!=s[i-1])ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 384
# 参考1: https://atcoder.jp/contests/abc125/submissions/8965716
# 参考2: https://qiita.com/hkrutknouch/items/e71488de4a0c8e83ee97

from fractions import gcd
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))

left = list(accumulate(A, gcd))
right = list(accumulate(A[::-1], gcd))[::-1]

ans = 0
for i in range(n):
  if i == 0:
    tmp = right[1]
  elif i == n - 1:
    tmp = left[-2]
  else:
    tmp = gcd(left[i-1], right[i+1])
  ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 16140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2e5+5,inf=0x3f3f3f3f,mo=1e9+7;
int a[N],b[N],mn[N],cnt[N],fac[N],inv[N];
poly v[N];
bool used[N];
int ksm(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mo){
		if(p&1) res=(ll)res*x%mo;
	}
	return res;
}
int main(){
	For(i,fac[0]=1,N-1) fac[i]=(ll)fac[i-1]*i%mo;
	inv[N-1]=ksm(fac[N-1],mo-2);
	Rep(i,N-2,0) inv[i]=(ll)(i+1)*inv[i+1]%mo;
	int n=read(),X=read(),Y=read(),zx=inf,cx=inf;
	For(i,1,n) mn[i]=inf;
	For(i,1,n){
		a[i]=read();b[i]=read();
		v[a[i]].pb(i);mn[a[i]]=min(mn[a[i]],b[i]);
	}
	For(i,1,n){
		if(mn[i]<zx) cx=zx,zx=mn[i];
		else if(mn[i]<cx) cx=mn[i];
	}
	For(i,1,n){
		if(mn[i]+zx>Y){
			for(auto x:v[i]) used[x]=1;
		}
		if(b[i]+mn[a[i]]>X&&b[i]+(mn[a[i]]==zx?cx:zx)>Y) used[i]=1;
	}
	int sum=0,ans;
	For(i,1,n) if(!used[i]) cnt[a[i]]++,sum++;
	ans=fac[sum];
	For(i,1,n) ans=(ll)ans*inv[cnt[i]]%mo;
	cout<<ans;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	cout << (a1 + a2 + a3 >= 22 ? "bust" : "win"); 
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    // テストの点数は、中間試験の点数 m、期末試験の点数 f、再試験の点数 r で構成されています。 

    int m, f, r;
    unsigned int total;

    while(1){

        cin >> m >> f >> r;

        if( m == -1 && f == -1 && r == -1){
            break;
        }

        total = m + f;

        if( m == -1 || f == -1){
            cout << 'F' << endl;
        }else if(total < 30){
            cout << 'F' << endl;
        }else if(total < 50){
            if( r < 50){
                cout << 'D' << endl;
            }else{
                cout << 'C' << endl;
            }
        }else if(total < 65){
            cout << 'C' << endl;
        }else if(total < 80){
            cout << 'B' << endl;
        }else{
            cout << 'A' << endl;
        }

    }

    return 0;
    
}


Measured memory_bytes: 3076
n, m = map(int, input().split())
ps = [int(p)-1 for p in input().split()]
xys = [tuple(int(x)-1 for x in input().split()) for _ in range(m)]

union = {node:node for node in range(n)}

def root(node):
    if union[node] == node:
        return node
    union[node] = root(union[node])
    return union[node]

for x, y in xys:
    union[root(x)] = root(y)

print(sum(root(i) == root(p) for i, p in enumerate(ps)))

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<pair<int, int>> P(N);
    rep(i, N) cin >> P[i].first >> P[i].second;

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

    ll now = 0;
    rep(i, N) {
        now += P[i].second;
        if (now >= K) {
            cout << P[i].first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(0) == '7' || s.charAt(1) == '7' || s.charAt(2) == '7' ) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35608
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
    ans = float('inf')
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))
    d = [[float('inf')]*N for _ in range(N)]
    for i in range(M):
        a,b,c = map(int, input().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c
    for i in range(N):
        d[i][i] = 0 #自身への最短経路は0
    #三重ループ
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    for p in permutations(r,R):
        cnt = 0
        for i in range(R-1):
            if d[p[i]-1][p[i+1]-1]<float('inf'):
                cnt += d[p[i]-1][p[i+1]-1]
            else:
                break
        else:
            ans = min(ans,cnt)
    return ans
print(solve())

Measured memory_bytes: 61144
N = int(input())
rate = list(map(lambda x:int(x), input().split(' ')))
isGrowing = False
money = 1000
upstart = None
for i in range(N-1):
    if not isGrowing and rate[i] < rate[i+1]:
        isGrowing = True
        upstart = i
    elif isGrowing and rate[i] > rate[i+1] and upstart is not None:
        money = (money//rate[upstart])*rate[i] + money%rate[upstart]
        upstart = i+1
        isGrowing = False
if isGrowing:
    money = (money//rate[upstart])*rate[N-1] + money%rate[upstart]
print(money)

Measured memory_bytes: 8996
def ndigits(A):
    ret = 0
    while A > 0:
        ret += 1
        A //= 10
    return ret


def F(A, B):
    return max(ndigits(A), ndigits(B))


def main():
    N = int(input())
    x = 1
    ans = float("inf")
    while x*x <= N:
        if N % x == 0:
            ans = min(ans, F(x, N//x))
        x += 1
    print(ans)


if __name__ == "__main__":
    main()


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256