akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int ans = 0;
	if (n <= k) {
		ans = n * x;
	}
	else {
		ans = k * x;
		n -= k;
		ans += n * y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

cnt = 1
top = True
    
for i in range(1,N):
    if A[i] == A[i-1]:
        continue
    if top == True:
        inc = (A[i]>A[i-1])
        top = False
        continue
    
    flag = (A[i]>A[i-1])
    if inc != flag:
        cnt += 1
        top = True
        
print(cnt)


Measured memory_bytes: 19960
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;
int main(void)
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = 0;
    for (int i = 0; i < A; i++) {
        if (K <= 0) {
            break;
        }
        ans += 1;
        K -= 1;
    }

    for (int i = 0; i < B; i++) {
        if (K <= 0) {
            break;
        }
        ans += 0;
        K -= 1;
    }

    for (int i = 0; i < C; i++) {
        if (K <= 0) {
            break;
        }
        ans += -1;
        K -= 1;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < string > W(N);
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}

	bool isOK = true;
	for (int i = 1; i < N && isOK; i++) {
		if (W[i - 1].back() != W[i].front()) {
			isOK = false;
		}
		for (int j = 0; j < i; j++) {
			if (W[i] == W[j]) {
				isOK = false;
			}
		}
	}

	cout << (isOK ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(void){

    long long L, R;     cin >> L >> R;
    long long ans = 2019;
    for(long long i = L ; i < R ; i++){
        for(long long j = i + 1 ; j <= R ; j++){
          
            if((i * j) % 2019 == 0){
                ans = 0;    break;
            }
    
          ans = min((i * j) % 2019,ans);
         }
        
        if(ans == 0)    break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 30
#define M 200000
using namespace std;
int n,A[N];
double calc(double a,double b){return abs(a-b)/a;}


double dp[2][M];
double DP(){
  bool f=0;  
  for(int i=0;i<M;i++) dp[0][i] = 1LL<<50;
  dp[0][1] = 0;

  for(int i=0;i<n;i++,f=!f){
    for(int j=0;j<M;j++) dp[!f][j] = 1LL<<50;

    for(int num=1;num<M;num++)
      for(int j=num;j<M;j+=num)
	dp[!f][j] = min(dp[!f][j],max(calc(A[i],j),dp[f][num]));
  }

  double res=1LL<<55;
  for(int i=0;i<M;i++) res=min(res,dp[f][i]);
  return res;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  printf("%.10f\n",DP());
  return 0;
}

Measured memory_bytes: 6328
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	ll n, k, x, y;
	cin >> n >> k >> x >> y;
	
	ll ans = 0LL;
	
	if( n > k ) { 
		ans = x * k + (n - k) * y; 
	} else {
		ans = x * n;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3684
#ifndef ___GEOMETRY_LIBRARY
#define ___GEOMETRY_LIBRARY

#include <vector>
#include <algorithm>

template<class type>
class point2d {
public:
	type x, y;
	point2d() : x(type(0)), y(type(0)) {};
	point2d(type x_, type y_) : x(x_), y(y_) {};
	bool operator==(const point2d& p) { return x == p.x && y == p.y; }
	bool operator!=(const point2d& p) { return x != p.x || y != p.y; }
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d& operator*=(type val) { x *= val; y *= val; return *this; }
	point2d& operator/=(type val) { x /= val; y /= val; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	point2d operator*(type val) const { return point2d(*this) *= val; }
	point2d operator/(type val) const { return point2d(*this) /= val; }
	type norm() const { return x * x + y * y; }
	type abs() const { return type(std::sqrt(x * x + y * y)); }
	long double fabs() const { return std::sqrt((long double)(x * x + y * y)); }
	type dot(const point2d& p) const { return x * p.x + y * p.y; }
	type cross(const point2d& p) const { return x * p.y - y * p.x; }
	int ccw(const point2d& p1, const point2d& p2) const {
		point2d pr1 = p1 - point2d(*this);
		point2d pr2 = p2 - point2d(*this);
		if (pr1.cross(pr2) != 0) return pr1.cross(pr2) > 0 ? 1 : -1;
		if (pr1.dot(pr2) < 0) return 2;
		return pr1.norm() < pr2.norm() ? -2 : 0;
	}
};

template<class type>
class segment2d {
public:
	point2d<type> p1, p2;
	segment2d() : p1(point2d<type>()), p2(point2d<type>()) {};
	segment2d(const point2d<type>& p1_, const point2d<type>& p2_) : p1(p1_), p2(p2_) {};
	type norm() const { return (p1 - p2).norm(); }
	type abs() const { return (p1 - p2).abs(); }
	long double fabs() const { return (p1 - p2).fabs(); }
};

#endif // ___GEOMETRY_LIBRARY

#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	point2d<double> p0, p1;
	cin >> p0.x >> p0.y >> p1.x >> p1.y;
	int q;
	cin >> q;
	cout.precision(15);
	for (int i = 0; i < q; ++i) {
		point2d<double> p2;
		cin >> p2.x >> p2.y;
		int res = p0.ccw(p1, p2);
		if (res == 1) cout << "COUNTER_CLOCKWISE\n";
		else if (res == -1) cout << "CLOCKWISE\n";
		else if (res == 2) cout << "ONLINE_BACK\n";
		else if (res == -2) cout << "ONLINE_FRONT\n";
		else cout << "ON_SEGMENT\n";
	}
	return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
#define KOZYUN(a) SORT(a); REVERSE(a) 
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s,t; cin >> s >> t;
    SORT(s);
    KOZYUN(t);
    int a = min(s.size(),t.size());
    rep(i,a){
        if(s[i] < t[i]){
            Yes;
            return 0;
        }else if(s[i] > t[i]){
            No;
            return 0;
        }
    }
    if(s.size() >= t.size()) No;
    else Yes;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
c = [0 for i in range(5)]
for i in range(n):
    s = input()
    if s[0] == 'M':
        c[0] += 1
    elif s[0] == 'A':
        c[1] += 1
    elif s[0] == 'R':
        c[2] += 1
    elif s[0] == 'C':
        c[3] += 1
    elif s[0] == 'H':
        c[4] += 1
from itertools import combinations
ans = 0
for v in combinations([0,1,2,3,4], 3):
    ans += c[v[0]]*c[v[1]]*c[v[2]]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  string str;cin>>str;
  int flg = 0;
  if(str.size() == 2)
  {
    if(str[0] == str[1])
    {
      cout<<"1 2"<<endl;
    }
    else
    {
      cout<<"-1 -1"<<endl;
    }
    return;
    
  }
  for (int i = 1; i < str.size()-1; i++)
  {
    if(str[i-1] == str[i] || str[i] == str[i+1] || str[i-1] == str[i+1])
    {
      cout<<i<<" "<<i+2<<endl;
      return;
    }
  }
  cout<<-1<<" "<<-1<<endl;

  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}


int f(int n)
{
	if (n <= 0)
		return 0;

	return 1 + 2 * f(n / 2);
}

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

	cout << f(n) << '\n';
	return 0;
}

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

class EularTourForEdge{
    private:
    vector<int> ds,us,dep,btm;
    void dfs(int v,int p,int d){
        dep[v]=d;
        for (int u:G[v]){
            if (u==p) continue;
            ds[u]=btm.size();
            btm.emplace_back(u);
            dfs(u,v,d+1);
            us[u]=btm.size();
            btm.emplace_back(u);
        }
    }
    public:
    vector<vector<int>> G;
    EularTourForEdge(int n):
        ds(n),us(n),dep(n),G(n){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    void build(int r=0){
        btm.clear();
        ds[r]=btm.size(); btm.emplace_back(r);
        dfs(r,-1,0);
        us[r]=btm.size(); btm.emplace_back(r);
    }
    int child(int u,int v){
        return dep[u]<dep[v]?v:u;
    }
    int bottom(int e){
        return btm[e];
    }
    template<typename T,typename F>
    T query(int v,F f){
        return f(0,us[v]);
    }
    //u or v must be lca(u,v)
    template<typename T,typename F>
    T query(int u,int v,F f){
        if (dep[u]<dep[v]) swap(u,v);
        return query<T>(u,f)-query<T>(v,f);
    }
    template<typename T,typename G>
    void update(int v,T x,G g){
        g(ds[v],x);
        g(us[v],-x);
    }
};

template<typename T>
struct BinaryIndexedTree{
    vector<T> dat;
    BinaryIndexedTree(int n):dat(n+1,0){}
    void add(int i,T x){
        if (i==0) return;
        for (;i<=dat.size();i+=(i&-i)) dat[i]+=x;
    }
    T sum(int i){
        T res=0;
        for (;i>0;i-=(i&-i)) res+=dat[i];
        return res;
    }
    T query(int l,int r){ //[l,r)
        return sum(r-1)-sum(l-1);
    }
    int lower_bound(T x){
        if (x<=0) return 0;
        int lb=0,r=1;
        while(r<dat.size()) r<<=1;
        for (;r>0;r>>=1){
            if (lb+r<dat.size()&&dat[lb+r]<x){
                x-=dat[lb+r]; lb+=r;
            }
        }
        return lb+1;
    }
    void add0(int i,T x){
        add(i+1,x);
    }
    T sum0(int i){
        return sum(i+1);
    }
    T query0(int l,int r){
        return sum(r)-sum(l);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    EularTourForEdge ET(n);
    rep(i,n){
        int k; cin >> k;
        rep(j,k){
            int c; cin >> c;
            ET.add_edge(i,c);
        }
    }
    ET.build();
    BinaryIndexedTree<int> BIT(2*n);
    auto f=[&](int l,int r){return BIT.query(l+1,r+1);};
    auto g=[&](int k,int d){BIT.add(k+1,d);};
    int q; cin >> q;
    rep(i,q){
        int c,v,w; cin >> c >> v;
        if (!c){
            cin >> w;
            ET.update(v,w,g);
        } else cout << ET.query<int>(0,v,f) << endl;
    }
}


Measured memory_bytes: 14372
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

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


Measured memory_bytes: 256
def fastSumPair(A):
    L = len(A)
    M = 1000000007
    
    # (a + b + c)**2 = a**2 + b**2 + c**2 + 2*(a*b + b*c + c*a)
    # derive from this equation
    
    # first array
    A_1_sum = 0
    for i in range(0, L):
        A_1_sum = (A_1_sum + A[i]) 
    
    A_1_sum = (A_1_sum ** 2) 
        
    # second array
    A_2_sum = 0
    for i in range(0, L):
        A_2_sum = (A_2_sum + A[i] ** 2) 
                  
    return int((A_1_sum - A_2_sum) // 2) % M        

N = int(input())
A = list(map(int, input().rstrip().split()))
print(fastSumPair(A))

Measured memory_bytes: 94192
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



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



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long
#define ms(a, b) memset(a, b, sizeof(a))

using namespace std;

const int Size = 26;
const int MAXN = 1e5 + 100;
const int maxn = 50 + 7;
const int MOD = 1e5;
const int INF = 0x3FFFFFFF;

set<int>s;
map<int, int>mp;
int pre[MAXN], a[MAXN];

int main()
{
    int n;
    ll m;
    ll ans = 0;
    ll temp;
    ios::sync_with_stdio(false);
    s.clear();
    mp.clear();
    cin >> n >> m;
    pre[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        pre[i] = a[i];
    }
    for(int i = 1; i <= n; i++)
    {
        pre[i] = (pre[i - 1] + pre[i]) % m;
        mp[pre[i]]++;
        if(!s.count(pre[i]))   s.insert(pre[i]);
    }
    set<int>::iterator it;
    for(it = s.begin(); it != s.end(); it++)
    {
        temp = mp[*it];
        ans += temp * (temp - 1) / 2;
    }
    if(*s.begin() == 0)
        ans += mp[0];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6912
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int x, a, b, c;

int main()
{
	int cnt = 0;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	for(int i = 0; i <= a; i++)
	{
		for(int j = 0; j <= b; j++)
		{
			for(int k = 0; k <= c; k++)
			{
				if(i*500 + j*100 + k*50 == x)
				{
					cnt++;
				}
			}
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
lst_a=list(map(int,input().split()))
one,two,three=lst_a.count(1),lst_a.count(2),lst_a.count(3)
# dp[i][j][k] := 残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から、
# 寿司をすべてなくすのに必要な操作回数の期待値
dp=[[[0.0] *(n+1) for _ in range(n+1)] for _ in range(n+1)]
#print(dp)
for k in range(three+1):
  for j in range(two+three+1-k):
    for i in range(one+two+three+1-k-j):
      if i==0 and j==0 and k==0:
        continue
      tmp=n*1.0
      if i>0:
        tmp+=i*dp[i-1][j][k]
      if j>0:
        tmp+=j*dp[i+1][j-1][k]
      if k>0:
        tmp+=k*dp[i][j+1][k-1]
      dp[i][j][k]=tmp/(i+j+k)
#print(dp)
print(dp[one][two][three])


Measured memory_bytes: 295776
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void){
    int N;
    cin >> N;
    int a,tmp1,tmp2;
    int count=0;
    a=N;
    int res=1<<30,sum,vala,valb;
    rep(i,N+1){
        sum=0; 
        vala=i;valb=N-i;
        int aa=1;
        while(vala>=aa*6)aa*=6;
        while(vala>0){
            sum+=vala/aa;
            vala=vala%aa;
            aa/=6;
        }
        int bb=1;
        while(valb>=bb*9)bb*=9;
        while(valb>0){
            sum+=valb/bb;
            valb=valb%bb;
            bb/=9;
        }
        if(res>sum){
            res=sum;
            DEBUG{cout << i << endl;}
        }
    }
    cout << res <<endl;
}

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

using namespace std;
typedef long long unsigned int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(void){
    ll n; cin >> n;
    ll sum = 0;
    string str_n = to_string(n);
    REP(i, str_n.length()){
        sum += int(str_n[i] - '0');
    }
    if (n%sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        k: u64,
        a: [Usize1; n],
    };

    let mut ci: usize = 0;
    let mut v = vec![std::usize::MAX; n];
    let mut count: usize = 0;
    v[0] = 0;

    for i in 0..n{
        ci = a[ci];

        if i as u64 == k - 1{
            println!("{}", ci + 1);
            return;
        }
        if v[ci] != std::usize::MAX{
            count = i+1;
            break;
        }
        v[ci] = i + 1;
    }

    let ll = count - v[ci];
    let si = count - ll;
    let ret_ind = ((k - si as u64) % (ll as u64)) as usize + si;

    for (i, &vv) in v.iter().enumerate(){
        if vv == ret_ind{
            println!("{}", i+1);
        }
    }

}


Measured memory_bytes: 6360
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int maxx = 200000;

int main()
{
	int n, k;
	vector<int> ve;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &k);
		ve.push_back(k);
	}

	make_heap(ve.begin(), ve.end());
	
	for (vector<int>::iterator it = ve.begin(); it != ve.end(); it++)
		printf(" %d", *it);
	printf("\n");
	return 0;
}

Measured memory_bytes: 4936
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9+7)
#define MAX_V (10)
#define MAX_E (45)
#define MAX_C (100)

int V, E;
int D[MAX_V][MAX_V];

void warshall_floyd() {

  for (size_t w = 0; w < V; w++)
    for (size_t u = 0; u < V; u++)
      for (size_t v = 0; v < V; v++) D[u][v] = min(D[u][v], D[u][w] + D[w][v]);
}

void solve() {
  int ans_c, ans_d = INF;

  warshall_floyd();

  for (size_t v = 0; v < V; v++) {
    int cost = 0;
    for (size_t u = 0; u < V; u++) cost += (D[u][v] < INF)? D[u][v]: 0;
    if (cost < ans_d) {
      ans_c = v;
      ans_d = cost;
    }
  }

  printf("%d %d\n", ans_c, ans_d);
}

int main() {
  while (true) {
    scanf("%d", &E);
    if (E == 0) break;

    for (size_t u = 0; u < MAX_V; u++)
      for (size_t v = 0; v < MAX_V; v++) D[u][v] = (u == v)? 0: INF;

    V = 0;
    for (size_t i = 0; i < E; i++) {
      int v, u, cost;
      scanf("%d %d %d", &u, &v, &cost);
      D[u][v] = D[v][u] = cost;
      V = max(V, (max(u, v)));
    }
    V++;

    solve();
  }

  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <iomanip>
#include <math.h> 

#define MAX_TOSSES 3000

using namespace std;

double dp[MAX_TOSSES];
double probabilities[MAX_TOSSES-1];

int main()
{
    int nTosses;
    double probability, ans = 0;
    cin >> nTosses;
    dp[0] = 1; 
    for (int i = 0; i < nTosses; i++)
    {
        cin >> probability;
        probabilities[i] = probability;
        for(int j = i + 1; j >= 0; j--)
        {
            if(!j)
                dp[j] = dp[j] * (1-probability);
            else
                dp[j] = dp[j-1] * probability + dp[j] * (1-probability);
        }
    }
    for(int i = 0; i <= nTosses; i++) 
    {
        int tails = nTosses - i;
        if(i > tails) {
            ans += dp[i];
        }
    }
    cout << setprecision(10);
    cout << ans;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define N 505
#define re register
using namespace std;
int H,W;
char mr[N][N],mb[N][N],str[N];
int main(){
	scanf("%d%d",&H,&W);
	for(re int i=1;i<=H;++i) mr[i][1]='#',mb[i][1]='.';
	for(re int i=1;i<=H;++i) mb[i][W]='#',mr[i][W]='.';
	for(re int i=1;i<=H;++i){
		for(re int j=2;j<W;++j){
			if(i&1) mr[i][j]='#',mb[i][j]='.';
			else mb[i][j]='#',mr[i][j]='.';
		}
	}
	for(re int i=1;i<=H;++i){
		scanf("%s",str+1);
		for(re int j=1;j<=W;++j) if(str[j]=='#') mr[i][j]=mb[i][j]='#';
	}
	for(re int i=1;i<=H;++i){
		for(re int j=1;j<=W;++j) printf("%c",mr[i][j]);
		printf("\n");
	}
	printf("\n");
	for(re int i=1;i<=H;++i){
		for(re int j=1;j<=W;++j) printf("%c",mb[i][j]);
		printf("\n");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    
    ll H,W;
    ll Ch,Cw,Dh,Dw;
    string S[1000];
    
    cin >> H >> W;
    cin >> Ch >> Cw >> Dh >> Dw;
    Ch--;Cw--;Dh--;Dw--;
    
    REP(i,H){
        cin >> S[i];
    }
    
    deque<pair<ll,ll>> Q;
    const int MEM = 1020;
    ll cost[MEM][MEM];
    REP(i,MEM){REP(j,MEM){cost[i][j]=INF;}}
    
    cost[Ch][Cw]=0;
    Q.push_front({Ch,Cw});
    
    
    ll dx[4]={1,0,-1,0};
    ll dy[4]={0,1,0,-1};
    
    
    while(!Q.empty()){
        pair<ll,ll> t = Q.front();
        Q.pop_front();
        ll i = t.first,j=t.second;
        
        REP(k,4){
            ll x=j+dx[k],y=i+dy[k];
            if(!(0<=x&&x<W))continue;
            if(!(0<=y&&y<H))continue;
            if(S[y][x]!='.')continue;
            if(cost[y][x]<=cost[i][j])continue;
            
            Q.push_front({y,x});
            cost[y][x]=cost[i][j];
            
        }
        
        for(ll k=-2;k<=2;k++){
            for(ll l=-2;l<=2;l++){
                ll x=j+k,y=i+l;
                if(!(0<=x&&x<W))continue;
                if(!(0<=y&&y<H))continue;
                if(S[y][x]!='.')continue;
                if(cost[y][x]<=cost[i][j]+1)continue;
                
                Q.push_back({y,x});
                cost[y][x]=cost[i][j]+1;
            }
        }
        
    }
    
    if(cost[Dh][Dw]==INF){
        cout << -1 << endl;
    }else{
        cout << cost[Dh][Dw] << endl;
    }
    
    /*
    REP(i,H){
        REP(j,W){
            cout << cost[i][j] << " ";
        }cout << endl;
    }*/
    
    //costメモリ!!
    
    return 0;
}



Measured memory_bytes: 13736
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif

int main()
{
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  lout << a << " " << b << " " << c << " " << d << endl;
  string s;
  cin >> s;
  s = "#" + s + "#";

  auto can_reach = [&](int start, int end) {
    for (int i = start; i + 1 <= end; i++)
    {
      if (s[i] == '#' && s[i + 1] == '#')
        return false;
    }
    return true;
  };

  // if (s.substr(b, d - b).find("##") != string::npos or
  //     s.substr(a, c - a).find("##") != string::npos)
  if (!(can_reach(a, c) && can_reach(b, d)))
  {
    puts("No");
    return 0;
  }

  if (c < d)
  {
    puts("Yes");
    return 0;
  }

  // if (s.substr(b - 1, d - b + 2).find("...") == string::npos)
  bool snuke_can_over = false;
  for (int i = b; i <= d; i++)
    if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
      snuke_can_over = true;

  if (!snuke_can_over)
  {
    puts("No");
    return 0;
  }
  else
  {
    puts("Yes");
    return 0;
  }
}


Measured memory_bytes: 772
import math


def primes(x):
    x+=1
    if x < 2:
        return []

    prime = [i for i in range(x)]
    prime[1] = 0

    for p in prime:
        if p > math.sqrt(x):
            break
        if p == 0:
            continue
        for non_prime in range(2 * p, x, p):
            prime[non_prime] = 0

    return [p for p in prime if p != 0]


n = int(input())
l = [list(map(int, input().split())) for i in range(n)]

p = primes(10**5)

q = []
s = 0
for i in range(len(p)):
    for j in range(s,len(p)):
        if (p[i]+1)//2 == p[j]:
            q.append(p[i])
            s = j
            break
        elif (p[i]+1)//2 < p[j]:
            s = j
            break


for i in range(n):
    ans = 0
    for j in range(len(q)):
        if l[i][0]<=q[j]<=l[i][1]:
            ans +=1
    print(ans)

Measured memory_bytes: 78424
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long N, long long K){
  cout << floor(log(N) / log(K))+1 << endl;
}

signed main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  solve(N, K);
}


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



int main()
{
        ll X;
        cin >> X;
        ll ans = 0;
        ans += X / 500 * 1000;
        X -= X/500 * 500;
        ans += X / 5 * 5;

        cout << ans << endl;
}

Measured memory_bytes: 3508
N, M = list(map(int, input().split()))
D = []
L = [0] * N
for i in range(M):
  D.append(list(map(int, input().split())))
D.sort(key = lambda x: x[1])

Ans = 0
Re = 0
for i in D:
  if Re < i[0]:
    Re = i[1]-1
    Ans += 1
print(Ans)

Measured memory_bytes: 29844
#include <stdio.h>
#include <string.h>

int main(void) {
	char buf[21] = {0};
	int i, len;
	scanf("%s", buf);

	len = strlen(buf);
	for (i = 1; i <= len; ++i) {
		putchar(buf[len - i]);
	}
	putchar('\n');
	
	return 0;
}

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

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

    string s;

    cin >> s;

    string scp = s;

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

    if (scp == s)
    {
        string shalf;
        rep(i , (s.size()-1)/2 +1)
        {
            shalf[i] = s[i];
        }
        string shalfcp = shalf;
        reverse(shalf.begin(), shalf.end());

        if(shalfcp == shalf)
        {
            string shalfafter;
            shalfafter.empty();
            for(int i =((s.size()+3)/2) -1; i< s.size(); ++i)
            {
                shalfafter.push_back(s[i]);
            }

            string shalfaftercp = shalfafter;
            reverse(shalfafter.begin(), shalfafter.end());
            if (shalfaftercp == shalfafter)
            {
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main(void) {

    int A, B;
    cin >> A >> B;
    int ADD = A + B;
    const int TH = 10;
    const string ERROR = "error";

    if (ADD < TH)
        cout << ADD << endl;
    else
        cout << ERROR << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int sugoroku[1010];

int main() {
	int n,m;
	while(n=in(),m=in()){
		int i;
		for(i=1;i<=n;i++){
			cin>>sugoroku[i];
		}
		int nw=1;
		int res=-1;
		for(i=1;i<=m;i++){
			if(res==-1){
				nw+=in();
				if(nw>=n&&res==-1){res=i;continue;}
				nw+=sugoroku[nw];
				if(nw>=n&&res==-1)res=i;
			}else in();
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[] like = new int[m];
		int ans=0;

		for(int i=0;i<n;i++) {
			int k=sc.nextInt();
			for(int j=0;j<k;j++) {
				int num = sc.nextInt();
				like[num-1]+=1;
			}
		}

		for(int a : like) {
			if(a==n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, t, u;
  cin >> s >> t >> u;

  cout << "A" << t[0] << "C" << endl;
  return 0;
}


Measured memory_bytes: 256
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGE
      // freopen ("INPUT.txt" , "r" , stdin);
       //freopen ("OUTPUT.txt", "w" , stdout);
    //#endif

    string st;
    cin>>st;
    if(st=="ARC")
      cout<<"ABC";
    else
      cout<<"ARC";

  














return 0;
}

Measured memory_bytes: 3568
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

res = 0
for i in range(N):
    tmp = 0
    for j in range(M):
        tmp += B[j] * A[i][j]
        
    if tmp + C > 0:
        res += 1
        
print(res)



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

const int N = int(1e4);

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	int n;
	scanf("%d", &n);

	vector<tuple<int, int, int>> blocks(n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &get<1>(blocks[i]), &get<0>(blocks[i]), &get<2>(blocks[i]));
		get<0>(blocks[i]) += get<1>(blocks[i]);
	}

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

	vector<ll> dp(N + 1, 0);
	ll ans = 0LL;

	for (int i = 0; i < n; i++) {
		ans = max(ans, dp[get<0>(blocks[i]) - get<1>(blocks[i])] + get<2>(blocks[i]));
		for (int s = min(N, get<0>(blocks[i])); s >= get<1>(blocks[i]); s--) {
			dp[s] = max(dp[s], dp[s - get<1>(blocks[i])] + get<2>(blocks[i]));
		}
		for (int s = get<0>(blocks[i]) + 1; s <= N; s++) {
			dp[s] = max(dp[s], dp[s - 1]);
		}
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n,x;
vector<int> m;

void input(){
    cin >> n >> x;
    m.resize(n);
    for(int i=0;i<n;i++) cin >> m[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    sort(m.begin(), m.end());
    for(int i=0;i<n;i++) x -= m[i];
    int ans = n;
    while(x >= 0){
        x -= m[0];
        ans++;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	p := make([]float64, n)
	for i := range p {
		fmt.Scan(&p[i])
	}

	idx := make([]float64, 0, k)
	maxIdx := make([]float64, k)
	var max, sum float64
	var head int
	for i := 0; i < n; i++ {
		sum += p[i]
		idx = append(idx, p[i])
		if i >= k-1 {
			// fmt.Println(sum, idx)
			if max < sum {
				max = sum
				copy(maxIdx, idx)
			}
			sum -= p[head]
			idx = idx[1:]
			head++
		}
	}

	// fmt.Println(max, maxIdx)

	// indexes := make([]float64, k)
	// max := 0
	// maxIndexes := make([]float64, k)
	// for i := 0; i <= n-k; i++ {
	// 	var sum int
	// 	for j := 0; j < k; j++ {
	// 		sum += p[i+j]
	// 		indexes[j] = float64(p[i+j])
	// 	}
	// 	// fmt.Println(max, sum, indexes)
	// 	if max < sum {
	// 		max = sum
	// 		copy(maxIndexes, indexes)
	// 	}
	// }

	// // fmt.Println(max, maxIndexes)

	sum = 0.0
	for _, v := range maxIdx {
		sum += expectation(v)
	}
	fmt.Printf("%.12f\n", sum)

}

func expectation(p float64) float64 {
	ratio := 1.0 / float64(p)
	var sum float64
	for i := 1.0; i <= p; i++ {
		sum += i * ratio
	}
	return sum
}


Measured memory_bytes: 8960
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++) {
			a[i] = stdIn.nextInt();
		}
		if(a[0] == 1 && a[1] == 1) {
			System.out.println("Open");
		}
		else if(a[2] == 1) {
			System.out.println("Open");
		}
		else {
			System.out.println("Close");
		}
		
	}

}

Measured memory_bytes: 17220
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    P = []
    for line in readlines():
        x, y = map(float, line.split(","))
        P.append((x, y))
    N = len(P)
    s = 0
    for i in range(N):
        x0, y0 = P[i-1]; x1, y1 = P[i]
        s += x0*y1 - x1*y0
    write("%.16f\n" % (abs(s)/2))
solve()


Measured memory_bytes: 5592
# https://atcoder.jp/contests/abc134/tasks/abc134_e　

from bisect import bisect_left
from collections import *

N = int(input())

A = [int(input()) for _ in range(N)]

LIS = deque([A[0]])
cnt = 0

for a in A[1:]:
    if a <= LIS[0]:
        LIS.appendleft(a)
    else:
        ind = bisect_left(LIS, a) -1
        LIS[ind] = a

print(len(LIS))

Measured memory_bytes: 8828
// finish date: 2018/07/03
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<long double> vd;
typedef vector<vector<long double>> vvd;
typedef vector<vector<vector<long double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
const int bigmod = 1000000007;
const int INF = 1050000000;


int main() {
    int n;

    while(true) {
        cin >> n;
        if(n == 0) {
            break;
        }

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

        vvi dp(n + 1, vi(n + 1, 0));

        rep(i, n - 1) {
            dp[i][i + 1] = (abs(w[i] - w[i + 1]) <= 1) ? 2 : 0;
        }

        FOR(k, 2, n) {
            rep(i, n) {
                int j=i+k;
                if(j >= n) {
                    continue;
                }
                if(abs(w[i] - w[j]) <=1 && dp[i + 1][j - 1] == (j - 1) - (i + 1) +1) {
                    dp[i][j] = j - i + 1;
                } else {
                    FOR(l, i, j) {
                        dp[i][j] = max(dp[i][j], dp[i][l] + dp[l + 1][j]);
                    }
                }
            }
        }

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

    return 0;
}



Measured memory_bytes: 3276
#include <cstdio>

int main(int argc, const char * argv[]) {
    
    int a,b,c,x;
    
    scanf("%d %d %d %d",&a,&b,&c,&x);
    
    int sum= 0;

    //(100,500,50)
    for(int i=1;i<=a;i++){
        int tmp = x;
        if(500 * i > tmp) break;
        tmp  = tmp - (500*i);
        for(int j=1;j<=b;j++){
            int tmp2 = tmp;
            if(100*j > tmp2 ) break;
            tmp2 = tmp2 - (100*j);
            for(int k=1;k<=c;k++){
                if(tmp2 == 50*k){
                    sum++;
                    break;
                }
            }
        }
    }
    

    //case1 (50,100)
    
    for(int i=1;i<=b;i++){
        int tmp = x;
        if(100*i > tmp) break;
        tmp = tmp - (100*i);
        for(int j=1;j<=c;j++){
            if(tmp == 50*j) {
                sum++;
                break;
            }
        }
    }
    //case2(50,500)
    for(int i=1;i<=a;i++){
        int tmp = x;
        if(500*i > tmp) break;
        tmp = tmp - (500*i);
        for(int j=1;j<=c;j++){
            if(tmp == 50*j){
                sum++;
                break;
            }
        }
    }
    //case3(100,500)
    for(int i=1;i<=a;i++){
        int tmp = x;
        if(500*i > tmp) break;
        tmp = tmp - (500*i);
        for(int j=1;j<=b;j++){
            if(tmp == 100*j) {
                sum++;
                break;
            }
        }
    }
    
    //(100||50||500)
    
    if(x%500==0 && x/500 <=a) sum++;
    if(x%100==0 && x/100 <=b) sum++;
    if(x%50 ==0 && x/50 <=c) sum++;
    
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 128
N = int(input())
card = []
for x in range(52):
    card.append(0)
for x in range(N):
    a, b = map(str, input().split())
    if a == 'S':
        card[13 * 0 + int(b) - 1] = 1
    elif a == 'H':
        card[13 * 1 + int(b) - 1] = 1
    elif a == 'C':
        card[13 * 2 + int(b) - 1] = 1
    elif a == 'D':
        card[13 * 3 + int(b) - 1] = 1
for x in range(52):
    if card[x] == 0:
        if x < 13: print("S " + str(x + 1))
        elif x < 26: print("H " + str(( x + 1) - 13 ))
        elif x < 39: print("C " + str(( x + 1) - 26 ))
        else: print("D " + str(( x + 1) - 39))


Measured memory_bytes: 5612
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

ll sum = 0;
vector<ll> a;
int N;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N; a.pb(0LL);
	F0R(i,N) {
	    ll z; cin >> z; sum += z;
	    a.pb(a[a.size()-1]+z);
	}
	ll ans = 1e18;
	FOR(i,1,a.size()-1) ans = min(ans,abs(sum-2*a[i]));
	cout << ans;
}

Measured memory_bytes: 2420
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long l,r;
    std::cin >> l>>r;
    
    int min=2019;
    
    for (long long i = l; i <= r && i<l+2019; i++) {
        for (long long j = i+1; j <= r && j < i+2019; j++) {
            if((i*j)%2019<min){
                min=(i*j)%2019;
            }
        }
    }
    std::cout << min << std::endl;

}


Measured memory_bytes: 256
import itertools

n,m=list(map(int,input().split()))
path=[[False]*n for _ in range(n)]
for i in range(m):
  a,b=list(map(int,input().split()))
  path[a-1][b-1]=True

ans=0
for i in itertools.permutations(list(range(n))):
  if i[0]!=0:
    continue
  flg=True
  for j in range(len(i)-1):
    if path[min(i[j],i[j+1])][max(i[j],i[j+1])]==False:
      flg=False
      break
  if flg:
    ans+=1
print(ans)

Measured memory_bytes: 3064
N = int(input())
A_list = list(map(int, input().split())) # len : N+1
B_list = list(map(int, input().split())) # len : N
ans = 0
before_num = 0
for i in range(N+1):
    if i < N:
        if A_list[i] >= before_num:
            ans += before_num
            A_list[i] -= before_num
            if A_list[i] >= B_list[i]:
                ans += B_list[i]
                A_list[i] -= B_list[i]
                B_list[i] = 0
                before_num = 0
            elif A_list[i] < B_list[i]:
                ans += A_list[i]
                B_list[i] -= A_list[i]
                A_list[i] = 0 
                before_num = B_list[i]
        elif A_list[i] < before_num:
            ans += A_list[i]
            before_num = B_list[i]
            A_list[i] = 0
    if i == N:
        if A_list[i] >= before_num:
            ans += before_num
            A_list[i] -= before_num
        elif A_list[i] < before_num:
            ans += A_list[i]
            A_list[i] = 0

print(ans)
    


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

int main() {
	int N;
	string S;
	cin>>N;
	cin>>S;
	int nx=0;
	int x=0;
	for(int i=0;i<=S.length();i++){	
		x=max(nx,x);
		if(S[i]=='I'){
			nx+=1;
		}else{
			nx-=1;
		}
	}
	cout<<x<<endl;
}

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

using namespace std;

int main(){
	double T, A;
	int N, ans = -1; double ans_m = (double)1e9; cin >> N >> T >> A;
	double H[N];
	for(int i = 0; i < N; ++i) cin >> H[i];
	
	for(int i = 0; i < N; ++i){
		if(abs(A - (T - H[i] * 0.006)) < ans_m){
			ans_m = abs(A - (T - H[i] * 0.006));
			ans = i;
		}
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 384