akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

typedef long long ll;


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

	int ans;

	if(s == "SUN") ans = 7;
	else if(s == "MON") ans = 6;
	else if(s == "TUE") ans = 5;
	else if(s == "WED") ans = 4;
	else if(s == "THU") ans = 3;
	else if(s == "FRI") ans = 2;
	else if(s == "SAT") ans = 1;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

inline int gcd(int a, int b)
{
	int r;
	if (a < b)
		r = a, a = b, b = r;

	while (r = a % b)
		a = b, b = r;

	return b;
}

int main()
{
	int n, x, xi, d, i;
	scanf("%d %d", &n, &x);

	scanf("%d", &xi);
	d = abs(xi - x);
	for (i = 1; i < n; i++) {
		scanf("%d", &xi);
		d = gcd(abs(xi - x), d);
	}

	printf("%d", d);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=LINF,a,b,c[11],d,cmp,cmpp,m,h,w,x,y,sum=0,pos,g,p[11];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>d>>g;
    rep(i,d)cin>>p[i]>>c[i];
    for(int bit=0;bit<(1<<d);bit++){
        ll toru[11],now=0,anss=0;
        map<ll,ll> mem;
        cnt=0;
        rep(i,d){
            if(bit&(1<<i)){
                toru[cnt++]=i;
                mem[i]=1;
            }
        }
        rep(i,cnt){
            now+=(toru[i]+1)*100*p[toru[i]]+c[toru[i]];
            anss+=p[toru[i]];
        }
        if(now>=g)ans=min(ans,anss);
        else{
            rrrep(i,d-1,0){
                if(mem[i]==1)continue;
                ll need;
                need=(g-now)/((i+1)*100);
                if((g-now)%((i+1)*100)!=0)need++;
                    anss+=need;
                    now+=min(need,p[i])*(i+1)*100;
                    break;
            }
            if(now>=g)ans=min(ans,anss);
        }
        //Cout(anss);
        if(anss==50){
            rep(i,cnt)Cout(toru[i]);
        }
    }
    Cout(ans);
    return 0;
}


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

int main()
{
  int64_t a,b,c,d,p,q,r,s;
  cin>>a>>b>>c>>d;
  p=a*d;
  q=a*c;
  r=b*c;
  s=b*d;
  cout<<max(p,max(q,max(r,s)))<<endl;
}

Measured memory_bytes: 3676
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> s;
	
	rep(i, 3)
	{
		if (s[i] == '1')
			a++;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    int cnt=0;
    long long int sum=0;
    vector<pair<long long int, long long int> >pairs;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        pair<long long int, long long int> p;
        cin >> p.first >> p.second;
        pairs.push_back(p);
    }
    sort(pairs.begin(), pairs.end());
    for(int i=0;i<n;i++){
        if(pairs.at(i).second<m-cnt){
            sum+=pairs.at(i).second*pairs.at(i).first;
            cnt+=pairs.at(i).second;
        }else{
            sum+=(m-cnt)*pairs.at(i).first;
            cnt+=(m-cnt);
        }
        if(cnt==m){
            break;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2420
/*
 * ARC098_C.cpp
 *
 *  Created on: May 26, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

string str;

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

	int N;
	cin >> N;
	cin >> str;
	int ans = 0;
	FOR(i, 1, N-1) {
		if(str[i] == 'E') {
			ans++;
		}
	}
	int now = ans;
	FOR(i, 1, N-1) {
		if(str[i-1] == 'W') {
			now++;
		}
		if(str[i] == 'E') {
			now--;
		}
		ans = min(ans, now);
	}

	cout << ans << endl;
}






Measured memory_bytes: 720
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Pattern a = Pattern.compile(">'(=+)#\\1~");
		Pattern b = Pattern.compile(">\\^(Q=)+~~");
		while (n-- > 0) {
			String line = scanner.next();
			Matcher ma = a.matcher(line);
			Matcher mb = b.matcher(line);
			if (ma.matches())
				System.out.println("A");
			else if (mb.matches())
				System.out.println("B");
			else
				System.out.println("NA");
		}
	}
}

Measured memory_bytes: 25672
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;


void solve()
{
    int n;
    scn(n);

    vvi shop(n, vi(10)), profit(n, vi(11));

    rep(i, 0, n) {
        rep(j, 0, 10)
            scn(shop[i][j]);
    }

    rep(i, 0, n) {
        rep(j, 0, 11)
            scn(profit[i][j]);
    }

    int ans = -100 * (int) 1e7;

    for(int i = 1; i < (1<<10); ++ i) {
        int here = 0;

        rep(k, 0, n) {
            int cnt = 0;
            rep(j, 0, 10) {
                if(((i >> j) & 1) and (shop[k][j]))
                    ++ cnt;
            }
            here += profit[k][cnt];
        }

        ans = max(ans, here);
    }

    prin(ans);
}

int main()
{
    int t = 1;
    // scn(t);
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3804
from itertools import permutations
N, M = map(int, input().split())
edge = []
for _ in range(M):
    a, b = map(int, input().split())
    edge.append(set((a, b)))

p = list(map(lambda x: [1] + list(x), permutations([i for i in range(2, N + 1)])))

ans = 0

for root in p:
    for i in range(len(root) - 1):
        if not set((root[i], root[i + 1])) in edge:
            break
    else:
        ans += 1

print(ans)


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

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

  ll ans = 0;
  for(int i = 1; i <= N; ++i) {
    if(i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }

  std::cout << ans << '\n';
}


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

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;

mint dp[63][2][2][2];
mint ans = 0;

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

    long long L, R;
    cin >> L >> R;

    dp[62][0][0][0] = 1;

    for (int i = 62; i >= 0; i--) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                for (int l = 0; l < 2; l++) {
                    for (int a = 0; a < 2; a++) {
                        for (int b = 0; b < 2; b++) {
                            if (a > b) continue;
                            if (!k && (L >> i & 1) == 1 && a == 0) continue;
                            if (!l && (R >> i & 1) == 0 && b == 1) continue;
                            if (j == 0 && a != b) continue;
                            int nk = k || (L >> i & 1) == 0 && a == 1;
                            int nl = l || (R >> i & 1) == 1 && b == 0;
                            if (i > 0) {
                                dp[i - 1][j || a == 1 && b == 1][nk][nl] += dp[i][j][k][l];
                            } else {
                                ans += dp[i][j][k][l];
                            }
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> vec(n);
    rep(i, n-1) {
        int tmp; cin >> tmp;
        tmp--;
        vec[tmp]++;
    }
    rep(i, n) cout << vec[i] << endl;
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> ans(N, 0);
  REP(i, N) FOR(j, i+1, N){
    ans[min(abs(i-j), min(abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(X-j)))]++;
  }

  FOR(i, 1, N) cout << ans[i] << endl;

  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int c = a + b;

  if(a%3 == 0) cout << "Possible" << endl;
  else if(b%3 == 0) cout << "Possible" << endl;
  else if(c%3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
char s[200];
int main(int argc, char const *argv[])
{
	int A, B;
	scanf("%d%d", &A, &B);
	scanf("%s", s);
	int len = strlen(s);
	if (len != A+B+1) return !printf("No\n");
	for (int i = 0; i < len; i++) {
		if (i < A && s[i] == '-') return !printf("No\n");
		else if (i > A && s[i] == '-' ) return !printf("No\n");
		else if (i == A and s[i] != '-') return !printf("No\n");
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a, b, c, x;
int ans;
int main()
{
	scanf("%d%d%d%d", &a, &b, &c, &x);
	for (int i = 0; i <= a && 500 * i <= x; i++)
	{
		for (int j = 0; j <= b && 100 * j + 500 * i <= x; j++)
		{
			for (int k = 0; k <= c && 50 * k + 100 * j + 500 * i <= x; k++)
			{
				if (500 * i + 100 * j + 50 * k == x)
					++ans;
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
def get_input():
    N = int(input())
    numbers = [int(i) for i in input().split()]
    return N, numbers

def DPsolve(N, numbers):
    count = 0
    dp = [[1 for i in range(len(numbers))] for j in range(len(numbers))]
    for i in range(N):
        for j in range(N-i):
            if j == 0:
                dp[i][j] = numbers[i]
            else:
                dp[i][j] = dp[i][j-1] + numbers[i+j]
            if dp[i][j] == 0:
                count += 1
    return dp, count

if __name__ == '__main__':
    N, numbers = get_input()
    s = [0]
    for i in range(N):
        s.append(s[-1] + numbers[i])
    s.sort()
    count = 1
    result = 0
    for i in range(N):
        if(s[i] == s[i+1]):
            count += 1
        else:
            result += count * (count -1 ) // 2
            count = 1
    result += count * (count -1 ) // 2
    print(result)

Measured memory_bytes: 25724
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


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

    if (A > 8 || B>8) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    static int Solve(int N, int[] A, int[] B)
    {
        Array.Sort(A);
        Array.Sort(B);
        if (N % 2 == 0)
        {
            int n1 = (N - 1) / 2;
            int n2 = (N + 0) / 2;
            return (B[n1] + B[n2]) - (A[n1] + A[n2]) + 1;
        }
        else
        {
            return B[N / 2] - A[N / 2] + 1;
        }
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var A = new int[N];
        var B = new int[N];
        for (int i = 0; i < N; ++i)
        {
            var V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            A[i] = V[0];
            B[i] = V[1];
        }
        Console.WriteLine(Solve(N, A, B));
    }
}


Measured memory_bytes: 42204
n, m = [int(i) for i in input().split()]
A = [int(input()) for i in range(m)]
p = int(1e9) + 7

is_broken = [False] * (n + 1)

for a in A:
    is_broken[a] = True

DP = [0] * (n + 2)
DP[0] = 1

for i in range(n):
    if is_broken[i]:
        DP[i] = 0
        continue
    
    DP[i + 1] += DP[i] % p
    DP[i + 2] += DP[i] % p

print(DP[n] % p)

Measured memory_bytes: 51160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;

int main(void){
  int n,k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++){
    long product = 1,two = i;
    double temp = 1;
    while(two < k){
      two *= 2;
      product *= 2;
    }
    temp /= n;
    temp /= product;
    ans += temp;
    //cout << product << endl;
  }
  cout << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> as(m); cin >> as;
    unordered_set<int> as2(as.begin(), as.end());
    vector<int> dp(n + 2);
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        if(dp[i]){
            if(!as2.count(i + 1)){ dp[i + 1] += dp[i]; }
            if(!as2.count(i + 2)){ dp[i + 2] += dp[i]; }
            dp[i + 1] %= M;
            dp[i + 2] %= M;
        }
    }
    cout << dp[n] << '\n';
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s,t;
	cin>>s>>t;
	ll a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s){
		a--;
	}
	else{
		b--;
	}
	cout << a<<" "<<b;
	// your code goes here
	return 0;
}

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

 
typedef pair<int,int>P;
 
int sosu[]={2,3,5,7,11,13,17,19,23,29,31,37},so=12;
 
int con(int n,string s){
  int res=0;
  for(int i=0;i<s.size();i++){
 
    res*=n;
     
    if(isalpha(s[i])){
      res+=(s[i]-'A')+10;
    }
    else{
      res+=(s[i]-'0');
    }
 
  }
  return res;
}
 
vector<int> bunkai(int n){
  vector<int>v;
  r(i,so){
    while(n%sosu[i]==0){
      n/=sosu[i];
      v.push_back(sosu[i]);
    }
  }
  return v;
}
 
signed main(){
 int N;
  string s;
  while( cin>>N>>s , N ){
    int n=N;
    int p=con(n,s);//cout<<p<<endl;
 
    vector<int>v=bunkai(n);
     
    vector<P>vec,vel;
 
    r(i,v.size()){
      int res=0;
      __int128 x=1;
      if(i&&v[i-1]==v[i])continue;
      __int128 pp=p;
      for(int j=1;;j++){
     
        x*=v[i];
 
        if(x>pp)break;
     
        res+=p/x;
      }
      vec.push_back(P(res,v[i]));
    }
     
    r(i,so){
      int res=0;
      r(j,v.size()){
        if(sosu[i]==v[j])res++;
      }
      if(res==0)continue;
      //cout<<sosu[i]<<' '<<res<<endl;
      //cout<<p/sosu[i]<<endl;
      vel.push_back(P(res,sosu[i]));
    }
 
    unsigned long long ans=ULLONG_MAX;
    r(i,vec.size()){
      ans=min(ans,(unsigned long long)(vec[i].first/vel[i].first));
    }
 
    cout<<ans<<endl;
  }
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll s=in<ll>();
    ll c=in<ll>();
    ll ans;ans=0;
    if(c>2*s){
        ans+=s;
        c-=2*s;
        ans+=c/4;
    }else{
        ans+=c/2;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        string s;
        cin >> s;
        int a = 0, b = 0;
        for(auto i : s){
            if(i == 'A'){
                a++;
            }else{
                b++;
            }
        }
        if(a == 0 || b == 0){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    } 
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n,k,c;
char a[N];
int l2[N];
int l1[N];
int ct1[N];
int ct2[N];
int f1[N], f2[N];
int mx = 0;
int main(){
    scanf("%d%d%d",&n,&k,&c);
    for (int i = 0; i < n; i++){
        scanf(" %c",&a[i]);
    }
    memset(f1,-1,sizeof(f1));
    memset(f2,-1,sizeof(f2));
    for (int i = 0; i < n; i++){
        if (a[i] == 'o'){
            l1[i] = mx+1;
            if (f1[l1[i]] == -1) f1[l1[i]] = i;
            ct1[l1[i]]++;
        }
        if (i >= c) {
            mx = max(mx,l1[i-c]);
        }
    }
    mx = 0;
    for (int i = n-1; i >= 0; i--){
        if (a[i] == 'o'){
            l2[i] = mx+1;
            if (f2[l2[i]] == -1) f2[l2[i]] = i;
            ct2[l2[i]]++;
        }
        if (i+c < n) {
            mx = max(mx,l2[i+c]);
        }
    }
    if (mx > k){
        return 0;
    }
    for (int i = 0; i < n; i++){
        if (f1[l1[i]] == i && f2[l2[i]] == i){
            printf("%d\n",i+1);
        }
    }
}


Measured memory_bytes: 6400
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b)
		printf("%d\n",c);
	else if(a==c)
		printf("%d\n",b);
	else
		printf("%d\n",a);
	return 0;
}

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

int n;

bool check(int x){
    string p=to_string(x);
    
    for(int i=1;i<(int)p.size();i++){
        if(p[i]!=p[i-1])
            return false;
    }

    return true;
}

int main(){
    cin >> n;

    while(1){
        
        if(check(n)){
            cout << n << endl;
            return 0;
        }else{
            n++;
        }
    }

    return 0;
}


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

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		
		long a = in.nextLong();
		long b = in.nextLong();
		long max = Math.max(a, b);
		
		if((a + b) % 2 == 0)
		{
			out.println((a + b) / 2);
			out.close();
			return;
		}
		
		
		out.println("IMPOSSIBLE");
		
		out.close();
	}
	
	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		
		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		
		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}
			
			return tokenizer.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
		
		public long nextLong()
		{
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<queue>

using namespace std;
static const int N=100;
static const int INFTY=(1<<21);

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  int i;

  for(i=0;i<n;i++)
    d[i]=INFTY;
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();
    q.pop();
    int v;
    for(v=0;v<n;v++){
      if(M[u][v]==0) continue;
      if(d[v]!=INFTY) continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(i=0;i<n;i++){
    cout<<i+1<<" "<<((d[i]==INFTY)?(-1):d[i])<<endl;
  }
}

int main(){
  int u,k,v,i,j;

  cin>>n;

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      M[i][j]=0;
  }

  for(i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

const int INF = 1000000010;

struct Segment{
    int pos, size, id;
    Segment(int pos, int size, int id): pos(pos), size(size), id(id) {}
    bool operator<(const Segment& right ) const {
        return pos == right.pos ? size < right.size : pos < right.pos;
    }
};

int main(){
    while(true){
        int N;
        cin >> N;
        if(N == 0) break;

        set<Segment> empty;
        empty.emplace(0, INF, -1);
        set<Segment> occupied;
        
        for(int i=0;i<N;i++){
            char cmd;
            cin >> cmd;
            if(cmd == 'W'){
                int id, size;
                cin >> id >> size;
                while(true){
                    Segment u = *empty.begin();
                    empty.erase(empty.begin());
                    if(u.size < size){
                        size -= u.size;
                        u.id = id;
                        occupied.insert(u);
                    }else{
                        empty.emplace(u.pos + size, u.size - size, -1);                    
                        occupied.emplace(u.pos, size, id);
                        break;
                    }
                }
            }else if(cmd == 'D'){
                int id;
                cin >> id;
                for(auto it=occupied.begin();it!=occupied.end();){
                    if(it->id == id){
                        empty.insert(*it);
                        occupied.erase(it++);
                    }else{
                        it++;
                    }
                }
            }else{
                int pos;
                cin >> pos;
                auto it = occupied.lower_bound(Segment(pos, INF, INF));
                bool found = false;
                if(it != occupied.begin()){
                    auto prev = next(it, -1);
                    if(prev->pos <= pos && pos < prev->pos + prev->size){
                        cout << prev->id << endl;
                        found = true;
                    }
                }
                if(!found){
                    cout << -1 << endl;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

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

using ll = long long int;
using namespace std;

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }

    return b;
}

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

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

    cout << lcm(A, B);
	return 0;
}

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

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

    for (char c = 'a'; c <= 'z'; c++)
    {
        bool found = false;
        for (char s : S)
        {
            if (c == s)
            {
                found = true;
                break;
            }
        }

        if (found == false)
        {
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a;
    vector<pair<int, int>> v_odd(100001);
    vector<pair<int, int>> v_even(100001);
    for(int i = 0; i <= 100000; i++){
        v_odd[i].first = 0;
        v_even[i].first = 0;
        v_odd[i].second = i;
        v_even[i].second = i;
    }
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(i % 2 == 0){
            v_odd[x].first++;
        }else{
            v_even[x].first++;
        }
    }
    sort(v_odd.begin(), v_odd.end());
    sort(v_even.begin(), v_even.end());
    reverse(v_odd.begin(), v_odd.end());
    reverse(v_even.begin(), v_even.end());
    if(v_odd[0].second != v_even[0].second){
        cout << n - v_odd[0].first - v_even[0].first;
    }
    else if(v_odd[0].first == v_even[0].first){
        if(v_odd[1].first >= v_even[1].first){
            cout << n - v_odd[1].first - v_even[0].first;
        }else{
            cout << n - v_odd[0].first - v_even[1].first;
        }
    }
    else if(v_odd[0].first > v_even[0].first){
        cout << n - v_odd[0].first - v_even[1].first;
    }
    else{
        cout << n - v_odd[1].first - v_even[0].first;
    }
}

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

int H,W;
char t[1000][1000];

int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>t[i][j];

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(t[i][j]=='#'){
        cout<<'#';
        continue;
      }
      int cnt=0;
      for(int di=-1;di<=1;di++){
        for(int dj=-1;dj<=1;dj++){
          if( i+di>=0 && i+di<H && j+dj>=0 && j+dj<W && t[i+di][j+dj]=='#' ){
            cnt++;
          }
        }
      }

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


Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split()))for i in range(2)]
x=a[0]
y=a[1]
total=-float("inf")
for k in range(n):
    ans=sum(x[:k+1])+sum(y[k:])
    total=max(ans,total)
print(total)
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

const vector<tuple<int, int>> dxy = {
        make_pair(1, 0),  // 右
        make_pair(1, 1),  // 右 下
        make_pair(0, 1),  // 下
        make_pair(-1, 1),  // 下　左
        make_pair(-1, 0),  // 左
        make_pair(-1, -1),  // 左 上
        make_pair(0, -1),  // 上
        make_pair(1, -1),  // 右 上
};

int main()
{
    int H, W; cin >> H >> W;
    string board[50];
    rep (i, 0, H) cin >> board[i];

    rep (i, 0, H) {
        rep (j, 0, W) {
            if ('#' == board[i][j]) continue;

            int num = 0;
            rep (k, 0, dxy.size()) {
                const int x = j + get<0>(dxy[k]);
                const int y = i + get<1>(dxy[k]);

                if (y < 0 or H <= y) continue;
                if (x < 0 or W <= x) continue;
                if ('#' == board[y][x]) num++;
            }
            board[i][j] = char(num + '0');
        }
    }

    rep (i, 0, H) cout << board[i] << endl;
}

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

using namespace std;
struct s
{
	int k;
	int f;
}a[100001];
int n,h,ans=0;
int comp1(const s&a,const s&b)
{
	if(a.k>b.k) return 1;
	else return 0;
}
int comp2(const s&a,const s&b)
{
	if(a.f>b.f) return 1;
	else return 0;
}
int main()
{
cin>>n>>h;
for(int i=1;i<=n;i++)
cin>>a[i].k>>a[i].f;
sort(a+1,a+n+1,comp1);
int maxx=a[1].k;
sort(a+1,a+n+1,comp2);
for(int i=1;i<=n;i++)
{
	if(a[i].f>maxx) ans++,h-=a[i].f;
	else break;
	if(h<=0) { cout<<ans;return 0; }
}
while(h>0)
{
	ans++;
	h-=maxx;
}
cout<<ans;
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
int main() {
  int N;
  std::string S;
  std::cin >> N >> S;

  int answer = 0;
  for (int i = 2; i < N; ++i) {
    if (S[i - 2] == 'A' && S[i - 1] == 'B' && S[i] == 'C') {
      ++answer;
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for (int i = 0; i < N; ++i) cin >> A[i], --A[i];
  for (int i = 0; i < N; ++i) cin >> B[i];
  for (int i = 0; i < N-1; ++i) cin >> C[i];
  long long res = 0;
  for (int i = 0; i < N; ++i) {
    res += B[A[i]];
    if (i+1 < N && A[i+1] == A[i]+1) res += C[A[i]];
  }
  cout << res << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) ((a) > (b) ? (a) : (b))

int asc(const void *a, const void *b){
  if(*(int *)a > *(int *)b) return 1;
  if(*(int *)b > *(int *)a) return -1;
  return 0;
}

int
main(int argc, char *argv[])
{
  long long n, a[100000];
  scanf("%lld", &n);
  for(int i = 0; i < n; i++) scanf("%lld", &a[i]);

  qsort(a, n, sizeof(long long), asc);

  

  if(n % 3 == 0){
    int flag[3] = {};
    for(int i = 1; i <= 3; i++){
      for(int j = (i - 1) * n / 3; j < i * n / 3; j++){
	if(a[(i - 1) * n / 3] != a[j]){
	  flag[i - 1]++;
	  break;
	}
      }
    }
    if(flag[0] == 0 && flag[1] == 0 && flag[2] == 0){
      if((a[0] ^ a[n / 3]) == a[2 * n / 3] && (a[0] ^ a[2 * n / 3]) == a[n / 3] &&
	 (a[n / 3] ^ a[2 * n / 3]) == a[0])
	printf("Yes\n");
      else printf("No\n");
    }
    else printf("No\n");
  }
  else{
    int flag = 0;
    for(int i = 0; i < n; i++){
      if(a[i] != 0){
	flag++;
	break;
      }
    }
    if(flag == 0) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}
	   


Measured memory_bytes: 1532
#include <iostream>

using namespace std;

#define repeat(i, start, end) for (int(i) = (start); (i) < (end); (i)++)
#define repeatR(i, end, start) for (int(i) = (end); (i) >= (start); i--)
#define times(n) for (int i = 0; i < n; i++)
#define len(ar) (sizeof(ar) / sizeof(ar[0]))

int main() {
  int N;
  cin >> N;
  int n = N, digitSum = 0;

  while (n != 0) {
    digitSum += n % 10;
    n /= 10;
  }

  string res = "No";
  if (N % digitSum == 0) res = "Yes";
  cout << res;
}

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

using namespace std;

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	int c = min(a, b), d = max(a, b);
	for (int i = 0; i < d; i++) {
		printf("%d", c);
	}
	printf("\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n , ans=0 ,l=0;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++) cin>>A[i];
    for(int k=0;k<n-1;k++){
      if(A[k]>=A[k+1]) l++;
      else l=0;
        ans=max(l,ans);
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
       int n;cin>>n;
       REP(i,1,9)REP(j,1,9){
           if(i*j == n){cout<<"Yes";return 0;}
       }
       cout<<"No";
    }
    


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

using line = pair<ll, ll>;

double x_int(line& l1, line& l2) {
    return (l2.second - l1.second) / ((double)(l1.first - l2.first));
}

double line_eval(line cur, double x) {
    return cur.first * x + cur.second;
}

double line_eval_ll(line cur, ll x) {
    return cur.first * x + cur.second;
}

void insert_line(line nline, vector<line>& lines, vd& ints) {
    while (!ints.empty()) {
        double curx = ints.back();
        double cury = line_eval(nline, curx);
        double hully = line_eval(lines.back(), curx);
        if (hully > cury){
            ints.pop_back();
            lines.pop_back();
        } else {
            break;
        }
    }

    if (ints.empty()) {
        ints.push_back(0);
        lines.push_back(nline);
    } else {
        ints.push_back(x_int(nline, lines.back()));
        lines.push_back(nline);
    }
}

ll query_lines(ll x, vector<line>& lines, vd& ints) {
    auto it = lower_bound(ints.begin(), ints.end(), (double)x);
    int ind = (it - ints.begin());

    return line_eval_ll(lines[ind-1], x);
}

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

    int N;
    ll C;
    cin >> N >> C;
    vll H(N);
    for(int i=0;i<N;i++) cin >> H[i];

    vll dp(N);
    dp[0] = 0;

    vd ints;
    vector<line> lines;

    ints.push_back(0);
    lines.push_back(make_pair(-2*H[0], dp[0] + H[0]*H[0]));

    for(int i=1;i<N;i++) {
        dp[i] = query_lines(H[i], lines, ints); // find min of lines

        dp[i] += C;
        dp[i] += H[i]*H[i];

        // add line
        line nline = make_pair(-2*H[i], dp[i] + H[i]*H[i]);
        insert_line(nline, lines, ints);
    }

    cout << dp[N-1] << endl;

    return 0;
}

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

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

int main()
{
  int h;
  int w;

  vector<pair<int, pair<int, int>>> list;
  for(int i = 1; i <= 150; ++i) {
    for(int j = i + 1; j <= 150; ++j) {
      list.push_back(
        make_pair(i*i + j*j, make_pair(i, j))
      );
    }
  }

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

  while(cin >> h >> w, (h|w)) {
    pair<int, pair<int, int>> p(h*h + w*w, pair<int, int>(h, w));

    for(auto v : list) {
      if(p < v) {
        cout << v.second.first << " " << v.second.second << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1332
#include<iostream>
 
int main()
{
	int num;
  	long long int num2=0;
	std::cin >> num;
  for(int i=0;i<=num/15-1;i++)
  {
  	num2+= 60+i*15*8;
  }
  for(int i=(num/15)*15;i <= num;i++)
  {

  	if(i%3==0||i%5==0)
    {
    }
    else
    {
          num2+=i;
    }
  }
  std::cout<<num2;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vint c(m,0), a(m);
    rep(i,m) {
        int a_, b_; cin >> a[i] >> b_;
        rep(j,b_) {
            int x; cin >> x;
            x--;
            c[i] += 1<<x;
        }
    }
    vint dp(1<<n,inf);
    dp[0] = 0;
    rep(i,m) {
        vint dp_2 = dp;
        rep(j,1<<n) chmin(dp_2[j|c[i]],dp[j]+a[i]);
        swap(dp_2,dp);
    }
    if (dp[(1<<n)-1] != inf) cout << dp[(1<<n)-1] << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[]args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int count = 0 ;
		int arr[][] = new int[n][m]; 
		
		for(int i = 0 ; i<n ; i++) {
			for(int j = 0 ; j< m ; j++) {
				arr[i][j] = scan.nextInt();
			}
		}
		
		for(int i = 0 ; i<n-1 ; i++) {
			
			for(int j = i+1 ; j< n ; j++) {
				int sum = 0 ; 
				for(int k = 0 ;k< m ; k++) {
					sum+=Math.pow(Math.abs(arr[i][k] - arr[j][k]),2);
				}
				if(Math.sqrt(sum) - (int)Math.sqrt(sum) == 0) {
					count++;
				}
			}
		
		}
		System.out.print(count);
		
		
		
		
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(305)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
int cnt[4],n;
ld dp[MAXN][MAXN][MAXN];
ld ev(int a,int b,int c)
{
	if(a==0 && b==0 && c==0)return 0;

	ld p_waste=((ld)n-a-b-c)/n;
	ld p_a=(ld)a/n,p_b=(ld)b/n,p_c=(ld)c/n;
	if(dp[a][b][c]>0)return dp[a][b][c];

	dp[a][b][c]=(1/(1-p_waste))*(1+
		(a==0?0:p_a*ev(a-1,b,c))+(c==0?0:p_c*ev(a,b+1,c-1))+(b==0?0:p_b*ev(a+1,b-1,c)));
	return dp[a][b][c]; 
}
int main()
{
	fastio;
	int a;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		cnt[a]++;
	}
	cout<<setprecision(15)<<ev(cnt[1],cnt[2],cnt[3])<<endl;

}


Measured memory_bytes: 436608
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

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

  int ans = 0;
  if(n<=1){
    ans+=0;
  }else{
    ans+=(n*(n-1))/2;
  }
  if(m<=1){
    ans+=0;
  }else{
    ans+=(m*(m-1))/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256