akhauriyash/Code-Regression huggingface dataset:
N = int(input())
X1 = []

for i in range(N):
    X, L = map(int, input().split())
    X1.append([X+L, X-L])
X1.sort()
ans = -10**10
cnt = 0
for j in range(N):
    if(X1[j][1] >= ans):
        cnt += 1
        ans = X1[j][0]
print(cnt)

Measured memory_bytes: 20104
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main()
{
    int i, x;
    
    for(i=1; i<=10000; i++)
    {
        cin >> x;
        if(x == 0)
          cout << ""<< endl;
          else
        
        cout << "Case" <<" "<< i <<  ":" << " " << x << endl;
    }
}


Measured memory_bytes: 2972
#include <bits/stdc++.h>
#define NMAX 500
#define zeros(x) (x ^ (x-1)) & x

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, k, dp[100005], V[100005], back[100005];
multiset<pair<ll, ll> > S;
vector<ll> Ans;
string s;

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    cin>>s;
    for (ll i=0; i<s.size(); i++)
        V[i] = s[i]-'0';

    ll ok = 1;
    dp[0] = 0;
    back[0] = -1;
    S.insert({0, 0});
    for (ll i=1; i<=n; i++)
    {
        if (S.empty())
        {
            ok = 0;
            break;
        }
        ll top = S.begin()->first;
        ll bk = S.begin()->second;
        if (i>=k && V[i-k] == 0)
        {
            S.erase(S.find({dp[i-k], i-k}));
        }

        if (V[i] == 0)
        {
            dp[i] = top + 1;
            back[i] = bk;
            S.insert({dp[i], i});
        }
    }

    ll act = n;
    while (act != 0)
    {
        ll bk = back[act];
        Ans.push_back(act-bk);
        act = bk;
    }

    reverse(Ans.begin(), Ans.end());

    if (ok)
    {
        for (auto i : Ans)
            cout<<i<<" ";
    }
    else
        cout<<-1;
    return 0;
}


Measured memory_bytes: 6016
def make(num):
  if num==1 or num==2:
    return []
  l3=['357','375','537','573','735','753']
  if num==3:
    return l3
  l4=set()
  for i in range(len(l3)):
    l4.add('3'+l3[i])
    l4.add('5'+l3[i])
    l4.add('7'+l3[i])
    for j in range(1,3):
      l4.add(l3[i][:j]+'3'+l3[i][j:])
      l4.add(l3[i][:j]+'5'+l3[i][j:])
      l4.add(l3[i][:j]+'7'+l3[i][j:])
    l4.add(l3[i]+'3')
    l4.add(l3[i]+'5')
    l4.add(l3[i]+'7')
  l4=list(l4)
  if num==4:
    return l4+l3
  l5=set()
  for i in range(len(l4)):
    l5.add('3'+l4[i])
    l5.add('5'+l4[i])
    l5.add('7'+l4[i])
    for j in range(1,4):
      l5.add(l4[i][:j]+'3'+l4[i][j:])
      l5.add(l4[i][:j]+'5'+l4[i][j:])
      l5.add(l4[i][:j]+'7'+l4[i][j:])
    l5.add(l4[i]+'3')
    l5.add(l4[i]+'5')
    l5.add(l4[i]+'7')
  l5=list(l5)
  if num==5:
    return l5+l4+l3
  l6=set()
  for i in range(len(l5)):
    l6.add('3'+l5[i])
    l6.add('5'+l5[i])
    l6.add('7'+l5[i])
    for j in range(1,5):
      l6.add(l5[i][:j]+'3'+l5[i][j:])
      l6.add(l5[i][:j]+'5'+l5[i][j:])
      l6.add(l5[i][:j]+'7'+l5[i][j:])
    l6.add(l5[i]+'3')
    l6.add(l5[i]+'5')
    l6.add(l5[i]+'7')
  l6=list(l6)
  if num==6:
    return l6+l5+l4+l3
  l7=set()
  for i in range(len(l6)):
    l7.add('3'+l6[i])
    l7.add('5'+l6[i])
    l7.add('7'+l6[i])
    for j in range(1,6):
      l7.add(l6[i][:j]+'3'+l6[i][j:])
      l7.add(l6[i][:j]+'5'+l6[i][j:])
      l7.add(l6[i][:j]+'7'+l6[i][j:])
    l7.add(l6[i]+'3')
    l7.add(l6[i]+'5')
    l7.add(l6[i]+'7')
  l7=list(l7)
  if num==7:
    return l7+l6+l5+l4+l3
  l8=set()
  for i in range(len(l7)):
    l8.add('3'+l7[i])
    l8.add('5'+l7[i])
    l8.add('7'+l7[i])
    for j in range(1,7):
      l8.add(l7[i][:j]+'3'+l7[i][j:])
      l8.add(l7[i][:j]+'5'+l7[i][j:])
      l8.add(l7[i][:j]+'7'+l7[i][j:])
    l8.add(l7[i]+'3')
    l8.add(l7[i]+'5')
    l8.add(l7[i]+'7')
  l8=list(l8)
  if num==8:
    return l8+l7+l6+l5+l4+l3
  l9=set()
  for i in range(len(l8)):
    l9.add('3'+l8[i])
    l9.add('5'+l8[i])
    l9.add('7'+l8[i])
    for j in range(1,8):
      l9.add(l8[i][:j]+'3'+l8[i][j:])
      l9.add(l8[i][:j]+'5'+l8[i][j:])
      l9.add(l8[i][:j]+'7'+l8[i][j:])
    l9.add(l8[i]+'3')
    l9.add(l8[i]+'5')
    l9.add(l8[i]+'7')
  l9=list(l9)
  if num==9 or num==19:
    return l9+l8+l7+l6+l5+l4+l3

n=int(input())
l=len(str(n))
arr=make(l)
if len(arr)==0:
  print(0)
else:
  cnt=0
  for i in range(len(arr)):
    if int(arr[i])<=n:
      cnt+=1
  print(cnt)

Measured memory_bytes: 5624
using System;

namespace abc157a
{
    class abc157a
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var ans = int.Parse(input[0].ToString()) + int.Parse(input[1].ToString()) + int.Parse(input[2].ToString());
            Console.WriteLine(ans);        }
    }
}


Measured memory_bytes: 27328
#include <cstdio>

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

int main()
{
  int n, k, x, y;
  scanf("%d %d %d %d", &n, &k, &x, &y);
  printf("%d\n", min(n, k) * x + max(n - k, 0) * y);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b;
    cin>>a>>b;
    int g = __gcd(a,b);
    cout << 1ll*a*b/g << endl;
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	MAX := 1 << uint(N)
	C := make([]int, M)
	A := make([]int, M)
	for i := 0; i < M; i++ {
		a, b := sc.nextInt(), sc.nextInt()
		C[i] = a
		sum := 0
		for j := 0; j < b; j++ {
			c := sc.nextInt() - 1
			sum += 1 << uint(c)
		}
		A[i] = sum
	}
	dp := make([][]int, M+1)
	for i := 0; i < M+1; i++ {
		dp[i] = make([]int, MAX)
		for j := 0; j < MAX; j++ {
			dp[i][j] = INF
		}
	}
	dp[0][0] = 0
	for i := 0; i < M; i++ {
		for bit := 0; bit < MAX; bit++ {
			dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit])
			union := bit | A[i]
			dp[i+1][union] = min(dp[i+1][union], dp[i][bit]+C[i])
		}
	}

	if dp[M][MAX-1] != INF {
		fmt.Fprintln(wtr, dp[M][MAX-1])
	} else {
		fmt.Fprintln(wtr, -1)
	}
}


Measured memory_bytes: 33920
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=True

for i in range(N):
  ans*=A[i]
  
  if(ans>10**18):
    flag=False
    break
if(0 in A):
  flag=True
  ans=0
if flag:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 21788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  int N;
    cin >> N;
  
  cin >> str;
  int countr = 0;
  int countb = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'R') {
      countr++;
    }
    if (str.at(i) == 'B') {
      countb++;
    }
  }
 if (countr > countb) {
      cout << "Yes" << endl;
    }
  
 if (countr <= countb) {
      cout << "No" << endl;
    }
  
}

Measured memory_bytes: 256
"use strict";
function main(input) {
    let S = input.replace("\n", "");
    let flg = S.charAt(2) === S.charAt(3) && S.charAt(4) === S.charAt(5)
    console.log(flg ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<stdio.h>
#include<algorithm>
using std::sort;



int main(){
    int r,g,b,n;
    int ans=0;
    scanf("%d%d%d%d",&r,&g,&b,&n);
    for(int i=0;r*i<=n;i++){
        for(int j=0;r*i+g*j<=n;j++){
            int left=n-r*i-g*j;
            if(left%b==0)ans++;
        }
    }
    printf("%d\n",ans );
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
ll gcd(ll a, ll b) {
  return (b == 0 ? a : gcd(b, a%b));
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll a, b; cin >> a >> b;
  ll g = gcd(a, b);
  int cnt = 0;
  for(ll i=2;i*i<=g;++i) {
    if(g%i == 0) {
      cnt++;
      while(g%i==0) g /= i;
    }
  }
  if(g != 1) cnt++;
  cout << cnt + 1 << endl;
}


Measured memory_bytes: 256
f=lambda:map(int,input().split())
n,m=f()

# Union Find
p=[-1]*n
def root(x):
  while p[x]>=0: x=p[x]
  return x
def unite(x,y):
  x,y=root(x),root(y)
  if x==y: return
  if x>y: x,y=y,x
  p[x]+=p[y]
  p[y]=x
def same(x,y):
  return root(x)==root(y)
def size(x):
  return -p[root(x)]

for _ in range(m):
  a,b=f()
  unite(a-1,b-1)
print(sum(i<0 for i in p)-1)

Measured memory_bytes: 10980
#include<stdio.h>
long long MAX(long long a,long long b){return a<b?b:a;}
int main(){
  long long n,a,b,d[100010],l,r,m,i,s;
  scanf("%lld %lld %lld",&n,&a,&b);
  for(i=l=0;i<n;i++)scanf("%lld",&d[i]);
  for(r=1e9+10;l-r;){//printf("%lld %lld\n",l,r);
    m=(l+r)/2;
    for(i=s=0;i<n;i++)s+=d[i]>m*b?((d[i]-m*b)-1)/(a-b)+1:0;
    //printf("%lld %lld %lld %lld\n",l,r,m,s);
    //if(s>m)l=m+1;
    //else   r=m;
    if(s<=m)r=m;
    else    l=m+1;
  }
  //printf("%d %d\n",((10-2*2)-1)/(5-2)+1,((4-2*2)-1)/(5-2)+1);
  printf("%lld\n",l);
  return 0;
}


Measured memory_bytes: 896
import math

N = int(input())
s = {}
ans = 0

for i in range(N):
    tmp = ''.join(sorted(input()))
    if tmp in s:
        s[tmp] += 1
    else:
        s[tmp] = 1

x = math.factorial(2)
for n in s.values():
  	if n > 1:
	    ans += math.factorial(n) // (math.factorial(n-2) * x)
print(ans)


Measured memory_bytes: 17848
def pow_self(x,n):
    ans = 1
    while n>0:
        if n&1 == 1:
            ans = (ans*x)%(10**9+7)
            
        x = (x*x)%(10**9+7)
        n >>= 1
    return ans

  
n,a,b = map(int, input().split())        
X,Y = 1,1
for i in range(b):
    X *= n-i
    X %= 10**9+7
    Y *= i+1
    Y %= 10**9+7

    if a-1 == i:
        Xa,Ya = X,Y

comb_a = (Xa*pow_self(Ya,10**9+5))%(10**9+7)
comb_b = (X*pow_self(Y,10**9+5))%(10**9+7)

result = pow_self(2,n)-1-comb_a-comb_b
while result <0:
    result += 10**9+7
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO
    ll k,n,ans=0;
    cin>>n>>k;
    int a[n];
    REP(i,0,n) cin>>a[i];
    sort(a,a+n);
    REP(i,0,k)
      ans+=a[i];
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	vector<int> S(3);
	cin >> S.at(0) >> S.at(1) >> S.at(2);
	sort(S.begin(), S.end());
	if (S.at(0) == 5 && S.at(1) == 5 && S.at(2) == 7) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for (int i = 0; i < R; i++)
    {
        cin >> r[i];
        r[i]--;
    }
    sort(r.begin(), r.end());
    vector<vector<int>> dp(N, vector<int>(N, INF));
    for (int i = 0; i < M; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = dp[b][a] = c;
    }
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
    int ans = INF;
    do {
        int total = 0;
        for (int i = 1; i < r.size(); i++) {
            total += dp[r[i-1]][r[i]];
        }
        ans = min(ans, total);
    } while (next_permutation(r.begin(), r.end()));

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

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int& x: a) {
        cin >> x;
    }

    vector<bool> dp(k+1);
    dp[0] = false;
    for(int i = 0; i <= k; i++) {
        for(int j = 0; j < n; j++) {
            if(dp[i] == false && i+a[j] <= k) {
                dp[i+a[j]] = true;
            }
        }
    }
    if(dp[k] == true) {
        cout << "First" << endl;
    }
    else {
        cout << "Second" << endl;
    }
}


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

int main() {
    int c[3][3];
    for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin >> c[i][j];

    for(int i = -100; i <= 100; i++) {
        int a0, b[3];
        a0 = i;
        b[0] = c[0][0] - i;
        b[1] = c[0][1] - i;
        b[2] = c[0][2] - i;
        if(c[1][0] - b[0] == c[1][1] - b[1] && c[1][1] - b[1] == c[1][2] - b[2]) {
            if(c[2][0] - b[0] == c[2][1] - b[1] && c[2][1] - b[1] == c[2][2] - b[2]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

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

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

using namespace std;

int m,n;
double p[16][16];

double dp[1<<16][16];
double dfs(int S,int pos){
	if(pos==n) return 1;
	if( S ==0) return 0;

	if(dp[S][pos]!=-1) return dp[S][pos];

	double res=0;
	rep(i,m) if(S&1<<i) { // ツ猫 i ツづーツ派ツ個ュツつキツづゥ
		double tmp=0,q=1;
		for(int j=pos;j<n;j++){ // j ツ氾板姪堋づ個敵ツづ可づ「ツづァツづェツつス
			tmp+=q*(1-p[i][j])*dfs(S&~(1<<i),j);
			q*=p[i][j];
		}
		tmp+=q*dfs(S&~(1<<i),n); // ツゴツーツδ?
		res=max(res,tmp);
	}
	return dp[S][pos]=res;
}

int main(){
	scanf("%d%d",&m,&n);
	rep(i,m) rep(j,n) scanf("%lf",p[i]+j);

	rep(S,1<<m) rep(j,n) dp[S][j]=-1;
	printf("%.15f\n",dfs((1<<m)-1,0));

	return 0;
}

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

int main(void) {
  int N;    // 1~3 桁
  int M;    // 条件数

  cin >> N >> M;

  vector<P> p(M);
  rep(i, M) {
    cin >> p.at(i).first >> p.at(i).second;
  }

  // 1~999が対象なので全検索で間に合う。
  rep(num, 1000) {
    // 数値から、各桁の配列へ変換する
    int next = num;
    vector<int> v;
    int keta = 0;
    do {
      keta++;
      v.push_back(next % 10);
      next = next / 10;
    } while (next != 0);
    reverse(v.begin(), v.end());
    // 1~999を調べ居るので0以外の先頭0は存在しない
    // 桁があっているかだけ確認する
    if (keta != N) {
      continue;
    }

    // 条件のチェック
    bool ok = true;
    rep(i, M) {
      if (v.at(p.at(i).first - 1) != p.at(i).second) {
        ok = false;
      }
    }

    if (ok) {
      cout << num << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}

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

constexpr int MAXN = 1e5;
int height[MAXN];
int cost[MAXN];

int mn(int index, int k)
{
    int lst = INT32_MAX / 2;

    for (int j = index - 1; j >= 0 && (index - j) <= k; j--)
        lst = min(lst, cost[j] + abs(height[index] - height[j]));

    return lst;
}

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) 
        cin >> height[i];

    for (int i = 1; i < n; i++)
        cost[i] = mn(i, k);

    cout << cost[n-1] << "\n";
}

Measured memory_bytes: 1024
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(0,N):
    asum=0
    bsum=0

    for j in range(i+1):
        asum+=A[j]
    for j in range(i,N):
        bsum+=B[j]
    ans=max(ans,asum+bsum)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;



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

	string N;
	int counter=0;
	int max_count=0;

	cin >> N;

	REP(i, N.length()) {
		if (N[i] == 'A' || N[i] == 'C' || N[i] == 'G' || N[i] == 'T') {
			counter++;
			if (max_count < counter)max_count = counter;
		}
		else
		{
			counter = 0;
		}
	}

	cout << max_count << endl;
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;

const int inf=1<<20;

int main(void){
	int n,m,l,s,t;
	while(cin >> n >> m >> l >> s >> t,n){
		s--;
		int dist[310][310];
		rep(i,n)rep(j,n) dist[i][j]=i==j?0:inf;
		rep(i,m){
			int a,b,c;
			cin >> a >> b >> c;
			dist[a-1][b-1]=dist[b-1][a-1]=c;
		}

		rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]);
		

		int tsp[1<<16][16],d[16],e[16];
		rep(mask,1<<l)rep(i,l) tsp[mask][i]=inf;

		rep(i,l) cin >> d[i] >> e[i],d[i]--;
		rep(i,l) tsp[bit(i)][i]=dist[s][d[i]];
		rep(mask,1,1<<l)rep(i,l) if(mask&bit(i)){
			rep(j,l){
				if(mask&bit(j)) continue;
				chmin(tsp[mask|bit(j)][j],tsp[mask][i]+dist[d[i]][d[j]]);
			}
		}

		int ans=0;
		rep(mask,1,1<<l)rep(i,l){
			rep(j,l) if(mask&bit(j)) tsp[mask][i]+=e[j];
			tsp[mask][i]+=dist[d[i]][s];
			if(tsp[mask][i]<=t) chmax(ans,popcount(mask));
		}
		cout << ans << endl;
	}		
	return 0;
}

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

int main(){
  int K,S;
  cin >> K >> S;
  int64_t ans=0;
  for(int X=0;X<=K;X++){
    for(int Y=0;Y<=K;Y++){
      int Z=S-X-Y;
      if((Z>=0)&&(Z<=K)){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k]) % MOD) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k;
    cin >> n >> k;

    LL res = 0;
    LL cnt = 0;
    for( int i = k; i <= n; ++i ) {
        if( i % k == 0 ) {
            ++cnt;

        }
    }

    res = cnt;
    if( cnt > 0 ) res += (cnt - 1) * 3 * cnt;

    if( cnt >= 3 ) {
        res += cnt * (cnt - 1) * (cnt - 2);

    }

    if( k % 2 == 0 ) {
        cnt = 0;
        for( int i = 1; i <= n; ++i ) {
            if( i % k == k / 2 ) {
                ++cnt;

            }
        }

        res += cnt;
        if( cnt > 0 ) res += (cnt - 1) * 3 * cnt;
        if( cnt >= 3 ) {
            res += cnt * (cnt - 1) * (cnt - 2);

        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
using namespace std;
inline char nc()
{
    // return getchar();
    static char buf[100000],*l=buf,*r=buf;
    return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
    x=0; int f=1,ch=nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x*=f;
}
typedef pair<int,int> pii;
const int maxn=2e5+50;
int n,a[maxn];
set<pii> s;
bool check(int c)
{
    s.clear();
    for(int i=2;i<=n;++i)
    {
        // debug("%d %d\n",c,i);
        if(a[i]<=a[i-1])
        {
            while(s.size()&&s.rbegin()->fi>a[i]) s.erase(*s.rbegin());
            int x=a[i];
            while(true)
            {
                set<pii>::iterator it=s.lower_bound(make_pair(x,0));
                int y=0; if(it!=s.end()&&it->fi==x) y=it->se,s.erase(it);
                if(++y==c)
                {
                    if(x==1) return 0;
                    --x; continue;
                }
                s.insert(make_pair(x,y));
                break;
            }
        }
    }
    return 1;
}
int main()
{
    read(n);
    for(int i=1;i<=n;++i) read(a[i]);
    int l=1,r=n,an=-1;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid)) r=mid-1,an=mid;
        else l=mid+1;
    }
    printf("%d\n",an);
    return 0;
}

Measured memory_bytes: 1152
N,M=map(int,input().split())
rest=[[] for _ in range(N)]
r2=[]
end=0
flag=0
buf=""
ans=float("inf")
end=0
for i in range(M):
    s,c=map(int,input().split())
    if len(rest[s-1])==0:
        rest[s-1].append(c)
    elif rest[s-1].count(c)==0:
        end=1
        break
#print(rest)

if N == 1:
    l=range(0,10**N,1)
else:
    l=range(10**(N-1),10**N,1)
fail=0
if end!=1:
    for i in l:
        buf=str(i)
        #print(i)
        for j in range(N):
            if len(rest[j])==1:
                if buf[j]!=str(rest[j][0]):
                    fail=1
                    break
        if fail==0:
            ans=i
            flag=1
            break
        fail=0
if (flag==1):
    print(ans)
else:
    print("-1")

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<vector<int> > dist;
vector<string> s;

int dh[] = {1, 0, -1, 0};
int dw[] = {0, 1, 0, -1};

void dfs(int h, int w, int sh, int sw, int k, set<P> &st) {
    dist[sh][sw] = k;
    st.insert(P(sh, sw));

    for (int i = 0; i < 4; i++) {
        int nh = sh + dh[i], nw = sw + dw[i];

        if (nh < 0 || h <= nh || nw < 0 || w <= nw || s[nh][nw] == '#' || dist[nh][nw] != -1)
            continue;

        dfs(h, w, nh, nw, k, st);
    }
}

int main() {
    int h, w;   cin >> h >> w;
    s.resize(h);
    dist.resize(h, vector<int>(w, -1));
    int c_h, c_w, d_h, d_w; 
    cin >> c_h >> c_w >> d_h >> d_w;
    c_h--, c_w--, d_h--, d_w--;

    for (int i = 0; i < h; i++)
        cin >> s[i];

    set<P> s1, s2;
    int k = 0;
    
    dfs(h, w, c_h, c_w, k, s1);
    if (s1.find(P(d_h, d_w)) != s1.end()) {
        cout << 0 << endl;
        return 0;
    }
    k++;
    
    

    while (1) {
        for (auto p: s1) {
            int y = p.first, x = p.second;
            for (int i = -2; i < 3; i++) {
                for (int j = -2; j < 3; j++) {
                    if (y + i < 0 || h <= y+i || x + j < 0 || w <= x + j || dist[y+i][x+j] != -1 || s[y+i][x+j] == '#')
                        continue;
                    s2.insert(P(y+i, x+j));
                }
            }
        }
        if (s2.size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        s1.clear();
        for (auto p: s2) {
            int y = p.first, x = p.second;
            if (dist[y][x] == -1)
                dfs(h, w, y, x, k, s1); //距離kでいける場所をs１に列挙
        }
        
        if (s1.find(P(d_h, d_w)) != s1.end()) {
            cout << k << endl;
            return 0;
        }
        k++;
        s2.clear();
    }
}

Measured memory_bytes: 10064
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type edge struct {
	to, idx int
}

var ma int
var node [][]edge
var col []int

func dfs(e, p, c int) {
	color := 1
	for _, v := range node[e] {
		if v.to == p {
			continue
		}
		if color == c {
			color++
		}
		col[v.idx] = color
		ma = max(ma, color)
		dfs(v.to, e, color)
		color++
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	node = make([][]edge, N)
	for i := 0; i < N-1; i++ {
		f, t := getInt()-1, getInt()-1
		node[f] = append(node[f], edge{t, i})
		node[t] = append(node[t], edge{f, i})
	}
	col = make([]int, N-1)
	dfs(0, -1, 0)

	out(ma)
	for _, v := range col {
		out(v)
	}
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H, W, A, B; cin >> H >> W >> A >> B;
  rep(i, H) {
    rep(j, W) {
      cout << "01"[(i < B) ^ (j < A)];
    }
    cout << endl;
  }
}


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

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

#define MOD 1000000007

int main(void) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    while(true) {
        C -= B;
        if(C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
from collections import Counter
import numpy as np
N = int(input())
S = []
for i in range(N):
    S.append(input())

c = Counter(S)
c_keys=np.array(list(c.keys()))
c_values=list(c.values())
max_value=max(c_values)
index_list=[index for index, value in enumerate(c_values) if value == max_value]
ans_list=list(c_keys[index_list])
ans_list.sort()
for text in ans_list:
    print(text)

Measured memory_bytes: 106932
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;

int main(){
  int N;
  cin >> N;
  double A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A, A+N);
  for(int i=1;i<N;i++){
    A[i] = (A[i-1] + A[i])/2;
  }
  cout << A[N-1] << endl;
}

Measured memory_bytes: 256
my Int $max-days = $*IN.get.Int;
my Int $former-days = $*IN.get.Int;
my Int $former-price = $*IN.get.Int;
my Int $latter-price = $*IN.get.Int;

say $former-price * ($former-days,$max-days).min + $latter-price * ($max-days - $former-days <= 0 ?? 0 !! $max-days - $former-days)

Measured memory_bytes: 64116
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

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

  for(int i = 1; i <= 9; i++) {
    for(int j = 1; j <= 9; j++) {
      if(i*j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

int main() {
  int n, k, i, ans = 0;
  cin >> n >> k;
  
  vector<int> l(n);
  for(i = 0; i < n; i++){
    cin >> l.at(i);
  }
  
  sort(l.begin(), l.end());
  
  for(i = n - 1; i >= n - k; i--){
    ans += l.at(i);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace testes
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] B = new int[N - 1];
            string[] str = Console.ReadLine().Split(' ');
            for (int i = 0; i < N-1; i++) B[i] = int.Parse(str[i]);

            int[] A = new int[N];
            A[0] = B[0];
            for(int i = 1; i < N - 1; i++)
            {
                A[i] = Math.Min(B[i], B[i - 1]);
            }
            A[N - 1] = B[N - 2];
            int ans = 0;
            for (int i = 0; i < N; i++) ans += A[i];
            Console.WriteLine(ans);
        }
    }

}

/*
int a, b, c;
a = int.Parse(Console.ReadLine()); //標準入力
string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
c = int.Parse(str[1]);
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力

string[] str = Console.ReadLine().Split(' ');
int[] a = new int[N];
for(int i = 0; i < N; i++) a[i] = int.Parse(str[i]);
 */
 

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int k = scanner.nextInt();

        long sum = 0;
        for (int a = 1; a <= k; a++) {
            for (int b = 1; b <= k; b++) {
                final long l = euclideanAlgorithm(a, b);
                for (int c = 1; c <= k; c++) {
                    sum += euclideanAlgorithm(l, c);
                }
            }
        }

        System.out.println(sum);
    }

    private static long euclideanAlgorithm(final long a, final long b) {
        if (b > a) {
            return euclideanAlgorithm(b, a);
        }

        if (b == 0) {
            return a;
        }

        return euclideanAlgorithm(b, a % b);
    }
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a,b; cin >> a >> b;
  ll n = b - a;
  cout << n * (n-1) / 2 - a << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007  
#define fi first
#define se second
vector<int> adj[100002];
int main()
{  
	int n,m;
	cin>>n>>m;
	vector<int> h(n+1);
	int i;
	int p[n+1];
	for(i=1;i<=n;i++)
		cin>>h[i];
	int u,v;
	for(i=0;i<m;i++)
	{
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int ans = 0,j;
	for(i=1;i<=n;i++)
	{
		int f = 0;
		for(j=0;j<adj[i].size();j++)
		{
			if(h[i]<=h[adj[i][j]])
				f=1;
		}
		if(f==0){
			ans++;
			// cout<<i<<" ";
		}
	}
	// cout<<"\n";
	cout<<ans;
}

Measured memory_bytes: 8728
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


int main() {
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;
	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

template<int M>
class Combination
{
public:
  int n;
  vector<int> fac, finv;

  Combination(int n_) : n(n_), fac(n_), finv(n_)
  {
    fac[0] = 1;
    for(int i = 1; i < n; i++) fac[i] = fac[i-1]*i%M;
    finv[n-1] = pow(fac[n-1], M-2);
    for(int i = n-1; i > 0; i--) finv[i-1] = finv[i]*i%M;
  }

  int pow(int a, int b)
  {
    if(b == 0) return 1; 
    return pow(a*a%M, b/2)*(b%2?a:1)%M;
  }

  int C(int a, int b)
  {
    if(b < 0 or a < b) return 0;
    return fac[a]*finv[a-b]%M*finv[b]%M;
  }

  int P(int a, int b)
  {
    if(b < 0 or a < b) return 0;
    return fac[a]*finv[a-b]%M; 
  }

  int H(int a, int b){
    if(a == 0 and b == 0) return 1;
    return C(a+b-1, b);
  }
};

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

  vi a(n+1);
  rep(i, 0, n+1){ cin >> a[i]; a[i]--; } 

  int l, r;
  vi memo(n, -1);
  rep(i, 0, n+1){
    if(memo[a[i]] != -1){
      l = memo[a[i]];
      r = i;
      break;
    }
    memo[a[i]] = i;
  }

  const int mod = 1e9 + 7;
  Combination<mod> comb(101010);

  rep(k, 1, n+2){
    int ans = (comb.C(n+1, k) - comb.C(l+n-r, k-1) + mod) % mod;
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;


vi count_letter(const vvi &ss, int l, int r)
{
	vi letters(26);
	for (int j = 0; j < 26; j++)
	{
		letters[j] = ss[r][j] - ss[l][j];
	}
	return letters;
}

int query2(const string &S, const vvi& ss, const unordered_map<int, char>& querys, int l, int r)
{
	--l;
	vi letters = count_letter(ss, l, r);
	for (auto q : querys)
	{
		if (l <= q.first && q.first < r)
		{
			int out = S[q.first] - 'a';
			int in = q.second - 'a';
			--letters[out];
			++letters[in];
		}
	}

	int q2 = 0;
	for (int l : letters)
	{
		if (l > 0) ++q2;
	}
	return q2;
}

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

	vvi ss(N+1, vi(26, 0));
	for (int i = 0; i < N; i++)
	{
		int ci = S[i] - 'a';
		for (int j = 0; j < 26; j++)
		{
			ss[i + 1][j] = ss[i][j] + (ci == j ? 1 : 0);
		}
	}

	unordered_map<int, char> querys;
	for (int q = 0; q < Q; q++)
	{
		int type;
		cin >> type;
		if (type == 1)
		{
			int i;
			char c;
			cin >> i >> c;
			querys[i-1] = c;
		}
		else
		{
			int l, r;
			cin >> l >> r;
			int ans = query2(S, ss, querys, l, r);
			cout << ans << endl;
		}
	}
}

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

int main() {
    int n;
    cin >> n;
    string c;
    cin >> c;
    int cntr=0;
    for (int i=0;i<n;i++) {
        if (c[i]=='R') cntr++;
    }
    int cntw_to_cntr=0;
    for (int i=0;i<cntr;i++) {
        if (c[i]=='W') cntw_to_cntr++;
    }
    cout << cntw_to_cntr << endl;
    return 0;
}

Measured memory_bytes: 3712
N,X,Y=map(int,input().split())

ans=[0]*(N)
for i in range(1,N):
    for j in range(i+1,N+1):
        res=min(abs(j-i),abs(X-i)+abs(Y-j)+1,abs(X-j)+abs(Y-i)+1)
        ans[res]+=1

for a in ans[1:]:
    print(a)

Measured memory_bytes: 3444
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	a_list = LI()
	a_dict = list(Counter(a_list).items())
	a_dict.sort()
	ans = 1
	if n % 2 == 0:
		for i in range(len(a_dict)):
			diff, number = a_dict[i]
			if diff % 2 == 0:
				ans = 0
				break
			if diff != 2*i+1 or number != 2:
				ans = 0
				break
			ans *= 2
			ans %= MOD
	else:
		for i in range(len(a_dict)):
			diff, number = a_dict[i]
			if diff % 2 == 1 or (diff == 0 and number !=1):
				ans = 0
				break
			if diff != 2*i or (diff > 0 and number != 2):
				ans = 0
				break
			if diff != 0:
				ans *= 2
				ans %= MOD
	print(int(ans))


	


if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> y(N);
  for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

  double ans = 0.0;
  for (int i = 0; i < N; i++) {
    if (y[i] == "JPY") ans += x[i];
    else if (y[i] == "BTC") ans += x[i] * 380000.0;
  }
  cout << fixed << setprecision(4) << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for (int i = 0; i < n + 1; i++)
			a[i] = in.nextInt();
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		System.out.println(solve(a, b));
		in.close();
	}

	private static long solve(int[] a, int[] b) {
		long r = 0;
		for (int i = 0; i < b.length; i++)
			for (int j = i; j <= i + 1; j++)
				if (a[j] > b[i]) {
					r += b[i];
					a[j] -= b[i];
					b[i] = 0;
				} else {
					r += a[j];
					b[i] -= a[j];
					a[j] = 0;
				}
		return r;
	}
}


Measured memory_bytes: 80220
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
using ll = long long;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int L[200002],R[200020],x[505][505],c[505][505];
int main(){
    int N,M,Q; cin >> N >> M >> Q;
    for(int i = 1; i <= M; i++){
        cin >> L[i] >> R[i];
        x[L[i]][R[i]]++;
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            c[i][j] = c[i][j-1] + x[i][j];
        }
    }
    for(int i = 1; i <= Q; i++){
        int p,q; cin >> p >> q;
        int sum = 0;
        for(int j = p; j <= q; j++){
            sum += c[j][q]-c[j][p-1];
        }
        cout << sum << endl;
    }
}
  



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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()

typedef tuple<ll, ll, char, ll, string> T;

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

    vector<T> A;

    FOR(i, 0, N){
        ll a, b;
        char c;
        ll d;
        string e;
        cin >> a >> b >> c >> d >> e;

        A.push_back(make_tuple(a, b, c, d, e));
    }
    sort(ALL(A));

    for(auto tup : A){
        ll a, b;
        char c;
        ll d;
        string e;
        tie(a, b, c, d, e) = tup;
        cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << endl;
    }

    return 0;
}


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

using namespace std;

string whowillwin(int *arr,int n,int k){

 
int DP[k+1]={0};



for(int i=1;i<=k;i++){

  for(int j=0;j<n;j++){

      if(arr[j]>i)
       continue;

   else{

           if(DP[i-arr[j]]==0)
             DP[i]=1;
   }


  }




}


 return (DP[k]==0)?"Second":"First";


}


int main(){

  
   int n,k;

   cin>>n>>k;

   int arr[n];

   for(int i=0;i<n;i++)
   	 cin>>arr[i];

 cout<<whowillwin(arr,n,k)<<endl;

	return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

string s;
int a;

int main(){
  cin >> a >>s;
  if(a >= 3200){
    cout << s <<endl;
  }else{
    cout << "red" <<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
//FILE *fi = freopen("P.inp", "r", stdin);
//FILE *fo = freopen("P.out", "w", stdout);
int main()
{
    //------------------------------
    // Faster
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //-------------------------------
    int a, b, c;
    cin >> a >> b >> c;
    if (b * c >= a)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

map<ll,ll> m;

ll solve(ll h){
  if(h==1) return 1;
  if(m[h/2]>0) return m[h/2]*2+1;
  else {
    ll a=solve(h/2);
    m[h/2]=a;
    return a*2+1;
  }
}

int main(){
  int i,j;
  ll h;
  cin>>h;
  cout<<solve(h)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


int main(){
	int n;
	cin >> n;
	vector<string> v;
	string s;
	cin >> s;
	v.push_back(s);
	for(int i=1;i<n;i++){
		cin >> s;
		if(v[i-1][v[i-1].length()-1]!=s[0]){
			cout << "No" << endl;
			return 0;
		}else{
			for (int j = 0; j < v.size(); j++){
				if(v[j]==s){
					cout << "No" << endl;
					return 0;
				}
			}
			v.push_back(s);
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
// 8/22 リアルタイム参加
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
    int N, X, T;
    cin >> N >> X >> T;

    int ans = ((N + X - 1) / X) * T;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x % mod;
        n = n / 2;
        x = x * x % mod;
    }
    return result;
}

int main(){
   char a;
   cin>>a;
   if(a>='a' and a<='z')
    cout<<'a'<<endl;
   else
    cout<<'A'<<endl;

  return 0;
}


Measured memory_bytes: 3584
import bisect
import math
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
am = max(A)
B.sort()
idx = bisect.bisect_right(B, am)
ans = 0
for i in range(1, N-idx+1):
  H -= B[-i]
  ans += 1
  if H <= 0:
    print(ans)
    exit()
print(ans + math.ceil(H/am))

Measured memory_bytes: 17096
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string ans = "";
    REP(i,3){
        string s;
        cin >> s;
        ans += s[0];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256