akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  ll n;
  cin >> n;
  vl a(n);
  re(i, n) cin >> a[i];

  int t = 0;
  re(i, n) {
    if(a[i] != 0) t++;
  }
  if(t != n) cout << 0 << endl;
  else {
    ll s = 1;
    bool can = true;
    re(i, n) {
      if(s > 1000000000000000000 / a[i]) {
      can = false;
      break;
      }
      s *= a[i];
    }
    if(can) cout << s << endl;
    else cout << -1 << endl;
  }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		StringBuilder sb = new StringBuilder();
		while (!(line = br.readLine()).equals("-1 -1 -1")) {

			int hc, mc, sc, h1, m1, s1, h3, m3, s3;
			hc = mc = sc = h1 = m1 = s1 = h3 = m3 = s3 = 0;
			
			StringTokenizer st = new StringTokenizer(line);
			hc = Integer.parseInt(st.nextToken());
			mc = Integer.parseInt(st.nextToken());
			sc = Integer.parseInt(st.nextToken());

			// sp
			s1 -= sc;
			if (s1 < 0) {
				s1 += 60;
				mc++;
			}
			m1 -= mc;
			if (m1 < 0) {
				m1 += 60;
				hc++;
			}
			h1 = 2 - hc;

			// ep
			s3 = s1 * 3;
			m3 = m1 * 3;
			h3 = h1 * 3;

			m3 += s3 / 60;
			s3 %= 60;

			h3 += m3 / 60;
			m3 %= 60;

			sb.append(String.format("%02d:%02d:%02d\n", h1, m1, s1));
			sb.append(String.format("%02d:%02d:%02d\n", h3, m3, s3));
		}
		System.out.print(sb.toString());
	}
}

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

int main(void)
{
    IOS
    int n, m;
    cin >> n >> m;
    vector<int> ac(n),wa(n);
    REP(i,m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") ac[p]++;
        else if (ac[p] == 0) wa[p]++;
    }

    int acount = 0, wcount = 0;
    REP(i,n) {
        if (ac[i] > 0) {
            acount++;
            wcount += wa[i];
        }
    }

    cout << acount << " " << wcount << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop(void);

int instack[200],stacknum=0;

int main(){
  int a,b;
  char s[200];

  while(1){
    if(scanf("%s",s)==EOF)break;
    switch(s[0]){
    case '+':
      a = pop();
      b = pop();
      push(a + b);
      break;
    case '-':
      b = pop();
      a = pop();
      push(a - b);
      break;
    case '*':
      a = pop();
      b = pop();
      push(a * b);
      break;
    default:
      push(atoi(s));
      break;
    }

  }

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

void push(int num){
  instack[stacknum] = num;
  stacknum++;
}

int pop(void){
  return instack[--stacknum];

}

Measured memory_bytes: 976
n,c,k,*t=`cat`.split.map(&:to_i)
t.sort!


cnt=0
i=0

while(t[i])
  tmp=t[i]+k
  cnt+=1
  c.times do
    i+=1
#    p t[i]-tmp                                                                                                                       
    if(t[i]&&tmp<t[i])
#      p [tmp,i,"hoge"]                                                                                                               
      break;
    end
  end

#  printf("cnt=%d\n",cnt)                                                                                                             
end
puts cnt


Measured memory_bytes: 11976
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int gcd2(int x, int y) { return (x % y)? gcd2(y, x % y): y; }
int gcd(int x, int y, int z) { return gcd2(x, gcd2(y, z)); }

int main() {
    int K;
    cin >> K;
    long long ret = 0;
    for(int i=1; i<=K; ++i) {
        // ptn1: pick all
        ret += i;

        for(int j=1; j<=K; ++j) {
            if(i == j)
                continue;
            //cout << i << " " << i << " " << j << endl;
            ret += gcd(i, i, j) * 3;
        }
    }
    for(int i=1; i<=K-2; ++i) {
        for(int j=i+1; j<=K-1; ++j) {
            for(int k=j+1; k<=K; ++k) {
    //            cout << i << " " << j << " " << k << endl;
                ret+=gcd(i, j, k) * 6;
            }
        }
    }
    cout << ret << endl;
    // pnt2: dup 2 {


    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >>a >>b >>c >>d;
  
  if(a + b > c + d){
    cout <<"Left" <<endl;
  }
  
  else if(a + b == c + d){
    cout <<"Balanced" <<endl;
  }
  
  else{
    cout <<"Right" <<endl;
  }

}



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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();

  int n;
            
  cin >> n;   
  multiset <int> s;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    s.insert (x);
  }
  int ans = 0;
  while (!s.empty()) {
    int x = *s.rbegin(); 
    s.erase (s.find (x));   
    int y = (1<<(int)log2(x)+1)-x;
    if (s.count (y))
      ans++, s.erase (s.find(y));
  }
  cout << ans;


  return 0;
}






// Coded by Z..


Measured memory_bytes: 9600
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int N,A,B;
    string ans;
    cin >> N>>A>>B;
    if(N==1){
        cout << "Hello World" << endl;
    }else{
        cout <<  A+B << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

const int N = 5e5 + 5, MOD = 1e9 + 7;

struct mi {
    ll v;

    explicit operator ll() const { return v; }

    mi() { v = 0; }

    mi(ll _v) {
        v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
        if (v < 0) v += MOD;
    }

    friend bool operator==(const mi &a, const mi &b) {
        return a.v == b.v;
    }

    friend bool operator!=(const mi &a, const mi &b) {
        return !(a == b);
    }

    friend bool operator<(const mi &a, const mi &b) {
        return a.v < b.v;
    }

    mi &operator+=(const mi &m) {
        if ((v += m.v) >= MOD) v -= MOD;
        return *this;
    }

    mi &operator-=(const mi &m) {
        if ((v -= m.v) < 0) v += MOD;
        return *this;
    }

    mi &operator*=(const mi &m) {
        v = v * m.v % MOD;
        return *this;
    }

    mi &operator/=(const mi &m) { return (*this) *= inv(m); }

    friend mi pow(mi a, ll p) {
        mi ans = 1;
        assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p & 1) ans *= a;
        return ans;
    }

    friend mi inv(const mi &a) {
        assert(a.v != 0);
        return pow(a, MOD - 2);
    }

    mi operator-() const { return mi(-v); }

    mi &operator++() { return *this += 1; }

    mi &operator--() { return *this -= 1; }

    mi operator++(int) {
        mi temp;
        temp.v = v++;
        return temp;
    }

    mi operator--(int) {
        mi temp;
        temp.v = v--;
        return temp;
    }

    friend mi operator+(mi a, const mi &b) { return a += b; }

    friend mi operator-(mi a, const mi &b) { return a -= b; }

    friend mi operator*(mi a, const mi &b) { return a *= b; }

    friend mi operator/(mi a, const mi &b) { return a /= b; }

    friend ostream &operator<<(ostream &os, const mi &m) {
        os << m.v;
        return os;
    }

    friend istream &operator>>(istream &is, mi &m) {
        ll x;
        is >> x;
        m.v = x;
        return is;
    }
};

mi facs[N], facInvs[N];

mi nCr(mi a, mi b) {
    if ((ll) b > (ll) a) return 0;
    if ((ll) a < 0) return 0;
    if ((ll) b < 0) return 0;
    mi cur = facs[(ll) a];
    cur = cur * facInvs[(ll) b];
    cur = cur * facInvs[(ll) a - (ll) b];
    return cur;
}

void initFacs() {
    facs[0] = 1;
    facInvs[0] = 1;
    for (int i = 1; i < N; i++) {
        facs[i] = (facs[i - 1] * i);
        facInvs[i] = inv(facs[i]);
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    initFacs();
    int n, m;
    cin >> n >> m;
    mi ans = 0, cur = 1;
    for (int i = 0; i <= n; i++) {
        ans += cur * facs[n - i] * nCr(m - i, n - i) * nCr(n, i);
        cur = -cur;
    }
    cout << ans * facs[n] * nCr(m, n) << "\n";
    return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, M;
int A[110000], B[110000], C[110000];
pint CB[110000];

signed main() {
    cin >> N >> M;
    for (int i = 1; i <= N; i++)cin >> A[i];
    for (int i = 1; i <= M; i++) {
        cin >> B[i] >> C[i];
        CB[i] = pint(C[i], B[i]);
    }
    sort(A + 1, A + N + 1);
    sort(CB + 1, CB + M + 1);
    reverse(CB + 1, CB + M + 1);
    int j = 1;
    for (int i = 1; i <= M; i++) {
        for (; CB[i].second > 0; CB[i].second--) {
            if (CB[i].first <= A[j])goto out;
            A[j] = CB[i].first;
            j++;
            if (j > N)goto out;
        }
    }
    out:;
    int ans = 0;
    for (int i = 1; i <= N; i++)ans += A[i];
    cout << ans << endl;

}

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

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

    map<ll, ll> l, r;

    rep(i, n) {
        ++l[i + a[i]];
        ++r[i - a[i]];
    }

    ll ans = 0;
    for (auto &p : l) {
        ans += p.second * r[p.first];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 38156
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    int A,B,C;
    cin>>A>>B>>C;

    
    if (A+B>=C) {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

if n < 357:
    print(0)
else:
    ans = 0
    for i in range(3, 10):
        for j in range(3**i):
            a = ''
            val = Base_10_to_n(j, 3).zfill(i)
            for k in val:
                if k == '1':
                    a += '3'
                elif k == '2':
                    a += '5'
                else:
                    a += '7'
            if len(set(a)) == 3 and n >= int(a):
                ans += 1
    print(ans)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, x, tmp; sc(n)
    ll ans = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++){
        sc(x) ++mp[x];
    }
    for (const auto &i : mp){
        tmp = i.second - i.first;
        if (tmp >= 0) ans += min(tmp, i.second);
        else ans += i.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main () {
    map<char, int> m;
    char c;
    int x = 0;
    int ans = 0;
    while (cin >> c) {
        if (c == 'I') {
            x++;
        }
        else if (c == 'D') {
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << endl;
}

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

int main(){
  string s;
  vector<char> c;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    c.push_back(s.at(i));
  }
  char batu = 'x';
  int count = 0;
  for(int i = 0;i < s.size();i++){
    if(c[i] == batu){
      count++;
    }
  }
  if(count >= 8){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define IREP(i, v) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(i, v) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const ll LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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


int main(){
    ll N; cin >> N;
    FORS(h, 1, 3500){
        FORS(n, 1, 3500){
            ll numerator(N*h*n), dominator(4*h*n - N*h - N*n);
            if(dominator <= 0) continue;
            if(!(numerator % dominator)){
                cout << h << " " << n << " ";
                cout << numerator/dominator << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1e9;

template<int V, class T = ll>
class max_flow {
	struct edge {
		int t, rev;
		T cap, f;
	};
	vector<edge> adj[V];
	int dist[V];
	int ptr[V];
	bool bfs(int s, int t) {
		memset(dist, -1, sizeof dist);
		dist[s] = 0;
		queue<int> q({ s });
		while (!q.empty() && dist[t] == -1) {
			int n = q.front();
			q.pop();
			for (auto& e : adj[n]) {
				if (dist[e.t] == -1 && e.cap != e.f) {
					dist[e.t] = dist[n] + 1;
					q.push(e.t);
				}
			}
		}
		return dist[t] != -1;
	}
	T augment(int n, T amt, int t) {
		if (n == t) return amt;
		for (; ptr[n] < adj[n].size(); ptr[n]++) {
			edge& e = adj[n][ptr[n]];
			if (dist[e.t] == dist[n] + 1 && e.cap != e.f) {
				T flow = augment(e.t, min(amt, e.cap - e.f), t);
				if (flow != 0) {
					e.f += flow;
					adj[e.t][e.rev].f -= flow;
					return flow;
				}
			}
		}
		return 0;
	}
public:
	void add(int u, int v, T cap = 1, T rcap=0) {
		adj[u].push_back({ v, (int) adj[v].size(), cap, 0 });
		adj[v].push_back({ u, (int) adj[u].size() - 1, rcap, 0 });
	}
	T calc(int s, int t) {
		T flow = 0;
		while (bfs(s, t)) {
			memset(ptr, 0, sizeof ptr);
			while (T df = augment(s, INF, t)) flow += df;
		}
		return flow;
	}
	void clear() {
		for (int n = 0; n < V; n++) adj[n].clear();
	}
};

char C[101][101];

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

	int H, W;
	cin >> H >> W;
	max_flow<202> MF;
	int s, t;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> C[i][j];
			if (C[i][j] == 'o') MF.add(i, j + H, 1, 1);
			else if (C[i][j] == 'S') {
				MF.add(i, j + H, INF, INF);
				s = i;
			}
			else if (C[i][j] == 'T') {
				MF.add(i, j + H, INF, INF);
				t = j + H;
			}
		}
	}
	ll ans = MF.calc(s, t);
	cout << (ans < INF ? ans : -1) << '\n';
	return 0;
}

Measured memory_bytes: 896
def main():
    n = int(input())    
    s = input()

    cnd = set()
    for i in range(10):
        idx_i = s.find(str(i))
        if idx_i == -1:
            continue
        for j in range(10):
            idx_j = s.find(str(j), idx_i+1)
            if idx_j == -1:
                continue
            for k in range(10):
                idx_k = s.find(str(k), idx_j+1)
                if idx_k == -1:
                    continue
                st = str(i)+str(j)+str(k)
                cnd.add(str(i)+str(j)+str(k))

    print(len(cnd))
main()

Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(w: str):
    count = [0] * 26
    for c in w:
        count[ord(c) - ord('a')] += 1
    for cnt in count:
        if cnt % 2:
            print(NO)
            return
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    w = next(tokens)  # type: str
    solve(w)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,Ma,Mb;
ll dp[50][410][410];
ll a[50],b[50],c[50];
int main(){
    cin>>N>>Ma>>Mb;
    for(ll i=0;i<=N;i++){
        for(ll j=0;j<=400;j++){
            for(ll k=0;k<=400;k++){
                dp[i][j][k]=INF;
            }
        }
    }
    dp[0][0][0]=0;
    for(ll i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(ll i=0;i<N;i++){
        for(ll j=0;j<=400;j++){
            for(ll k=0;k<=400;k++){
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
            }
        }
    }
    ll ans=INF;
    for(ll i=0;i<=400;i++){
        for(ll j=0;j<=400;j++){
            if(i!=0 && j!=0 && i*Mb==j*Ma){
                ans=min(ans,dp[N][i][j]);
            }
        }
    }
    cout<<(ans==INF?-1:ans)<<endl;
}

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

#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;

#define sqr(a) ((a)*(a))
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define nrof(i, n) for(int i = (int)n - 1; i >= 0; --i)
#define rep(i, k, n) for(int i = (int)k; i < (int)n; ++i)
#define per(i, k, n) for(int i = (int)k - 1; i >= (int)n; --i)
#define x first
#define y second
#define mp make_pair
#define sz(a) (int)(a.size())
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e6 + 9;
const int M = 2e3 + 9;
const int INFINT = 1e9 + 9;
const ll INFLL = 1e18 + 9;
const ll MOD = (ll) (1000000007);

vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, -1, 0, 1};

void solve() {
    ll d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3648
var int = x=>parseInt(x,10);var spln = x=>x.split(/\n/g);var spsp = x=>x.split(/\s/g);
function main(input) {
  var a = spln(input);
  var n = int(spsp(a[0])[0]);
  var x = int(spsp(a[0])[1]);
  var s = spsp(a[1]).slice(0,n).map(x=>int(x));
  var m = s.map((sa)=>Math.abs(sa-x));
  console.log(go(m))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function go(array){
  function euc(A,B){
    var a = Math.max(A,B),b = Math.min(A,B);
   while(b!==0){
      var k = b;
      b = a%b;
      a = k;
    }
    return a;
  }
  return array.reduce((p,c)=>{
    return p?euc(p,c):c
  })
}

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

#define FALSE 0
#define TRUE 1

struct point
{
	double x;
	double y;
};

void initialize(double array[], int n);
double calculate_edge(double edge[], double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
double helon(double edge1, double edge2, double edge3);
int judge(double area[]);
void output(int flag);
main()
{
	struct point a = {0, 0};
	struct point b = {0, 0};
	struct point c = {0, 0};
	struct point d = {0, 0};
	int flag = 0;
	double edge[6]; //辺の長さを代入する為の配列
	double area[4]; //面積を代入する為の配列
	initialize(edge, 6);
	initialize(area, 4);
	
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &d.x, &d.y) != EOF)
	{
		calculate_edge(edge, a.x, a.y, b.x, b.y, c.x, c.y, d.x, d.y);
		area[0] = helon(edge[0], edge[1], edge[2]);
		//printf("area[0] = %lf\n", area[0]);
		area[1] = helon(edge[0], edge[3], edge[5]);
		//printf("area[1] = %lf\n", area[1]);
		area[2] = helon(edge[1], edge[3], edge[4]);
		//printf("area[2] = %lf\n", area[2]);
		area[3] = helon(edge[2], edge[4], edge[5]);
		//printf("area[3] = %lf\n", area[3]);
		flag = judge(area);
		output(flag);
		initialize(edge, 6);
	initialize(area, 4);
	}
	return 0;
}

void initialize(double array[], int n)
{
	int i = 0;
	for(i = 0; i < n; i++)
	{
		array[i] = 0;
	}
}

double calculate_edge(double edge[], double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
{
	edge[0] = sqrt(pow(x1 - x4, 2) + pow(y1 - y4, 2));
	edge[1] = sqrt(pow(x2 - x4, 2) + pow(y2 - y4, 2));
	edge[2] = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
	edge[3] = sqrt(pow(x3 - x4, 2) + pow(y3 - y4, 2));
	edge[4] = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2));
	edge[5] = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
}

double helon(double edge1, double edge2, double edge3)
{
	double s = (edge1 + edge2 + edge3) / 2;
	double result = sqrt(s * (s - edge1) * (s - edge2) * (s - edge3));
	return result;
}
int judge(double area[])
{
	int i = 0, j = 0, temp = 0;
	for(i = 0; i < 4; i++)
	{
		for(j = i; j < 4; j++)
		{
			if(area[i] < area[j])
			{
				temp = area[i];
				area[i] = area[j];
				area[j] = temp;
			}
		}
	}
	
	if(area[0] <= (area[1] + area[2] + area[3]))
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
void output(int flag)
{
	if(flag == TRUE)
	{
		puts("YES");
	}
	else
	{
		puts("NO");
	}
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<lint> A(N);
    rep(i, N) cin >> A[i];
    int color = 0;

    vector<vector<int>> ans(H, vector<int>(W, 2));

    for (int i = 0; i < H; i++) {
        if (i % 2 == 0)
            for (int j = 0; j < W; j++) {
                ans[i][j] = color + 1;
                A[color]--;
                if (A[color] == 0) color++;
            }
        else {
            for (int j = W - 1; 0 <= j; j--) {
                ans[i][j] = color + 1;
                A[color]--;
                if (A[color] == 0) color++;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << ans[i][j] << (j < W - 1 ? ' ' : '\n');
        }
    }

    return 0;
}

Measured memory_bytes: 3680
#include <algorithm>
#include <array>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#ifdef ENABLE_ASSERT
#include <cassert>
#else
#undef assert
#define assert static_cast<void>(0)
#endif

using namespace std;
using namespace std::literals;

int main() {
    int n;
    cin >> n;
    auto len = vector<int>(n);
    auto count_of = vector<int>(2000 + 5);
    auto count_of_longer_than = vector<int>(2000 + 5);
    auto count_of_shorter_than = vector<int>(2000 + 5);

    for (auto &len_i : len) {
        cin >> len_i;
        count_of[len_i]++;
    }

    count_of_longer_than[0] = n;
    count_of_shorter_than[0] = 0;
    for (int x = 1; x <= 2000; x++) {
        count_of_longer_than[x] = count_of_longer_than[x - 1] - count_of[x];
        count_of_shorter_than[x] = count_of_shorter_than[x - 1] + count_of[x - 1];
    }

    sort(len.begin(), len.end());
    // let a <= b && b <= c
    // 1. a < b + c --> always
    // 2. b < c + a --> b - a < c
    // 3. c < a + b --> b + a > c

    auto sum = 0ULL;
    for (int i = 0; i + 2 < n; i++) {
        const int a = len[i];
        for (int j = i + 1; j + 1 < n; j++) {
            const int b = len[j];
            const int c_min = b - a + 1;
            const int c_max = b + a - 1;

            int index_c_min = count_of_shorter_than[c_min];
            int index_c_max = (int)(len.size()) - count_of_longer_than[c_max] - 1;

            if (index_c_min < j + 1)
                index_c_min = j + 1;
            if (index_c_min > index_c_max)
                continue;

            int num = index_c_max - index_c_min + 1;
            sum += num;
        }
    }

    cout << sum;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    public class Program
    {
        public static void Main()
        {
            int i;
            int n,k;
            int []num_treat;
            string line = System.Console.ReadLine();
            string []input = line.Split(' ');
            n = int.Parse(input[0]);
            k = int.Parse(input[1]);
            num_treat = new int[n];
            for(i=0;i<k;i++){
                line = System.Console.ReadLine();
                line = System.Console.ReadLine();
                input = line.Split(' ');
                foreach(string s in input){
                    num_treat[int.Parse(s)-1]++;
                }
            }
            int num_trick=0;
            for(i=0;i<n;i++){
                if(num_treat[i] == 0) num_trick++;
            }
            System.Console.WriteLine(num_trick.ToString());
        }
    }
}


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

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N*3);
  for(int i=0;i<N*3;++i){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll p=0;
  for(int i=1;i<N*2;i+=2){
    p += a.at(i);
  }
  cout << p << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <fstream>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldb = long double;

#define forn(i, x, n) for (int i = x; i < (int)(n); ++i)
#define sqr(x) ((x) * 1ll * (x))

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    int n;
    cin >> n;
    unordered_map<ll, ll> m;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
       ll next;
       cin >> next;
       sum += next;
       m[sum]++;
    }
    ll ans = 0;
    for (auto i : m) {
        //cout << i.first << " " << i.second << "\n";
        ans += ((i.second - 1) * i.second / 2);
        if (i.first == 0) {
            ans += i.second;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8520
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	int n;
	cin >> n;
	if (n < 1000)PRI("ABC");
	else PRI("ABD");
	return 0;
}

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

int main(){
    int n; string op;
    cin >> n;
    int a = n/1000, b = n/100-a*10, c = n/10-b*10-a*100, d = n - 1000*a - 100*b -10*c;
    int ans;
    while(true){
        op = "+++"; ans = a+b+c+d; if(ans==7) break;
        op = "++-"; ans = a+b+c-d; if(ans==7) break;
        op = "+-+"; ans = a+b-c+d; if(ans==7) break;
        op = "-++"; ans = a-b+c+d; if(ans==7) break;
        op = "--+"; ans = a-b-c+d; if(ans==7) break;
        op = "+--"; ans = a+b-c-d; if(ans==7) break;
        op = "-+-"; ans = a-b+c-d; if(ans==7) break;
        op = "+++"; ans = a+b+c+d; if(ans==7) break;
    }
    cout << a << op[0] << b << op[1] << c << op[2] << d << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
import statistics
import math
import datetime
from collections import Counter
import itertools

def func(xx, yy):
    pass

def main():
    x, y = map(int, input().split())

    rr = 4 * x

    print("Yes") if rr >= y and y >= 2 * x and (rr - y) % 2 == 0 else print("No")
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 11060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string S;
    cin >> S;
    REP(i, S.size()) FOR(j, i, S.size()) {
        if (S.substr(0, i) + S.substr(j, S.size()) == "keyence") {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    A,B,C,K = map(int, input().split())
    score=0
    count=K
    i=0
    while count>0:
        if i==0:
            if A<=K:
                score=score+A
            else:
                score=K
            
            count=count-A
            # print(score,"s",count)
        elif i ==1:
            count=count-B
            # print(score,"s",count)
        else:
            score=score-count
            count=count-C
            # print(score,"s",count)
        i=i+1
        
    print(score)
main()

Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
const char nl = '\n';
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
ll power(ll x, unsigned int y) {ll res = 1;	while (y > 0) { if (y & 1) res = res*x%mod; y = y>>1; x = x*x;} return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ar[500005];
ll n,q,S;
class Query{
	public :
	int l;
	int r;
	ll index;
	ll answer;
};
bool cmp(Query A, Query B)
{
  if (A.l/S != B.l / S) return A.l / S < B.l / S;
  return A.r > B.r;
}
void solve(){
     cin>>n>>q;
     f(i,0,n)cin>>ar[i];
     vector<Query>v;
     S=sqrt(n);
    //  map<pair<int,int>,int>mp;
      vector<pair<int,int>>p;
     for(int i=0;i<q;i++){
     	int a,b;cin>>a>>b;
     	//cout<<a<<" "<<b;
     	//a--,b--;
     	//mp[{a,b}]=0;
       p.pb({a,b});
     	Query *q =new Query;
     	q->l=a;
     	q->r=b;
     	q->index=i;
     	v.pb(*q);
     }
    
     
    sort(v.begin(),v.end(),cmp);
   int fre[500005]={0};
   int le=0,ri=0; int j=0;
    int cur_dif=0;
    while(j<q){
    	int L=v[j].l;
    	int R=v[j].r;
    	L--; R--;
    	while(le<L){
    		fre[ar[le]]--;
    		if(fre[ar[le]]==0)cur_dif--;
    		le++;
    	}
    	while(le>L){
    		fre[ar[le-1]]++;
    		if(fre[ar[le-1]]==1)cur_dif++;
    		le--;
    	}
    	
    	while(ri<=R){
    		fre[ar[ri]]++;
    		if(fre[ar[ri]]==1)cur_dif++;
    		ri++;
    	}
    	
    	while(ri>R+1){
    		fre[ar[ri-1]]--;
    		if(fre[ar[ri-1]]==0)cur_dif--;
    		ri--;
    	}
    	v[j].answer=cur_dif;
    	//cout<<L+1 <<" "<<R+1<<" "<<cur_dif<<"\n";
    	j++;
    	
    }
    //cout<<"\n";
   ll vec[q+1];
    for(int i=0;i<q;i++){
    	vec[v[i].index]=v[i].answer;
    }
    f(i,0,q)cout<<vec[i]<<"\n";
}	
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


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

using namespace std;

int n[1000]={};
long long a[1000][1000]={};
long long ans = 10000000000;

int main(){
    int s=0;
    while(1){
        scanf("%d",&n[s]);
        if(n[s] == 0){
            break;
        }
        for(int i=0;i<n[s];i++){
           scanf("%lld",&a[s][i]); 
        }
        s++;
    }

    int times =s;
    int sub;
    for(int i=0;i<s;i++){
        sort(a[i],a[i]+n[i]);
        for(int j=0;j<n[i]-1;j++){
            sub = abs(a[i][j] - a[i][j+1]);
            if(ans >= sub){
                ans = sub;
            }
        }
        cout << ans << endl;
        ans = 1000000000;
    }
    

    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>
#include <cstdlib>
#define maxn 10000000
#define pi acos(-1)
#define ll long long
using namespace std;

int n;
int a[27];
int solve(int i,int m)
{
	if(m==0)return 1;
	if(i>=n)return 0;
	int res=solve(i+1, m)||solve(i+1, m-a[i]);
	return res;
}
int main()
{
	int q,m,i;
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	cin>>q;
	while(q--)
	{
		cin>>m;
		if(solve(0, m))cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int r; cin >> r;
    cout << 2 * r * 3.1415926535 << endl;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

ll gcd(ll a, ll b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  ll g = a[0];
  for (int i = 1; i < n; i++) {
    g = gcd(g, a[i]);
  }

  for (int i = 0; i < n; i++) {
    if (((a[i] - k) % g == 0) && (a[i] >= k)) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(int argc, char const* argv[])
{
  string S;
  cin >> S;
  vector<int32_t> vec(S.length(), 0);
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '1') vec[i] = 1;
  }

  size_t sz = vec.size();
  int64_t cnt = 0;
  for (int i = 0; i + 1 < sz; sz = vec.size()) {
    if ((vec[i] != vec[i + 1])) {
      vec.erase(vec.begin() + i, vec.begin() + i + 2);
      cnt += 2;
      i = 0;
    } else {
      i++;
    }
  }

  printf("%ld\n", cnt);

  return 0;
}


Measured memory_bytes: 896
def main():
    """
    """
    N, M, X, Y = map(int, input().split())
    *x, = map(int, input().split())
    *y, = map(int, input().split())

    x.append(X)
    y.append(Y)
    max_x = max(x)
    min_y = min(y)

    if max_x < min_y:
        print("No War")
    else:
        print("War")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	if(n==1) cout << "Hello World" << endl;
	else{
		int a,b;
		cin >> a >> b;
		cout << a+b << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 3e3+7;
string s,t;
int n,m;
int mem[N][N];
int dp(int i,int j)
{
    int &ret = mem[i][j];
    if (ret != -1) return ret;
    if (i == n || j == m) return ret = 0;
    int ret1 = dp(i+1,j);
    int ret2 = dp(i,j+1);
    int ret3 = 0;
    if (s[i] == t[j]) ret3 = dp(i+1,j+1)+1;
    return ret = max(ret1,max(ret2,ret3));
}

void findsol(int i,int j)
{
    int ret = mem[i][j];
    if (i == n || j == m) return ;
    int ret1 = dp(i+1,j);
    int ret2 = dp(i,j+1);
    int ret3 = 0;
    if (s[i] == t[j]) ret3 = dp(i+1,j+1)+1;
    if (ret == ret1) findsol(i+1,j);
    else if (ret == ret2) findsol(i,j+1);
    else if (ret == ret3) {cout << s[i];findsol(i+1,j+1);}
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    memset(mem,-1,sizeof mem);
    cin >> s >> t;
    n = s.size();
    m = t.size();
    dp(0,0);findsol(0,0);cout << endl;
    return 0;
}


Measured memory_bytes: 36096
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; cin >> n; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(begin(a), end(a));
	
	double ma = 0;
	for(int i = 0; i < n - 1; i++) {
		double tmp = 0;
		for(int j = n - 1, c = 0; j >= 0 and c < 2; j--) {
			if(j == i || j == i + 1) continue;
			tmp += a[j]; c++;
		}
		
		ma = std::max(ma, tmp / (a[i + 1] - a[i]));	
	}
	
	cout << std::fixed << std::setprecision(10) << ma << endl;
	return 0;
}



Measured memory_bytes: 3292
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(void) {
	int h, w, n;
	cin >> h >> w >> n;
	int ans = 0;
	while (n > 0) {
		++ans;
		n -= max(h, w);
	}
	cout << ans;
}
/*

*/

Measured memory_bytes: 256
l = [i for i in range(-10000,10000)]
x,n = list(map(int,input().split()))
p = list(map(int,input().split()))

l = set(l)
p = set(p)
dif = list(l-p)
dif.sort(reverse=True)
ans_min=1000000
ans = 0
for i in dif:
    if ans_min>=abs(x-i):
        ans_min=abs(x-i)
        ans = i

print(ans)



Measured memory_bytes: 12800
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b)
{
    while (b != 0) swap(b, a %= b);
    return a;
}

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x : vect)
        cout << x << " ";
    cout << "\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
//LCM
int lcm(int a, int b)
{
    return a * (b / gcd(a, b));
}

//For sort by second
bool cmp(const pair<int, int> &a)
{
    return a.first < a.second;
}

const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];

//ModPower
ll modpower(ll a, ll b, ll c)
{
    ll res = 1;
    while(b)
    {
        if(b & 1LL)
            res = (res * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return res;
}
ll n;

ll dp[MAXN][2];


void mul(ll &a, ll b)
{
    a *= b;

    if(a >= mod)
        a -= mod;

}

void add_self(ll &a, ll b)
{
    a += b;

    if(a >= mod)
        a -= mod;
}

ll solve(ll u, ll par, int color)
{
    if(dp[u][color] != 0)
        return dp[u][color];

    ll res = 0;
    //I i am coloring the current node white:
    ll ways1 = 1;
    for(ll child : adj[u])
    {

        if(child != par)
        {
            ways1 =  (ways1 * solve(child, u, 0)) % mod;
        }

    }
    add_self(res, ways1);

    //I am coloring the current node black only if parent is white

    if(color == 0)
    {
        ll ways2 = 1;
        for(ll child : adj[u])
        {
            if(child != par)
            {
                ways2 =  (ways2 * solve(child, u, 1)) % mod;
            }
        }
        add_self(res, ways2);
    }


    return dp[u][color] = res;
}


int main()
{
    FASTIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> n;

    for(ll i = 0; i < n - 1; i++)
    {
        ll u, v;
        cin >> u >> v;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    memset(dp, sizeof dp, 0);
    cout << solve(1, -1, 0) << "\n";
    return 0;
}

Measured memory_bytes: 17600
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
tmp = [[0 for i in range(6)] for j in range(n+1)]
absDiff = abs(x[0]-y[0])
tmp[0][3] = tmp[0][0] = absDiff
tmp[0][4] = tmp[0][1] = absDiff ** 2
tmp[0][5] = tmp[0][2] = absDiff ** 3
max = absDiff
for i in range(1, n, 1):
    absDiff = abs(x[i]-y[i])
    tmp[i][0] = absDiff
    tmp[i][1] = absDiff ** 2
    tmp[i][2] = absDiff ** 3
    tmp[i][3] = tmp[i-1][3] + tmp[i][0]
    tmp[i][4] = tmp[i-1][4] + tmp[i][1]
    tmp[i][5] = tmp[i-1][5] + tmp[i][2]
    if absDiff > max:
        max = absDiff
print(tmp[n-1][3])
print(tmp[n-1][4] ** (1/2))
print(tmp[n-1][5] ** (1/3))
print(max)

Measured memory_bytes: 7804