akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

vector<ll> parent[10001];
vector<ll> child[10001];
vector<ll> adj[10001];
ll ans[10001];


int main(){
    ll n;
    cin>>n;
    rep0(i,n-1){
        ll a,b;
        cin>>a>>b;
        --a,--b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ll c[n];
    rep0(i,n) cin>>c[i];
    sort(c,c+n);
    reverse(c,c+n);
    queue<ll> q;
    q.push(0);
    bool v[n];
    fill(v,v+n,false);
    v[0]=true;
    ans[0]=c[0];
    int index=1;
    while(q.size()){
        ll node=q.front();
        q.pop();
        ll N=adj[node].size();
        rep0(i,N){
            ll nextnode=adj[node][i];
            if(!v[nextnode]){
                v[nextnode]=true;
                ans[nextnode]=c[index];
                index++;
                q.push(nextnode);
            }
        }
    }
    ll ret=0;
    rep0(i,n){
        ll M=adj[i].size();
        rep0(j,M){
            ll k=adj[i][j];
            ret+=min(ans[i],ans[k]);
        }
    }
    cout<<ret/2<<endl;
    rep0(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;

    return 0;
}

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

int main(){
    int n,x;
    while(true){
        cin >> n >> x;
        if(n==0&&x==0)break;
        int count=0;
        for(int i=1;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n+1;k++){
                    if(i+j+k==x)count++;
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
 
int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X);
  vector<ll> B(Y);
  vector<ll> C(Z);
  for (int i = 0; i < X; i++) cin >> A[i];
  for (int i = 0; i < Y; i++) cin >> B[i];
  for (int i = 0; i < Z; i++) cin >> C[i];
  
  vector<ll> ab;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      ab.push_back(A[i] + B[j]);
    }
  }
  sort(ab.begin(), ab.end(), greater<>());
  
  vector<ll> ans;
  for (int i = 0; i < min(K, X * Y); i++) {
    for (int j = 0; j < Z; j++) {
      ans.push_back(ab[i] + C[j]);
    }
  }
  sort(ans.begin(), ans.end(), greater<>());
  
  for (int i = 0; i < K; i++) cout << ans[i] << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

vector<pair<int, int>> test[100];

int solve(vector<int> work){
    int ret = 0;
    rep(i, work.size()){
        if(work[i]){
            ret++;
            rep(j, test[i].size()){
                int man = test[i][j].first;
                int fact = test[i][j].second;
                if(work[man] != fact) return 0;
            }
        }
    }
    return ret;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    rep(i, N){
        int a; cin >> a;
        rep(j, a){
            int x, y; cin >> x >> y; x--;
            test[i].push_back(make_pair(x, y));
        }
    }
    int ans = 0;
    int loop = (1 << N);
    rep(i, loop){
        int val = i;
        vector<int> work;
        rep(j, N){
            work.push_back(val%2);
            val/=2;
        }
        ans = max(ans, solve(work));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string str;cin>>str;
    for(int i=0;i<str.length();i+=2){
        cout << str[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

int main(){
    int s,w;
    cin >> s >> w;
    if ( s>w){
        cout << "safe" << endl;
    }
    else
    {
        cout << "unsafe" << endl;
    }
    
    
    return 0;
}

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

int main(){
    int A,B;
    cin>>A>>B;
    if(A!=1&&B!=1) cout<<1<<endl;
    if(A!=2&&B!=2) cout<<2<<endl;
    if(A!=3&&B!=3) cout<<3<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    X = list(map(int, input().split()))
    min = 10000000000
    for venue in range(1, 101):
        sum = 0
        for i in range(N):
            if sum > min:
                break
            # print((venue - X[i])**2)
            sum += (venue - X[i])**2
        if sum < min:
            min = sum
    print(min)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63672
#include <stdio.h>

int f(int s,int i){
  if(i==1){
    return s;
  }int temp=f(s,i-1);
  if(temp%2==0){
    return (temp/2);
  }else{
    return (3*temp+1);
  }
}

int main(void){
  int s=0;
  scanf("%d", &s);
  int i=0,j=0,m=0;
  int a[1000005];
  int flag=0;
  while(1){
    a[i]=f(s,i+1);
    for(j=0;j<i;j++){
      if(a[j]==a[i]) {
        flag=1;
         m=i+1;
        break;
      }
    }
    if(flag) break;
    i++;
  }
    printf("%d", m);
    return 0;
  }
  

Measured memory_bytes: 1740
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl W(N);
  REP(i, N) cin >> W[i];
  ll sum = 0;
  REP(i, N) sum += W[i];
  ll mi = llINF;
  ll count = 0;
  REP(i, N) {
    count += W[i];
    if (mi > abs(sum - count - count)) {
      mi = abs(sum - count - count);
    }
  }
  cout << mi << endl;

  return 0;
}


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

int main() {

  int M, N;
  cin >> N >> M;

  vector<int> A(N);

  int sum = 0;
  for(auto &a : A){
    cin >> a;
    sum += a;
  }

  int count = 0;
  for(auto a : A){
    if(a >= ceil((float)(sum / (4.0 * M)))){
      count++;
    }
  }

  if(count >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		long sum = 0;
		for(int i = 1; i <= n; i++) {
			if ( i % 3 != 0 && i % 5 != 0)
				sum +=(long)i;
		}
		out.println(sum);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 32748
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define INF 10000000

int n;
vector< vector<int> > hyou(16, vector<int>(16));
vector<int> dp((1<<16)-1);

int saitan(int s, int k) {
	int p = dp[1<<k];
	for (int i = 0; i < n; i++) {
		if ((s&(1<<i)) != 0) {
			p = min(p, hyou[k][i]);
		}
	}
	return p;
}

int rec(int s) {
	if (dp[s] != INF) {
		return dp[s];
	} else {
		for (int i = 0; i < n; i++) {
			if ((s&(1<<i)) != 0) {
				dp[s] = min(dp[s], rec(s^(1<<i))+saitan(s^(1<<i), i));
			}
		}
		return dp[s];
	}
}

int main() {
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		dp[0] = 0;
		for (int i = 1; i < (1<<16); i++) {
			dp[i] = INF;
		}
		int k = 1;
		for (int i = 0; i < n; i++) {
			cin >> dp[k];
			k <<= 1;
			for (int j = 0; j < n; j++) {
				cin >> hyou[i][j];
			}
		}
		cout << rec((1<<n)-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
const int mod = 998244353;
int power(int a, int b){
    int res = 1;
    while(b > 0){
        if(b & 1){
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
        b >>= 1;
    }
    return res;
}
int main(){
    int n, m, a, b, c, ans = 1, flag = 1, tot[N] = {0}, bit[N][4], dp[2][2];
    map<pair<int, int>, int> tell;
    scanf("%d %d", &n, &m);
    memset(bit, -1, sizeof(bit));
    for(int i = 1; i <= m; i++){
        scanf("%d %d %d", &a, &b, &c);
        if(abs(a - b) <= 1){
            bit[max(a, b)][2 - (a - b)] = c;
        }else{
            if(abs(a - b) > 2){
                if(tell[{b, a}] == 0){
                    tot[max(a, b)]++;
                }else if(tell[{b , a}] != c + 1){
                    flag = 0;
                }
            }
            tell[{a, b}] = c + 1;
        }
    }
    if(!flag){
        printf("0\n");
        return 0;
    }
    for(int i = 4; i <= n; i++){
        ans = 1LL * ans * power(2, (i - 3 - tot[i])) % mod;
    }
    for(int i = 1; i < n; i++){
        bit[i + 1][0] = bit[i][2];
    }
    b = 0;
    dp[1][0] = (bit[1][2] < 1);
    dp[1][1] = (bit[1][2] != 0);
    for(int i = 2; i <= n; i++){
        dp[b][0] = dp[b][1] = 0;
        int c1 = tell[{i, i - 2}], c2 = tell[{i - 2, i}];
        for(int j = 0; j < 16; j++){
            flag = 1;
            int cnt = 0;
            for(int k = 0; k < 4; k++){
                if(j & (1 << k)){
                    cnt ^= 1;
                    if(bit[i][k] == 0){
                        flag = 0;
                    }
                }else{
                    if(bit[i][k] == 1){
                        flag = 0;
                    }
                }
            }
            if(!flag || cnt) continue;
            int oneprev = (j & 1 ? 1 : 0);
            int onecurr = (j & 4 ? 1 : 0);
            int mul = 0;
            if(c1 + c2 == 0){
                mul = 2;
            }else if(c1 + c2 == 1){
                mul = 1; 
            }else if(c1 + c2 == 3){
                mul = (oneprev ? 1 : 0);
            }else if(c1 + c2 == 4){
                mul = (oneprev ? 0 : 1);
            }else{
                if(c1 == 1){
                    mul = (oneprev ? 0 : 1);
                }else{
                    mul = 1;
                }
            }
            if(i == 2) mul = 1;
            dp[b][onecurr] += 1LL * mul * dp[b ^ 1][oneprev] % mod;
            if(dp[b][onecurr] >= mod){
                dp[b][onecurr] -= mod;
            }
        }
        b ^= 1;
    }
    ans = 1LL * ans * ((dp[b ^ 1][0] + dp[b ^ 1][1]) % mod) % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 20992
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

namespace mod {
  ll power(ll x, ll e) {
    ll v = 1;
    for (; e > 0; e >>= 1) {
      if (e & 1) {
        v = v * x % MOD;
      }
      x = x * x % MOD;
    }
    return v;
  }

  ll inverse(ll x) {
    return power(x, MOD - 2);
  }

  vector<ll> fact, factInv;
  void initFact(int N) {
    fact.resize(N + 1); factInv.resize(N + 1); 
    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
      fact[i] = fact[i-1] * i % MOD; 
    }
    factInv[N] = inverse(fact[N]);
    for (int i = N - 1; i >= 0; i--) {
      factInv[i] = factInv[i + 1] * (i + 1) % MOD;
    }
  }

  ll choose(int n, int k) {
    if (k > n) {
      return 0;
    } else {
      return fact[n] * factInv[k] % MOD * factInv[n-k] % MOD;
    }
  }

  ll multiChoose(int n, int k) {
    if (n == 0 && k == 0) {
      return 1;
    } else {
      return choose(n + k - 1, k);
    }
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  mod::initFact(max(N, M));
  ll res = 0;
  if (N == M || N == M + 1) {
    res = (res + mod::fact[N] * mod::fact[M] % MOD) % MOD;
  }
  if (M == N || M == N + 1) {
    res = (res + mod::fact[M] * mod::fact[N] % MOD) % MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int N, H, W;
    cin >> N >> H >> W;
    cout << (N - H + 1) * (N - W + 1) << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    int d = gcd(a,b);
    if (c % d == 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }

  private static int gcd(int num1,int num2) {
    if(num2==0) return num1;
    else return gcd(num2,num1%num2);
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  a -= c;
  cout << a/(b+c) << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

lamp_switch = []
for i in range(M):
    lamp_switch.append(list(map(int, input().split()))[1:])

pattern = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    A = [0]*M #スイッチの状態
    for j in range(N):
        if (i >> (N-j-1))&1:
            for k in range(M):
                if j+1 in lamp_switch[k]:
                    A[k] += 1
                    A[k] %= 2
    if pattern == A:
        ans += 1
print(ans)



Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int a, b,c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  sum -= max({a,b,c});

  cout << sum << LF;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int n,m,i,j,k,dp[2][22][1<<20],nxt[22][1<<20][2],x;
int main()
{
	scanf("%d%d",&n,&m);
	x=0;
	fz0g(i,n){
		scanf(" ");
		fz0k(j,(1<<i)){
			char c;
			scanf("%c",&c);
			if(c=='1'){
				dp[x][i][j]=1;
			}
		}
	}
	fz1(i,n){
		fz0k(j,(1<<i)){
			nxt[i][j][0]=nxt[i][j][1]=-1;
			fz0k(k,i){
				if((j>>k)&1) nxt[i][j][1]=k; else nxt[i][j][0]=k;
			}
		}
	}
	int len=0,ans=0;
	fz0k(i,n){
		fz1(j,n-i){
			fz0k(k,(1<<(i+j)))if(dp[x][i+j][k]){
				int t=nxt[j][k&((1<<j)-1)][0];
				if(t!=-1){
					dp[x^1][i+t+1][((k>>j)<<(t+1))|(k&((1<<(t+1))-1))]+=dp[x][i+j][k];
				}
				t=nxt[j][k&((1<<j)-1)][1];
				if(t!=-1){
					dp[x^1][i+t+1][((k>>j)<<(t+1))|(k&((1<<(t+1))-1))]+=dp[x][i+j][k];
				}
			}
		}
		memset(dp[x],0,sizeof(dp[x]));
		x^=1;
		fz1(j,n-i-1){
			fz0k(k,(1<<(i+j+1))){
				dp[x][i+1][k>>j]+=dp[x][i+j+1][k];
			}
		}
		for(k=(1<<(i+1))-1;k>=0;k--){
			if(dp[x][i+1][k]>=m){
				len=i+1;
				ans=k;
			}
		}
	}
	fd0k(i,len) putchar('0'|((ans>>i)&1));puts("");
	return 0;
}

Measured memory_bytes: 235904
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int xl=0,xr=w,yb=0,yt=h;
    rep(i,n){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            xl=max(xl,x);
        }
        if(a==2){
            xr=min(xr,x);
        }
        if(a==3){
            yb=max(yb,y);
        }
        if(a==4){
            yt=min(yt,y);
        }
    }
    int S = max(xr-xl,0)*max(yt-yb,0);
    cout << S << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    
    int N; cin >> N;
    vector<int> s(N);
    int ans = 0;
    for(int i = 0;i < N;i++){
        cin >> s[i];
        ans += s[i];
    }
    if(ans %10 != 0){
        cout << ans << endl;
        return 0;
    }else{
        sort(all(s));
        for(int i = 0;i < N;i++){
            if(s[i] %10 != 0){
                ans -= s[i];
                cout << ans << endl;
                return 0;
            }
        }
        cout << 0 << endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
bool check(int x, vector<int> &v, int k)
{
  int cuts = 0;
  for (int i = 0; i < v.size(); i++)
  {
    cuts += v[i] / x;
    if (v[i] % x == 0)
      cuts--;
  }
  if (cuts <= k)
    return true;
  else
    return false;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  int low = 1;
  int high = 1000000000;
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
  }
  int ans;
  while (low <= high)
  {
    int mid = (low + high) / 2;
    if (check(mid, v, k))
    {
      ans = mid;
      high = mid - 1;
    }
    else
    {
      low = mid + 1;
    }
  }
  cout << ans ;
}


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

using namespace std;

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

    int n, ans = 0;
    cin >> n;
    int arr[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++) {
            int k = lower_bound(arr, arr + n, arr[i] + arr[j]) - arr - 1;
            int l = upper_bound(arr, arr + n, max(arr[i], arr[j]) - min(arr[i], arr[j])) - arr;
            l = max(l, j + 1);

            if (k >= l)
                ans += k - l + 1;
        }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if ( T[u].p == NIL ) cout << "root, ";
  else if ( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ) {
    if (i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

void rec(int u, int p) {
  D[u] = p;
  if ( T[u].r != NIL ) rec(T[u].r, p);
  if ( T[u].l != NIL ) rec(T[u].l, p + 1);
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for ( i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n; i++ ) {
    cin >> v >> d;
    for ( j = 0; j < d; j++ ) {
      cin >> c;
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
for ( i = 0; i < n; i++ ) {
    if (T[i].p == NIL) r = i;
  }

  rec(r, 0);

  for ( i = 0; i < n; i++ ) print(i);

  return 0;
}

Measured memory_bytes: 7772
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100009];
int dp[100009];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[1]=abs(a[0]-a[1]);
    for(int i=2;i<n;i++){
        int x=abs(a[i]-a[i-1]) + dp[i-1];
        int y=abs(a[i]-a[i-2]) + dp[i-2];
        dp[i]=min(x,y);
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	long n, result = 100000;

	cin >> n;

	for(int i = 0; i < n; i++) {
		result *= 1.05;
		if(result % 1000 != 0) {
			result += 1000;
			result -= result % 1000;
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int n, k;
    int a = 1;
    scanf("%d%d",&n,&k);
    for(int i = 1; i <= n; i++)
    {
        if(a + k < 2 * a)
            a += k;
        else
            a *= 2;
    }
    printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<3;i++){
		if(s[i]=='9'){
			s[i]='1';
		}
		else{
			s[i]='9';
		}
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;
  char c;
  cin >> n;
  loop(i,0,n) {
    cin >> c;
    if (c == 'Y') {
      cout << "Four" << endl;
      return;
    }
  }
  cout << "Three" << endl;
}


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

int main(){
int a;
int b;
int c;
int n;
int d;
while(cin >> a >> b){
c=a+b;
d=1;
n=0;
while(1){
if(d>c){break;}
d=d*10;
n=n+1;}
cout << n << endl;
}
    return 0;
}

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

using namespace std;

#define all(x)  x.begin(),x.end()
#define sz(x)   x.size()
#define pb      push_back

const int   N   = 2e3 + 5;

typedef long long   ll;
typedef vector<int> vi;

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

vi  mer(vi a,vi b)  {
    vi c;
    int i = 0, j = 0;
    while(i < sz(a) && j < sz(b))   {
        if(a[i] < b[j]) c.pb(b[j++]);
        else            c.pb(a[i++]);
    }
    while(i < sz(a))    c.pb(a[i++]);
    while(j < sz(b))    c.pb(b[j++]);
    return c;
}

vector<int> g[N], ar[N];

ll  a[N];
int p[N], n;

void dfs(int u) {
    for(int v : g[u])
        if(v != p[u] && p[v] < 0)   {
            p[v] = u;
            dfs(v);
        }
}

void sol(int u) {
    ar[u].push_back(u);
    vector<int> res;
    for(int v : g[u])
        if(p[v] == u)   {
            sol(v);
            res = mer(res,ar[v]);
        }
    for(int i = 0 ; i < sz(res) ; ++i)
        ar[u].pb(res[i]);
}

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

    cin >> n;

    for(int i = 1 ; i <= n ; ++i)
        cin >> a[i];

    sort(a + 1,a + 1 + n);

    int j = 1;
    while(j <= n && a[j] < 2)
        ++j;

    vector<int> res(j - 1,1);

    n -= (j - 1);
    for(int i = 1 ; i <= n ; ++i)
        a[i] = a[i + j - 1];

    for(int i = 0 ; i <= n ; ++i)
        for(int j = 0 ; j <= n ; ++j)    {
            if(i == j || gcd(a[i],a[j]) < 2)
                continue;
            g[i].pb(j);
        }

    memset(p,-1,sizeof p);
    p[0] = 0;
    dfs(0);
    sol(0);

    for(int i = sz(ar[0]) - 1 ; i ; --i)
        res.pb(a[ar[0][i]]);

    reverse(all(res));
    for(int i = 0 ; i < sz(res) ; ++i)
        cout << res[i] << ' ';
}


Measured memory_bytes: 28288
# ABC131D - Megalomania
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = sorted(
        [tuple(map(int, input().rstrip().split())) for _ in range(n)], key=lambda x: x[1]
    )
    tasks = 0
    for i, j in arr:
        tasks += i
        if tasks > j:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 33456
import std.algorithm;
import std.ascii;
import std.array;
import std.container;
import std.conv;
import std.numeric;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

const int INF = 10000;

int op(char c, int a, int b) {
    if (c == '+') return a + b;
    if (c == '-') return a - b;
    assert(false);
}

int next_op_index(in string s, int i) {
    for (int j = i; j < s.size; j++) {
        if (s[j] == '+' || s[j] == '-') return j;
    }
    throw new Exception("");
}
int prev_op_index(in string s, int i) {
    for (int j = i; j >= 0; j--) {
        if (s[j] == '+' || s[j] == '-') return j;
    }
    throw new Exception("");
}

void main() {
    string s = readln.chomp;

    auto t_index = new int[s.size]; t_index[] = -1;
    int cur = 0;
    foreach (i, c; s) {
        if (c == '(' || c == ')') continue;
        t_index[i] = cur++;
    }
    auto buf = new char[cur];
    foreach (i, c; s) {
        if (c == '(' || c == ')') continue;
        buf[t_index[i]] = c;
    }
    string t = buf.idup;

    int N = t.size;
    auto open_banned = new bool[N];
    auto close_banned = new bool[N];
    foreach (int i, c; s) {
        try {
            if (c == '(')      close_banned[t_index[next_op_index(s, i)]] = true;
            else if (c == ')') open_banned[t_index[prev_op_index(s, i)]] = true;
        } catch (Exception e) {}
    }

    auto dp_min = new int[][](N + 1, N + 1);
    auto dp_max = new int[][](N + 1, N + 1);
    foreach (ref a; dp_max) a[] = -INF;
    foreach (ref a; dp_min) a[] = INF;
    foreach (i, c; t) {
        if (c.isDigit) dp_max[i][i + 1] = dp_min[i][i + 1] = cast(int)(c - '0');
    }

    for (int k = 2; k <= N; k++) {
        for (int i = 0; i + k <= N; i++) {
            for (int j = i + 1; j < i + k; j++) {
                if (! (t[j] == '+' || t[j] == '-')) continue;
                int lcount = cast(int)t[i .. j].count!isDigit;
                int rcount = cast(int)t[j .. i + k].count!isDigit;
                if (lcount >= 2 && close_banned[j]) continue;
                if (rcount >= 2 && open_banned[j]) continue;
                switch (t[j]) {
                    case '+':
                        dp_max[i][i + k] = max(dp_max[i][i + k], dp_max[i][j] + dp_max[j + 1][i + k]);
                        dp_min[i][i + k] = min(dp_min[i][i + k], dp_min[i][j] + dp_min[j+ 1][i + k]);
                        break;
                    case '-':
                        dp_max[i][i + k] = max(dp_max[i][i + k], dp_max[i][j] - dp_min[j + 1][i + k]);
                        dp_min[i][i + k] = min(dp_min[i][i + k], dp_min[i][j] - dp_max[j + 1][i + k]);
                        break;
                    default:
                        break;
                } 
            }
        }
    }
    /*
    foreach (L; dp_max) log(L);
    log();
    foreach (L; dp_min) log(L);
    */
    writeln(dp_max[0][t.size]);
}

Measured memory_bytes: 2788
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
template <class T>bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

ll modPow(long long a, long long n, long long p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll mod=1000000007;

std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%mod;
    }
  }
  return v;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  ll maxxpy=-1000000000000;
  ll maxxmy=-1000000000000;
  ll minxpy=1000000000000;
  ll minxmy=1000000000000;
  rep(i,n){
    ll x;
    cin >> x;
    ll y;
    cin >> y;
    maxxpy=max(maxxpy,x+y);
    minxpy=min(minxpy,x+y);
    maxxmy=max(maxxmy,x-y);
    minxmy=min(minxmy,x-y);
  }
  cout<<max({abs(maxxpy-minxpy),abs(maxxmy-minxmy)})<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

map<string, int> mp;
void solve()
{
    string s;
    int N, cnt = 0;
    cin >> N;
    for (int i = 1; i <= N;i++)
    {
        cin>>s;
        if(mp.count(s))
            continue;
        cnt++;
        mp[s] = 1;
    }
    cout << cnt << "\n";
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 19244
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");
 

vector<tuple<ll, ll, ll>> tf;
pair<string, ll> bit(ll n, ll k){
  string b = "";
  ll c=0;
  rep(i, 0, k){
    if(n % 2 == 1) c++;
    b += to_string(n % 2);
    n /= 2;
  }
  return make_pair(b, c);
}


int main(){
    ll n, a, x, y, mx=0;
    cin >> n;
    rep(i, 0, n){
      cin >> a;
      rep(j, 0, a){
        cin >> x >> y;
        tf.push_back(make_tuple(x, y, i));
      }
    }
    //print(tf.size());

    rep(num, 0, pow(2, n)){
      pair<string, ll> s = bit(num, n);
      //print(s);
      bool flag = true;
      rep(i, 0, tf.size()){
        //cout << s.first[tf[i].first-1] << " " << tf[i].second<<endl; 
        if(s.first[get<2>(tf[i])] - '0' == 1){
          if(s.first[get<0>(tf[i]) - 1] - '0' != get<1>(tf[i])){
            flag = false;
            break;
          }
        }
      }
      if(flag == true){
        //print(s.first);
        mx = max(mx, s.second);
      }
    }

    print(mx);
 
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdint.h>
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define LL int64_t
#define REP(i,n) for (LL (i) = 0; (i) < (n); i++)
#define REPr(i,n) for (LL (i) = (n); (i) --> 0;)
#define INF 1e9
int DP[1<<18][18];
int A[18][2];

int bitcount(LL bits) {
    bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);
    bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);
    bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);
    bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);
    bits = (bits & 0x0000ffff0000ffff) + (bits >>16 & 0x0000ffff0000ffff);
    return (bits & 0x00000000ffffffff) + (bits >>32 & 0x00000000ffffffff);
}

int main() {
    int N;
    LL ans = INF;
    scanf("%d", &N);
    REP(i, N) scanf("%d", &A[i][0]);
    REP(i, N) scanf("%d", &A[i][1]);

    REP(i, 1<<N) REP(j, N) DP[i][j] = INF;
    REP(j, N) DP[1<<j][j] = 0;

    REP(i, 1<<N) {
        REP(j, N) {
            if (DP[i][j] >= INF) continue;
            int ic = bitcount(i);
            int a = A[j][(j^ic^1)&1];
            REP(k, N) {
                if (i&(1<<k) || a > A[k][(k^ic)&1]) continue;
                int t = ic - bitcount(((1<<k)-1)&i);
                DP[i|(1<<k)][k] = MIN(DP[i|(1<<k)][k], DP[i][j]+t);
            }
        }
    }

    REP(j, N) ans = MIN(ans, DP[(1<<N)-1][j]);
    if (ans >= INF) ans = -1;
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 1000010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

bitset<MAX> sieve;
vector<ll> ps;

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

void precomp()
{
    sieve.set();
    ps.push_back(2);
    ps.push_back(3);

    for (ll j = 5, step = 2; j < MAX; j += step, step = 6 - step)
    {
        if (sieve[j])
        {
            ps.push_back(j);

            for (ll k = j * j; k < MAX; k += 2*j)
                sieve[k] = false;
        }
    }
}

void factorization(ll n, map<ll, ll>& fs)
{
    for (auto p : ps)
    {
        if (p * p > n)
            break;

        ll k = 0;

        while (n % p == 0)
        {
            ++k;
            n /= p;
        }

        if (k)
            fs[p] = max(fs[p], k);
    }

    if (n > 1)
        fs[n] = max(fs[n], 1LL);
}

ll mod_pow(ll a, ll n)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % MOD;

        base = (base * base) % MOD;
        n >>= 1;
    }

    return res;
}

ll inv(ll n)
{
    return mod_pow(n, MOD - 2);
}

ll lcm(const vector<ll>& xs)
{
    map<ll, ll> fs;

    for (auto x : xs)
        factorization(x, fs);

    ll ans = 1;

    for (auto f : fs)
    {
        auto p = f.first, k = f.second;

        ans = (ans * mod_pow(p, k)) % MOD;
    }
 
    return ans;
}

ll solve(int N, const vector<ll>& xs)
{
    if (N == 1)
        return 1;

    vector<ll> ds;
    ll xN = xs.back();

    for (int i = 0; i < N - 1; ++i)
    {
        auto d = gcd(xs[i], xN);

        ds.push_back(xs[i] / d);
    }

    ll mmc = lcm(ds);

#ifdef DEBUG
    cout << "ds = ";
    for (auto d : ds)
        cout << d << ' ';
    cout << endl;

    cout << "xN = " << xN << ", mmc = " << mmc << endl;
#endif
    
    ll ans = mmc;

    for (int i = 0; i < N - 1; ++i)
    {
        ll n = (xN * mmc) % MOD;
        n = (n * inv(xs[i])) % MOD;

        ans = (ans + n) % MOD;
#ifdef DEBUG
    cout << "B" << (i + 1) << " = " << n << ", new ans = " << ans << endl;
#endif
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    int N;
    cin >> N;

    vector<ll> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s1,s2;
 cin>>s1;
 cin>>s2;
 int count=0;
 int n=s2.size();
 for(int i=0; i<s1.size(); i++)
 {
 	if(s1[i]==s2[i])
 	{
 		count++;
	 }
 }
 if(count==s1.size() && (s2[n-1]>='a' && s2[n-1]<='z'))
 {
 	cout<<"Yes"<<endl;
 }else
 {
 	cout<<"No"<<endl;
 }
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

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

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

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

	int ans;
	if (A == 1) {
		if (B == 2)ans = 3;
		else if (B == 3)ans = 2;
	}
	else if (A == 2) {
		if (B == 1)ans = 3;
		else if (B == 3)ans = 1;
	}
	else{
		if (B == 1)ans = 2;
		else if (B == 2)ans = 1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2560
object Main extends App{

    val ab = scala.io.StdIn.readLine.replaceAll("\\s","").toInt

    import math._

    def check(ab: Int):Boolean = {
        for (i<- 1 to ceil(sqrt(ab)).toInt) {
          if (pow(i,2) == ab) return true
        }
        return false
    }

    if (check(ab)) println("Yes") else println("No")
}

Measured memory_bytes: 27192
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

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


	int N = getint(), M = getint();
	int to[100001], ne[100001], he[100001] = {};
	rep1(i, M) {
		int u = getint();
		to[i] = getint();
		ne[i] = he[u];
		he[u] = i;
	}
	int S = getint(), T = getint();

	int D[300004];
	rep(i, 300004) D[i] = 1e9;
	D[3 * S] = 0;

	int q[300000];
	int k1 = 0;
	int k2 = 1;
	q[0] = 3 * S;
	for (int k1 = 0; k1 < k2; k1++) {
		int i = q[k1];
		int i2 = i / 3;
		int d = D[i] + 1;
		for (int j = he[i2]; j; j = ne[j]) {
			int j2 = to[j] * 3 + (i + 1) % 3;
			if (D[j2] > d) {
				D[j2] = d;
				q[k2++] = j2;
			}
		}
	}

	if (D[3 * T] == 1e9) printf("-1");
	else printf("%d", D[3 * T] / 3);

	Would you please return 0;
}

Measured memory_bytes: 3840
fun main(args: Array<String>) {
    var N = readLine()!!.toInt()
    var A = readLine()!!.split(" ").map(String::toLong)
    var c = 0
    var a = A
    while(a.filter{it%2==0L}.size == A.size){
        a = a.map{it/2}
        c++
    }
    println(c)
}


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

int main(){
    int n;
    cin >> n;
    vector<int> card(n);
    for(int i = 0; i < n; i++){
        cin >> card[i];
    }
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());

    int alice = 0, bob = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            alice += card[i];
        }
        else{
            bob += card[i];
        }
    }

    cout << alice - bob << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	s := ReadString()
	n := len(s)
	s = "." + s
	if s[1] == '0' || s[n] == '1' {
		fmt.Println(-1)
		return
	}
	for i := 1; i < n; i++ {
		if s[i] != s[n-i] {
			fmt.Println(-1)
			return
		}
	}
	chars := []byte(s)
	chars[n] = '1'
	vertices := []int{}
	for i := 1; i <= n; i++ {
		if chars[i] == '1' {
			for _, v := range vertices {
				fmt.Printf("%d %d\n", v, i)
			}
			vertices = []int{i}
		} else {
			vertices = append(vertices, i)
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 6216
#include<iostream>
using namespace std;
#include<vector>
#include<stack>
#define MAX 100000
int n,m;
vector<int>G[MAX];
stack<int>mp;
int color[MAX];

void dfs(int r,int c){
	mp.push(r);
	color[r] = c;
	while (!mp.empty()){
		int u = mp.top();
		mp.pop();
		for (int i = 0;i < G[u].size();i++){
			int v = G[u][i];
			if (color[v] == -1){
				color[v] = c;
				mp.push(v);
			}
		}
	}
}

void assignColor(){
	int id = 1;
	for (int i = 0;i < n;i++){
		color[i] = -1;
	}
	for (int j = 0;j < n;j++){
		if (color[j] == -1){
			dfs(j,id++);
		}
	}
}

int main()
{
	cin >> n >> m;
	int x,y; 
	for (int i = 0; i < m ;i++){
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	assignColor();
	cin >> m;
	for (int i = 0 ;i < m;i++){
		cin >> x >> y;
		if (color[x] == color[y]){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 9020