akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <limits.h>

using namespace std;

int main() {
	int N;
	cin >> N;
	int h[N], dp[N];
	for (int i = 0; i < N; ++i) cin >> h[i];

	dp[0] = 0;
	for(int i = 1; i < N; ++i) {
		dp[i] = INT_MAX;
		for(int j = 1; j <= 2; ++j) {
			if (i-j >= 0) {
				dp[i] = min(abs(h[i]-h[i-j])+dp[i-j], dp[i]);
			}
		}
	}
	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	N := ReadInt()
	T, A := ReadInt(), ReadInt()
	Hs := ReadInts(N)

	best := 0
	bestAbs := Abs(float64(A) - Kion(Hs[0], T))

	for i := 1; i < N; i++ {
		kion := Kion(Hs[i], T)
		abs := Abs(float64(A) - kion)
		if bestAbs > abs {
			best = i
			bestAbs = abs
		}
	}

	fmt.Println(best + 1)
}

func Kion(h int, T int) float64 {
	return float64(T) - float64(h)*0.006
}

func Abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func ReadInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
#define pb push_back

int K, k, digitKs_S;

/*dp[i][j] := i桁以下の最上位数がjのルンルン数(0も含む)*/
vector<vector<int>> dp(15, vector<int>(10, 0)); 
vector<int> cumulS(15, 0); //lln's cumulative S
vector<char> lln;  //LunLun number...



void LunLunNumber(int U, int digit){  //digit桁llnの下からU番目
    int tmp = 0, i = 1;
    while(digit > 0){     //digit桁目を決定しi
        while(tmp+dp[digit][i] < U) tmp += dp[digit][i++];
        lln.pb('0'+i);
        U -= tmp;         //次はdigit桁がiである下からU番目のlln
        --digit;
        tmp = 0;
        if(i != 0) --i;
    }
    return ;
}


int main(){
    cin >> K;

    dp[1] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};  //初期条件

    int k = 9, d = 1;  //d桁以下のルンルン数の個数和がk
    while(k < K){
        cumulS[d] = k;  //d桁以下のルンルン数総数
        ++d;
        dp[d][0] = dp[d-1][0]+dp[d-1][1];  //ルンルン数ではない
        dp[d][9] = dp[d-1][8]+dp[d-1][9];  k += dp[d][9];
        for(int i = 1; i <= 8; i++){
            dp[d][i] = dp[d-1][i-1]+dp[d-1][i]+dp[d-1][i+1];
            k += dp[d][i];
        }
    }
    /*この時点でルンルン数はd桁であることが判明*/
    /*d桁のルンルン数の小さい方からK-cumulS[d]番目の数を出力*/
    LunLunNumber(K-cumulS[d-1], d);
    for(int i = 0; i < lln.size(); i++) cout << lln[i];
    cout << endl;
    return 0;
}






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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int n;
    cin >> n;
    int target = 1;
    rep (i , n ) {
        int a;
        cin >> a;
        if (a == target) target++;
    } 
    if ( target == 1) cout << -1 << endl;
    else cout << n - target + 1 << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b;
	cin >> a >> b;


	int ans = max(a, b) + max(a - 1, b - 1);
	ans += a == b;

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


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

int cnt = 0;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long int p, q;
	cin >> p >> q;

	for(int i = 0; i < p; ++i)
	{
		long long int x , y;
		cin >> x >> y;
		long long int total = (x*x) + (y*y);
		if(total <= (q*q))
		{
			cnt++;
		}
		
 	}	
 	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ll3 = array<ll,3>;
ll a[1000],b[1000],c[1000];
int main(){
    int x,y,z;
    std::size_t k;
    cin >> x >> y >> z >> k;
    rep(i,x)cin >> a[i];
    rep(i,y)cin >> b[i];
    rep(i,z)cin >> c[i];
    sort(a,a+x,greater<ll>());
    sort(b,b+y,greater<ll>());
    sort(c,c+z,greater<ll>());
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    rep(ix,x)rep(iy,y)rep(iz,z){
        if(pq.size()<k)pq.push(a[ix]+b[iy]+c[iz]);
        else if(pq.top()<a[ix]+b[iy]+c[iz]){
            pq.pop();
            pq.push(a[ix]+b[iy]+c[iz]);
        }else{
            break;
        }
    }
    vector<ll> ret;
    while(!pq.empty()){
        ret.push_back(pq.top());
        pq.pop();
    }
    sort(ret.begin(),ret.end(),greater<ll>());
    for(const auto &r:ret){
        cout << r << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  cout << fixed;
  cout.precision(5);
  int n;
  cin >> n;
  double ans = 0.0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans += 1.0 / x;
  }
  cout << 1 / ans << '\n';
  return 0;
}


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

int digit_sum(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  
  return sum;
}

int main(){
  int N;
  cin>>N;
  
  int a=digit_sum(N);
  
  if(N%a==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

ll dp[100100][15];
ll mod=1e9+7;
int main(){
    string s; cin >> s;
    dp[0][0]=1;
    int n=s.size();
    for(int i=0;i<n;i++){
        for(int j=0;j<15;j++){
            if(dp[i][j]==0)continue;
            if(s[i]=='?'){
                for(int k=0;k<=9;k++){
                    (dp[i+1][(j*10+k)%13]+=dp[i][j])%=mod;
                }
            }
            else{
                int d=s[i]-'0';
                (dp[i+1][(j*10+d)%13]+=dp[i][j])%=mod;
            }
        }
    }
    cout << dp[n][5] << endl;
}

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

int main() {
  int K; cin >> K;
  string S; cin >> S;
  string ans = "";
  int s_len = S.length();
  if (s_len > K) {
    for (int i=0; i<K; i++) ans += S[i];
    ans += "...";
  } else {
    ans = S;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
import math

(a, b, h, m) = [float(s) for s in input().split()]

p_2 = 2 * math.pi

h_deg = 360 / 12 * h + (30 / 60 * m)
m_deg = 360 / 60 * m

diff_rad = (h_deg - m_deg) * math.pi / 180

cos = math.cos(diff_rad)

c_sqr = pow(a, 2) + pow(b, 2) - (2 * a * b * cos)
c = math.sqrt(c_sqr)

print(c)


Measured memory_bytes: 9452
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}
		int m = n+1; int count = 0;
		for (int i = 0; i < n; i++) {
			if(m >= p[i]) {
				count++;
				m = p[i];
			}
		}
		System.out.println(count);
		sc.close();
	}
}

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

typedef unsigned uint;

int main(){
  std::ios_base::sync_with_stdio(false);

  uint n;
  std::cin >> n;
  std::vector<uint> s(n,0);
  for(uint i = 0; i < n; i++){
    std::cin >> s[i];
  }
  s.erase(std::unique(s.begin(),s.end()),s.end());

  uint q;
  std::cin >> q;
  std::vector<uint> t(q,0);
  for(uint i = 0; i < q; i++){
    std::cin >> t[i];
  }

  uint count = 0;
  for(uint i = 0; i < t.size(); i++){
    uint v = t[i];
    uint min = 0, max = s.size();
    while(min < max){
      uint mid = (min + max) / 2;
      uint v_mid = s[mid];
      if(v_mid == v) count++;

      if(v_mid >= v) max = mid;
      else min = mid+1;
    }
  }

  std::cout << count << '\n';
}

Measured memory_bytes: 1580
using System;
using System.Linq;

class Program {
    static void Main() {
        while(true) {
            string[] stdin = Console.ReadLine().Split();
            int n = int.Parse(stdin[0]);
            int x = int.Parse(stdin[1]);
            if((n | x) == 0) break;
            int ans = 0;
            for(int i = 1; i <= n - 2; i++) {
                for(int j = i + 1; j <= n - 1; j++) if(j < x - i - j && x - i - j <= n) ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


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

using namespace std;
typedef long long ll;

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

int main()
{
    int n, x, t;
    cin >> n >> x >> t;

    cout << ((n + x - 1) / x * t) << '\n';
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, r;

    cin >> n >> r;

    if (n >= 10) cout << r << endl;
    else {
        cout << r + 100 * (10 - n) << endl;
    }
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=998244353;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

string s;
ll cnt,ans;

void input(){
	cin>>s;
	return;
}

void solve(){
	for(int i=0;i<s.size();i++){
		if(s[i]=='B')cnt++;
		else ans+=cnt;
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(input()) for i in range(n)]
    sa = sorted(a, reverse=True)

    for i in a:
        if i == sa[0]:
            print(sa[1])
        else:
            print(sa[0])


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

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

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

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

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


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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long int64;

int main()
{
  int N, Q;
  int64 A[100000], X[100000];

  scanf("%d %d", &N, &Q);
  for(int i = 0; i < N; i++) scanf("%lld", &A[i]);
  for(int i = 0; i < Q; i++) scanf("%lld", &X[i]);


  for(int j = 0; j < Q; j++) {
    int tail = 0;
    int64 sum = 0, ret = 0;
    for(int i = 0; i < N; i++) {
      while(tail < N && sum + A[tail] <= X[j]) {
        sum += A[tail++];
      }
      ret += tail - i;
      sum -= A[i];
    }
    printf("%lld\n", ret);
  }
}

Measured memory_bytes: 3952
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  sort(all(v));
  cout<<abs(v[0]-v[n-1])<<endl;
}

int main(){
  solve();
  return 0;
}


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

int main(void){
  int N;
  int *a;
  int mini,max;
  int i;
  scanf("%d",&N);
  a = (int *)malloc(N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  mini=a[0];max=a[0];
  for(i=1;i<N;i++){
    if(a[i]<mini)
      mini=a[i];
    if(a[i]>max)
      max=a[i];
  }
  printf("%d\n",max-mini);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main (){
char a[5];
  int k=0;
scanf ("%s",a);
  for (int i=0;i<4;i++){
  if (a[i]==a[i+1]){
  k++;
 break;   
  }
  }
 if (k>0){
printf ("Bad");
 }
  else{
  
  printf ("Good");
  }
return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

#define MAX 100000

using namespace std;

size_t get_first_true(vector<bool>& primes, size_t start) {
    for (; start < primes.size(); start++) {
        if (primes[start]) {
            return start;
        }
    }
    return -1;
}

int main() {
    vector<bool> primes(MAX, true);

    primes[0] = primes[1] = false;

    for (int i = get_first_true(primes, 0); i != -1; i = get_first_true(primes, i + 1)) {
        for (int j = 2; j * i < primes.size(); j++) primes[j * i] = false;
    }

    vector<int> result(MAX);
    result[0] = result[1] = 0;

    REP(i, MAX) {
        if (i % 2 == 0)
            result[i] = result[i - 1];
        else
            result[i] = result[i - 1] + ((primes[i] && primes[(i + 1) / 2]) ? 1 : 0);
    }

    int Q;
    cin >> Q;

    REP(i, Q) {
        int l, r;
        cin >> l >> r;

        l--;

        cout << result[r] - result[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8

def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    A = tuple(map(int, args[1].split()))

    l, r = 1, max(A)
    while 0.1 < r-l:
        m = (l+r)/2
        cnt = 0
        for a in A:
            cnt += -int(-a//m)-1

        if k < cnt:
            l = m
        else:
            r = m

    return str(-int(-l//1))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 33640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

// https://drken1215.hatenablog.com/entry/2019/10/05/173700
void solve() {
  int n;
  cin >> n;
  vector<char> a(n);
  cin >> a;

  // 上から i 段目, すでに j 個マッチングしてる
  int dp[300][300];
  fill_n(*dp, 300 * 300, 0);
  dp[0][0] = 1;

  rep(i, n) rep(j, n + 1) {
    if (a[i] == '-') {
      add(dp[i + 1][j + 1], dp[i][j]);
    } else if (a[i] == 'D') {
      // 頂点 D からは, 上に上がってる (相方 (前回の中継所) からが下がってる)
      // ペアは上がるか下がるか

      // i-j : 上にあるのが i 個
      add(dp[i + 1][j + 2], 1LL * dp[i][j] * (i - j) * (i - j) % mod);
      add(dp[i + 1][j + 1], 1LL * dp[i][j] * (i - j) % mod);
    } else {
      add(dp[i + 1][j], dp[i][j]);
      add(dp[i + 1][j + 1], 1LL * dp[i][j] * (i - j) % mod);
    }
  }
  cout << dp[n][n] << endl;
  // rep(i, n + 1) { rep(j, n + 1) cout << dp[i][j] << " "; cout << endl; }
}



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

int n, a;
int res;

int main()
{
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &a);
		while (a % 2 == 0) {
			res++; a /= 2;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
s = [ord(i)-97 for i in s]

dic = {}
for i in range(26):
    dic[i] = []

for i in range(n):
    dic[s[i]].append(i)

for i in range(26):
    dic[i].append(float('inf'))

from bisect import bisect_left
q = int(input())
for i in range(q):
    x, y, z = input().split()
    if x == '1':
        y, z = int(y) - 1, ord(z) - 97
        p = bisect_left(dic[s[y]], y)
        dic[s[y]].pop(p)
        dic[z].insert(bisect_left(dic[z], y), y)
        s[y] = z
    else:
        res = 0
        y, z = int(y) - 1, int(z) - 1
        for i in range(26):
            p = dic[i][bisect_left(dic[i], y)]
            if p <= z:
                res += 1
        print(res)

Measured memory_bytes: 35432
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i].first >> vec[i].second;
    }
    sort(vec.begin(), vec.end());
    multiset<int> b;
    vector<int> dp(m, 0);
    int i = 0;
    for (int day = 0; day < m; ++day) {
        while (i < n && vec[i].first <= day + 1) {
            b.insert(vec[i].second);
            //cout << vec[i].second << '|';
            ++i;
        }
        if (b.size() > 0) {
            auto it = b.end();
            advance(it, -1);
            dp[day] += *it;
          //  cout << *it << '\\';
            b.erase(it);
        }
        if (day > 0) {
            dp[day] += dp[day - 1];
        }
    }
    cout << dp[m - 1] << endl;
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

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

int		main(void)
{
	int a, b;
	string s;

	cin >> a >> b;
	cin >> s;
	bool flag = true;

	if (s[a] != '-')
		flag = false;
	for (int i = 0; i < a; i++)
	{
		if (!('0' <= s[i] && s[i] <= '9'))
			flag = false;
	}
	for (int i = a + 1; i < a + b + 1; i++)
	{
		if (!('0' <= s[i] && s[i] <= '9'))
			flag = false;
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};



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

  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> G(M);
  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    a--;
    b--;
    G[i] = make_pair(a, b);
  }

  int ans = 0;
  for(int i = 0; i < M; i++){

    UnionFind uf(N);

    for(int j = 0; j < M; j++){
      if(j != i){
        uf.merge(G[j].first, G[j].second);
      }
    }

    if(uf.size(0) != N){
      ans++;
    }

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int n, m, x; 
  cin >> n >> m >> x;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> c(n);
  for(int i = 0; i < n; ++i) {
    cin >> c[i];
    for(int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  int best = 1e9;
  for(int mask = 1; mask < (1 << n); ++mask) {
    vector<int> cur(m);
    int was = 0;
    for(int i = 0; i < n; ++i) {
      if((mask & (1 << i))) {
        for(int j = 0; j < m; ++j) {
          cur[j] += a[i][j];
        }
        was += c[i];
      }
    }
    bool good = true;
    for(int j = 0; j < m; ++j) {
      if(cur[j] < x) good = false;
    }
    if(good) {
      best = min(best, was);
    }
  }
  cout << (best >= 1e9 ? -1: best) << endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = 0;
        for (int i = 0; i < a.length; i++) {
            while (a[i] % 2 == 0) {
                a[i] /= 2;
                result++;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 29932
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;

typedef long long int ll;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e14 + 7;



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

ll dp[ARRAY_MAX][2];

int main() {

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


	for (int i = 0; i < ARRAY_MAX; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			dp[i][j] = -INF;
		}
	}

	dp[0][0] = 0;
	for (ll i = 0; i < n - 1; i++)
	{
		if (i == 0)
		{
			dp[i + 1][0] = max(dp[i + 1][0], dp[0][0] + a[i]);
			dp[i + 1][1] = max(dp[i + 1][1], dp[0][0] - a[i]);
		}
		else
		{
			for (int j = 0; j < 2; j++)
			{
				if (j == 0)
				{
					//自身は変化していない時
					dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + a[i] * (-1));//変える時
					dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + a[i]);//変えない場合
				}
				else
				{
					//自信が既に変化している場合
					dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] - a[i]);//変えない場合次のは変わらない
					dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + a[i]);//変える場合次のは変わる
				}
			}
		}
		
	}

	

	cout << max(dp[n-1][1] - a[n-1], dp[n-1][0] + a[n-1]) << endl;
}





Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const long long INF=1e18,MOD=1e9+7;
int main(){
  int h,w;
  cin>>h>>w;
  vector<string>maze(h);
  for(int i=0;i<h;i++)cin>>maze[i];
  bool flag=true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      bool flag2=false;
      if(maze[i][j]=='#'){
        if(i>0&&maze[i-1][j]=='#')flag2=true;
        if(j>0&&maze[i][j-1]=='#')flag2=true;
        if(i<h-1&&maze[i+1][j]=='#')flag2=true;
        if(j<w-1&&maze[i][j+1]=='#')flag2=true;
        if(!flag2)flag=false;
      }
    }
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

class Edge
{
public:
    ll from;
    ll to;
    ll cost;
    Edge() : from{0}, to{0}, cost{0} {}
    Edge(ll a, ll b, ll c) : from{a}, to{b}, cost{c} {}
};


const ll MAX = 1010;        // Set
vll dist(MAX);
vector<bool> negative(MAX);
vector<Edge> edges;


void bellmanford(long long s, long long N)
{
        fill(dist.begin(), dist.end(), 1LL<<60);
        dist[s] = 0;

        for (long long node = 0; node < N; ++node) {
                for (auto e : edges) {
                        if (dist[e.to] > dist[e.from] + e.cost) {
                                dist[e.to] = dist[e.from] + e.cost;
                        }
                }
        }

        for (long long node = 0; node < N; ++node) {
                for (auto e : edges) {
                        if (dist[e.to] > dist[e.from] + e.cost) {
                                dist[e.to] = dist[e.from] + e.cost;
                                negative[e.to] = true;
                        }
                }
        }
}

int main()
{
        ll N, M;
        cin >> N >> M;
        rep(i, 0, M) {
                ll a, b, c;
                cin >> a >> b >> c;
                Edge e(a, b, -c);
                edges.push_back(e);
        }

        bellmanford(1, N);
        if (negative[N]) {
                cout << "inf" << endl;
        } else {
                cout << -dist[N] << endl;
        }

}

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

int main() {
  string N;
  cin >> N;
  char a = N.at(0);
  char b = N.at(1);
  char c = N.at(2);
  int count = 0;
  if(c == '1'){
      count++;
   }
    if(a == '1'){
      count++;
   } 
   if(b == '1'){
      count++;
   }
 cout << count;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll h; cin>>h;
	ll w; cin>>w;
	ll ans=0;
	if(h==1 || w==1){
		cout<<1<<endl;
		return 0;
	}
	if(h%2!=0 && w%2!=0){
		h--;
		ans=h/2;
		ans*=w;
		w--;
		ans+=w/2;
		ans++;
	}else if(h%2==0){
		ans=h/2;
		ans*=w;
	}else{
		ans=w/2;
		ans*=h;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int res = 0;
  rep(i,n) res += a[i];
  cout << res - n << endl;
  return 0;
} 

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

struct qlist {
    int p;
    int c;
};

int ans = 999999;
int D, G;
vector<qlist> pc;

void dfs(int d, int sum, int count, int cBit) {
    if (d == D) {
        if (sum >= G) {
            ans = min(ans, count);
            return;
        }
        else {
            int maxQ = 0;
            for (int i = D - 1; i >= 0; i--) {
                if (!(cBit & (1 << i))) {
                    maxQ = i;
                    break;
                }
            }
            int point = (maxQ + 1) * 100;
            int devide = (G - sum) / point;
            if(devide > pc[maxQ].p) return;
            if ((G - sum) % point == 0) { count += (G - sum) / point; }
            else {
                count += ((G - sum) / point) + 1;
            }
            ans = min(ans, count);
            return;
        }
    }

    d += 1;
    // 全部使わない場合
    dfs(d, sum, count, cBit);

    // 全部使う場合
    sum += d * 100 * pc[d - 1].p + pc[d - 1].c;
    count += pc[d - 1].p;
    cBit |= (1 << d-1);
    dfs(d, sum, count, cBit);
}

int main() {
    cin >> D >> G;
    pc.resize(D);
    rep(i, D) cin >> pc[i].p >> pc[i].c;

    dfs(0, 0, 0, 0b0);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int sa[100010], sb[100010], ta[100010], tb[100010];

int main(){
    string s, t;
    cin >> s >> t;
    rep(i, s.size()){
        if (s[i] == 'A') sa[i+1]++;
        if (s[i] == 'B') sb[i+1]++;
    }
    rep(i, t.size()){
        if (t[i] == 'A') ta[i+1]++;
        if (t[i] == 'B') tb[i+1]++;
    }
    rep(i, s.size()) sa[i+1] += sa[i], sb[i+1] += sb[i];
    rep(i, t.size()) ta[i+1] += ta[i], tb[i+1] += tb[i];

    int q;
    cin >> q;
    vector<string> ans;
    
    while(q--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, c--;
        int xa = sa[b] - sa[a];
        int xb = sb[b] - sb[a];
        int ya = ta[d] - ta[c];
        int yb = tb[d] - tb[c];
        if ((xa - xb - ya + yb) % 3 == 0) ans.push_back("YES");
        else ans.push_back("NO");
    }
    for (auto e:ans) cout << e << endl;
    return 0;
}


Measured memory_bytes: 9352
n,k = map(int, input().split())
s = input().split()
t = 1
for i in range(10 * n):
    n2 = list(str(n))
    for j in range(len(n2)):
        if s.count(n2[j]) == 1:
            n = n + 1
            t = 0
            break
    if t == 1:
        break
    else:
        t = 1
    
print(n)

Measured memory_bytes: 3060
import bisect
n = int(input())
ln = list(map(int, input().split()))
ln.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        a = ln[i]
        b = ln[j]
        index = bisect.bisect_left(ln, a+b)-1
        ans += index - j
print(ans)

Measured memory_bytes: 3188
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int A, B; cin >> A >> B;
	cout << max(A + B, max(A - B, A * B)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    int c = 0;
    rep(i, S.size()) {if (S[i] == '-') c++;}
    if (S.at(A) == '-' && S.size() == A + B + 1 && c == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int arr[103];
int dp[100005][2];
 
int solve(int k, int p, int n){
    if(k==0)return 0;
    for(int  i =1; i<=n; ++i){
        if(arr[i]==k){
            return 1;
        }
    }
    if(dp[k][p]!=-1)return dp[k][p];
 
    int ret = 0;
    for(int i = 1; i<=n; ++i){
        if(arr[i]<=k)ret = ret | (1-solve(k-arr[i],1-p,n));
    }
 
    return dp[k][p] = ret;
}
 
int main(){
    memset(dp,-1,sizeof(dp));
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i = 1; i<=n; ++i){
        scanf("%d",&arr[i]);
    }
    int w = solve(k,0,n);
    if(w==1){
        cout<<"First\n";
    }
    else{
        cout<<"Second\n";
    }
    return 0;
}

Measured memory_bytes: 8832
#include <stdio.h>
int main(void){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if(x-r>=0&&y-r>=0&&x+r<=w&&y+r<=h) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
    int a,b,c;
    int rect=0;
    int dia=0;
    while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
        if(a*a+b*b==c*c){
            rect+=1;
        }
        if(a==b){
            dia+=1;
        }
    }
    cout<<rect<<endl;
    cout<<dia<<endl;
}



Measured memory_bytes: 3064
A,B,C,D = map(int,input().split( ))
if C%B == 0:
    num_takahashi = C//B
else:
    num_takahashi = C//B + 1
if A%D == 0:
    num_aoki = A//D
else:
    num_aoki = A//D + 1
if num_takahashi <= num_aoki:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9048
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	map<char,char>rep,rev;
	for(int i=0;i<s.size();i++){
		rep[s[i]]=t[i];
		rev[t[i]]=s[i];
	}
	for(int i=0;i<s.size();i++){
		if(rep[s[i]]!=t[i]||rev[t[i]]!=s[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 776
import itertools as it
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

A = list(it.combinations_with_replacement(list(range(1, m+1)), n))

max_list = [0] * len(A)
index = 0
for item in A:
    for i in range(q):
        if item[b[i]-1] - item[a[i]-1] == c[i]:
            max_list[index] += d[i]
    index += 1

# print(max_list)
print(max(max_list))


Measured memory_bytes: 25088
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << #x << " = " << x << endl

int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	ll n, k;
	cin >> n >> k;
	int t[n];
	for(int &x: t)
		cin >> x;
	vector<int> path;
	vector<bool> visited(n, 0);
	for(int i=1; !visited[i-1]; i = t[i-1]){
		path.push_back(i);
		visited[i-1] = true;
	}
	if(k < (int)path.size())
		cout << path[k] << '\n';
	else{
		int path_2;
		for(path_2=0; path[path_2]!=t[path.back()-1]; path_2++){}
		cout << path[path_2 + (k-(int)path.size())%((int)path.size()-path_2)] << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 5072
#include<stdio.h>

#define Max 100000

int a[Max], n;

int partition(int p, int r){
  int x, i, j, t;
  x = a[r];
  i = p - 1;

  for(j = p ; j < r ; j++){
    if(a[j] <= x){
      i++;
      t = a[i] ;
      a[i] = a[j];
      a[j] = t;
    }
  }

  t = a[i + 1];
  a[i + 1] = a[r];
  a[r] = t;

  return i + 1;
}


int main(){
  int i, q;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++) scanf("%d", &a[i]);

  q = partition(0, n - 1);

  for(i = 0 ; i < n ; i++){
    if(i) printf(" ");
    if(i == q) printf("[");
    printf("%d", a[i]);
    if(i == q) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2244
N, M = map(int, input().split())
a = [input() for i in range(N)]
b = [input() for i in range(M)]

ans = 0
for i in range(N - M + 1):
    for j in range(N - M + 1):
        t = [k[j:j + M] for k in a[i:i + M]]
        if t==b:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define int long long

const int MAXN = 1;
const int INF = 2e9;
const int mod = 1e9 + 7;

int a,b,c;

signed main () {
	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a << ' ' << b << ' ' << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

#include <cstdio>

#include <vector>

#include <cstring>

#include <cstdlib>

#include <cassert>

#include <iostream>

#define rep(i,a,b) for(int i = a; i <= b; i++)

#define dep(i,a,b) for(int i = a; i >= b; i--)

#define Rep(i,a) for(int i = 0; i < a; i++)

#define pb push_back

#define mp make_pair

typedef long long LL;

using namespace std;

const int N = 90, mod = 1e9 + 7;
typedef pair<LL, LL> pii;
LL f[N];
int cnt = 0;
vector<pii> g[N];
void dfs(int t, LL a, LL b) {
	if (a > 2LL * f[t] || b > LL(1e18)) return;
	if (f[t] <= a && a < f[t + 2] && f[t + 1] <= b && b < f[t + 2]) g[t].pb(mp(a, b));
	rep(i,1,4) dfs(t + 1, b, a + b * i);
}

LL read() {
	char c = getchar(); LL x = 0;
	while (c < '0' || c > '9') c = getchar();
	while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}


int main() {

//	freopen("gcd.in","r",stdin);

//	freopen("gcd.out","w",stdout);

	f[0] = f[1] = 1; rep(i,2,87) f[i] = f[i - 1] + f[i - 2];
	dfs(0, 1, 1);
	int Q; scanf("%d",&Q);
	while (Q--) {
		LL a, b; a = read(), b = read();
		if (a > b) swap(a, b); int mx = 1;
		dep(i,86,1) if (f[i] <= a && f[i + 1] <= b) { mx = i; break; }
		if (mx == 1) printf("%d %d\n",mx, 1LL * a * b % mod);
		else {
			int len = g[mx].size(); int ans = 0;
			Rep(j,len) {
				LL x = g[mx][j].first, y = g[mx][j].second;
				if (x <= a && y <= b) ans++;
				if (y <= a && x <= b) ans++;
			}
			len = g[mx - 1].size();
			Rep(j,len) {
				LL x = g[mx - 1][j].first, y = g[mx - 1][j].second;
				if (y <= a && b >= f[mx + 2]) 
					ans = (ans + (b - x) / y - (f[mx + 2] - 1 - x) / y) % mod;
			}
			if (ans < 0) ans += mod;
			printf("%d %d\n",mx, ans);
		}
	}
	return 0;

}

Measured memory_bytes: 4096
N = int(input())

Plan = [list(map(int, input().split())) for _ in range(N)]
Plan.append([0,0,0])
flag = True
for i in range(N):
    if abs(Plan[i][0] - Plan[i + 1][0]) < abs(Plan[i][1] - Plan[i + 1][1]) + abs(Plan[i][2] - Plan[i + 1][2]):
        flag = False
        break
    elif abs(Plan[i][0] - Plan[i + 1][0])%2 != (abs(Plan[i][1] - Plan[i + 1][1]) + abs(Plan[i][2] - Plan[i + 1][2]))%2:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')

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

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var a = vals[0];
        var b = vals[1];

        var prod = -1;
        if(a <= 9 && b <= 9)
        {
            prod = a * b;
        }

        Console.WriteLine(prod);
    }
}

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

using namespace std;
#define ll               long long
#define dl               double
#define ull              unsigned long long
#define ft               first
#define sd               second
#define pi               acos(-1)
#define ct(tc)           scanf("%lld",&tc)
#define scnm(n,m)        scanf("%lld %lld",&n,&m);
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(a,max(b,max(c,d)))
#define min3(a,b,c)      min(a,min(b,c))
#define min4(a,b,c,d)    min(a,min(b,min(c,d)))
#define pb               push_back
#define srt              sort(v.begin(),v.end())
#define rsrt             reverse(v.begin(),v.end())
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll a,b;
    cin>>a>>b;
    ll m;
    m=(a*b);
    cout<<m<<"\n";

    return 0;
}


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

void solve(string s){
	for(int k = 1 ; k <= s.size() ; k++) {
		int a[26] = {};
		for(int i = 0 ; i < 26 ; i++) a[i] = 1;
		for (int i = 0; i+k <= s.size() ; i++){
			int b[26] = {};
			for(int j = 0 ; j < k ; j++){
				b[s[i+j]-'a'] = 1;
			}
			for(int j = 0 ; j < 26 ; j++)
				a[j] &= b[j];
		}
		for(int i = 0 ; i < 26 ; i++)
			if( a[i] ){
				cout << k - 1 << endl;
				return;
			}



	}
}

int main(){	
	string s;
	cin >> s;
	solve(s);
	return 0;
}



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

using namespace std;

int main()
{
    string n;
    cin>>n;
    for(int i = 0;i < 3;i++){
        if(n[i]=='1'){
            n[i]='9';
        }else if(n[i]=='9'){
            n[i]='1';
        }
   }
    cout<<n<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  if(X < 600){
	cout << "8" << endl;
    return 0;
  }else if(X < 800){
	cout << "7" << endl;
    return 0;
  }else if(X < 1000){
	cout << "6" << endl;
    return 0;
  }else if(X < 1200){
	cout << "5" << endl;
    return 0;
  }else if(X < 1400){
	cout << "4" << endl;
    return 0;
  }else if(X < 1600){
	cout << "3" << endl;
    return 0;
  }else if(X < 1800){
	cout << "2" << endl;
    return 0;
  } else cout << "1" << endl;
}

Measured memory_bytes: 3648