akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int H, W, A, B, **ans, flag=0, i, j, ans_0=0, ans_W=0, len;
	char S[100], T[10], U[10];

	scanf("%s", S);


	len = strlen(S);
//	printf("%d\n", len);

	for (i = 0; i < len; i++)
		printf("x");

	printf("\n");

	/*
	ans = (int **)malloc(sizeof(int *)* H);


	for (i = 0; i<H; i++) {
		ans[i] = (int *)malloc(sizeof(int)* W);
	}

	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			ans[i][j] = 0;
		}
	}
	*/

	return 0;

}
    


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
	int n;
	int key;
	cin>>n;
	int a[100000];
	for (int i = 0; i < n; i++)
		cin>>a[i];
	for (int i = 0; i < n; i++)
	{
		key = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > key)
		{
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
		cout<<a[0];
		for (int k = 1; k < n; k++)
		{
				cout << " "<< a[k] ;
		}
		cout <<endl;
	}
	return 0;
}

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

int main(){
  int64_t A,B,N;
  cin>>N>>A>>B;
  if((B-A)%2==0) cout<<(B-A)/2<<endl;
  else{
    if(A-1<N-B) cout<<A+(B-A-1)/2<<endl;
    else cout<<N-B+1+(B-A-1)/2<<endl;
  }
}


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

using namespace std;

int main() {
	long long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	
	vector<long long> p = {a, b, c, d, e};
	long long min = *min_element(p.begin(), p.end());

	cout << 4 + n / min + (n % min > 0 ? 1 : 0);
}


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

ll n,ans1,ans2,k,kk,p,pp;
cin>>n;
ll a[n],b[n],c[n],d[n];
for(int i=0;i<n;i++)
{
    cin>>a[i]>>b[i];
    c[i]=a[i]+b[i];
    d[i]=a[i]-b[i];
}
sort(c,c+n);
k=*max_element(c,c+n);
kk=*min_element(c,c+n);
p=*max_element(d,d+n);
pp=*min_element(d,d+n);
ans1=k-kk;
ans2=p-pp;
cout<<max(ans1,ans2)<<endl;
}


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


def dfs(i, A):
    global ans
    if i == n:
        res = 0
        for j in range(q):
            if A[l[j][1]] - A[l[j][0]] == l[j][2]:
                res += l[j][3]
        return res
    lim = 1
    lim = 1 if i == 0 else A[i-1]
    for k in range(lim, m+1):
        A[i] = k
        ans = max(ans, dfs(i+1, A))
    return ans

A = [0] * n
l = []
ans = 0

for i in range(q):
    a, b, c, d = map(int, input().split())
    l.append([a-1, b-1, c, d])

print(dfs(0, A))

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    string s;
    getline(cin, s);
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    std::cout << s;
    s[s.size() - 1] == '.' ? cout << '\n' : cout << ' ';

    return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
	int H, W, h, w, flag = 0;

	while (flag == 0)
	{
		scanf("%d %d", &H, &W);

		if ((H == 0) && (W == 0))
			break;

		for (w = 0; w < W; w++)
		{
			printf("#");
		}

		printf("\n");

		for(h = 0; h < (H - 2); h++)
		{
			printf("#");

			for (w = 0; w < (W - 2); w++)
			{
				printf(".");
			}

			printf("#\n");
		}
		
		for (w = 0; w < W; w++)
		{
			printf("#");
		}
	
		printf("\n\n");
	}

	return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define rep(i,s,t) for(int i=s;i<=t;i++)

using namespace std;

typedef long long LL;
LL ans1,ans2,sum;
int n;
int a[100010];

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	sum=0;
	for(int i=1,s=1;i<=n;i++,s*=-1){
		sum+=a[i];
		if(sum*s<=0) ans1+=abs(sum-s),sum=s;
	}
	sum=0;
	for(int i=1,s=-1;i<=n;i++,s*=-1){
		sum+=a[i];
		if(sum*s<=0) ans2+=abs(sum-s),sum=s;
	}
	printf("%lld\n",min(ans1,ans2));
	return 0;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,f=0;
	cin>>n;
	int a[n];
	for(int i=1 ; i<=n ; i++)
	{
		cin>>a[i];
		if(i%2==1 && a[i]%2==1)
			f++;
	}
	cout<<f<<endl;
	return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#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 FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 3010;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int n;
ld p[MAXN], dp[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> p[i];
    dp[0][0] = 1;
    FOR(i,1,n)
        FOR(head,0,i) {
            dp[i][head] += dp[i-1][head] * (1-p[i]);
            if (head) dp[i][head] += dp[i-1][head-1] * p[i];
        }
    ld res = 0;
    FOR(head,0,n) {
        int tail = n - head;
        if (head > tail) res += dp[n][head];
    }
    cout << fixed << setprecision(9) << res;
    return 0;
}


Measured memory_bytes: 69120
#include<bits/stdc++.h>
#include<queue>
using namespace std;
int main () {
  int N;
  cin >> N;
  priority_queue<long long, vector<long long>, greater<long long>>R;
  priority_queue<long long>B;
  vector<long long>R_a(N + 1, 0);
  vector<long long>B_a(N + 1, 0);
  vector<long long>A(N * 3);
  for (int i = 0; i < N * 3; i ++) cin >> A[i];
  for (int i = 0; i < N; i ++) {
    R_a[0] += A[i];
    R.push(A[i]);
  }
  for (int i = 1; i <= N; i ++) {
    int i_ = N - 1 + i;
    R_a[i] = R_a[i - 1] + A[i_];
    R.push(A[i_]);
    R_a[i] -= R.top();
    R.pop();
  }
  for (int i = N * 3 - 1; i >= N * 2; i --) {
    B_a[0] += A[i];
    B.push(A[i]);
  }
  for (int i = 1; i <= N; i ++) {
    int i_ = N * 2 - i;
    B_a[i] = B_a[i - 1] + A[i_];
    B.push(A[i_]);
    B_a[i] -= B.top();
    B.pop();
  }
  long long ans = 1e15;
  ans *= -1;
  //cout << ans << endl;
  for (int i = 0; i <= N; i ++) {
    int j = N - i;
    //cout << R_a[i] << ' ' << B_a[j] << endl;
    ans = max(ans, R_a[i] - B_a[j]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int time1 = h1 * 60 + m1;
  int time2 = h2 * 60 + m2;
  cout << time2 - time1 - k << endl;
}


Measured memory_bytes: 3632
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int X, Y;
  cin >> X >> Y;

  if (Y < X)
    swap(X, Y);
  if (Y - X >= 2)
    cout << "Alice" << endl;
  else
    cout << "Brown" << endl;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll 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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
const int MX = 305;
double dp[305][305][305];

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

    int n; cin >> n;
    int k;
    map<int, int> mp;
    rep(i,n) {
        cin >> k;
        mp[k-1]++;
    }

    double p = 1.0/n;
    rep(k, n+1) rep(j,n+1) rep(i, n+1) {
        int z = n - i - j - k;
        if (z < 0) break;
        if (z == n) continue;
        double x = 1 - z * p;
        if (i) dp[i][j][k] += dp[i-1][j][k] * i * p;
        if (j) dp[i][j][k] += dp[i+1][j-1][k] * j * p;
        if (k) dp[i][j][k] += dp[i][j+1][k-1] * k * p;
        dp[i][j][k] += 1;
        dp[i][j][k] /= x;
    }


//    rep(i, n+1) {
//        rep(j,n+1) {
//            rep(k, n+1) {
//                cout << dp[i][j][k] << ' ';
//            }
//            cout << endl;
//        }
//        cout << endl;
//    }
    cout << fixed << setprecision(10) << dp[mp[0]][mp[1]][mp[2]] << endl;
    return 0;
}


Measured memory_bytes: 219392
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(s) string(s);cin >> (s)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<int,int>
#define I vector<int>
#define V vector
#define S set<int>
#define pb(v) push_back(v)
LL cou[5];
int main(){
    CIN(N);
    V<string> s;
    REP(a,N){
        SCIN(str);
        s.pb(str);
    }
    REP(a,N){
        char q = s.at(a).at(0);
            if(q=='M'){
                cou[0]++;
            }
            if(q=='A'){
                cou[1]++;
            }
            if(q=='R'){
                cou[2]++;
            }
            if(q=='C'){
                cou[3]++;
            }
            if(q=='H'){
                cou[4]++;
            }
    }
    LL ans = 0;
    REP(a,5){
        FOR(b,a+1,5){
            FOR(c,b+1,5){
                if(a!=b&&a!=c&&b!=c){
                    ans += cou[a]*cou[b]*cou[c];
                }
            }
        }
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 6132
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String text = "";
        HashMap<Character, Integer> map = new HashMap<Character, Integer>();
        for (char i = 97; i < 123; i++) {
            map.put(i, 0);
        }
        while (scanner.hasNextLine()) {
            text += scanner.nextLine().toLowerCase();
        }
        for (int i = 0; i < text.length(); i++) {
            map.put(text.charAt(i), map.getOrDefault(text.charAt(i), 0) + 1);
        }
        for (char key = 97; key < 123; key++) {
            System.out.println(key + " : " + map.get(key));
        }
    }
}



Measured memory_bytes: 26012
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

bool is_square_num(lint num) {
    lint i = 1;
    while (i * i < num) {
        i += 1;
    }
    return i * i == num ? true : false;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    lint num = stoll(a + b);
    cout << (is_square_num(num) ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	char a[100];
	cin>>a;
	cout<<a[0]<<a[1]<<a[2]<<8<<a[4]<<a[5]<<a[6]<<a[7]<<a[8]<<a[9]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    long long int a[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int c=0;
    long long int y=n-1;
    while(c!=k)
    {
     a[y]=0;
     c++;
     y--;   
    }
    long long int sum=0;
    for(long long int i=0;i<n;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N=I()
    ans=1
    for i in range(10**5):
        a=i*i
        if a>N:
            ans=(i-1)*(i-1)
            break
    print(ans)

main()


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    auto g = make_vec<int>(H, W);
    REP(i, H) {
        REP(j, W){
            if((j < A && i < B) || (j >= A && i >= B)) g[i][j] = 1;
            else g[i][j] = 0;
        }
    }

    REP(i, H) {
        REP(j, W) cout << g[i][j];
        cout << endl;        
    }

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int dp[int(1e6+2)][2][2];
ll DFS(int i, int n, bool have_0, bool have_9) {
  if (i == n) return have_9 && have_0;
  if (dp[i][have_0][have_9] != -1) return dp[i][have_0][have_9];
  ll ans = 0;
  for (int x = 0; x <= 9; ++x) {
    ans += DFS(i+1, n, have_0 || (x==0), have_9 || (x==9));
    ans %= mod;
  }
  return dp[i][have_0][have_9] = ans;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  memset(dp, -1, sizeof(dp));
  cout << DFS(0, n, 0, 0) << endl;

}


Measured memory_bytes: 112892
#include <iostream>
using namespace std;
int main(){
  int n,i;
  string s;
  cin>>n>>s;
  int j=s.size()/2;
  if(s.size()%2==0){
  for(i=0;i<s.size()/2;i++,j++){
    if(s[i]!=s[j]){
      cout<<"No";
      break;
    }
   }
  }
  else if(s.size()%2==1){
  cout<<"No";
  }
  if(i==s.size()/2&&s.size()>1)cout<<"Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin >> s;
    
    if(s[0] == 'S')
        cout << "Cloudy" << endl;
    
    else if(s[0] == 'C')
        cout << "Rainy" << endl;
        
    else
        cout << "Sunny" << endl;
    
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

template <unsigned long long mod> class modint {
public:
	unsigned long long v;
	modint(const long long x = 0) : v(x % mod) {}
	modint operator+(const modint rhs) { return modint(*this) += rhs; }
	modint operator-(const modint rhs) { return modint(*this) -= rhs; }
	modint operator*(const modint rhs) { return modint(*this) *= rhs; }
	modint operator/(const modint rhs) { return modint(*this) /= rhs; }
	modint operator-() { return modint(mod - this->v); }
	modint& operator+=(const modint rhs) {
		v += rhs.v;
		if (v >= mod) v -= mod;
		return *this;
	}
	modint& operator-=(const modint rhs) {
		if (v < rhs.v) v += mod;
		v -= rhs.v;
		return *this;
	}
	modint& operator*=(const modint rhs) {
		v = v * rhs.v % mod;
		return *this;
	}
	modint inverse(modint a) {
		unsigned long long exp = mod - 2;
		modint ret(1ULL);
		while (exp) {
			if (exp % 2) { ret *= a; }
			a *= a;
			exp >>= 1;
		}
		return ret;
	}
	modint& operator/=(modint rhs) {
		(*this) *= inverse(rhs);
		return *this;
	}
	friend ostream& operator<<(ostream& os, modint& u) {
		os << u.v;
		return (os);
	}
	friend istream& operator>>(istream& is, modint& u) {
		is >> u.v;
		return (is);
	}
};

const int MOD = 1000000007;
using mint = modint<MOD>;

const int MAX = 200005;
mint fact[MAX], invfact[MAX], inv[MAX];

void facinit() {
	fact[0] = fact[1] = 1;	
	invfact[0] = invfact[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fact[i] = fact[i - 1] * i;
		inv[i] = - inv[MOD%i] * (MOD / i);
		invfact[i] = invfact[i - 1] * inv[i];
	}
}

mint nPr(int n, int r){
	return fact[n] * invfact[n-r];
}

mint nCr(int n, int r){
	if(n < 0|| r < 0 || n < r)return mint{0};
	return fact[n]*invfact[r]*invfact[n-r];
}

mint nHr(int n, int r){
	if(n == 0 && r == 0)return mint{1};
	return nCr(n+r-1, r);
}

class Solution {
public:
	void solve() {
		facinit();
		int h, w, a, b;
		cin >> h >> w >> a >> b;
		mint ans = nCr(h+w-2, h-1);
		for(int i = 0; i < a; i++){
			ans -= nCr(h-i+b-2, b-1)*nCr(i+w-b-1, i);
		}
		cout << ans << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vl a(n-1);
    rep(i,n-1) cin >> a[i];
    vl ans(n);
    rep(i,n-1){
        ans[--a[i]]++;
    }
    rep(i,n){
        printf("%lld\n",ans[i]);
    }
}


Measured memory_bytes: 6372
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   vector<int> a(n);
   f(i,0,n){
      cin >> a[i];
   }
   sort(all(a));
   int ans = 0;
   f(i,0,k){
      ans += a[i];
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){
    char c='A';
    c+=(n+(s[i]-'A'))%26;
    cout << c ;
  }
  cout << endl;
return 0;}

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

int main(){
  int x, i;
  i = 1;
  while (true){
    cin >> x;
    if (x == 0){
      break;
    }else{
      cout << "Case " << i << ": " << x << endl;
    }
    i += 1;
  }
}


Measured memory_bytes: 3076
#include<algorithm>
#include<iostream>
#include<cstring>
#include<climits>
#include<cstdio>
using namespace std;
int T,a[15],isac;
void dfs(int num,int left,int right)
{
    if(num==11){isac=1;return ;}
    if(a[num]>left)dfs(num+1,a[num],right);
    if(a[num]>right)dfs(num+1,left,a[num]);
}
int main()
{
    scanf("%d",&T);
    while(T--)
    {
        isac=0;
        for(int i=1;i<=10;i++)scanf("%d",&a[i]);
        dfs(1,0,0);
        if(isac)printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
	if (s[0] == s[1]) cout << "Bad" << endl;
	else if (s[1] == s[2]) cout << "Bad" << endl;
	else if (s[2] == s[3]) cout << "Bad" << endl;
	else cout << "Good" << endl;
}

Measured memory_bytes: 256
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
xs = Is()
c = []
for i in range(n-k+1):
    L,R = xs[i], xs[i+k-1]
    if L < 0 and R >= 0:
        c.append(-L + R + min(-L,R))
    else:
        c.append(max(abs(L),abs(R)))
        
print(min(c))

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

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

#define REP(i,m,n) for(int i=(int)m; i < (int) n; ++i)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()

vector<P> to[100010];
vector<int> ans;

void dfs(int color, int v, int parent = -1) {
  ans[v] = color;
  for(auto nv : to[v]) {
    if(nv.first == parent) continue;
    if(nv.second&1) {
      dfs(color^1, nv.first, v);
    } else {
      dfs(color, nv.first, v);
    }
  }
}

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

  int n; cin >> n;
  rep(i, n-1) {
    int u, v, w; cin >> u >> v >> w;
    u--, v--;
    to[u].push_back(make_pair(v, w));
    to[v].push_back(make_pair(u, w));
  }

  ans.resize(n);
  dfs(0, 0);
  rep(i, n) cout << ans[i] << '\n';
  return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> a(N);
    ll sum=0;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        a[i]=x-i-1;
    }
    sort(a.begin(),a.end());
    ll mid=a[N/2];
    for(int i=0;i<N;i++){
        sum+=abs(a[i]-mid);
    }
    cout << sum;

}

/*



 */


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

int64_t a[500000];//入力
int64_t w[500000];
int64_t merge_cnt(int64_t l, int64_t r){
        if(l + 1 >= r) return 0;//[l, r)だから要素0 or 1
        else if(l + 2 == r){//[l, l + 1], 要素2つのとき
                if(a[l] <= a[l + 1]) return 0;//反転なし
                else{
                        swap(a[l], a[l + 1]);
                        return 1;//反転1個
                }
        }
        else{//要素3以上
                int64_t m = (l + r) / 2;
                int64_t cl = merge_cnt(l, m);//[l, m)左側で数える
                int64_t cr = merge_cnt(m, r);//[m, r)右側
                int64_t i = l, j = m, c = 0;//iは左側要素, jは右側要素, cは並べ替えるときに見つけた反転
                int64_t k = l;//左側と右側見比べて小さいものからWに入れていく
                while(i < m && j < r){//並べる
                        if(a[i] <= a[j]) w[k++] = a[i++];//左要素のほうが小さいとき
                        else{//大きいとき
                                w[k++] = a[j++];
                                c += m - i;
                        }
                }
                //これ以降はどっちかが最後余ったときの処理
                while(i < m) w[k++] = a[i++];
                while(j < r) w[k++] = a[j++];
                assert(k == r);//確認
                copy(w + l, w + r, a + l);
                return cl + cr + c;
        }
}
int main(){
        int64_t n;
        cin >> n;
        for(int64_t i = 0; i < n; i++) cin >> a[i];
        cout << merge_cnt(0, n) << endl;
        return 0;
}



Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define F first
#define S second
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define one(x) cout<<#x<<" : "<<x<<endl;
#define two(x,y) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<endl;
#define three(x,y,z) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<" , "<<#z<<" : "<<z<<endl;
#define PI acos(-1)
const int M = 1000000007;
const int N=3e5+5;


signed main()
{
    int a , b;
    cin >> a >> b;
    if ( a - 2*b < 0){
        cout<<0<<endl;
    }
    else{
        cout<<a - 2*b <<endl;
    }

}




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

using namespace std;

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

	vector<float> X;
	vector<string> U;
	for (int i = 0; i < N; i++) {
		float x;
		string u;
		cin >> x >> u;
		X.push_back(x);
		U.push_back(u);
	}

	float total_yen = 0.0;
	for (int i = 0; i < N; i++) {
		if (U[i] == "JPY") {
			total_yen = total_yen + X[i];
		}
		else if (U[i] == "BTC") {
			total_yen = total_yen + X[i]* 380000.0;
		}
	}

	cout << total_yen << endl;

}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
		long n =fr.nextLong() ,i ,j ,k ,sm =0 ;
		for (i =1 ; i<=n ; ++i) {
		 	for (j =1 ; j<=n ; ++j) {
		 		for (k =1 ; k<=n ; ++k) {
		 			sm += gcd (i , gcd(j,k)) ;
		 		}
		 	}
		 } 
		 op.println(sm) ;
		op.flush();	op.close();
	}
	static long gcd (long num , long den) {
		if (num<den)	{	num^=den ;	den^=num ;	num^=den ;	}
		return (num%den == 0l ? den : gcd (den,num%den)) ;
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

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

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 33428
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int n;
const int MAX_V = 10010;

vector<vector<int>> G(MAX_V);
bool visited[MAX_V];
int indeg[MAX_V];
list<int> out;

void bfs(int s){
    queue<int> que;
    que.push(s);
    visited[s] = true;

    while(que.size()){
        int cv = que.front(); que.pop();
        out.push_back(cv);
        for(int i=0; i<G[cv].size(); i++){
            int nv = G[cv][i];
            indeg[nv]--;
            if(indeg[nv] == 0 && !visited[nv]){
                visited[nv] = true;
                que.push(nv);
            }
        }
    }
}

void tsort(){
    for(int i=0; i<n; i++){
        for(int j=0; j<G[i].size(); j++){
            int v = G[i][j];
            indeg[v]++;
        }
    }

    for(int i=0; i<n; i++){
        if(indeg[i] == 0 && !visited[i]) bfs(i);
    }

    for(auto i:out){
        cout << i << endl;
    }
}

int main(){
    int m; cin>>n>>m;
    for(int i=0; i<m; i++){
        int s, t; cin>>s>>t;
        G[s].emplace_back(t);
    }

    tsort();
}


Measured memory_bytes: 3816
#include <stdio.h>
#include <math.h>

int main( void ) {

	int s, t, dir = 90;
	double x = 0.0, y = 0.0, pi;

	pi = 4 * atan( 1.0 );

	while ( scanf( "%d,%d", &s, &t ) && ( s != 0 || t != 0 ) ) {

		x += s * cos( ( double ) dir / 180 * pi );
		y += s * sin( ( double ) dir / 180 * pi );
		dir -= t;

	}
	
    printf( "%d\n",( int ) x );
    printf( "%d\n",( int ) y );

	return 0;

}

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

int main(void) {
  int a, b, c, k;

  if(scanf("%d %d %d %d %d", &a, &b, &c, &k) == 1);

    for(int i = 0; i < k; i++) {
      if(b <= a && c <= a) {
        a *= 2;
      } else if(a <= b && c <= b) {
        b *= 2;
      } else {
        c *= 2;
      }
    }



  printf("%d", a + b + c);

  return 0;
}


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

int main(){
  int A[4], i, min, tmp;
  for(i = 0; i < 3; i++){
	cin >> A[i];
  }
  A[3] = A[0];
  min = 200;
  for(i = 0; i < 3; i++){
    tmp = A[i] + A[i+1];
    if(tmp < min){
      min = tmp;
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  
  int r[n];
  rep(i,n) r[i] = 0;
  rep(i,n) rep(j0,n-i-1) {
    int j = j0 + i + 1;
    int k = min(j - i, abs(x - i) + 1 + abs(y - j));
    r[k]++;
  }
  rep(i,n-1) cout << r[i+1] << endl;
  return 0;
}

Measured memory_bytes: 3204
N = int(input())
A = list(map(int, input().split()))
A_MAX = 10 ** 5
idx = [0] * (A_MAX + 1)
sum = 0
for i in A:
  idx[i] += 1
  sum += i
Q = int(input())
for i in range(Q):
  B, C = list(map(int, input().split()))
  sub = C - B
  num = idx[B]
  idx[B] = 0
  idx[C] += num
  sum += (sub * num)
  print(sum)

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

int main(){
  int n; cin >> n;
  vector<int> a(2*n);
  for(int i = 0; i < 2*n; i++){ cin >> a[i];}
  
  sort(a.begin(),a.end());
  
  ll ans = 0;
  
  for(int i = 0; i < n; i++){
    ans += min(a[2*i],a[2*i+1]);
  }
  
  cout << ans << endl; return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.Maybe (fromJust)
import Data.Ratio
import Data.List 

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  as <- getParms
  let (sw,s) = select as
  putStrLn $ show sw ++ " " ++ show s

type SW = Int -- SugarWater
type S  = Int -- Sugar

ratio :: (SW, S) -> Ratio Int
ratio (a,b) = if a==0 then -1    -- emergency evacuation
                      else b % a 

combinations :: [Int] -> [(SW,S)]
combinations [a,b,c,d,_e,f] 
  = [(w + s,s)
      | let fa = f `div` (100*a)
      , na <- [0 .. fa]
      , let fb = (f-100*a*na) `div` (100*b)
      , nb <- [0 .. fb]
      , let w = 100*(a*na + b*nb)
      , let fc = (f-w) `div` c
      , nc <- [0 .. fc]
      , let fd = (f-w-c*nc) `div` d
      , nd <- [0 .. fd]
      , let s = c*nc + d*nd
--      , na + nb > 0
--      , nc + nd > 0
      ]

select :: [Int] -> (SW,S)
select as@[a,b,c,d,e,f] = h e ls l
  where
    (l:ls) = combinations as

    h :: Int -> [(SW,S)] -> (SW,S) -> (SW,S)
    h _ []     best     = best
    h e (m:ms) best
      | rmax == rm      = m
      | rmax <  rm      = h e ms best
      | ratio best < rm
          && rm < rmax  = h e ms m
      | otherwise       = h e ms best
      where
        rm = ratio m
        rmax = ratio (e+100, e)

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

void solve() {
    int n, k;
    cin >> n >> k;

    int d;
    vector<int> cnt(n, 0);
    int x;
    for (int i = 0; i < k; ++i) {
        cin >> d;
        for (int j = 0; j < d; ++j) {
            cin >> x;
            ++cnt[x-1];
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (cnt[i] == 0) {
            ++res;
        }
    }
    cout << res << endl;
}

int main() {
    FAST_IO;

    int t;
    // cin >> t;
    t = 1;

    while (t--) {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3648
/* ----------------------- reclone_rk -------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;
#define re return
#define rep(i, n) for (int i = 0; i < (n); i++)
int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}

signed main()
{
	string s;
	cin>>s;
	if(s[2] == s[3]  && s[4] == s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	re 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void){
    int a, b;
 
    cin >> a >> b;

    if (a < b) cout << "a < b\n";
    else if (a > b) cout << "a > b\n";
    else cout << "a == b\n";

    return 0;
} 

Measured memory_bytes: 1124
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int a,b,c; cin>>a>>b>>c;
  cout<<(c<a? a-c:0)<<" "<<(c<a? b:(a+b-c<0? 0:a+b-c))<<endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	int t[n], x[n], y[n];
	REP(i, n) cin >> t[i] >> x[i] >> y[i];
	int fl = 1;
	int dx = x[0];
	int dy = y[0];
	int dt = t[0];
	REP(i, n){
		if(dx + dy > dt || (dx + dy) % 2 != (dt % 2)) fl = 0;
		if(i != n-1){
			dx = abs(x[i+1] - x[i]);
			dy = abs(y[i+1] - y[i]);
			dt = t[i+1] - t[i];
		}
	}
	if(fl == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


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

#define endl '\n'

int const MOD = 998244353;

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

    int n, s; cin >> n >> s;
    int a[n+1], dp[n+1][3001], ac[n+1][3001];
    for (int i=1; i<=n; i++) cin >> a[i];

    memset(dp, 0, sizeof dp);
    long long ans = 0;
    for (int i=1; i<=n; i++){
        dp[i][a[i]] = i;
        for (int j = a[i]+1; j<=s; j++){
            dp[i][j] = (dp[i][j] + ac[i-1][j - a[i]])%MOD;
            ac[i][j] = (dp[i][j] + ac[i-1][j])%MOD;
        }
        for (int j = a[i]; j>=1; j--) ac[i][j] = (dp[i][j] + ac[i-1][j])%MOD;
    }
    for (int i=1; i<=n; i++) ans = (ans + ( (((long long)dp[i][s] )*(n-i+1LL)))%MOD )%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 70656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static int m=1000000007;
    static long dp[][];
	public static long 	 Solve(int i,int womenset,int n,int comp[][]) {
		// Base Condn : No men is left
		if(i==n) {
			if(womenset==0) return 1;
			else return 0;
		}
		if(dp[i][womenset]!=-1) return dp[i][womenset];
		long ans=0;
		for(int women=0;women<n;women++) {
			boolean available= (((1<<women)&womenset)!=0);
		
			if(available&&comp[i][women]==1) {
				ans=(ans%m+ Solve(i+1, (womenset^(1<<women)), n, comp)%m)%m;
				
				
			}
		}
		dp[i][womenset]=ans;
	
		return dp[i][womenset];
	}
	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	// comp matrix
	int comp[][]=new int[n][n];
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) comp[i][j]=sc.nextInt();
	}
	dp=new long[n][1<<n];
	for(int i=0;i<n;i++) Arrays.fill(dp[i], -1);
	long ans=Solve(0, (1<<n)-1, n, comp);
	System.out.println(ans);
	
	

	}

	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

}





Measured memory_bytes: 413132