akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<int> Q;

bool solve(int n, int i, int m)
{
	// ??????????????????????????????0???????§£
	if (m == 0)
		return true;
	
	// Q???????´???°??\???????????¨??§?????????
	if (i >= n)
		return false;

	// Q[i]???????????´?????¨??????????????´?????????????????¢?´¢
	return solve(n, i + 1, m) || solve(n, i + 1, m - Q[i]);
}

int main()
{
	int A, N, M;
	string ans;
	cin >> N;

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

	cin >> A;

	// ???M??????????????¢?´¢
	for (int i = 0; i < A; i++)
	{
		cin >> M;

		ans += solve(N, 0, M) ? "yes\n" : "no\n";
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    scanf("%d", &N);
    double dp[N + 1]; // dp[i] is the probability of getting i heads so far(as we iterate over coins see so far).
  	fill(dp, dp + (N + 1), 0.0);
    dp[0] = 1.0; // dp[0] = 1 because initially when we haven't seen any coins, the probability of getting 0 heads for 0 coins seen is always 1
    
  	for (int i=1; i<=N; ++i) { // iterate over coins
  	    double p;
  	    scanf("%lf", &p);
        for (int j=i; j>=0; --j){ // iterate over heads seen so far; reverse iteration so that we don't use modified j while computing j+1.
            if (j != 0)
                dp[j] = dp[j]*(1-p) + dp[j-1]*p; // when j != 0, to get j number of heads for coins seen so far, we can either take old j*(1-p) or take p*(j-1) - in which we consider current coin's head.
            else
                dp[j] = dp[j]*(1-p); // when j = 0, that means 0 heads seen, so we just multiply the probability of tail for current coin with previous j which contains probability of just seeing tails.
        }
    }  
    
    double answer = 0.0;
  	for (int i = (N/2) + 1; i<=N; ++i) {
        answer += dp[i];
    }
    cout << setprecision(12) << answer << endl;
  	
  return 0;
}

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

int main (){
  string A,B,C;
  cin>>A>>B>>C;
  if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
struct BIT{
    vector<int> bit;
    int n;
    BIT(int n){
        bit.resize(n+1,0);
        this->n = n;
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add(int i,int x){
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }
};

int main() {
    int N;
    cin >> N;
    BIT bit(N*N);
    vector<pair<int,int> > x;

    rep(i,1,N+1){
        int tmp;
        cin >> tmp;
        x.emplace_back(tmp,i);
    }
    sort(all(x));
    vector<int> v(N*N+1,0),out;
    rep(i,0,x.size()){
        v[x[i].first] = x[i].second;
    }
    out = v;
    int l = 1,r = N*N;
    rep(i,0,x.size()){
        rep(j,0,x[i].second-1){
            if(l >= x[i].first){
                cout << "No" << endl;
                return 0;
            }else if(out[l] == 0){
                out[l] = x[i].second;
            }else{
                l++;
                j--;
                continue;
            }
        }
    }

    for(int i = x.size() - 1; i >= 0; i--){
        rep(j,0,N - x[i].second){
            if(r <= x[i].first){
                cout << "No" << endl;
                return 0;
            }else if(out[r] == 0){
                out[r] = x[i].second;
            }else{
                r--;
                j--;
                continue;
            }
        }
    }

    cout << "Yes" << endl;
    rep(i,1,out.size()){
        cout << out[i];
        if(i == out.size() - 1){
            cout << endl;
        }else{
            cout << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
    

    long long n;
    cin >> n;
    long p = floor(sqrt(2*n));
    long ans = n;
    if(p*(p+1)/2 < n){
        p += 1;
    }
    for (int i=p;i>=1;i--){
        if(ans >= i){
            cout << i << endl;
            ans -= i;
        }

    }


}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N,T;
  cin>>N;

  int all=0;

  vector<int> s(N);
  for(int i=0;i<N;i++) cin>>s.at(i),all+=s.at(i);

  if(all%10!=0){
    cout<<all<<endl;
    return 0;
  }

  sort(s.begin(),s.end());
  //for(int i=0;i<N;i++) cout<<s.at(i)<<' ';
  
  for(int i=0;i<N;i++){
    if((all-s.at(i))%10!=0){
      cout<<all-s.at(i)<<endl;
      return 0;
    }
  }

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

Measured memory_bytes: 256
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def main():
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0:
        print(0)
        return
    Xp = (X + Y) // 3
    Yp = Y - Xp
    if Yp < 0 or Yp > Xp:
        print(0)
        return
    print(cmb(Xp, Yp, mod))

main()


Measured memory_bytes: 127572
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll Q; cin >> Q;
    vector<ll> c(Q),a(Q),n(Q);
    for(int i = 0; i < Q;i++){
        cin >> c[i] >> a[i] >> n[i];
    }
    for(int i = 0; i < Q;i++){
        ll ans = 0;
        ll Min = min({c[i],a[i],n[i]});
        ans += Min;

        c[i] -= Min; a[i] -= Min; n[i] -= Min;
        
        ll Min2 = min(c[i]/2,a[i]);
        
        ans += Min2;
        
        c[i] -= 2*Min2; a[i] -= Min2;
        
        ans += c[i]/3;
        
        cout << ans << endl;
    }
	return 0;
}



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

static const int MAX = 1e+5;
int num[MAX+1];

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        num[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int b, c;
        cin >> b >> c;
        sum += num[b] * (c - b);
        cout << sum << endl;
        num[c] += num[b];
        num[b] = 0;
    }
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s,c;
    cin >>s;
    c=s;
    reverse(all(c));
    ll cnt=0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]!=c[i])cnt++;
    }
    cout <<cnt /2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 205;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
ll arr[MAXN];
char S[MAXN];
struct basis {
    ll a[70];
    void clear() { memset(a, 0, sizeof(a)); }
    bool add(ll x) {
        for (ll i = 63; i >= 0; i--) {
            if ((x >> i) & 1) {
                if (!a[i]) {
                    a[i] = x;
                    return true;
                }
                x ^= a[i];
            }
        }
        return false;
    }
};
basis dp[MAXN];
int fastExp(ll x, ll p, int mod) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}
void solve() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", &arr[i]);
    scanf("%s", S);
    memset(dp, 0, sizeof(dp));
    for (int i = n - 1; i >= 0; i--) {
        memcpy(&dp[i], &dp[i + 1], sizeof(basis));
        if (S[i] == '0') {
            dp[i].add(arr[i]);
        } else {
            if (dp[i].add(arr[i])) {
                printf("%d\n", 1);
                return;
            }
        }
    }
    bool flag = false;
    for (int i = 0; i < 64; i++) {
        if (dp[0].a[i]) {
            flag = true;
            break;
        }
    }
    printf("%d\n", !flag);
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int T = read<int>();
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3792
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
	int a, b, c;
	double C;

	scanf("%d %d %d", &a, &b, &c);
	C = sqrt(a*a + b*b -2*a*b*cos((double)c * M_PI / 180.0));

	printf("%lf\n%lf\n%lf\n", 0.5*(double)a * b * sin((double)c * M_PI / 180.0),
	a+b+C, 0.5*(double)a * b * sin((double)c * M_PI / 180.0)*2.0/a);

	return 0;

}


Measured memory_bytes: 2044
S = input()

if S == 'SUN':
  ans = 7
elif S == 'MON':
  ans = 6
elif S == 'TUE':
  ans = 5
elif S == 'WED':
  ans = 4
elif S == 'THU':
  ans = 3
elif S == 'FRI':
  ans = 2
elif S == 'SAT':
  ans = 1

print(ans)

Measured memory_bytes: 3060
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

ans=0
t_ans=0

for i in range(n):
	tmp=abs(a-t+h[i]*0.006)
	if i==0 or t_ans>tmp:
		t_ans=tmp
		ans=i+1

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cctype>
#include <climits>
#include <vector>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	//return n; }
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

#define v vector
struct graph {
	struct node {int n, w;};
	v<v<node>> nodes;

	void read(int n) {
		nodes.resize(n);
		for (auto &x: nodes) {
			in();
			for (int k = in(); k--;) {
				int c = in();
				x.push_back({c, in()});
			}
		}
	}

	v<node> dks() {
		v<node> w(nodes.size(), {0, INT_MAX});
		w[0].w = 0;
		priority_queue<node> q;
		q.push({0, 0});
		while (!q.empty()) {
			node n = q.top();
			q.pop();
			if (w[n.n].n)
				continue;
			w[n.n].n = 1;
			for (node &x: nodes[n.n]) {
				int a = n.w + x.w;
				if (w[x.n].w > a) {
					w[x.n].w = a;
					q.push({x.n, a});
				}
			}
		}
		return move(w);
	}
};

bool operator < (const graph::node &a, const graph::node &b) {
	return a.w > b.w;
}

int main() {
	graph g;
	g.read(in());
	int i = 0;
	for (auto &x: g.dks())
		out(i++, ' ', x.w, '\n');
}


Measured memory_bytes: 7284
def main():
    N = int(input())
    *A, = map(int, input().split())
    *B, = map(int, input().split())

    ans = 0
    for i in range(N):
        beaten = min(A[i], B[i])
        A[i] -= beaten
        B[i] -= beaten
        ans += beaten

        if B[i]:
            beaten = min(A[i + 1], B[i])
            A[i + 1] -= beaten
            B[i] -= beaten
            ans += beaten

    print(ans)


if __name__ == '__main__':
    main()


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

#define MAX 15
#define INF 1e9

double dp[1<<MAX][MAX];
double dist[MAX][MAX];
int N;
 
double rec(int S, int v)
{
    if (dp[S][v] >= 0) return dp[S][v];
    if (S == (1 << N)-1 && v == 0) return dp[S][v] = 0;
 
    double res = INF;
    for (int i = 0; i < N; i++) {
	if (!(S >> i & 1)) { 
	    res = min(res, rec(S | 1 << i, i) + dist[v][i]);
	}
    }
    return dp[S][v] = res;
}
 
int main()
{
    string in;
   
    while (getline(cin, in)) {
	vector<double> v;
	stringstream s(in);
	int num, box_length;
 
	s >> box_length;
 
	while (s >> num) {
	    v.push_back(num);
	}
 
	N = (int)v.size();
	memset(dp, -1, sizeof(dp));
 
	for (int i = 0; i < N; i++) {
	    for (int j = 0; j < N; j++) {
		if (i == j) {
                    dist[i][j] = 0;
		} else {
                    dist[i][j] = sqrt(pow(v[i] + v[j], 2.0) - pow(v[i] - v[j], 2.0));
                }
	    }
	}      
 
	dist[N][N] = 0;
	for (int i = 0; i < N; i++) {
	    dist[i][N] = dist[N][i] = v[i];   
	}
	N++;
	if (rec(0, 0) <= box_length) {
            cout << "OK" << endl;
	} else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s,t;
	cin>>s>>t;
	ll ans=0;
	rep(i,0,s.size()){
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<bitset<10>>F(N);
  for(int i=0;i<N;i++)for(int j=0;j<10;j++){int t;cin>>t;if(t)F[i].set(j);}
  vector<vector<int>>P(N,vector<int>(11));
  for(int i=0;i<N;i++)for(int j=0;j<=10;j++)cin>>P[i][j];
  int M=INT_MIN;
  for(int b=1;b<(1<<10);b++){
    bitset<10>B=b;
    int p=0;
    for(int i=0;i<N;i++)p+=P[i][(B&F[i]).count()];
    M=max(M,p);
  }
  cout<<M<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define all(a) a.begin(),a.end()
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18
# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};
ll N=1e5+5;
vector <ll> p(N,-1);
ll c=0;
vector <ll> vis(N,0);
vector <vector <ll> >vec(N);


int main(){
    IOS;
    make2(ll,n,m);
    fr(i,m){
        make2(ll,x,y);
        vec[--x].push_back(--y);
        vec[y].push_back(x);
    }
    vis[0]=1;
    queue <ll> q;
    q.push(0);
    while(!q.empty()){
        ll e=q.front(); q.pop();
        for(auto x : vec[e]){
            if(!vis[x]){
                vis[x]=1;
                p[x]=e;
                q.push(x);
            }
        }

    }
    fr(i,n) if(vis[i]==1) c++;
    if(c!=n) cout<<"No \n";
    else{
            cout<<"Yes"<<endl;
        for(ll i=1;i<n;i++) cout<<p[i]+1<<"\n";
    }
    return 0;
}


Measured memory_bytes: 13692
#include<algorithm>
#include<cstdio>
#define s(A) std::sort(A,A+10);
main(){
int W[10],K[10],Z[20],p;
for(int i=0;i<20;i++)
scanf("%d",&p),Z[i]=p;
s(Z);
s(Z+10);
printf("%d %d\n",Z[7]+Z[8]+Z[9],Z[17]+Z[18]+Z[19]);
return 0;
}

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

ll solve() {
    ll N, D, x, y;
    cin >> N >> D;
    vector<ll> X(N), Y(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> Y[i];
    }
    atcoder::two_sat ts(N);
    for ( int i = 0; i < N; i++ ) {
        for ( int j = i+1; j < N; j++ ) {
            if ( abs(X[i]-X[j]) < D ) {
                ts.add_clause(i,true,j,true);
            }
            if ( abs(X[i]-Y[j]) < D ) {
                ts.add_clause(i,true,j,false);
            }
            if ( abs(Y[i]-X[j]) < D ) {
                ts.add_clause(i,false,j,true);
            }
            if ( abs(Y[i]-Y[j]) < D ) {
                ts.add_clause(i,false,j,false);
            }
        }
    }
    if ( !ts.satisfiable() ) {
        cout << "No" << "\n";
    } else {
        cout << "Yes" << "\n";
        auto vs = ts.answer();
        for ( int i = 0; i < N; i++ ) {
            cout << (vs[i] ? Y[i] : X[i]) << "\n";
        }
    }
    
    return 0;
}

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

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n;
 	cin >> n;
 	vector <string> s(n);
 	vector <int> t(n);
 	for(int i=0; i<n; i++)
 	{
 		cin >> s[i] >> t[i];
 	}
 	string x;
 	cin >> x;
 	int sum = 0;
 	for(int i=0; i<n; i++)
 	{
 		if(s[i]==x)
 		{
 			for(int j=i+1; j<n; j++)
 				sum += t[j];
 			break;
 		}
 	}
 	cout << sum;
	return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int l[n];
	rep(i, n) cin >> l[i];
	
	sort(l, l + n);
	
	int sum = 0;
	rep(i, n - 1) sum += l[i];
	
	if (l[n - 1] < sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	string ans;
	char tmp;
	tmp = a[0] - 32;
	ans += tmp;
	tmp = b[0] - 32;
	ans += tmp;
	tmp = c[0] - 32;
	ans += tmp;
	cout << ans;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from heapq import heappop, heappush

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    hq = []
    for i, _b in enumerate(b):
        heappush(hq, (-_b, i))

    ans = 0
    while len(hq) != 0:
        q = heappop(hq)
        if -q[0] == a[q[1]]:
            # 同じなら何もする必要はない
            continue
        elif -q[0] < a[q[1]]:
            # 増やすことは出来ないので、小さいなら構築不可
            ans = -1
            break

        ac = b[(q[1] - 1) % n] + b[(q[1] + 1) % n]
        if (b[q[1]] - a[q[1]]) // ac == 0:
            # 一致しておらず、さらに減らせないので構築不可
            ans = -1
            break
        else:
            # できる限り減らす
            tmp = (b[q[1]] - a[q[1]]) // ac
            b[q[1]] -= ac * tmp
            ans += tmp
            heappush(hq, (-b[q[1]], q[1]))
    
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 123956
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



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

	ll a, b;
	cin >> a >> b;
	cout << a * b / __gcd(a, b) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll X; cin >> X;
    vector<ll> v;
    REP(i,1001) {
        v.push_back(pow(i,5));
    }

    REP(i,v.size()) {
        REP(j,v.size()) {
            if (v[i] - v[j] == X) {
                cout << i << " " << j << endl;
                return 0;
            }

            if (v[i] + v[j] == X) {
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4084
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int n, m, a;
	scanf("%d%d", &n, &m);
	vector<int> bridge(n, 0);
	rep(i, m * 2) {
		scanf("%d", &a);
		++bridge[a - 1];
	}
	rep(i, n)printf("%d\n", bridge[i]);
	return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)
a = 0
ls = ["A","T","C","G"]
for i in range(l):
    for j in range(i + 1,l + 1):
        t = s[i:j]
        l2 = len(t)
        if a < l2:
            b = 0
            for k in range(l2):
                if t[k] not in ls:
                    b = 1
            if b == 0:
                a = l2

print(a)



Measured memory_bytes: 3060
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if (L[i] + L[j] > L[k]) and (L[i] != L[j] !=L[k]):
                ans += 1
print(ans)


Measured memory_bytes: 9124
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N, M;
vi a;

vl dp;

void solve() {

	cin >> N >> M;
	a.resize(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i];
	}
	dp.resize(N + 1);

	dp[0] = 1;
	int cur = 0;
	dp[1] = 1;
	if (a.size() != 0) {
		if (a[0] != 1) dp[1] = 1;
		else {
			dp[1] = 0;
			cur++;
		}
	}
	for (ll i = 2; i <= N; i++) {
		if (cur < M && i == a[cur]) {
			dp[i] = 0;
			cur++;
			continue;
		}
		dp[i] = dp[i - 1] + dp[i - 2];
		dp[i] %= MOD;
	}

	cout << dp[N] % MOD << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


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

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 3636
import sys
nums = list(map(lambda x: int(x), sys.stdin.readline().split()))
while not (nums[0] == 0 and nums[1] == 0):
  if nums[0] >  nums[1]:
    print(nums[1], nums[0])
  else:
    print(nums[0], nums[1])
  nums = list(map(lambda x: int(x), sys.stdin.readline().split()))


Measured memory_bytes: 5892
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

class HeapQueue:
    def __init__(self,flag): # flag == True 最小値pop / False 最大値pop
        if flag: self.inv = 1
        else: self.inv = -1
        self.hq = []
        heapq.heapify(self.hq)

    def push(self,x):
        heapq.heappush(self.hq,self.inv*x)

    def pop(self):
        return self.inv * heapq.heappop(self.hq)

    def is_empty(self):
        if self.hq:
            return False
        else:
            return True


N,M = inpl()
que = HeapQueue(False)
ABs = [inpl() for _ in range(N)]
ABs.sort()
ABs.append([M+5,0])

itr = 0
ans = 0
for d in range(1,M+1):
    while True:
        A,B = ABs[itr]
        if A > d:
            break
        else:
            que.push(B)
            itr += 1
    if not que.is_empty():
        ans += que.pop()

print(ans)


Measured memory_bytes: 32576
#include <bits/stdc++.h>
#define int long long 
using namespace std;
int lcm(int a,int b){
	return a*(b/__gcd(a,b));
}
int32_t main(){
	int a,b;cin>>a>>b;
	cout<<lcm(a,b)<<endl;
	return 0;
}

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

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < (n); i++){
        cin >> a[i];
    }
    a.push_back(a[0] + k);
    int l = 0;
    for (int i = 0; i < (n); i++){
        l = max(l, a[i + 1] - a[i]);
    }
    int ans = k - l;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a, int b){
	return a<b;
}
int main(){
	int n, i, j, Count = 0, max = 0, a;
	int m[100] = {0}, sum_s = 0, sum = 0;
	cin >> n;
	for(i = 0; i < n; i++){
		cin >> a;
		if(a%10!=0){
			m[Count++] = a;
			sum+=a;
		}else{
			sum_s += a;
		}
	}
	sort(m,m+Count,cmp);
	if(sum%10==0){
		if(sum!=0){
			sum=sum-m[0]+sum_s;
		}
	}else{
		if(sum!=0){
			sum+=sum_s;
		}
	}
	cout << sum << endl;
	return 0; 
} 

Measured memory_bytes: 256
h,w=map(int,input().split())
meize=[list(input()) for i in range(h)]
mod=10**9+7

dp=[[0]*(1+w) for i in range(1+h)]

dp[0][1]=1
for i in range(h):
  for j in range(w):
    if meize[i][j]=='#':
      dp[i+1][j+1]=0
    else:
      dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
      dp[i+1][j+1]%=mod

print(dp[h][w]%mod)

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

int div(int n){
    int cnt=0;
    int ans=1;
    for(int i=1;i<=n;i++){
        int num=i;
        int tmp=0;
        while(num%2==0){
            num/=2;
            tmp++;
        }
        if(tmp>cnt){
            cnt=tmp;
            ans=i;
        }
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    cout << div(n) << endl;
}


Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    A = int(input())
    B = int(input())

    s = list({1, 2, 3} - {A, B})
    print(s[0])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n = onem()

p = l()

pp = p[:]
pp.sort()
if p == pp:
	print("YES")
	exit()

for i in range(n):
	for j in range(i+1,n):
		ppp = p[:]
		ppp[i],ppp[j] = ppp[j],ppp[i]
		if all(pp[k] == ppp[k] for k in range(n)):
			print("YES")
			exit()
else:
	print("NO")







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


int main(){


    int n, i, t;

    int s = 0;

    vector<int> p;


    cin >> n;


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

         cin >> t;

         s += t;

         p.push_back(t);

         }


    sort( p.rbegin(), p.rend() );

    s -= p.at(0);

    s += p.at(0) / 2;


    cout << s << endl;

    
    return 0;


    }


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	
	public String result(int start, int stop){
		StringBuilder ans = new StringBuilder();
		if( start < stop ){
			for(int i = start; i <= stop; i++){
				ans.append(i + " ");
			}			
		} else {
			if( start < 6 ){
				for(int i = start; i >= stop; i--){
					ans.append(i + " ");
				}				
			} else {
				for(int i = start; i <= 9; i++){
					ans.append(i + " ");
				}
				if( stop < 6 ){
					for(int i = 5; i >= stop; i--){
						ans.append(i + " ");
					}					
				} else {
					for(int i = 5; i >= -5; i--){
						int x = Math.abs(i);
						ans.append(x + " ");
					}
					for(int i = 6; i <= stop; i++){
						ans.append(i + " ");
					}
				}
			}				
		}
		ans.deleteCharAt(ans.length()-1);
		return ans.toString();
	}
	public void solve() throws IOException{
		int n = nextInt();
		for(int i = 0; i < n; i++){
			int start = nextInt(), stop = nextInt();
			writer.println(result(start, stop));
		}
		writer.flush();
	}			
	public static void main (String args[]) throws IOException{
		new Main().run();
	}
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;
	
	public void run() throws IOException{
		try{
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e){
			e.printStackTrace();
			System.exit(1);
		}
	}
	public int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}		
	public String nextToken() throws IOException{
		while( tokenizer == null || !tokenizer.hasMoreTokens() ){
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}

Measured memory_bytes: 9368
#include <iostream>
#include <algorithm>
#include <cstring>
 
using namespace std;
const int K = 1e5+10;
int n, k;
int a[K], dp[K];
 
int main() 
{
  cin >> n >> k;
  memset(dp, 0, sizeof dp);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      if (i >= a[j] && !dp[i-a[j]]) {
        dp[i] = 1;
        break;
      }
    }
  }
  
  cout << (dp[k] ? "First" : "Second") << endl;
  
  return 0;
  
}

Measured memory_bytes: 640
b=input()
a=''
n=len(b)
for i in range(n):
  if b[i] == 'A':
    a += 'T'
  elif b[i] == 'T':
    a += 'A'
  elif b[i] == 'C':
    a += 'G'
  else:
    a += 'C'

print(a)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define pt pair<double,double>
#define x first
#define y second
const double INF=1e7;
pt p[100010];
double dist(pt a,pt b)
{return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
bool cmp(pt a,pt b){return a.y<b.y;}
double closest(int l,int r)
{
  if(l==r) return INF;
  int mid=(l+r)/2,pp=l,qq=mid+1;
  double midline=p[mid].x;
  double ret=min(closest(l,mid),closest(mid+1,r));
  vector<pt> slab;
  inplace_merge(p+l,p+mid+1,p+r+1,cmp);
  for(int i=l;i<=r;i++)
    if(abs(p[i].x-midline)<ret)
      slab.push_back(p[i]);
  for(int i=0;i<slab.size();i++)
    for(int j=i+1;j<slab.size() && abs(slab[i].y-slab[j].y)<ret;j++)
      ret=min(ret,dist(slab[i],slab[j]));
  return ret;
}
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>p[i].x>>p[i].y;
  sort(p+1,p+n+1);
  cout<<fixed<<closest(1,n)<<endl;
  return 0;
}

Measured memory_bytes: 7808
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 2e5 + 10; 
int n, a[N]; 

int main(int argc, char const *argv[]) {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]); 
        a[i] -= i;
    }
    sort(a + 1, a + n + 1); 
    int b = a[(n + 1) / 2];
    ll ans = 0; 
    for(int i = 1; i <= n; ++i) {
        ans += abs(a[i] - b);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
from sys import stdin
from collections import defaultdict, Counter

INF = int(1e10)
MOD = int(1e9 + 7)
M = 10 ** 6 + 5

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    cnt = [0] * M

    for a in A:
        if cnt[a] != 0:
            cnt[a] = 2
            continue
        for i in range(a, M, a):
            cnt[i] += 1

    ans = 0
    for a in A:
        if cnt[a] == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 105468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		double[]	point   = null;
		MyPolygon	polygon = new MyPolygon();

		while ((point = parsePoint()) != null) {
			polygon.AddEx(point);
		}

		System.out.printf("%.6f\n", polygon.calcSum());
	}

	private static double[] parsePoint() {
		String		line  = null;
		String[]	split = null;
		double[]	point = null;

		if ((line = parseStdin()) != null) {
			if (!line.isEmpty()) {
				split    = line.split(",");
				point    = new double[4];
				point[0] = Double.parseDouble(split[0]);
				point[1] = Double.parseDouble(split[1]);
			}
		}

		return point;
	}

	private static String parseStdin() {
		String	stdin = null;

		try {
			stdin = br.readLine();
		}
		catch (IOException e) {}

		return stdin;
	}
}

class MyPolygon extends ArrayList<double[]> {
	private	static	double[]	oPos = null;

	public void AddEx(double[] element) {
		int	len = size();

		if (len == 0) {
			oPos = element;
		}
		else {
			if (element[1] < oPos[1] || (element[1] == oPos[1] && element[0] < oPos[0])) {
				oPos = element;
			}
		}

		add(element);
		Collections.sort(this, new MyComparator());
	}

	public void clearEx() {
		clear();
		oPos = null;
	}

	public double calcSum() {
		int			max = size();
		double		z   = 0.0;
		double		sum = 0.0;
		double[][]	tmp = new double[2][];
		double[]	len = new double[3];

		if (max >= 3) {
			for (int n = 1; n < max - 1; n++) {
				tmp[0] = get(n);
				tmp[1] = get(n + 1);
				len[0] = tmp[0][2];
				len[1] = tmp[1][2];
				len[2] = Math.sqrt(Math.pow(tmp[0][1] - tmp[1][1], 2.0) + Math.pow(tmp[0][0] - tmp[1][0], 2.0));
				z      = (len[0] + len[1] + len[2]) / 2.0;
				sum   += Math.sqrt(z*(z - len[0])*(z - len[1])*(z - len[2]));
			}
		}

		return sum;
	}

	class MyComparator implements Comparator<double[]> {
		public int compare(double[] pos1,double[] pos2){
			pos1[2] = Math.sqrt(Math.pow(pos1[1] - oPos[1], 2.0) + Math.pow(pos1[0] - oPos[0], 2.0));
			pos1[3] = Math.atan2(pos1[1] - oPos[1], pos1[0] - oPos[0]);
			pos2[2] = Math.sqrt(Math.pow(pos2[1] - oPos[1], 2.0) + Math.pow(pos2[0] - oPos[0], 2.0));
			pos2[3] = Math.atan2(pos2[1] - oPos[1], pos2[0] - oPos[0]);

			return (pos1[3] == pos2[3]) ? (pos1[2] == pos2[2]) ? 0 : (pos1[2] < pos2[2]) ? -1 : 1 : (pos1[3] < pos2[3]) ? -1 : 1;
		}
	}
}

Measured memory_bytes: 16960
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>
using namespace std;
#define mod (long)(998244353)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int f = 0, s = 0, t = 0;
    for(int i = 0; i < N; i++){
        int P;
        cin >> P;
        f += (P <= A);
        s += (A + 1 <= P && P <= B);
        t += (B + 1 <= P);
    }
    cout << min({f, s, t}) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map> 
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pb push_back
int A[100005],B[100005];
int main(int argc, char** argv) {
	int a,b,m;
	cin>>a>>b>>m;
	int mna=1e9;
	int mnb=1e9;
	rep(i,1,a)
	{
		scanf("%d",&A[i]);
		mna=min(mna,A[i]);
	}
	rep(i,1,b)
	{
		scanf("%d",&B[i]);
		mnb=min(mnb,B[i]);
	}
	int ans=mna+mnb;
	rep(i,1,m)
	{
		int l,r,c;
		scanf("%d%d%d",&l,&r,&c);
		ans=min(A[l]+B[r]-c,ans);
	}
	cout<<ans;
		return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int MOD = 1000000007;

long long res[200010];

int main(){
	
	long long mi, ma;
	mi=ma=0;
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n+1;i++){
		mi = mi + i -1;
		ma = ma+ n-i+1;
		res[i] = ma + res[i-1] -mi +1;
		res[i]%=MOD;
	}
	long long r = res[n+1] - res[k-1];
	if(r<0)r+=MOD;
	cout<<r<<endl;
	
	return 0;
}

Measured memory_bytes: 4648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,p;cin>>n>>p;
  if(n==1){
    cout<<p<<endl;
    return 0;
  }
  ll ans=1;
  for(ll i=2;;i++){
    if(pow(i,n)>p)break;
    ll num=pow(i,n);
    if(p%num==0)ans=i;
  }
  cout<<ans<<endl;
}


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

string f(ll n) {
	if (n == 0) return "";
	n--;
	return f(n / 26) + string(1,'a' + n % 26);
}


int main() {
	long long n;
	cin >> n;
	cout << f(n) << "\n";
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans, x;
	cin >> n;
	vector<long long> a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a.begin(), a.end());

	x = a[n / 2];

	ans = 0;
	for (auto p : a) ans += abs(p - x);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;
	cin >> s;
	vector<int> a(26,0);
	for(int i = 0;i<s.size();i++){
		if (a[s[i] - 'a'] == 0){
			a[s[i] - 'a']++;
		}
	}

	int flag = 0;
	for(int i = 0;i<26;i++){
		if (a[i] == 0){
			cout << char(i + 'a') <<endl;
			flag = 1;
			break;
		}
	}
	if (flag == 0){
		cout << "None" << endl;
	}

	return 0;
}

Measured memory_bytes: 512