akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, t;
  std::cin >> n >> t;
  t = t / 1000;
  for (int x = 0; x <= n; x++) {
    for (int y = 0; y <= n; y++) {
      int z = max((int)0, (n - x - y));
      if (x + y + z > n)
        continue;
      if ((x * 10) + (y * 5) + z == t) {
        print(x, 2);
        print(y, 2);
        print(z);
        return 0;
      }
    }
  }
  std::cout << "-1 -1 -1" << std::endl;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n,a,b;
int il=0,ilb=0;
string z;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> a >> b >> z;
  for(char el:z){
    if((el == 'a' || (el == 'b' && ilb < b)) && il < a + b){
      cout << "Yes\n";
      il++;
      if(el == 'b')ilb++;
    }else{
      cout << "No\n";
    }
  }
}


Measured memory_bytes: 848
// https://atcoder.jp/contests/abc163/tasks/abc163_c
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main() {

    int n;
    cin >> n;

    constexpr int MAX = int(2e5) + 5;
    vector<int> arr(n);
    vector<int> freq(MAX, 0);

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

    ll ans = 0;

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

    return 0;
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int a, b;
/**********************************************/

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

    cin >> a >> b;
    if(a*b & 1) cout << "Odd" << endl;
    else cout << "Even" << endl;
}


Measured memory_bytes: 256
# D
import numpy as np
N, K = map(int,input().split())
p = list(map(int,input().split()))

sums=np.cumsum([(s+1)/2 for s in p])

ans=np.max([ sums[i+K]-sums[i] for i in range(N-K)]+[sums[K-1]])

print(ans )

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

using namespace std;

int main() {
    int n, a, b, s = 0, ss = 0;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> a;
        s += a;
        ss += a*a;
    }
    cout << (s*s - ss)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int i,n;

  getline(cin,str);

  while(1)
  {
    n=0;
  for(i=0;i<str.size();i++){
    n=n+ str[i]-48;

  }
  if(n==0)
    break;

  cout << n << endl;
  getline(cin,str);
}
  return 0;
}



Measured memory_bytes: 3228
program r20711c

implicit none
integer :: x, y, z, n, f, i
integer :: a(1:11000)

a = 0

read *, n
 do x = 1, 100
  do y = 1, x
   roop: do z = 1, y
    f = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if(f > 11000) then
     exit roop
    end if
    if(x == z) then
     a(f) = a(f) + 1
    else if(x == y .or. y == z) then
     a(f) = a(f) + 3
    else
     a(f) = a(f) + 6
    end if
   end do roop
  end do 
end do 

do i = 1, n
 print *, a(i)
end do
   
end program r20711c


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,m; cin >> N >> m;
    vector<pair<int,int>> pos;
    for (int i=0;i<m;++i){
        int c,d; cin >> c >> d;
        pos.emplace_back(c,d);
    }
    pos.emplace_back(N+1,N+1);
    sort(pos.begin(),pos.end());
    int l=0,r=0,ans=N+1;
    for (int i=0;i<m+1;++i){
        if (r<pos[i].first) ans+=2*(r-l),l=pos[i].first;
        r=max(r,pos[i].second);
    }
    cout << ans << '\n';
}


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

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

int main(void)
{
    int n,a,b;
    cin >> n >> a >> b;
    
    int ans = 0;
    for ( int i = 1; i <= n; i++ )
        if ( sumOfDigits(i) >= a && sumOfDigits(i) <= b )
            ans += i;
    
    cout << ans << endl;
}


Measured memory_bytes: 3616
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }
    let mut cnt = 0;
    let mut color = 10000;
    for i in 1..n {
        if a[i - 1] == a[i] {
            cnt += 1;
            a[i] = color;
            color -= 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){

int a[1000];
int n;

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

int j;
for( j = n - 1; j  > -1 ; j = j - 1 )
{cout<<a[j];

	 if(j>0){ cout<<" ";}
	 if(j==0 ){ cout<<endl;}
}


}



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

MOD = 10**9+7
dp = [[[[0]*4 for i in range(4)] for j in range(4)] for k in range(N+1)]
dp[0][3][3][3] = 1
'''
for i in range(4):
    for j in range(4):
        for k in range(4):
            if k == 2 and j == 1 and i == 0:
                continue
            if k == 1 and j == 2 and i == 0:
                continue
            if k == 2 and j == 0 and i == 1:
                continue
            dp[3][i][j][k] = 1
'''
for n in range(N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                if dp[n][i][j][k] == 0:
                    continue
                for new in range(4):
                    if new == 2 and i == 1 and j == 0:
                        continue
                    if new == 1 and i == 2 and j == 0:
                        continue
                    if new == 2 and i == 0 and j == 1:
                        continue
                    if new == 2 and i == 1 and k == 0:
                        continue
                    if new == 2 and j == 1 and k == 0:
                        continue
                    dp[n+1][new][i][j] += dp[n][i][j][k]
                    dp[n+1][new][i][j] %= MOD

ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
            ans %= MOD

print(ans)

Measured memory_bytes: 44656
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c-=b;
        if(c<=0){
            cout<<"Yes";
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define I insert
#define SG getchar()
using namespace std;
set<char> uoi;
signed main()
{
	uoi.I('a'),uoi.I('e'),uoi.I('i'),uoi.I('o'),uoi.I('u');
	puts(((uoi.count(SG))?("vowel"):("consonant")));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include "math.h"
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    int N;
    long long P;
    cin >> N >> P;
    const auto &pf = prime_factorize(P);
    long res = 1;
    for (auto p : pf) {
        // for (int j = 0; j < p.second/N; ++j) res *= p.first;
        int tmp = int(p.second/N);
        // console.log(tmp)
        res *= pow(p.first,tmp);
    }
    cout << res << endl;
}


Measured memory_bytes: 3876
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;

void solve(){
	int n , k ;
	cin >> n >> k ;
	vi a(n) , f(n) ;
	for(auto& x : a) cin >> x ;
	for(auto& x : f) cin >> x ;
	sort(all(a)) ;
	sort(all(f)) ;
	reverse(all(f)) ;
	int lo = 0 , hi = 1e18 + 5LL ;
	while(lo < hi){
		int mid = (hi+lo)/2LL ;
		int cnt = 0 ;
		for(int i = 0 ; i < n ; i++){
			cnt += max(0LL, (a[i] - mid/f[i])) ;
		}
		if(cnt <= k) hi = mid ;
		else lo = mid+1 ;
	}
	cout << lo << endl ;
}

int32_t main(){_
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int N;
void dfs(string S, char max) {
    if(S.length() == N) {
        cout << S << endl;
    } else {
        for(char c = 'a'; c <= max; c++) {
            dfs(S + c, (c == max ? max + 1 : max));
        }
    }
}

int main() {
    cin >> N;
    dfs("", 'a');
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <map>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { ++i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr range(itr l_, itr r_) noexcept : l(l_), r(std::max(l_, r_)) { }
  constexpr iterator begin() const noexcept { return l; }
  constexpr iterator end() const noexcept { return r; }
};

struct revrange {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { --i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr revrange(itr l_, itr r_) noexcept : l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr iterator begin() const noexcept { return r; }
  constexpr iterator end() const noexcept { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;
constexpr size_t mx = 1000000;

int main() {
  size_t N;
  std::cin >> N;
  std::map<i32, i32> map;
  for (auto i: range(0, N)) {
    i32 x;
    std::cin >> x;
    map[x]++;
  }
  std::vector<bool> ok(mx + 1, true);
  for (auto [x, c]: map) {
    for (i32 i = x + x; i <= mx; i += x) {
      ok[i] = false;
    }
  }
  i32 ans = 0;
  for (auto [x, c]: map) {
    if (c == 1 && ok[x]) {
      ++ans;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    ll X;
    cin >> X;
    ll total = 0;
    
    ll root = 100;
    
    while(true)
    {
        if(root >= X) break;
        root += root/100;
        total++;
    }

    cout << total << endl;

    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n), c(m), d(m);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, m) cin >> c[i] >> d[i];

  rep(i, n) {
    int dist = 1000000000;
    int ans = -1;
    rep(j, m) {
      int _dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (dist > _dist) {
        ans = j + 1;
        dist = _dist;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

char S[20];
int C=0;

int main(){
    scanf("%s\n",S);
    if(S[0]!='A'){
        printf("WA");
        return 0;
    }
    int i;
    for(i=1;S[i]!='\0';i++){
        if(S[i]=='C'){
            if(C==0){
                C=i;
            }else{
                C=0;
                break;
            }
        }else if(S[i]<'a'||'z'<S[i]){
            C=0;
            break;
        }
    }
    if(2<=C&&C<=i-2){
        printf("AC");
    }else{
        printf("WA");
    }

    return 0;
}

Measured memory_bytes: 128
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

C = Hash.new{|h, k| h[k] = 0}
A.each{|a| C[a] += 1}
wk = 0
C.each{|k, v|
  wk += (v*(v-1))/2
}

A.each{|a|
  puts wk - (C[a] - 1)
}


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

using namespace std;

int main()
{
  string S;
  cin >> S;
  auto latte = S.substr(1);
  auto malta = S.substr(0, 3);
  if(set< char >(begin(latte), end(latte)).size() == 1 ||
     set< char >(begin(malta), end(malta)).size() == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005


signed main(){
	fast
	// For(i, 0, 10){
	int n, k, temp;
	vector<int> v;
	cin>>n>>k;
	For(i, 0, n){
		cin>>temp;
		v.pb(temp);
	}

	vector<int> dp(n, INF);;
	dp[0]=0;
	
	For(i, 0, n){
		int m = min(i+k+1, n);
		For(j, i+1, m){
			dp[j] = min(dp[j], dp[i]+abs(v[i]-v[j]));
		}
	}
	// For(i, 0, n){
	// 	cout<<dp[i]<<" ";
	// }
	// cout<<endl;
	cout<<dp[n-1]<<endl;
	// }
    return 0;
}
    



Measured memory_bytes: 1908
r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)
        if k >= 0 and k % b == 0:
            cnt += 1
            # print(i, j, k)

print(cnt)

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

struct Node{
	int value;
	int cnt;
	bool operator < (const Node& rhs) const {
		return value>rhs.value;
	}
};

const int maxn=2e5+10;

int n,m;
long long sum;
Node p[maxn];
int main (){
	std::cin >> n >> m;
	for (int i=1;i<=n;i++)
		std::cin >> p[i].value,p[i].cnt=1;
	for (int i=1;i<=m;i++)
		std::cin >> p[i+n].cnt >> p[i+n].value;
	std::sort(p+1,p+1+n+m);
	for (int i=1;;i++){
		if (p[i].cnt>=n){
			sum+=1LL*n*p[i].value;
			break;
		}else {
			sum+=1LL*p[i].cnt*p[i].value;
			n-=p[i].cnt;
		}
	}
	std::cout << sum << '\n';
	return 0;
}



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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  char b;
  cin >> b;

  if (b == 'A')
    cout << 'T' << endl;
  else if (b == 'G')
    cout << 'C' << endl;
  else if (b == 'T')
    cout << 'A' << endl;
  else
    cout << 'G' << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
using namespace std;
int a[maxn];
int  main()
{
	int n;
	scanf("%d",&n);
	a[0]=0;
	for(int i=1;i<maxn;i++)
	{
		a[i]=a[i-1];
		if(i>=0&&i<10)
			a[i]++;
		if(i>=100&&i<1000)
			a[i]++;
		if(i>=10000&&i<100000)
			a[i]++;

	}
	printf("%d\n",a[n]);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct step
{
	int p;
	int migi;
	int hidari;
};

int main(void)
{
	string s;
	int ans;
	int i1;

	while(1){
		cin>>s;
		if(s=="#") break;

		vector<step> dp(s.size());

		for(i1=0;i1<s.size();i1++){
			dp[i1].p=s[i1]-48-1; //0から8までにしたい
			dp[i1].migi=0;
			dp[i1].hidari=0;
		}

		for(i1=1;i1<s.size();i1++){
			if(dp[i1-1].p%3<dp[i1].p%3){
				dp[i1].migi = min(dp[i1-1].hidari,dp[i1-1].migi+1);
				dp[i1].hidari = dp[i1-1].hidari+1;
			}
			else if(dp[i1-1].p%3==dp[i1].p%3){
				dp[i1].migi = min(dp[i1-1].hidari,dp[i1-1].migi+1);
				dp[i1].hidari = min(dp[i1-1].hidari+1,dp[i1-1].migi);
			}
			else {
				dp[i1].migi = dp[i1-1].migi+1;
				dp[i1].hidari = min(dp[i1-1].hidari+1,dp[i1-1].migi);
			}
			//cout<<dp[i1].hidari<<" "<<dp[i1].migi<<endl;
		}

		ans=min(dp[s.size()-1].migi,dp[s.size()-1].hidari);


		cout<<ans<<endl;		
	}

	return 0;
}

Measured memory_bytes: 3484
n,m = map(int,input().split())

if n == m == 1:
    ans = 1
    
elif min(n,m) == 1 and max(n,m) > 1:
    ans = max(n,m) - 2
    
else:
    ans = (n-2) * (m-2)
    
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll n;
    std::cin >> n;
    ll vote, t_vote, a_vote;
    std::cin >> t_vote >> a_vote;
    vote = t_vote + a_vote;
    for(int i = 1; i < n; i++){
        ll t, a;
        std::cin >> t >> a;
        /*
        if(vote % (t + a) != 0){
            vote = (vote / (t + a) + 1) * (t + a); 
        }
        */
        ll k_min = std::max(t_vote / t, a_vote / a);
        // vote >= k_min * (t + a)である必要がある
        vote = k_min * (t + a);        
        for(; ; vote += t + a){
            ll k = vote / (t + a);
            ll t_target = k * t;
            ll a_target = k * a;
            if(t_target < t_vote) continue;
            if(a_target < a_vote) continue;
            t_vote = t_target;
            a_vote = a_target;
            break;
        }
    }

    std::cout << vote << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // input
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        int n = s.length();
        int ans = 0;
        for (int i = 0; i < n / 2 + 1; i++) {
            String fs = s.substring(0, i);
            String ls = s.substring(i, 2 * i);
            if (fs.equals(ls)) {
                if(i * 2 == n){
                    break;
                }
             ans = i * 2;
            }
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

map<int, int> fct(int x) {
	map<int, int> ans;
	int cx = x;
	for (int i = 2; i * i <= x; i++) {
		int c = 0;
		while (cx % i == 0) {
			c++;
			cx /= i;
		}
		if (c) ans[i] = c;
	}
	if (cx > 1) ans[cx] = 1;
	return ans;
}

int sl(int x) {
	int ans = 0;
	for (int i = 1; ; i++) {
		if (x < i) {
			return ans;
		} else {
			x -= i;
			ans++;
		}
	}
	return -1;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int x;
	cin >> x;
	auto c = fct(x);
	int ans = 0;
	for (auto [f, s] : c) {
		ans += sl(s);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int V,E,ans;
ll edge[64];
ll sum_edge[64];
void MDS(int cur,int cost,ll mask){
	if(cost>=ans)return;
	if(mask==(1LL<<V)-1){
		ans=cost;
		return;
	}
	if(cur>=V)return;
	//if((mask|sum_edge[cur])!=(1LL<<V)-1)return;
	MDS(cur+1,cost+1,mask|edge[cur]);
	MDS(cur+1,cost,mask);
}
int main(){
	while(cin>>V>>E,V){
		memset(edge,0,sizeof(edge));
		memset(sum_edge,0,sizeof(sum_edge));
		for(int i=0;i<V;i++)edge[i]|=(1LL<<i);
		for(int i=0;i<E;i++){
			int A,B;
			cin>>A>>B;
			edge[A]|=(1LL<<B);
			edge[B]|=(1LL<<A);
		}
		for(int i=V-1;i>=0;i--) sum_edge[i] |= edge[i];
		for(int i=V-2;i>=0;i--) sum_edge[i] |= sum_edge[i+1];
		ans=1e9;
		MDS(0,0,0);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
  fast;
  int n,ans=1;
  string str;
  cin>>n>>str;
  for(int i=0;i<n-1;i++){
    if(str[i]!=str[i+1])
      ans++;
  }
  cout<<ans;
  return 0;
}
  
  

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  int ab,ac,ad,ae;
  ab=b-a;
  ac=c-a;
  ad=d-a;
  ae=e-a;
  if(ab<=k&&ac<=k&&ad<=k&&ae<=k)
    cout<<"Yay!"<<endl;
  else
    cout<<":("<<endl;
}

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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  ll ans;
  ll mod = 1e9+7;
  bool vt;
  for(int i=0; i<n; i++){
    if(s1[i]==s2[i]){
      if(i==0){
        ans = 3LL;
        vt = true;
        continue;
      }
      if(vt){
        ans *= 2;
        ans %= mod;
      }else{
        vt = true;
      }
    }else{
      if(i==0){
        ans = 6LL;
        vt = false;
        i++;
        continue;
      }
      if(vt){
        ans *= 2;
        ans %= mod;
        i++;
        vt = false;
      }else{
        ans *= 3;
        ans %= mod;
        i++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second


int main() {
	ll x,y,a,b,c ; cin >> x >> y >> a >> b >> c ;
	vector<ll> ai(a),bi(b),ci(c) ;
	for(int i = 0; i < a ; i++)cin>>ai[i];
	for(int i = 0; i < b ; i++)cin>>bi[i];
	for(int i = 0; i < c ; i++)cin>>ci[i];

	sort(ai.begin(),ai.end(),greater<ll>());
	sort(bi.begin(),bi.end(),greater<ll>());

	vector<ll> comb ;
	for(int i = 0; i < x ; i++)comb.pb(ai[i]);
	for(int i = 0; i < y ; i++)comb.pb(bi[i]);
	for(int i = 0; i < c ; i++)comb.pb(ci[i]);

	sort(comb.begin(),comb.end(),greater<ll>()) ;
	ll ans = 0 ;

	for(int i = 0; i < (x+y) ; i++){
		ans+=comb[i] ;
	}
	cout << ans ;
	return 0 ;
}

Measured memory_bytes: 8688
r, c = map(int, input().split())

matrix = [list(map(int, input().split())) for _ in range(r)]

for i in range(r):
    matrix[i].append(sum(matrix[i]))

matrix.append(list(map(sum, zip(*matrix))))

for m in matrix:
    print(' '.join(str(e) for e in m))

Measured memory_bytes: 7664
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int k;
long long ans;
int mp[201][201];

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k;
	for (int i = 1; i <= 200; i++) {
		for (int j = 1; j <= 200; j++) {
			mp[i][j] = gcd(i, j);
		}
	}
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int r = 1; r <= k; r++) {
				ans += mp[i][mp[j][r]];
			}
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3804
/**********************************
	author:  mariogzsl
**********************************/

#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,b,a) for(int i=b-1;i>=a;i--)
#define f first
#define s second
#define puts(x) cout<<x<<endl
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,Q;
	string s;
	cin>>N>>Q;
	cin>>s;
	vector<int>sum(N,0);
	FOR(i,1,N){
		if(s[i-1]=='A' and s[i]=='C'){
			sum[i]=1+sum[i-1];
		}else{
			sum[i]=sum[i-1];
		}
	}
	int l,r;
	FOR(i,0,Q){
		cin>>l>>r;
		cout<<sum[r-1]-sum[l-1]<<endl;
	}
	return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	LL H, W;
	cin >> H >> W;
	if(H==1||W==1) cout << 1 << endl;
	else if(H%2==0||W%2==0) cout << H*W/2 << endl;
	else cout << H*(W-1)/2+(H+1)/2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    SPEED;
    string str;
    cin >> str;
    int flag = 0;
    if (str[2] == str[3] && str[4] == str[5]) {
        flag = 1;
    }
    flag == 1 ? cout << "Yes" : cout << "No";
    return 0;
}

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

#define endl "\n"
#define double long double


double computeDistance(vector<long long int> p1, vector<long long int> p2){
    double ans = 0;
    for(long long int i = 0; i < p1.size(); i++)
        ans += pow(p1[i] - p2[i], 2);
    return sqrt(ans);
}

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

    long long int n,d, ans = 0;
    cin>>n>>d;

    vector<vector<long long int>> v(n,vector<long long int>(d));

    for(long long int i = 0; i  <n; i++)
        for(long long int j = 0; j < d; j++)
            cin>>v[i][j];
    
    for(long long int i = 0; i < n-1; i++)
        for(long long int j = i+1; j < n; j++){
            double d = computeDistance(v[i],v[j]);
            long long int m = d;
            if(m == d)
                ans++; 
        }
    
    cout<<ans;
    return 0;
}


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

using namespace std;

template <class Type>
class Bit {
    public:
    
    Bit() : bit(NULL) {}
    
    Bit(int n) : size(n + 1) {
        bit = (Type *)calloc(size, sizeof(Type));
    }
    
    ~Bit() {
        free(bit);
    }
    
    void add(int x, Type value) {
        for (x++; x < size; x += x & -x) bit[x] += value;
    }
    
    Type sum(int x) {
        Type value = 0;
        
        for (x++; x > 0; x -= x & -x) value += bit[x];
        
        return value;
    }
    
    private:
    
    int size;
    Type *bit;
};

int main() {
    int n, m, i, j, k;
    vector <pair<int, pair<int, int> > > v;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < n; i++) {
        int l, r;
        
        scanf("%d %d", &l, &r);
        
        v.push_back(make_pair(r - l + 1, make_pair(l, r)));
    }
    
    sort(v.begin(), v.end());
    
    Bit <int> b(m + 1);
    
    for (i = 1, j = 0; i <= m; i++) {
        int ans = 0;
        
        while (j < v.size()) {
            if (v[j].first >= i) break;
            
            b.add(v[j].second.first, 1);
            b.add(v[j].second.second + 1, -1);
            
            j++;
        }
        
        ans += v.size() - j;
        
        for (k = 0; k <= m; k += i) ans += b.sum(k);
        
        printf("%d\n", ans);
    }
    
    return 0;
}


Measured memory_bytes: 6512
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k ;
    multiset<int> p;
    int t1;
    for(int i=0; i!=n; i++){
        cin >> t1;
        p.insert(t1);
    }
    int out =0;
    auto it = p.begin();
    for(int i=0; i!=k; i++){
        out +=  *it;
        it++;
    }

    cout << out << endl;
    return 0; 
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n,m;
  cin >> n >> m;
  vector<long> h(n);
  rep(i,n) cin >> h.at(i);
  vvi Graph(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    Graph.at(a).push_back(b);
    Graph.at(b).push_back(a);
  }
  int ans = 0;
  rep(i,n){
    int now = h.at(i);
    bool flag = true;
    for(int nv : Graph.at(i)){
      if(now > h.at(nv)) continue;
      flag = false;
      break;
    }
    ans += flag;
  }
  cout << ans << endl;
}

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

int main(void){
  double x1,y1,x2,y2,x3,y3,x4,y4;
  int n;

  cin >> n;

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

    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

    if( (y2-y1)/(x2-x1) == (y4-y3)/(x4-x3) ) cout << "YES" << endl;
    else cout << "NO" << endl;

  }

  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef long long LL;
const LL N = 310;
inline LL read()
{
  char ch=getchar(); LL p=0; LL f=1;
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

LL h,w,a[N][N],d;

pair<LL,LL> pr[N*N];

LL costd[N*N][25];

int main()
{

  h=read(); w=read(); d=read();
  for(LL i=1;i<=h;i++) for(LL j=1;j<=w;j++) a[i][j] = read(),pr[a[i][j]] = MP(i,j);
  
  for(LL i=1;i<=h*w-d;i++)
  {
    LL x1 = pr[i].first; LL y1=pr[i].second;
    LL x2 = pr[i+d].first; LL y2=pr[i+d].second;
    costd[i][0] = abs(x1-x2) + abs(y1-y2);
  }

  for(LL j=1;j<=20;j++) for(LL i=1;i<=h*w-d;i++) if(i+(1<<j)*d <= h*w)
    costd[i][j] = costd[i+(1<<(j-1))*d][j-1] + costd[i][j-1];

  LL q=read();
  while(q--)
  {
    LL l=read(),r=read(); LL de=(r-l) /d; LL ans=0; LL x=l;
    for(LL i=20;i>=0;i--) if((1<<i) <= de){de-=(1<<i); ans += costd[x][i]; x+=(1<<i)*d;}
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

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

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;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    for( int i = 0; i < s.size(); ++i ) {
        if( !( i % 2 ) ) cout << s[i];
    }
    cout << endl;
    return 0;
}



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

int dp[303][303][303];
string s;

int getdp(int i, int j, int k){
    if (i<0) return -1;
    if (j>k) return 0;
    if (j == k) return 1;
    if (dp[i][j][k] != -1) return dp[i][j][k];
    int res = -1;
    if (s[j] == s[k]) res = getdp(i, j+1, k-1)+2;
    else res = max(getdp(i-1, j+1, k-1)+2, max(getdp(i, j+1, k), getdp(i, j, k-1)));
    dp[i][j][k] = res;
    return res;
}

int main(){
    cin >> s;
    int k; cin >> k;
    for(int i=0; i<302; i++)for(int j=0; j<302; j++)for(int k=0; k<302; k++) dp[i][j][k] = -1;
    cout << getdp(k, 0, s.size()-1);
}


Measured memory_bytes: 108800
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define M 1000000007
int main() {
    int h,w,i,j;
    cin>>h>>w; 
    char a[h+1][w+1];
    long int dp[h+1][w+1];
    for(i=1;i<=h;i++)
    dp[i][0]=0,dp[0][i]=0;
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
             cin>>a[i][j];
            if(a[i][j]=='.'){dp[1][1]=1;
            dp[i][j]=(dp[i-1][j]%M+dp[i][j-1]%M)%M;
                
            }
            else
            dp[i][j]=0;
        }
    }
     cout<<dp[h][w];
     
        
    
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll n;
		cin >> n;
		vl a(n);
		rep(i, n) {
			cin>>a[i];
		}
		if(n<=2) cout<<"0\n";
		else {
			sort(all(a));
			ll rs = 0;
			rep(i, n-2) {
				f(j, i+1, n-1) {
					if(a[i]==a[j]) continue;
					f(k, j+1, n) {
						if(a[j]==a[k]) continue;
						if(a[i]+a[j]>a[k]) rs++;
					}
				}
			}
			cout<<rs<<"\n";
		}
	// }
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 3000 + 7;

int n;
ld a[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%Lf", &a[i]);
	return true;
}

ld dp[N][N];

void solve() {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	forn(i, n) forn(j, i + 1){
		dp[i + 1][j] += dp[i][j] * (1 - a[i]);
		dp[i + 1][j + 1] += dp[i][j] * a[i];
	}
	ld sum = 0;
	forn(i, n / 2 + 1)
		sum += dp[n][i];
	printf("%.15Lf\n", 1 - sum);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

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

int main() {
	while (true) {
		int a, b;
		char op;
		cin >> a >> op >> b;
		if (op == '?') {
			break;
		}
		else if (op == '+') {
			cout << a + b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '*') {
			cout << a*b << endl;
		}
		else if (op == '/') {
			cout << a / b << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b=n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		for(int j=0;j<i;j++){
			if(a[i]==a[j]){
				b--;
				break;
			}
		}
	}
	cout<<b;
	return 0;
}


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

int main(void) 
{
    int a, b, c, i, ans = 0;
    cin >> a >> b >> c;
    for(int i = a; i <= b; i++) {
        if(c % i == 0) ans++;
    }
    cout << ans << endl;

}



Measured memory_bytes: 3116
while True:
    n,m = map(int, input().split())
    if n == 0 and m == 0:
        break
    nlist = [0]
    mlist = [0]
    for i in range(n):
        nlist += [nlist[-1] + int(input())]
    for i in range(m):
        mlist += [mlist[-1] + int(input())]

    l = [0for i in range(1000*1501)]
    for i in range(n):
        t = 0
        for k in range(i+1,n+1):
            t = nlist[k] - nlist[i]
            l[t] += 1
    count = 0
    for i in range(m):
        for k in range(i+1,m+1):
            t = mlist[k] - mlist[i]
            count += l[t]
    
    print(count) 


Measured memory_bytes: 41492
from fractions import gcd


def gcd_list(A):
    num=A[0]
    for i in A:
        num=gcd(num,i)
    return num


n,k=map(int,input().split())
A=list(map(int,input().split()))
print("POSSIBLE" if k%gcd_list(A)==0 and k<=max(A) else "IMPOSSIBLE")

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


int main(){

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;    
    while(1){
        bool ok = true;
        for(int i = 0; i < n; i++){
            if(a[i] != 0) ok = false;
           // cout << a[i] << " ";
        }
        //cout << endl;*/
        if(ok) break;
        
        int l = 0;
        for(int i = 0; i < n; i++){
            if(a[i] != 0){
                l = i;
                break;
            }
        }

        int r = n;
        for(int i = l; i < n; i++){
            if(a[i] == 0){
                r = i;
                break;
            }
        }

        //cout << l << " " << r << endl;
        for(int i = l; i < r; i++) a[i]--;
        ans++;
        
    }

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

Measured memory_bytes: 256
A=int(input())
B=int(input())
if A==1 and B==2:
  print(3)
elif A==1 and B==3:
  print(2)
elif A==2 and B==1:
  print(3)
elif A==2 and B==3:
  print(1)
elif A==3 and B==1:
  print(2)
elif A==3 and B==2:
  print(1)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
 
int main(){
    int N;
    int M;
    cin >> N >> M;
    int prod1=1;
    int prod2=1;
    if(N>2){
        for(int i=N;i>N-2;i--){
            prod1=i*prod1;
        }
        prod1/=2;
    }else if(N==2){
        prod1=1;
    }else{
        prod1=0;
    }
    if(M>2){
        for(int i=M;i>M-2;i--){
            prod2=i*prod2;
        }
        prod2/=2;
    }else if(M==2){
        prod2=1;
    }else{
        prod2=0;
    }
    cout << prod1+prod2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n;
long long a[100099];
long long dp[100099];
long long bt(long long pos)
{
    if(pos==n-1)
        return 0;
    if (pos==n-2) return abs(a[n-2]-a[n-1]);
        if(dp[pos]!=-1)
            return dp [pos];
    long long minn=0;
    minn=min(bt(pos+1)+abs(a[pos]-a[pos+1]),bt(pos+2)+abs(a[pos]-a[pos+2]));
    dp[pos]=minn;
   // minn=min(,minn);
    return minn;
}
int main()
{memset(dp,-1,sizeof dp);
    cin>>n;
    for(long long i=0; i<n; i++)
    {
        cin>>a[i];
    }
cout<<bt(0);
}

Measured memory_bytes: 3328
import numpy as np
N, D, = map(int, input().split())

points = []
tmp_p  = []

for i in range(N):
    tmp_p = list(map(int, input().split()))
    points.append(tmp_p)

points_arr = np.array(points)

# print(points_arr)

param_result = 0
for param_start in range(N):
    # print("****************************")

    for param_end in range(N):

        if  param_start >= param_end:
            # print(param_start)
            # print(param_end)
            # print("PASS: s > e")
            pass

        else:
            # print(param_start)
            # print(param_end)

            dist = points_arr[param_start,] - points_arr[param_end,]
            res = np.linalg.norm(dist)
            # print(res)

            if res.is_integer() is True:
                # print("is int")
                param_result += 1
            else:
                # print("is float")
                pass

print(param_result)

Measured memory_bytes: 12452