akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int cnt = 0 ;
	for(int i=0;i<6;i++){
		char n ; cin >> n ;
		cnt += n-'0' ;
	}
	cout << cnt << endl ;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut sm = Vec::new();
    for _ in 0..m {
        let mut si = read::<usize>();
        si.remove(0);
        sm.push(si);
    }

    let pm = read::<usize>();
    let mut ans = 0;
    for b in 0..1 << n {
        let mut sw = Vec::new();
        let mut on = 0;
        for i in 0..n {
            if b & (1 << i) != 0 { sw.push(i + 1); }
        }

        for i in 0..m {
            let mut cnt = 0;
            for s in sw.iter() {
                if sm[i].contains(s) { cnt += 1; }
            }

            if cnt % 2 == pm[i] { on += 1; }
        }
        if on == m { ans += 1; }
    }

    println!("{}", ans);
}

#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 2216
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;


int main() {
	int i, j, n, m, q;
	cin >> n >> m >> q;
	vector<vector<int>> t(n + 2, vector<int>(n + 2, 0)), sum(n + 2, vector<int>(n + 2, 0));

	for (i = 0; i < m; i++) {
		int left, right;
		cin >> left >> right;
		t[left][right]++;
	}
	for (i = 1; i < n + 1; i++) {
		for (j = 1; j < n + 1; j++) {
			sum[i][j] = sum[i][j - 1] + t[i][j];
		}
	}
	for (i = 0; i < q; i++) {
		int ql, qr, ans = 0;
		cin >> ql >> qr;
		for (j = ql; j <= qr; j++) {
			ans += sum[j][qr] - sum[j][ql - 1];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2944
#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 chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int h, w;
const int MAX_N = 50;
char c[MAX_N][MAX_N];
int cnt;
int reached[MAX_N][MAX_N];
// fill_n(*reached, MAX_N * MAX_N, inf);
void dfs(int y, int x) {
    rep3(i, -1, 2) rep3(j, -1, 2) {
        if ((i != 0 && j != 0) || (i | j) == 0) continue;
        // if ((i | j) == 0) continue;
        int ny = y + i;
        int nx = x + j;
        if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        if (reached[ny][nx] <= reached[y][x] + 1 || c[ny][nx] == '#') continue;
        reached[ny][nx] = reached[y][x] + 1;
        dfs(ny, nx);
    }
}

int main() {
    cin >> h >> w;
    rep(i, h) rep(j, w) { cin >> c[i][j]; if (c[i][j] == '#') cnt++; }
    fill_n(*reached, MAX_N * MAX_N, inf);
    reached[0][0] = 0;
    dfs(0, 0);
    // out(reached[h - 1][w - 1]);
    if (reached[h - 1][w - 1] == inf) out(-1);
    else out(h * w - cnt - reached[h - 1][w - 1] - 1);
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int64_t n; cin >> n;


	int64_t ans = 0;

	int64_t th = sqrt(n - 1);
	for (int64_t d = 1; d <= th; d++) {
		int64_t m = n / d;
		int64_t r = n % d;
		if (r == m) {
			ans += m;
		}
		if (r == 0 && (n / (m - 1) == d)) {
			ans += (m - 1);
		}
	}

	int64_t m = n / (th + 1);
	for (m; 2 <= m; m--) {
		if (n / m == n % m) {
			ans += m;
		}
	}

	cout << ans << endl;


	return 0;
}

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

using namespace std;

#define EPS 1e-10

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}

    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE;
    if(dot(a,b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

typedef vector<Point> Polygon;

#define prev(G,i) (G[(i-1+G.size())%G.size()])
#define curr(G,i) (G[i%G.size()])
#define next(G,i) (G[(i+1)%G.size()])

bool isConvex(const Polygon &p){
    for(int i = 0 ; i < (int)p.size() ; i++){
        if(ccw(prev(p,i),curr(p,i),next(p,i)) == CLOCKWISE){
            return false;
        }
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    Polygon p(N);
    for(int i = 0 ; i < N ; i++){
        cin >> p[i].x >> p[i].y;
    }
    cout << isConvex(p) << endl;
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int S; cin >> S;
    int upper = S / 100;
    int lower = S % 100;

    string res;
    if (upper == 0 and lower > 12) res = "NA";
    else if (upper > 12 and lower == 0) res = "NA";
    else if (upper > 12 and lower > 12) res = "NA";
    else if (upper == 0 and lower == 0) res = "NA";
    else if (upper == 0 or upper > 12) res = "YYMM";
    else if (lower == 0 or lower > 12) res = "MMYY";
    else res = "AMBIGUOUS";

    cout << res << "\n";
}

Measured memory_bytes: 256
import copy
from collections import defaultdict
n=int(input())
a=[int(input()) for _ in range(n)]
b=copy.copy(a)
b.sort()
d=defaultdict(int)
for i in range(n):
  d[b[i]]=i
ans=0
for i in range(n):
  if (d[a[i]]-i)%2==1:
    ans+=1
print(ans//2)

Measured memory_bytes: 63064
#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)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    // ランレングス圧縮
    int n = sz(s);
    vector<pair<char, int>> cnt;
    cnt.emplace_back(s[0], 0);
    rep(i, n) {
        if (cnt.back().fi == s[i]) cnt.back().se++;
        else cnt.emplace_back(s[i], 1);
    }

    // 移動をx成分とy成分に分ける（初めのFは別で処理）
    int sx = 0, sy = 0;
    vector<int> xlist, ylist;
    int now = 0;
    rep(i, sz(cnt)) {
        if (i == 0 && cnt[i].fi == 'F') {
            sx += cnt[i].se;
        } else if (cnt[i].fi == 'T') {
            now ^= (cnt[i].se % 2);
        } else {
            if (now == 0) xlist.push_back(cnt[i].se);
            else ylist.push_back(cnt[i].se);
        }
    }

    // どこに移動できるかDP（10000を0としている）
    vector<bool> to_x(60000, false);
    vector<bool> to_y(60000, false);
    to_x[30000] = true;
    to_y[30000] = true;

    rep(i, sz(xlist)) {
        vector<bool> pre_x(60000, false);
        swap(to_x, pre_x);
        rep(j, 60000) if (pre_x[j]) {
            if (j+xlist[i] < 60000) to_x[j + xlist[i]] = true;
            if (j-xlist[i] >= 0) to_x[j - xlist[i]] = true;
        }
    }

    rep(i, sz(ylist)) {
        vector<bool> pre_y(60000, false);
        swap(to_y, pre_y);
        rep(j, 60000) if (pre_y[j]) {
            if (j+ylist[i] < 60000) to_y[j + ylist[i]] = true;
            if (j-ylist[i] >= 0) to_y[j - ylist[i]] = true;
        }        
    }

    // 移動できるかチェック
    int dx = x - sx, dy = y - sy;
    dx += 30000, dy += 30000;
    if (to_x[dx] && to_y[dy]) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

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

template<i64 M>
struct modint {
  i64 a;
  constexpr modint(const i64 x = 0) noexcept: a((x % M + M) % M) {}
  constexpr i64 value() const noexcept { return a; }
  constexpr modint pow(i64 r) const noexcept {
    modint ans(1);
    modint aa = *this;
    while(r) {
      if(r & 1) {
        ans *= aa;
      }
      aa *= aa;
      r >>= 1;
    }
    return ans;
  }
  constexpr modint& operator+=(const modint r) noexcept {
    a += r.a;
    if(a >= M) a -= M;
    return *this;
  }
  constexpr modint& operator=(const i64 r) {
    a = (r % M + M) % M;
    return *this;
  }
  constexpr modint& operator-=(const modint r) noexcept {
    a -= r.a;
    if(a < 0) a += M;
    return *this;
  }
  constexpr modint& operator*=(const modint r) noexcept {
    a = a * r.a % M;
    return *this;
  }
  constexpr modint& operator/=(modint r) noexcept {
    i64 ex = M - 2;
    while(ex) {
      if(ex & 1) {
        *this *= r;
      }
      r *= r;
      ex >>= 1;
    }
    return *this;
  }

  constexpr modint operator+(const modint r) const {
    return modint(*this) += r;
  }
  constexpr modint operator-(const modint r) const {
    return modint(*this) -= r;
  }
  constexpr modint operator*(const modint r) const {
    return modint(*this) *= r;
  }
  constexpr modint operator/(const modint r) const {
    return modint(*this) /= r;
  }
};

template<const i64 M>
std::ostream& operator<<(std::ostream& os, const modint<M>& m) {
  os << m.value();
  return os;
}

const i64 MOD = 1e9 + 7;
using fp = modint<MOD>;

int main() {
  i64 N;
  cin >> N;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  vector<i64> ps(1e6 + 1);
  rep(i,0,N) {
    i64 x = A[i];
    for(i64 p = 2; p * p <= x; p++) {
      if(x % p == 0) {
        i64 cnt = 0;
        while(x % p == 0) {
          cnt++;
          x /= p;
        }
        ps[p] = std::max(ps[p], cnt);
      }
    }
    if(x != 1) {
      ps[x] = std::max(ps[x], 1ll);
    }
  }
  fp G = 1;
  for(i64 p = 2;p < ps.size();p++) {
    G *= fp(p).pow(ps[p]);
  }
  fp ans = 0;
  rep(i,0,N) {
    ans += G / fp(A[i]);
  }
  cout << ans.value() << endl;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
int main(){
    int n;
    cin>> n;
    vector<int> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }

    int ans = 1;
    bool can;

    for(int i = 1; i < n; ++i){
        can = true;
        for(int j = 0; j < i; ++j){
            
            if(h[j] > h[i]){
                can = false;
            }
        }
        if(can) ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,k;
    cin>>a>>b>>k;
    if(a>k){
        cout<<a-k<<" "<<b<<endl;
        return 0;
    }
    else if(a<=k && b-(k-a)<=0)cout<<"0 0"<<endl;
    else{
        cout<<0<<" "<<b-(k-a)<<endl;
    }
}

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

// APG4b-L
int main() {
  int N;
  cin >> N;

  vector<int> num(N);
  for (int i = 0; i < N; i++) { // 奇数が混じっていないか確認(1回目の操作の前にだけ)
    int a;
    cin >> a;
    if (a & 1) {
      cout << 0 << endl;
      return 0;
    } else {
      num.at(i) = a;
    }
  }

  int sum = 0;
  while (true) {
    for(int i = 0; i < N; i++) {
      if (num.at(i) & 1) {
        cout << sum << endl;
        return 0;
      } else {
        num.at(i) /= 2;
      }
    }
    sum++;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define REREACE

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define ALL(v) v.begin(), v.end()

int main(){
    
    vector<vector<int>> A(3+10,vector<int>(3+10));
    int N;
    REP(i,3){
        REP(j,3){
            cin>>A[i][j];
        }
    }
    cin>>N;
    vector<int> b(N+10);
    REP(k,N){
        cin>>b[k];
        REP(i,3){
            REP(j,3){
                if(b[k]==A[i][j])A[i][j]=-1;
                s(A[i][j]);
            }
            sl();
        }
        sl();
    }
    int sumy=0,sumt=0;
    REP(i,3){
        REP(j,3){
            sumy+=A[i][j];
            sumt+=A[j][i];
        }
        if(sumy==-3||sumt==-3){
            cout<<"Yes";
            return 0;
        }
        sumt=0;sumy=0;
    }
    REP(i,3){
        sumy+=A[i][i];
        sumt+=A[4-i][i];
    }
    if(sumy==-3||sumt==-3){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  string s;
  cin >> s;
  stack< int > st;
  int ret = 0;
  for(int i = 0; i < s.size(); i++) {
    if(st.size() && st.top() != s[i]) {
      ++ret;
      st.pop();
    } else {
      st.push(s[i]);
    }
  }
  cout << 2 * ret << endl;
}






Measured memory_bytes: 768
def inpl(): return list(map(int, input().split()))
from collections import defaultdict

G = dict()
for i in range(9):
    G[(i, 9)] = 0
    G[(9, i)] = 0
G[(9, 9)] = 0

for i in range(8)[::-1]:
    a = 8 - i
    b = -(-(8 - i)//2)
    i= i+1
    for j in range(8)[::-1]:
        if j % 2 == 1:
            j = j+1
            G[(i, j)] = G[(i, j+1)] + b
        else:
            j = j+1
            G[(i, j)] = G[(i, j+1)] + a

q = int(input())
for _ in range(q):
    a, b, c, d = inpl()
    print(G[(a, b)] - G[(c+1, b)] - G[(a, d+1)] + G[(c+1), (d+1)])


Measured memory_bytes: 6000
# -*- coding: utf-8 -*-
"""
Created on Tue Sep  8 20:25:36 2020

@author: liang
"""

def Eratosthenes(x):
    lis = [int(i) for i in range(2,x+1)]
    #print(lis)
    res = list()
    while lis:
        a = lis.pop(0)
        res.append(a)
        lis = [i for i in lis if i%a != 0]
        #print(lis)
    return res

import math
X = int(input())
N = int(math.sqrt(X))
lis = Eratosthenes(N)
#print(N)
#print(lis)
ans = X 

while True:
    if all(ans%i != 0 for i in lis):
        print(ans)
        break
    ans += 1

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

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;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    scanf("%lld", &N);
    const auto &res = prime_factorize(N);

    ll count = 0;

    for(auto p : res){
            count +=
                ((-1.0 + sqrtl(1.0 + 8.0 * static_cast<long double>(p.second))) /
                 2.0);
        
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3760
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

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

int main(){
  
  int a,b,c;
  char x,y;
  int cnt1=0;
  int cnt2=0;
  while(cin>>a>>x>>b>>y>>c){
    if(a*a+b*b==c*c) cnt1++;
    if(a==b) cnt2++;
  }
  
  cout<<cnt1<<endl;
  cout<<cnt2<<endl;
      
  return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


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



void print(const vint& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

vector< bool > primes(ll n){
  vector< bool > rtn(n+1, true);
  // bool checked[n+1];
  // rep(i,n+1) checked[i] = false;

  for(ll i=2; i*i <= n; ++i){
    if(!rtn[i]) continue;
    // checked[i] = true;
    ll j = i;
    while( (j+=i) <= n ){
      rtn[j] = false;
    }
  }

  return rtn;
}

int main() {


  cout<<fixed<<setprecision(10);

  ll n; cin>>n;
  vector<bool> pnum = primes(100000000);

  ll cnt = 0;
  rep(i,n){
    ll m; cin>>m;
    cnt += pnum[m];
  }

  cout<<cnt<<endl;
}





//




Measured memory_bytes: 14964
/*
ID: lit20182
TASK: beads
LANG: C++                 
*/
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) vector<ll> ft(1, 1LL);rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define int ll
 
 
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
/*_____________________________________________________________________________________________________*/
 
 
signed main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
    next :
	while(t--){
        int n, ans;
        cin >> n;
        ans = min(2LL, n-1LL);
        for(int i = 2; i*i <= n; i++){
           int m = n;
           while(m%i == 0)m /= i;
           if(m%i == 1)ans += 1 + ((m==n) and (i*i != n-1));
        }
        cout << ans << endl;
    }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    int t = N;
    vector<int> ans;
    int pt = N;
    while(t > 0){
        for (int i = M; i > 0; i--) {
            if(t - i >= 0 && S[t-i] == '0'){
                ans.push_back(i);
                t = t - i;
                break;
            }
        }
        if(pt == t){
            printf("-1\n");
            return 0;
        }
        pt = t;
    }
    int L = ans.size();
    for (int i = L-1; i >= 0; i--) {
        printf("%d ", ans[i]);
    }
    printf("\n");


}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int dp[2001][2001];

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i];
    }
    priority_queue<pair<Int, Int>> q;
    for (Int i = 0; i < (Int)n; i++) {
        q.push({a[i], i});
    }
    for (Int i = 0; i < n; i++) {
        pair<Int, Int> p = q.top();
        for (Int j = 0; j <= i; j++) {
            dp[j + 1][i - j] = max(dp[j + 1][i - j], dp[j][i - j] + p.first * abs(j - p.second));
            dp[j][i - j + 1] = max(dp[j][i - j + 1], dp[j][i - j] + p.first * abs(n - 1 - (i - j) - p.second));
        }
        q.pop();
    }
    // for (Int i = 0; i <= n; i++) {
    //     for (Int j = 0; j <= n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    Int res = 0;
    for (Int i = 0; i < (Int)n; i++) {
        res = max(res, dp[i][n - i]);
    }
    print(res);
    return 0;
}

Measured memory_bytes: 26244
H, W=map(int,input().split())
if H==1:
  print(1)
elif W==1:
  print(1)
else:
  if W%2==0:
    s=H*W/2
    print(int(s))
  elif W%2==1:
    if H%2==0:
      t=W*H/2
      print(int(t))
    else:
      u=W*(H+1)/2-(W-1)/2
      print(int(u))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#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 ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll x=0,g=0,n,k,w,l,ans,ptr=0;
    string s,s1,s2;
    cin >> n >> k;
    VI h(n);
    VI dp(n,INF);
    dp[0] = 0;
    rep(i,n){
        cin >> h[i];
	}
    for(int i=0;i<n-1;i++){     // i:移動する前の位置
        for(int j=1;j<=k;j++){   // j:移動する値
            if(i+j < n)       // i+j+1:移動後の位置
                dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
            else break;
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
N=input()
A=map(int,raw_input().split())
for i in range(N-1):
	for k in range(N-1):
		print A[k],
	print A[N-1]
	v=A[i+1]
	j=i
	while j>=0 and A[j] >v:
		A[j+1]=A[j]
		j=j-1
	A[j+1]=v

for m in range(N-1):
	print str(A[m]),
print A[N-1]

Measured memory_bytes: 6348
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main(){
	int val[3] = {};
	string str;
	cin >> str;
	for(char &c : str){
		switch(c){
			case 'a':++val[0];break;
			case 'b':++val[1];break;
			default:++val[2];break;
		}
	}
	int maxval = *max_element(&val[0],&val[3]);
	
	if(abs(maxval-val[0]) <= 1 && abs(maxval-val[1]) <= 1 && abs(maxval-val[2]) <= 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())
        uf.union(a, b)
    print(uf.group_count() - 1)   

if __name__ == "__main__":
    main()



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

using ll = long long;
using cd = complex<double>;

constexpr ll mod = 998244353;

const int delta = 310 * 310;

int buf[310] = {};
int d[310][2 * delta] = {};
int d2[310][2 * delta] = {};

// dyn[i][j + delta] = in cate moduri putem fixa o latura "mare"
// si sa fixam toate pana la i astfel incat diferenta intre latura
// mare si celelalte 2 e fix j.

void add(int& i, ll x){
    i = (i + x) % mod;
    i += mod;
    i %= mod;
}

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

    int n;

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

    d[0][0 + delta] = 3;
    d2[0][0 + delta] = 3;

    for(int i = 0; i < n; ++i)
        for(int j = -delta; j < delta; ++j)
            if(d[i][j + delta]){
                add(d[i + 1][j + buf[i] + delta], d[i][j + delta]),
                add(d[i + 1][j - buf[i] + delta], 2ll * d[i][j + delta]);

                add(d2[i + 1][j + buf[i] + delta], d2[i][j + delta]);
                add(d2[i + 1][j - buf[i] + delta], d2[i][j + delta]);
            }

    int ret = 0;

    add(d[n][0 + delta], mod - d2[n][0 + delta]);

    for(int j = 0; j < delta; ++j){
        if(d[n][j+delta])
        add(ret, d[n][j + delta]);
    }

    ret = mod - ret;
    ret %= mod;
    ret += mod;
    ret %= mod;

    ll p3 = 1;
    for(int i = 0; i < n; ++i){
        p3 = 3 * p3;
        p3 %= mod;
    }

    add(ret, p3);

    cout << ret << endl;






    return 0;
}



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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main(){
  int K,S;
  cin >> K >> S;
  int ans = 0;
  for(int i = 0;i < K+1;i++){
    for(int j = 0;j < K + 1;j++){
      if(S-i-j >= 0 && S-i-j <=K){
        ans++;
      }
    }
  }
  printf("%d\n",ans);
}
  

Measured memory_bytes: 3736
#include <cstdio>

using namespace std;

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

typedef long long ll;

const int N_MAX = 200000;

int N;
int A[N_MAX];

void solve() {
  if (A[0] > 0) {
    puts("-1");
    return;
  }
  ll ans = 0;
  FOR(i, 1, N - 1) {
    int d = A[i] - A[i - 1];
    if (d > 1) {
      puts("-1");
      return;
    } else if (d == 1) {
      // printf("%d : +1\n", i);
      ans += 1;
    } else if (d == 0) {
      // printf("%d : +%d\n", i, A[i]);
      ans += A[i];
    } else if (A[i] > 0) {
      // printf("%d : +1\n", i);
      ans += A[i];
    }
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

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


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		while(n > 1000) {
			n -= 1000;
		}
		System.out.println(1000 - n);
		
	}

}


Measured memory_bytes: 35644
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)
#define DMP(x) cerr << #x << ": " << x << "\n"

using namespace std;
typedef long long lint;
const int MOD = 1000000007;


int main() {

	cin.tie(0);
	
	int N, tmp;
	cin >> N;

	set<int> A;
	FOR(i, 0, N) {
		cin >> tmp;
		A.insert(tmp);
	}
	
	if ((int)(A.size()) % 2 == 0)cout << A.size() - 1;
	else cout << A.size();

	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  
  cin >> n;
  
  while(n != 0){
    
    int a[12][12] ={};

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin >> a[i][j];
	a[i][n] += a[i][j];
	a[n][j] += a[i][j];
      }
      a[n][n] += a[i][n];
    }
    
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	printf("%5d",a[i][j]);
      }
      printf("\n");
    }
    
    cin >> n;
  }

  return (0);
}

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

int main(){
  int n;
  cin  >>  n;
 vector<int>  a(n);
for(int i=0;i<n;i++){
cin  >>  a[i];
}
for (int i=n-1; i >0; i--){
cout  <<  a[i]  <<  " " ;
}
cout << a[0] << endl;
return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

// 入力
int n, k;
vector<int> a;

// dp[i] := 石が i 個残っている時の勝敗
// (1, 0, -1) = (勝ち, 負け, 不定)
vector<int> dp(100005, -1);

// メモ化再帰
int memo_rec(int x){
    if(dp[x] != -1) return dp[x];
    
    int res = 1;
    for(int i = 0; i < n; ++i){
        if(x - a[i] < 0)    continue;
        res &= memo_rec(x - a[i]);
    }
    return dp[x] = res ^ 1;
}

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

    cin >> n >> k;
    int min_e = INF;
    for(int i = 0; i < n; ++i){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
        chmin(min_e, tmp);
    }

    // 負けが確定するところを 0 で埋める
    for(int i = 0; i < min_e; ++i){
        dp[i] = 0;
    }

    if(memo_rec(k)) cout << "First\n";
    else    cout << "Second\n";
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define EPS (1e-10)    //誤差
typedef complex<double> P;

//実数同士の比較
bool EQ(double a, double b){
    return (abs(a - b) < EPS);
}

//二つのベクトルが等しいかどうか
bool EQV(P a, P b){
    return (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag()));
}

//内積
double dot(P a, P b){
    return (a.real() * b.real() + a.imag() * b.imag());
}

//外積
double cross(P a, P b){
    return (a.real() * b.imag() - a.imag() * b.real());
}

// 点a,bを通る直線と点cとの距離
double distance_l_p(P a, P b, P c) {
  return abs(cross(b-a, c-a)) / abs(b-a);
}

// 点cが線分a,b上にあるかないか(3)
int is_point_on_line(P a, P b, P c) {
  // |a-c| + |c-b| <= |a-b| なら線分上
  return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

// 点a,bを端点とする線分と点cとの距離
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

//図を思い出す
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}

// a1,a2を端点とする線分とb1,b2を端点とする線分の交差判定
int is_intersected_ls(P a1, P a2, P b1, P b2) {
  return ( ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 ) &&
           ( ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0 );
}

// a1,a2を通る直線とb1,b2を通る直線の交点計算
P intersection_l(P a1, P a2, P b1, P b2) {
  P a = a2 - a1; P b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

int main(){
   
   int q; cin >> q;
    for(int i = 0; i < q; i++){
        P p0, p1, p2, p3; cin >> p0.real() >> p0.imag() >> p1.real() >> p1.imag() >> p2.real() >> p2.imag() >> p3.real() >> p3.imag();
        double ans = 1e10;
        ans = min(ans, distance_ls_p(p0, p1, p2));
        ans = min(ans, distance_ls_p(p0, p1, p3));
        ans = min(ans, distance_ls_p(p2, p3, p0));
        ans = min(ans, distance_ls_p(p2, p3, p1));
        if(is_intersected_ls(p0, p1, p2, p3)) ans = 0.0;
        printf("%.10f\n", ans);
    }
    
    return 0;
}





Measured memory_bytes: 3252
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>


using namespace std;


int main(void){
  
  int R;
  double ans=0;
  
  
  cin >> R;

  ans = 2 * M_PI*R;

  cout << ans << endl;
  

  return 0;
}




Measured memory_bytes: 3780
package main

import "fmt"

func main() {
	var o, e string
	fmt.Scan(&o, &e)
	n := (len(o) + len(e)) / 2
	for i := 0; i < n; i++ {
		fmt.Print(string(o[i]))
		fmt.Print(string(e[i]))
	}
	if len(o) > len(e) {
		fmt.Print(string(o[len(o)-1]))
	}
	fmt.Println()
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

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

int main() {
    ll n,k;
    cin >> n >> k;
    vector<int> a;
    for (ll i = 1;i*i <= n;++i) {
        a.push_back(n/i);
        a.push_back(i);
        if (i*i == n) a.pop_back();
    }
    sort(a.begin(),a.end());
    int m = a.size();
    vector<vector<ll>> dp(k+1,vector<ll>(m,0));
    for (int i = 0;i < m;++i) dp[0][i] = 1;
    for (int i = 0;i < k;++i) {
        ll sum = 0;
        for (int j = 1;j < m;++j) (dp[i][j] *= a[j]-a[j-1]) %= mod;
        for (int j = 0;j < m;++j) {
            (sum += dp[i][j]) %= mod;
            dp[i+1][m-j-1] = sum;
        }
    }
    ll ans = 0;
    for (int i = 0;i < m;++i) (ans += dp[k-1][i]) %= mod;
    cout << (ans+mod)%mod << endl;
}

Measured memory_bytes: 51196
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll nax=305;
ld dp[nax][nax][nax], ev[nax][nax][nax], one=1;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n;
	cin>>n;
	vector<ll> v(n), cnt(4,0);
	rep(i,0,nax)
		rep(j,0,nax)
			rep(k,0,nax){
				ev[i][j][k]=0;
				dp[i][j][k]=-one;
			}
	rep(i,0,n){
		cin>>v[i];
		cnt[v[i]]++;
	}
	dp[cnt[1]][cnt[2]][cnt[3]]=1;
	ev[cnt[1]][cnt[2]][cnt[3]]=0;
	for(ll c=n;c>=0;c--){
		for(ll b=n;b>=0;b--){
			for(ll a=n;a>=0;a--){
				if(a+b+c>n)continue;
				if(dp[a][b][c]!=-one and a+b+c>0){
					ld x=(n-a-c-b*one)/(n);
					ld waste=one/(one-x);
					ev[a][b][c]+=waste*dp[a][b][c];
					ld pa=(a*one)/(a+b+c*one), pb=(b*one)/(a+b*one+c), pc=(c*one)/(a*one+b+c);
					if(a>0){
						if(dp[a-1][b][c]==-one)dp[a-1][b][c]=0;
						dp[a-1][b][c]+=(pa*(dp[a][b][c]));
						ev[a-1][b][c]+=(pa*(ev[a][b][c]));
					}
					if(b>0){
						if(dp[a+1][b-1][c]==-one)dp[a+1][b-1][c]=0;
						dp[a+1][b-1][c]+=(pb*(dp[a][b][c]));
						ev[a+1][b-1][c]+=(pb*(ev[a][b][c]));
					}
					if(c>0){
						if(dp[a][b+1][c-1]==-one)dp[a][b+1][c-1]=0;
						dp[a][b+1][c-1]+=(pc*(dp[a][b][c]));
						ev[a][b+1][c-1]+=(pc*(ev[a][b][c]));
					}
				}
			}
		}
	}
	cout<<fixed<<setprecision(10)<<ev[0][0][0];
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    ll x;
    cin >> x;
    ll ans=x/11;
    ans*=2;
    ll vs=x%11;
    if(vs>6) ans+=2;
    else if(vs > 0) ans+=1;
    cout << ans;
}


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


main()
{
  int a,s,d,f;
  cin >> a >> s >> d >> f;
  int count = 0;
  for (int i = 0; i <= a;i++){
    for (int j = 0; j <= s;j++){
      for (int k = 0; k <= d;k++){
        if(500*i+100*j+50*k==f)
          count++;
      }
    }
  }
  cout << count << endl;
  
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
if n % 2 == 0:
    l = [2 * i + 1 for i in range(n // 2)] * 2
else:
    l = [2 * i for i in range(1, n // 2 + 1)] + [2 * i for i in range(n // 2 + 1)]
a.sort()
l.sort()
if a != l:
    print(0)
else:
    print(pow(2, n // 2, 10 ** 9 + 7))

Measured memory_bytes: 14008
/**
*       Author: K.R.Surrya  26/04/2020 17:45:16 
*       
**/
/*      review : 29/04/2020 01:08:45*/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define fo(i,a,b)             for(int i=a;i<b;++i)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

long long int funcMatch(string& curr,string& S) {
    long long int cnt=0;
    for(int i=0;i<S.size();++i) {
        if(S[i]==curr[0]) {
           if(i+curr.size()-1<=S.size()-1 && S.substr(i,curr.size()).compare(curr)==0) {
               ++cnt;
            // cerr << i+1 << " " << i+curr.size() << endl;
           }
        }
    }
    return cnt;
}
void solve() {
    string S;
    cin >> S;
    long long int start=2019;
    long long int cnt=1;
    long long int curr=1;
    set<string> visited;
    while(curr<200010) {
        curr=start*cnt;
        string temp=to_string(curr);
        if(curr<=200010)
        visited.insert(temp);
        ++cnt;
    }
    long long int ret=0;
   for(auto s:visited) {
       ret+=funcMatch(s,S);
   }
   cout << ret << endl;
}
//-----------------------------------------------------------------------------------------
void upSolve() {
    string s;
    cin >> s;
    int n=s.size();
    vector<int>dp(2019);
    vector<int>dp2(2019);
    long long ret=0;
    for(int i=1;i<=n;++i) {
      for(int j=0;j<dp2.size();++j) dp2[j]=0;  //dp2 is filled using dp;
      
      for(int j=0;j<2019;++j) {
          dp2[(j*10+s[i-1]-'0')%2019]+=dp[j];
      }
      ++dp2[s[i-1]-'0'];
      ret+=dp2[0];
      swap(dp,dp2);
    }
    cout << ret << '\n';
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);

     auto start = chrono::high_resolution_clock::now();

     upSolve();

     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    string s;
    set<string> t;
    for(i=0;i<n;i++){
        cin >> s;
        t.insert(s);
    }
    cout << t.size() << endl;
    return 0;
}

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

using namespace std;

int main(){
    string a;
    cin >> a;

    int yen = 700;

    if(a.at(0) == 'o') yen += 100;
    if(a.at(1) == 'o') yen += 100;
    if(a.at(2) == 'o') yen += 100;

    cout << yen;

}


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

int main(){
    string s,t;
    cin >> s >> t;
    t.erase(s.size()); //最後消す
    if(t == s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3584