akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2105,M=N*10,inf=1<<30;
int head[N],nxt[M],to[M],wei[M],cost[M],s,t,tot=1,n;
ll dis[N],ans; bool vis[N];
void addedge(int u, int v, int w, int c)
{
	nxt[++tot]=head[u],head[u]=tot,to[tot]=v,wei[tot]=w,cost[tot]=-c;
	nxt[++tot]=head[v],head[v]=tot,to[tot]=u,wei[tot]=0,cost[tot]=c;
}
bool spfa()
{
	memset(vis,0,sizeof(bool)*(t+3));
	memset(dis,0x3f,sizeof(ll)*(t+3));
	queue<int> q;
	dis[t]=0,q.push(t);
	while(!q.empty())
	{
		int u=q.front();
		vis[u]=false,q.pop();
		for(int e=head[u];e;e=nxt[e])
			if(wei[e^1]&&dis[to[e]]>dis[u]-cost[e])
			{
				dis[to[e]]=dis[u]-cost[e];
				if(!vis[to[e]]) vis[to[e]]=true,q.push(to[e]);
			}
	}
	return dis[s]!=dis[0];
}
int dfs(int u, int mx)
{
	vis[u]=true;
	if(u==t) return mx;
	int l=mx;
	for(int e=head[u];e&&l;e=nxt[e])
		if(!vis[to[e]]&&wei[e]>0&&dis[to[e]]==dis[u]-cost[e])
		{
			int f=dfs(to[e],min(l,wei[e]));
			ans+=1ll*f*cost[e];
			l-=f,wei[e]-=f,wei[e^1]+=f;
		}
	return mx-l;
}
ll exec()
{
	while(spfa())
		do
		{
			memset(vis,0,sizeof(bool)*(t+3));
			dfs(s,inf);
		} while(vis[t]);
	return -ans;
}
int main()
{
	scanf("%d",&n);
	s=2*n+5,t=s+1;
	for(int i=1,x,y,c;i<=n;++i)
	{
		scanf("%d%d%d",&x,&y,&c);
		addedge(s,i,c,0);
		addedge(i,2*n+1,inf,x+y);
		addedge(i,2*n+2,inf,x-y);
		addedge(i,2*n+3,inf,-x+y);
		addedge(i,2*n+4,inf,-x-y);
	}
	for(int i=1,x,y,c;i<=n;++i)
	{
		scanf("%d%d%d",&x,&y,&c);
		addedge(2*n+1,i+n,inf,-x-y);
		addedge(2*n+2,i+n,inf,-x+y);
		addedge(2*n+3,i+n,inf,x-y);
		addedge(2*n+4,i+n,inf,x+y);
		addedge(i+n,t,c,0);
	}
	printf("%lld\n",exec());
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int ans = 0, l, r, d;
	cin >> l >> r >> d;
	for (int i = l; i <= r; ++i)
		if (i % d == 0)
			++ans;
	cout << ans << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,ans=0;
  cin>>N;
  int B[N-1];
  for(int i=0;i<N-1;i++) cin>>B[i];
  for(int i=0;i<N-2;i++){
    ans+=min(B[i],B[i+1]);
  }
  cout<<ans+B[0]+B[N-2]<<endl;
}



Measured memory_bytes: 256
def main() -> None:
    s = int(input())
    dp = [s]
    st = set()
    st.add(s)

    i = -1
    while True:
        i += 1
        n = dp[i]
        if n % 2 == 0:
            dp += [n // 2]
        else:
            dp += [3 * n + 1]

        m = i + 1
        if dp[m] in st:
            print(m + 1)
            return
        st.add(dp[m])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	n--;
	vector<int> c(n), s(n), f(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 0; i < n; i++) {
		int tim = s[i] + c[i];
		for (int j = i + 1; j < n; j++) {
			int k = 0;
			while (tim > s[j] + f[j] * k) k++;
			tim = s[j] + f[j] * k + c[j];
		}
		cout << tim << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    long long i,a;
    vector<int>v;
    for(i=0;i<10;i++)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    cout<<v[9]<<endl<<v[8]<<endl<<v[7]<<endl;
    v.clear();
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
void dfs(int,int);
int w,h,mat[50][50],flagb,flagw,cnt;
int main(){
  int i,j,bcnt,wcnt;
  string data[50];
  while(1){
    bcnt=0;
    wcnt=0;
    cin >> w >> h;
    if(w==0&&h==0) break;
    for(i=0;i<h;i++){
      cin >> data[i];
    }  
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(data[i][j]=='B') mat[i][j]=1;
        else if(data[i][j]=='W') mat[i][j]=2;
        else mat[i][j]=0;
      }
    }
    
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
    cnt=0;
    flagb=0;
    flagw=0;
        if(mat[i][j]==0){
      dfs(i,j);
      if(flagb==1&&flagw==1){
        bcnt+=0;
        wcnt+=0;
      }
      else if(flagb==1){
        bcnt+=cnt;
      }
          else if(flagw==1){
        wcnt+=cnt;
      }
    }
      }
    }
    cout << bcnt << ' ' << wcnt << endl;
  }
  return 0;
}
void dfs(int i,int j){
  if(mat[i][j]==3) return ;
  if(mat[i][j]==1){
    flagb=1;
    return ;
  }
  if(mat[i][j]==2){
    flagw=1;
    return ;
  }
  if(mat[i][j]==0){
    cnt++;
  } 
  if(mat[i][j]==3) return ;
  mat[i][j]=3;
  if(j+1<w) dfs(i,j+1);
  if(0<=j-1) dfs(i,j-1);
  if(i+1<h) dfs(i+1,j);
  if(0<=i-1) dfs(i-1,j);
}
//1:B 2:W

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

#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)

using ll = long long;
#define INF 1e9

int main(){
  int N, K;
  cin >> N >> K;
  ll ans = K;
  REP(i, N-1){
    ans *= K-1;
  }
  cout << ans << endl;
  return 0;
}


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

vector<char> P;
int N,i=2;

char M(char A,char B){
    if(A == 'T' && B == 'F') return 'F';
    return 'T';
}

int main(){
    cin >> N;
    P.resize(N);
    for(int i=0;i<N;i++) cin >> P[i];

    char ans = M(P[0],P[1]);
    for(int i=2;i<N;i++) ans = M(ans,P[i]);

    cout << ans << endl;
}


Measured memory_bytes: 3168
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (N, C) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };

  let mut D: Vec<Vec<i64>> = Vec::new();
  for _ in 0..C {
    let d: Vec<i64> = read_vec();
    D.push(d);
  }

  let mut c: Vec<Vec<i64>> = Vec::new();
  for _ in 0..N {
    let v: Vec<i64> = read_vec::<i64>().iter().map(|a| a - 1).collect();
    c.push(v);
  }

  // 前計算
  let mut sum: Vec<Vec<i64>> = vec![vec![0; C]; 3];
  for i in 0..C {
    for j in 0..N {
      for k in 0..N {
        if (j + k) % 3 == 0 {
          sum[0][i] += D[c[j][k] as usize][i];
        }
        else if (j + k) % 3 == 1 {
          sum[1][i] += D[c[j][k] as usize][i];
        }
        else {
          sum[2][i] += D[c[j][k] as usize][i];
        }
      }
    }
  }

  // 全探索
  let mut res = 1_000_000_000;
  for i in 0..C {
    for j in 0..C {
      if i == j {
        continue;
      }
      for k in 0..C {
        if j == k || i == k{
          continue;
        }

        res = min(sum[0][i] + sum[1][j] + sum[2][k], res);

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


Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

const ll mod = 1e9+7;

ll f_[1000100];
ll f(ll n) {
	if(n == 0)
		return 1;
	if(f_[n])
		return f_[n];
	return f_[n] = n * f(n-1) % mod;
}

ll ivf_[1000100];
ll ivf(ll n) {
	if(ivf_[n])
		return ivf_[n];
	ll x = f(n);
	ll p = mod -2;
	ll res = 1;
	while(p) {
		if(p & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		p /= 2;
	}
	return ivf_[n] = res;
}

ll choose(ll n, ll r) {
	return (f(n) * ivf(n-r)) % mod;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<pii> A(N), B(M);
	rep(i, N) {
		int a; cin >> a;
		A[i] = pii(a,i);
	}
	rep(i, M) {
		int a; cin >> a;
		B[i] = pii(a,i);
	}
	A.push_back(pii(1000100, -1));
	B.push_back(pii(1000100, -1));
	sort(rall(A));
	sort(rall(B));

	int x = 0;
	ll res = 1;

	unordered_map<ll,int> mp;
	rep(i,N) {
		mp[A[i+1].fi]++;
		if(mp[A[i+1].fi] >= 2)
			res = 0;
	}
	mp.clear();
	rep(i,M) {
		mp[B[i+1].fi]++;
		if(mp[B[i+1].fi] >= 2)
			res = 0;
	}
	while(res && A.size()+B.size() > 2) {
		bool a, b;
		a = b = false;
		if(A.back().fi == B.back().fi)
			a = b = true;
		else if(A.back().fi < B.back().fi)
			a = true;
		else
			b = true;

		int c = 0;
		int n = 0;
		if(a) {
			c += B.size()-1;
			n = A.back().fi;
			A.pop_back();
		}
		if(b) {
			c += A.size()-1;
			n = B.back().fi;
			B.pop_back();
		}
		if(n < x+c) {
			res = 0;
		}
		else {
			res = res * choose((n-1)-x, c-1) % mod;
			if(a && !b)
				res = res * (B.size()-1) % mod;
			else if(!a && b)
				res = res * (A.size()-1) % mod;
			x += c;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 31104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int a[5],k;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	cin>>k;
	sort(a,a+5);
	if(a[4]-a[0]>k)cout<<":("<<endl;
	else fin("Yay!");
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>

#define lson (idx << 1)
#define rson (idx << 1 | 1)
#define INF 1000000000000LL
#define MAXN 200010

using namespace std;
typedef long long ll;
// `lo` is the current minimum of the segment.
// `lh` is the current value of the left endpoint.
// `lazy` is the lazy tag for addition.
struct Node {
	int l, r;
	ll lo, lh;
	bool flag = false;
} s[MAXN << 2];
int h, w;
// Push up
void calc(int idx) {
	s[idx].lo = min(s[lson].lo, s[rson].lo);
	s[idx].lh = s[lson].lh;
}
void build(int idx, int l, int r) {
	s[idx].l = l, s[idx].r = r;
	if (l == r)	return;
	int mid = (l + r) >> 1;
	build(lson, l, mid);
	build(rson, mid + 1, r);
}
// Lazy propagation
void pushdown(int idx) {
	if (s[idx].flag) {
		ll L = s[idx].lh;
		int l = s[idx].l;
		for (int i = lson; i <= rson; ++i) {
			s[i].lo = s[i].lh = L + s[i].l - l;
			s[i].flag = true;
		}
	}
	s[idx].flag = false;
}
// Assign segment [l, r] according to f[l-1] = L
void update(int idx, int l, int r, ll L) {
  if (s[idx].l >= l && s[idx].r <= r) {
    s[idx].lo = s[idx].lh = L + s[idx].l - l + 1;
    s[idx].flag = true;
    return;
  }
  pushdown(idx);
  int mid = (s[idx].l + s[idx].r) >> 1;
  if (l <= mid)
    update(lson, l, r, L);
  if (mid + 1 <= r)
    update(rson, l, r, L);
  calc(idx);
}
// Range minimum query
ll query(int idx, int l, int r) {
	if (r < 1 || l > w)
		return INF;
	if (s[idx].l >= l && s[idx].r <= r)
		return s[idx].lo;
	pushdown(idx);
	ll ans = INF;
	int mid = (s[idx].l + s[idx].r) >> 1;
	if (l <= mid)
		ans = min(ans, query(lson, l, r));
	if (mid + 1 <= r)
		ans = min(ans, query(rson, l, r));
	return ans;
}
void solve() {
	scanf("%d%d",&h,&w);
	vector<int> l(h), r(h);
	for (int i = 0; i < h; ++i)
		scanf("%d%d",&l[i],&r[i]);
	vector<ll> ans(h, INF);
	build(1, 1, w);
	for (int i = 0; i < h; ++i) {
		ll L = query(1, l[i] - 1, l[i] - 1);
		update(1, l[i], r[i], L);
		ans[i] = min(ans[i], query(1, 1, w))+i+1;
		if (ans[i] == INF)	break;
	}
	for (ll i : ans)
	cout << (i >= INF ? -1 : i) << endl;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	solve();
}

Measured memory_bytes: 31476
#
# abc175 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """RRS"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """SSS"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """RSR"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    S = input()
    if S.count("R") == 0:
        print("0")
    elif S.count("R") == 3:
        print("3")
    elif S.count("R") == 1:
        print("1")
    elif "RR" in S:
        print("2")
    else:
        print("1")


if __name__ == "__main__":
    #unittest.main()
    resolve()


Measured memory_bytes: 16336
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    int a,b,h,m;
    cin >> a >> b >> h >> m;

    double tm,th;

    tm = (m*M_PI)/30;
    th = ((h*M_PI)/6) + ((m*M_PI)/360);

    double theta = tm - th;
    if(theta<0){
        theta = th - tm;
    }

    if(theta > M_PI){
        theta = 2*(M_PI) - theta;
    }

    double c = sqrt(a*a + b*b - (2*a*b*cos(theta)));
    cout << setprecision(20) << c << endl;
    return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
#define finish(x) reutrn cout << x << endl, 0;
#define ll long long

int h, w, n, x, y, dp[3005], fact[200001], inv[200001], mod = 1e9 + 7;
vector <pair <int, int> > a;

int powlog(int a, int b){
    if(b == 0) return 1;
    int ret = powlog(a, b / 2);
    if(b % 2) return 1LL * ret * ret % mod * a % mod;
    return 1LL * ret * ret % mod;
}
int C(int n, int r){
    return 1LL * fact[n] * inv[r] % mod * inv[n - r] % mod;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    fact[0] = 1;
    inv[0] = 1;
    for(int i = 1 ; i <= 200000 ; i++){
        fact[i] = 1LL * i * fact[i - 1] % mod;
        inv[i] = powlog(fact[i], mod - 2);
    }
    cin >> h >> w >> n;
    for(int i = 0 ; i < n && cin >> x >> y ; i++)
        a.push_back(make_pair(x, y));
    a.push_back(make_pair(h, w));
    sort(a.begin(), a.end());
    for(int i = 0 ; i < a.size() ; i++){
        dp[i] = C(a[i].first + a[i].second - 2, a[i].first - 1);
        for(int j = 0 ; j < i ; j++)
            if(a[j].second <= a[i].second)
                dp[i] = (dp[i] - 1LL * C(a[i].first - a[j].first + a[i].second - a[j].second, a[i].first - a[j].first) * dp[j] % mod + mod) % mod;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1920
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		String a[] = new String[N];
		
		HashSet set = new HashSet();
		
		
		for (int i=0; i<N; i++){
			String temp = sc.next();
			if (set.contains(temp)){
				set.remove(temp);
			}
			else {
				set.add(temp);				
			}
		}
		
		System.out.println(set.size());
		
		
	}
}

Measured memory_bytes: 50316
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> pll;
#define fi first
#define se second
typedef long long ll;
const int N = 2* 1e5+5;
ll n,a[N],b[N];
ll mod=1e9+7;
ll modpow(ll a,ll b){
        a%=mod; ll res=1;
        while(b){
                if(b&1) res=(res*a)%mod;
                a=(a*a)%mod;
                b>>=1;
        }
        return res;
}
map<pll,ll> mp;
ll arr[2];
set<pll> s;
void f(pll a){
        if(mp.find(a)==mp.end()) mp[a]=1;
        else mp[a]++;
}
ll f2(pll a){
        if(mp.find(a)==mp.end()) return 0;
        return mp[a];
}
ll gcd(ll a,ll b){
        if(b==0) return a;
        return gcd(b,a%b);
}
void f3(pll a){
        pll tmp;
        if(a.fi<0) tmp={a.se,-a.fi};
        else{ tmp={-a.se,a.fi};}
        if(s.find(tmp)!=s.end()) return;
        //cout<<a.fi<<" "<<a.se<<endl;
        s.insert(a);
}
void solve(){
        ll ans=0;
        arr[0]=arr[1]=0;
        for(int i=1;i<=n;i++){
                if(a[i]==0&&b[i]==0) f({0,0});
                else if(a[i]==0) arr[0]++;
                else if(b[i]==0) arr[1]++;
                else{
                        int sgn1=0,sgn2=0;
                        sgn1=(a[i]>0?1:0);
                        sgn2=(b[i]>0?1:0);
                        a[i]=abs(a[i]); b[i]=abs(b[i]);
                        ll gd=gcd(a[i],b[i]);
                        a[i]/=gd,b[i]/=gd;
                        if(sgn1^sgn2){ f({-a[i],b[i]}); f3({-a[i],b[i]}); }
                        else{f({a[i],b[i]}); f3({a[i],b[i]}); }
                }
        }
        ans=(modpow(2,arr[0])+modpow(2,arr[1])-1ll+mod)%mod;
        for(pll i: s){
                if(i.fi<0){ ans=(ans*(modpow(2,f2(i))+modpow(2,f2({i.se,-i.fi}))-1ll+mod)%mod)%mod;}
                else { ans=(ans*(modpow(2,f2(i))+modpow(2,f2({-i.se,i.fi}))-1ll+mod)%mod)%mod;}
                //cout<<i.fi<<" "<<i.se<<" "<<ans<<endl;
        }
        ans=(ans+f2({0,0})-1ll+mod)%mod;
        cout<<ans<<endl;
}



int main(){
        //freopen("sub1_11.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
        solve();
}


Measured memory_bytes: 31588
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N):
    ans+=B[A[i]-1]
    if i > 0 and A[i]==A[i-1]+1: ans+=C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int A = 0;
    int B = 0;
    cin >> A >> B;
    
    for (int x = 0; x <= 1300; ++x) {
        int taxA = static_cast<int>(x * 0.08);
        int taxB = static_cast<int>(x * 0.1);
        if (taxA == A && taxB == B) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    if((s.charAt(0)==t.charAt(2)) && (s.charAt(1) == t.charAt(1)) && (s.charAt(2) == t.charAt(0))){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 23124
#include <stdio.h>
#define N 10000005
int n, m, i, j, k;
long long f[N], ans;
int main(){
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		for(j=i; j<=n; j+=i){
			f[j]++;
		}
	}
	for(i=1; i<=n; i++){
		ans += i*f[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 79856
n,q=map(int,input().split())
s=input()
c=[0]
t=0
for i in range(1,n):
    t+=1 if (s[i-1]=='A' and s[i]=='C') else 0
    c.append(t)
for i in range(q):
    l,r=map(int,input().split())
    print(c[r-1]-c[l-1])


Measured memory_bytes: 7688
#include <stdio.h>
#include <stdbool.h>

int main()
{
    int n, a[100000], i, on=0, count=0;
    bool flag = false;
    scanf("%d\n", &n);
    for (i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    while (n>0) {
        on = a[on] - 1;
        count ++;
        n --;
        if (on == 1) {
            flag = true;
            break;
        }
    }
    if (flag == true) printf("%d\n", count);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 512
NMAX = 55

N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[[0] * NMAX for s in range(3000)] for i in range(NMAX)]

dp[0][0][0] = 1 # dp[i][s][k]: i個からk個選ぶとき、総和がsのものの個数
for i in range(N): # N-1時点でNが更新されるのでここまでで十分
    for s in range(3000):
        for k in range(N+1):
            if dp[i][s][k] == 0:
                continue
            dp[i+1][s][k] += dp[i][s][k]
            dp[i+1][s+X[i]][k+1] += dp[i][s][k]

ans = 0
for k in range(1, N+1):
    ans += dp[N][A*k][k]

print(ans)


Measured memory_bytes: 103308
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <queue>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    int sum = 0;
    int num = n;
    while (num != 0)
    {
        sum += num % 10;
        num /= 10;
    }
    
    cout << ((n % sum == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//int n;
	//cin>>n;
	int a[101];
	
	int js=0;	memset(a,-1,sizeof(a));
	for(int i=0;i<5;i++) 
	cin>>a[i];

	for(int i=0;i<5;i++)
	{
		if(a[i]==0) js=i;
	//	cout<<a[i]<<' ';
	}
	cout<<js+1<<endl;
 } 

Measured memory_bytes: 3588
#include<iostream>

using namespace std;

bool ok(int P,int k,int n,int* w){
  int weight=0,howmany=1;
  int i=0;
  while(i<n){
    if( weight + w[i] <= P ){
      weight += w[i];
      i++;
    }else if( w[i] > P ){
      howmany = k + 1;
      i=n;
    }else{
      weight = w[i];
      howmany++;
      i++;
    }
  }

  if( howmany <= k) return 1;
  else return 0;
}

int main(void){
  int n,k;
  cin >> n >> k;
  int w[n];
  for(int i=0;i<n;i++) cin >> w[i];
  
  int l=0,h=10000*n;
  while(l+1<h){
    int m = (l+h)/2;
    if(ok(m,k,n,w)) h=m;
    else l = m;
  }
  cout << l+1 << endl;
}

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

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

Measured memory_bytes: 3632
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

simulate :: [Int] -> Int -> Int -> Int
simulate _ 0 _ = 0
simulate [x] ans _ = ans
simulate (x : xs) (-1) (-1) = simulate xs ans diff
  where
    diff = x - sum xs
    ans = abs diff
simulate (x : xs) ans diff = simulate xs ans'' diff'
  where
    diff' = diff + 2 * x
    ans' = abs diff
    ans'' = if ans > ans' then ans' else ans

main = do
  n <- getInt
  as <- getIntList
  print $ simulate as (-1) (-1)


Measured memory_bytes: 19384
#include<bits/stdc++.h>
#define MAXN 1100000
using namespace std;

inline void read(long long &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}

inline void read(int &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}


inline void write(long long x){
    static const long long maxlen=100;
    static char s[maxlen];
    if (x<0) {   putchar('-'); x=-x;}
    if(!x){ putchar('0'); return; }
    long long len=0; for(;x;x/=10) s[len++]=x % 10+'0';
    for(long long i=len-1;i>=0;--i) putchar(s[i]);
}


long long n , m;
int a[ MAXN ];

int main(){
    read(n);    read(m);
    if ( n>m )
        swap( n , m );
    if ( n!=1 )
        cout<<n*m-n*2-m*2+4;
    else
    if ( m!=1)
        cout<<max( 0ll , m-2 );
    else
        puts("1");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  ll K;
  cin>>K;
  ll ans=0;
  rep(a,K) rep(b,K) rep(c,K) ans+=gcd(gcd((a+1),(b+1)),c+1);
  cout<<ans<<endl;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
void s1()
{
    int n,m;
    cin>>n>>m;
    if(m==n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
void s2()
{

}
void s3()
{

}
void s4()
{

}
int main()
{
    s1();
    //s2();
    //s3();
    //s4();
}


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

int main(){
    int N,K,count= 0;
    cin >> N >> K;
    int d = 0;

    vector<int> kazu(N+1);

    vector<int> sunuke(N+1);

    for(int i = 0;i <= N;i++)
        sunuke.at(i) = false;


    for(int i = 0;i < K;i++){
        cin >> d;
        for(int j = 0;j < d;j++){
            cin >> kazu.at(j);
        }
        for(int k = 0;k < N;k++){
            sunuke.at(kazu.at(k)) = true; 
        }
        
    }

    for(int i = 1;i <= N;i++){
        if(sunuke.at(i) == false){
            count++;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
int ans[100005];
int b[13]={0,1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int main(){
   int n,k;
   cin>>n;
   for(int i=1;i<=n;i++)ans[i]=1000000;
 
	for(int j=12;j>=1;j--)
	  {
	  	  for(int i=b[j];i<=n;i++)
	  	   ans[i]=min(ans[i],ans[i-b[j]]+1);
	  }
    cout<<ans[n];
   
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector> 
#include<algorithm>
using namespace std;
int b,c,i,j,k,heap[100009],a[500009],t,n,minn,maxp,cost=0;
int main(){
	cin>>n>>t;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	minn=a[1];
	maxp=0;
	for(i=2;i<=n;i++){
		maxp=max(maxp,a[i]-minn);
		minn=min(minn,a[i]);
	}
//	cout<<maxp<<endl;
	heap[1]=a[1];
	for(i=2;i<=n;i++){
	//	cout<<heap[1]<<endl;
		while(a[i]-heap[1]==maxp){
			int t=heap[1]+1;
			pop_heap(heap+1,heap+i,greater<int>());
			heap[i-1]=t;
			push_heap(heap+1,heap+i,greater<int>());
			cost++;
		}
	//	cout<<a[i]<<' ';
		heap[i]=a[i];
		push_heap(heap+1,heap+i+1,greater<int>());
	//	cout<<heap[1]<<endl;
	}
	cout<<cost<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<double> que;
	rep(i, n) {
		double k;
		cin >> k;
		que.push(k);
	}
	rep(i, m) {
		double k = que.top();
		que.pop();
		k /= 2;
		que.push(k);
	}
	ll ans = 0;
	while (que.size()) {
		double k = que.top();
		que.pop();
		ans += (int)k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
        cout << "pon";
    else
        if (n % 10 == 3)
            cout << "bon";
        else
            cout << "hon";
    return 0;
}


Measured memory_bytes: 3644
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<fstream>
using namespace std;
//ifstream fin(.in);
//ofstream fout(.out);
int n,one,two,four;
int num[100003];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
        cin>>num[i];
        if(num[i]%4==0){
        	four++;
		}else if(num[i]%2==0){
        	two++;
		}else{
        	one++;
		}
    }
	if(one>four+1||(one==four+1&&two!=0)){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}
//沈♂哲贝是最强的！！！
//大佬祝您AK
//周♂雨扬是最强的！！！

Measured memory_bytes: 640
while True:
	try:
		N=input()
	except:
		break
	a=list(map(int, input().split(" ")))
	#print(a)
	ans=1
	for v in a:
		ans*=v
		if 1000000000000000000 < ans:
			ans = -1
			break
	if any([v==0 for v in a]):
		ans=0
	print(ans)


Measured memory_bytes: 21472
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int a,b,t;
int main(){
	cin>>a>>b>>t;
	cout<<t/a*b;
	return 0;
}

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

int n, x;
vector<int> cnt_vec;

int main(){

    cin >> n >> x;
    int i, j, k, sum = 0, cnt = 0;

    while ((n != 0) || (x != 0)) {
        for (i=1; i<=n; i++){
            for (j=i+1; j<=n; j++){
                for (k=j+1; k<=n; k++){
                    sum = i + j + k;
                    if (sum == x){
//                        cout << i << j << k << endl;
                        cnt++;
                    }
                }
            }
        }
        cnt_vec.push_back(cnt);
        cin >> n >> x;
        cnt = 0;
    }

    for (int x:cnt_vec){
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 3156
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if A[i] +1 == A[i+1]:
        ans += C[A[i]-1]
ans += sum(B)
print(ans)


Measured memory_bytes: 9124
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
void add_self(ll& a , ll b){a =  (a + b)%mod;}
#define a(x)  get<0>(x) 
#define b(x)  get<1>(x)
#define c(x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n ;cin>>n;
vector<tuple<ll,ll,ll>> v(n);
for(auto &i : v)cin>>a(i)>>b(i)>>c(i);
tuple<ll,ll,ll> x  , y ;

y=v[0];

for(ll i = 1; i<n ; i++){
a(x) = a(v[i]) + max(b(y),c(y));
b(x) = b(v[i]) + max(a(y),c(y));
c(x) = c(v[i]) + max(a(y),b(y));
y = x;
}

cout<<max(a(y),max(b(y),c(y)));


	
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <utility>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstring>
using namespace std;
using ll = long long;

int main(){
  string s, t; cin >> s >> t;
  s = " " + s; t = " " + t;

  int dp[s.size()][t.size()];
  for(int i=0; i<s.size(); i++){
    for(int j=0; j<t.size(); j++){
      if(i == 0) dp[i][j] = j;
      else if(j == 0) dp[i][j] = i;
      else dp[i][j] = 1e5;
    }
  }

  for(int i=1; i<s.size(); i++){
    for(int j=1; j<t.size(); j++){
      if(s[i] == t[j])
        dp[i][j] = min(dp[i][j], dp[i-1][j-1]);
      else 
        dp[i][j] = min(dp[i][j], dp[i-1][j-1]+1);

      dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
      dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
    }
  }

  cout << dp[s.size()-1][t.size()-1] << endl;

  return 0;
}



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

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

using namespace std;

int main() {
  int q;
  cin>>q;
  REP(i,q){
    string str;
    cin>>str;
    int n=0;
    while(1){
      if(str.size() == 1) break;
      int mx = 0;
      REP(j,str.size()-1){
        int fwd=stoi(str.substr(0,j+1));
        int bwd=stoi(str.substr(j+1));
        mx = max(mx, fwd*bwd);
      }
      str = to_string(mx);
      ++n;
    }
    cout<<n<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  ll X;
  cin >> X;
  vector<ll> x(n);
  for (int i = 0; i < n; ++i) cin >> x[i];

//  X = 1e9;
//  n = 2e5;
//  x = vector<ll>(n, 1e9);

  reverse(x.begin(), x.end());
  vector<ll> s(2 * n + 1);
  for (int i = 0; i < n; ++i) s[i + 1] = s[i] + x[i];
  for (int i = n + 1; i < s.size(); ++i) s[i] = s[i - 1];



  ll result = ll(1e18);
  for (ll k = 1; k <= n; ++k) {
    ll curResult = (n + k) * X;
    double curResultDouble = (n + k) * X;
    ll mul = 3;
    for (int at = 0; at <= n; at += k) {
      curResult += (s[at + k] - s[at]) * (mul + (mul == 3) * 2);
      curResultDouble += (s[at + k] - s[at]) * (mul + (mul == 3) * 2);
      mul += 2;
    }
    if (curResultDouble > 1e18) continue;
    //cerr << k << " " << curResult << endl;
    result = min(result, curResult);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
main(){
  int a[1000000]={0},i,j,n,cnt;
  while(scanf("%d",&n)!=EOF){
    for(i=0;i<=n;i++)a[i]=0;
    cnt=0;
    for(i=2;i<=n;i++){
      if(a[i]==0){
	cnt++;
	for(j=1;i*j<=n;j++){
	  a[i*j]=1;
	}	   
      }
    }


    printf("%d\n",cnt);
  }
  return 0;
}



Measured memory_bytes: 5648
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

const int MOD = 2019;

int main(){
    ios;
    string S; cin >> S;
    unordered_map<int,int>Remainders;
    Remainders[0] = 1;
    int _10Power = 1, number = 0, remainder;
    ll ans = 0;
    for(ll i = S.size() - 1; ~i; --i){
        number += (S[i] - '0') * _10Power;
        remainder = number % MOD;
        ans += Remainders[remainder];
        ++Remainders[remainder];
        _10Power *= 10;
        _10Power %= MOD;
        number   %= MOD;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

int n,t,a;

int main(void)
{
    cin >> n >> t >> a;
    t *= 1000;
    a *= 1000;
    int res = 0;
    int diff = inf;
    rep(i,n)
    {
        int h;
        cin >> h;

        int aa = t - h * 6;
        int dd = abs(a - aa);
        if(diff > dd)
        {
            res = i + 1;
            diff = dd;
        } 
    }

    cout << res << endl;

    return 0;
}


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

int main(){
  int min_p, max_p;
  int p;
  int k;
  cin >> min_p;
  for(int i=0; i<4; i++){
    cin >> max_p;
  }
  cin >> k;
  if(k >= (max_p-min_p)){
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge{ int to, time, cost; };
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;
const double infd = (double)1e+9;

int sum = 0;
std::string str;
std::string::iterator it;

int number(){
	int ret = 0;
	while (isdigit(*it)){
		ret *= 10;
		ret += (*it - '0');
		++it;
	}
	return ret;
}

int main(){
	while (std::cin >> str){
		str += ".";
		it = str.begin();
		while (it != str.end()){
			if (isdigit(*it))sum += number();
			++it;
		}
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    vector<int64_t> Y(N+1,1);
    rep(i,2,N+1){
        int n=i;
        while(n<=N){
            Y.at(n)++;
            n+=i;
        }
    }

    int64_t ans=0;
    rep(i,1,N+1) ans+=Y.at(i)*i;

    cout<<ans<<endl;
}

Measured memory_bytes: 81400
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,q;
	int m,a,b,x,y;
	int par[10000],ran[10000];
	int i;
	cin>>n>>q;
	for(i=0;i<n;i++)	par[i]=i,ran[i]=0;
	for(i=0;i<q;i++){
		cin>>m>>a>>b;
		x=a;	y=b;
		while(x!=par[x])	x=par[x];
		while(y!=par[y])	y=par[y];
		if(m==0){
			if(x!=y){
				if		(ran[x]>ran[y])	par[y]=x;
				else if	(ran[x]<ran[y])	par[x]=y;
				else					par[y]=x,ran[x]++;
			}
		}
		else{
			if(x==y)	cout<<1<<endl;
			else		cout<<0<<endl;
		}
	}
	return 0;
}
			


Measured memory_bytes: 3176
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=52;
int n,a,x[N];
LL ans,dp[N][N][N*N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
//	freopen("Tak and Cards.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,a);
	for(int i=1;i<=n;i++) read(x[i]);
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j>=0;j--)
		{
			for(int k=a*n;k>=0;k--)
			{
				dp[i][j][k]=dp[i-1][j][k];
				if(k>=x[i] && j) dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
			}
		}
	}
	for(int i=1;i<=n;i++) ans+=dp[n][i][a*i];
	printf("%lld\n",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}


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

#define INF 1000000000000

int main(){
  int n;
  cin>>n;
  double ans=0;
  rep(i,n){
    double x;
    string u;
    cin>>x>>u;
    if(u=="JPY"){ans+=x;}
    else{ans+=380000.0*x;}
  }
  cout<<ans;


}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int64 n; cin >> n;
		vector<int64> a(n), ans(n);
		rep (i, n) {
			cin >> a[i];
		}
		int64 x2 = 0;
		rep (i, n) {
			if (i%2) x2 -= a[i];
			else x2 += a[i];
		}
		ans[0] = x2 / 2;
		rep (i, n - 1) {
			ans[i + 1] = a[i] - ans[i];
		}
		rep (i, n) ans[i] *= 2;
		rep (i, n) {
			cout << ans[i] << endl;
		}
    return;
}

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



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define PI 3.14159265358979323846

int main(){
  long double a,b,h,m;
  cin >> a >> b >> h >> m;
  long double sita = 2*PI*(h/12+m/720-m/60);
  cout << fixed << setprecision(20);
  cout << sqrt(a*a+b*b-2*a*b*cos(sita)) << endl;
}


Measured memory_bytes: 4136
n,x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans=0
for i in range(n):
  if a[i] == x:
    ans+=1
    break
  elif a[i] > x:
    break
  else:
    if i!=(n-1):
      ans+=1
      x-=a[i]
print(ans)
    

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

int main(){
  int flag = 1;
  int H,W;
  int i,j;

  while(1){
    cin>>H>>W;
    if(H==0&&W==0) break;

    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
  
  int N,K; cin >> N >> K;
  
  string S; cin >> S;
  
  if(S[K-1] == 'A'){
    S[K-1] = 'a';
  }
  
  else if(S[K-1] == 'B'){
    S[K-1] = 'b';
  }
  
  else if(S[K-1] == 'C'){
    S[K-1] = 'c';
  }
  
  cout << S << endl;
 
  return 0;
}

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

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

int main() {
  long long int N, A, B;
  cin >> N >> A >> B;
  long long int a = N / (A + B);
  long long int b = N % (A + B);
  long long int no;

  if (b <= A) {
    cout << a * A + b << endl;
  }
  if (b > A) {
    cout << a * A + A << endl;
  }

return 0;
}

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

int c_less(string x, string y) { 
    if (x[1] < y[1]) return true;
    else return false;
}

int main() {
    int N;
    cin >> N;
    vector<string> A(N), B(N), S(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        B[i] = S[i] = A[i];
    }
    stable_sort(A.begin(), A.end(), c_less);

    for ( int i = 0; i < N; i++ ) {
        for ( int j = N-1; j > i; j-- ) {
            if ( c_less(B[j], B[j-1]) ) {
                string t = B[j];
                B[j] = B[j-1];
                B[j-1] = t;
            }
        }
    }

    for ( int i = 0; i < N; i++ ) {
        int minj = i;
        for ( int j = i; j < N; j++ ) {
            if ( c_less(S[j], S[minj]) ) {
                minj = j;
            }
        }
        string t = S[minj];
        S[minj] = S[i];
        S[i] = t;
    }

    for ( int i = 0; i < N; i++ ) {
        cout << (i==0 ? "" : " ") << B[i];
    }
    cout << '\n';
    if ( equal(A.begin(), A.end(), B.begin()) ) {
        cout << "Stable\n";
    } else {
        cout << "Not stable\n";
    }

    for ( int i = 0; i < N; i++ ) {
        cout << (i==0 ? "" : " ") << S[i];
    }
    cout << '\n';
    if ( equal(A.begin(), A.end(), S.begin()) ) {
        cout << "Stable\n";
    } else {
        cout << "Not stable\n";
    }
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n; cin >> n;
    vector<ll> a(n+1);
    rep(i, n+1) cin >> a[i];

    vector<ll> jun(n+1, 1), gyaku(n+1, 0);
    for (int i = 1; i <= n; i++) {
        jun[i] = jun[i-1] * 2 - a[i];
    }
    for (int i = n-1; i >= 0; i--) {
        gyaku[i] = gyaku[i+1] + a[i+1];
    }

    ll ans = 0;
    rep(i, n+1) ans += a[i];
    vector<ll> mini(n+1);
    for (int i = 0; i <= n; i++) {
        ll m;
        if (jun[i] >= 0 && gyaku[i] >= 0) {
            m = min(jun[i], gyaku[i]);
        } else if (jun[i] < 0) {
            m = gyaku[i];
        } else if (gyaku[i] < 0) {
            m = jun[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
        mini[i] = m;
        ans += m;
    }

    if (a[0] + mini[0] > 1) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        if (mini[i-1] * 2 < mini[i] + a[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}


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

int main(){
    long long n;
    cin>>n;
    long long a[n],b[n];
    long long ans=0,t=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(t<a[i]){
            ans=a[i]+b[i];
            t=a[i];
        }
    }

    cout<<ans<<endl;
    

}

Measured memory_bytes: 1792