akhauriyash/Code-Regression huggingface dataset:
#d
n=int(input())
tree=[[] for _ in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    tree[u-1].append((v-1,w))
    tree[v-1].append((u-1,w))

color=[0]*(n+1)
q = [(-1,0,0)]
while q:
    parent,x,l = q.pop()
    for y in tree[x]:
        if y[0] == parent:
            continue
        q.append((x,y[0],y[1]))
    if l%2==1:
        color[x+1]=1-color[parent+1]
    else:
        color[x+1]=color[parent+1]

for i in range(1,n+1):
    print(color[i])

Measured memory_bytes: 73124
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		AtCoderGroupContest solver = new AtCoderGroupContest();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class AtCoderGroupContest {

		private int n;
		private ArrayList<Integer> a;
		private long  output;
		private Scanner scanner;

		public AtCoderGroupContest() {
			scanner = new Scanner(System.in);
			a = new ArrayList<Integer>();
		}
		public void readInput() {
			n = scanner.nextInt();
			for(int i=0; i<3*n;i++) {
				a.add(scanner.nextInt());
			}
		}

		public void solve() {
			Collections.sort(a,Collections.reverseOrder());
			for(int i=0; i<n*2;i++) {
				if(i%2==1) {
					output+=a.get(i);
				}
			}
		}

		public void writeOutput() {
			System.out.print(output);
		}
	}

}


Measured memory_bytes: 94644
#include <cstdio>

int main()
{
    int num, a, b, c, d;
    scanf("%d", &num);

    a = num / 1000;
    num %= 1000;
    b = num / 100;
    num %= 100;
    c = num / 10;
    d = num % 10;

    char op[] = {'+', '-'};
    for (int i = 0; i <= 1; ++i) {
        int ans = 0;
        if (i == 0) ans = a + b;
        else ans = a - b;
        for (int j = 0; j <= 1; ++j) {
            if (j == 0) ans += c;
            else ans -= c;

            if ((ans + d) == 7) {
                printf("%d%c%d%c%d%c%d=7\n", a, op[i], b, op[j], c, op[0], d);
                return 0;
            } else if ((ans - d) == 7) {
                printf("%d%c%d%c%d%c%d=7\n", a, op[i], b, op[j], c, op[1], d);
                return 0;
            } else {
                ans -= c;  // j == 1 の前に元の状態に戻す
            }
        }
    }
}

Measured memory_bytes: 128
(loop with a = 0 and b = 1 and c = 1 and d = 8
      repeat (1- (read))
      do (setf a (+ (* 10 a) b c)
               b (+ (* 9 b) d)
               c (+ (* 9 c) d)
               d (* 8 d))
      (setf a (mod a (+ 7 (expt 10 9)))
            b (mod b (+ 7 (expt 10 9)))
            c (mod c (+ 7 (expt 10 9)))
            d (mod d (+ 7 (expt 10 9))))
      finally (princ (mod a (+ 7 (expt 10 9)))))

Measured memory_bytes: 24488
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
const int maxn=100010;
int n,m;
vector<int>g[maxn];
int vis[maxn];
int ans;
int x[maxn],y[maxn];
int a[maxn],d[maxn];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	for(int i=1;i<=n;i++) a[i]=1;
	d[1]=1;
	for(int i=1;i<=m;i++){
		if(d[x[i]]) d[y[i]]=1;
		a[x[i]]--;a[y[i]]++;
		if(!a[x[i]]) d[x[i]]=0;
	}
	for(int i=1;i<=n;i++) ans+=d[i];
	printf("%d",ans);
	return 0;
}

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

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] input_array = br.readLine().split(" ");

        long result = 0;
        long mod = 1000000000 + 7;


        long sum = 0;
        long calc = 0;

        for(int i = 0; i < N; i++) {
            sum += Long.parseLong(input_array[i]);
        }

        for(int i = 0; i < N; i++) {
            calc = Long.parseLong(input_array[i]);
            sum -= calc;
            result += ((calc % mod) * (sum % mod)) % mod;
            // result = result % mod;
        }

        result = result % mod;
        pw.println(result);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 61556
from collections import defaultdict
import math

def soi(num_ref):
    arr = []
    num = num_ref
    for i in range(2, int(math.sqrt(num))+1):
        if num%i == 0:
            cnt = 0
            while num%i == 0:
                cnt += 1
                num //= i
            arr.append([i, cnt])
    if num != 1:
        arr.append([num, 1])
    if arr == []:
        arr.append([num_ref, 1])
    return arr

N = int(input())
if N == 1:
    print(0)
    exit()
arr = soi(N)
cnt = 0
for i in arr:
    minus = 1
    tmp = i[1]
    while(tmp - minus >= 0):
        tmp -= minus
        minus += 1
        cnt += 1
print(cnt)

Measured memory_bytes: 68104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
string s[100000];
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s,s+n);
	int ind=0;
	while(ind<n)
	{
		string t=s[ind];
		ll cnt=1;
		ind++;
		while(ind<n && s[ind]==t)
		{
			cnt++;
			ind++;
		}
		ans+=cnt*(cnt-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  
  int a=0;
  
  for(int i; i<N; i++){
    
    string x;
    cin >> x;
    
    if(x == "Y"){
      a=1;
    }
  }
  
  if(a==1){
    cout<<"Four"<<endl;
  }
  
  else{
    cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}

int main(){
    vector<int> v(0);
    for(;;){
        int x,y,s; cin >> x >> y >> s;
        if (x == 0 && y == 0 && s == 0) break;
        int mx = 0;

        for(int m1 = 1; m1 <= s; m1++){
            for(int m2 = 1; m2 <= s; m2++){
                if (m1*(100+x)/100 + m2*(100+x)/100 == s){
                    int money = m1*(100+y)/100 + m2*(100+y)/100;
                    mx = max(mx,money);
                }
            }
        }
        v.push_back(mx);
    }
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
    }
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int a[15][15];
int price[15];

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    rep(i,n) {
        int c;
        cin >> c;
        price[i] = c;
        rep(j,m) {
            cin >> a[i][j];
        }
    }
    int ans = INF;
    for (int bit = 0; bit < (1<<n); bit++) {
        int understanding[m];
        int sum_price = 0;
        rep(i,m) understanding[i] = 0;
        rep(i,n) {
            if (bit & (1 << i)) {
                sum_price += price[i];
                rep(j,m) {
                    understanding[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        rep(i,m) {
            if (understanding[i] < x) {
                ok = false;
                break;
            }
        }
        if (ok) ans = min(ans, sum_price);
    }
    if (ans == INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};


int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<tuple<int, int, int>> v(m);
        for (int i = 0; i < m; ++i) {
            int s, t, c;
            cin >> s >> t >> c;
            s--; t--;
            v[i] = make_tuple(c, s, t);
        }
        sort(v.begin(),v.end());
        vector<int> e;
        UnionFind uf(n);
        for(auto &&i : v){
            int c, s, t; tie(c, s, t) = i;
            if(uf.unite(s, t)) e.emplace_back(c);
        }
        cout << e[(n-1)/2] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3296
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long  ll;
const int N=1e5+5;
int main(){
string a,b;
cin>>a>>b;
int x=a.size();
bool flag=false;
for(int i=0;i<x;i++)if(a[i]!=b[i]){
    flag=true;
        break;
}
if(flag)puts("No");
else puts("Yes");
return 0;}


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

int main() {
    int N, D, L;
    while (cin >> N >> D >> L, N || D || L) {
        vector<int> v(N);
        for (int i = 0; i < N; i++) {
            int l;
            cin >> l;
            if (l >= L) v[i]++, v[min(N-1, i+D)]--;
        }

        int count = 0;
        int ans = 0;
        for (int i = 0; i < N-1; i++) {
            count += v[i];
            if (count > 0) ans++;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3460
#include <bits/stdc++.h>
#if 0
using namespace std;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
typedef long long ll;
typedef pair<int, int> pii;
#define int ll

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;
#endif
signed main() {
    int N, K, T, U, V, L;
    scanf("%d %d %d %d %d %d", &N, &K, &T, &U, &V, &L);

    std::vector<int>  C(L+1);
    for (int i=0; i<N; ++i) {
        int D;
        scanf("%d", &D);
        ++C[D];
    }

    int num_carrot=0;
    int remain=0;
    std::vector<int> F(L+1);
    for (int i=0; i<=L; ++i) {
        if (remain-- > 0)
            F[i] = 1;

        if (C[i])
            ++num_carrot;

        if (num_carrot) {
            if (remain <= 0 || num_carrot > K) {
                --num_carrot;
                remain = V*T;
            }
        }
    }

    int dist[2]={};
    for (int i=0; i<L; ++i)
        ++dist[F[i+1]];

    printf("%.16f\n", (dist[0]*1.0/U)+(dist[1]*1.0/V));
    return 0;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int N; cin >> N;
  int ans = 0;
  vector<int> V(N), C(N);
  for(int i = 0; i < N; ++i) cin >> V[i];
  for(int i = 0; i < N; ++i) cin >> C[i];
  for(int i = 0; i < N; ++i) {
    if(V[i]-C[i] > 0) ans += (V[i]-C[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = INF;
    for(int i = 0; i < n - 1; i++) {
        int s1 = 0, s2 = 0;
        for(int j = 0; j < n; j++) {
            if(j <= i) {
                s1 += a[j];
            } else {
                s2 += a[j];
            }
        }
        chmin(ans, abs(s1 - s2));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, M, X, Y;
int x[110];
int y[110];


signed main(){
	cin >> N >> M>> X >> Y;
	rep(i, 0, N) cin >> x[i];
	x[N] = X;
	rep(i, 0, M) cin >> y[i];
	y[M] = Y;

	sort(RNG(x, 0, N+1));
	sort(RNG(y, 0, M+1));

	int Z = y[0];
	if(x[N] >= Z) cout << "War" << endl;
	else cout << "No War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
//#include "ext/pb_ds/assoc_container.hpp"
//#include "ext/pb_ds/tree_policy.hpp"
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
//const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//int rand(int l, int r){
//    uniform_int_distribution<int> uid(l, r);
//    return uid(rng);
//}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    ll ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 55;
int dp[N][N][N * N];
int a[N];

void solve(){
    int n, A;
    cin >> n >> A;
    fr(i, 1, n) {
        cin >> a[i];
    }
    int ans = 0;
    dp[0][0][0] = 1;
    fr(i, 0, n - 1) {
        fr(j, 0, i) { // taken
            fr(k, 0, 50 * j) { // sum
                if(!dp[i][j][k]) continue;
                int val = a[i + 1];
                dp[i + 1][j][k] += dp[i][j][k];
                dp[i + 1][j + 1][k + val] += dp[i][j][k];
            }
        }
    }
    fr(i, 1, n) {
        fr(j, 0, 50 * i) {
            if(A * i == j) {
                ans += dp[n][i][j];
            }
        }
    }
    cout << ans;
}

signed main(){
    IO;
#ifdef LOCAL
    freopen("inp.txt","r", stdin);
#endif
    cout << setprecision(3) << fixed;
    //    srand(time(NULL));
    //    build();
    int t = 1;
//    cin >> t;
    fr(tt, 1, t){
//        cout << "Case #" << tt << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 65792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, s;
    cin >> n >> s;
    vector<vector<mint>> dp(n+1, vector<mint>(s+1));
    dp[0][0] = mint(2).pow(n);
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, s+1) {
            dp[i+1][j] += dp[i][j];
            if (j+a <= s) dp[i+1][j+a] += dp[i][j]/2;
        }
    }
    cout << dp[n][s] << endl;
}



Measured memory_bytes: 73656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
    double d,t,s; cin >> d >> t >> s;
    if(d/t > s) cout << "No";
    else cout << "Yes";
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3736
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
S= list(input())
s = []
cnt= 1
for i in range(len(S)-2):
  if S[i]==S[i+1]:
    cnt+=1
  else:
    s.append(cnt)
    cnt=1
s.append(cnt)
print(len(s))

Measured memory_bytes: 4644
#include<stdio.h>
int main(void){
    int i,j=1,a,b,c,d=10;
    while(scanf("%d%d" ,&a ,&b) != EOF){
        for(i=1;;i++){
            c=a+b;
            j=1;
            d=10;
            while(j!=i){
                d=d*10;
                j++;
            }
            c=c-d;
            if(c<0)
                break;
        }
        printf("%d\n",i);
    }

return 0;
}

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

#define ll long long
#define ld double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const long long int INF=0x3f3f3f3f3f;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;

int main()
{
	vivek_ghosh;
	
	ll d;
	cin>>n;
	cin>>d;
	
	ans = 0;
	while(n>0)
	{
		ans++;
		n-=((2*d)+1);
	}
	cout<<ans<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}








Measured memory_bytes: 384
x=int(input())
dp=[-1]*(x+1)
dp[0]=1
for i in range(1,x+1):
  for j in range(100,106):
    if i-j>=0:
      if dp[i-j]==1:
        dp[i]=1
if dp[x]==1:
  print(1)
else:
  print(0)

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
        
        if (N % 10 == 0) {
        	answer = 10;
        } else {
        	String n = Integer.toString(N);
        	for (int i = 0; i < n.length(); i++) {
        		answer += Integer.valueOf(n.substring(i,i+1));
        	}
        	
        }
        
        return answer;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c= sc.next();
		int count =0;
		for (int i=0;i<N;i++) {
			if (a.charAt(i)==b.charAt(i)) {
				if (c.charAt(i)!=b.charAt(i)) {
					count ++;
				}
			} else if (b.charAt(i)==c.charAt(i)) {
				count ++;
			} else if(a.charAt(i)==c.charAt(i)) {
				count ++;
			} else {
				count +=2;
			}
		}
		System.out.println(count);
		}
}

Measured memory_bytes: 21972
#include<iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> d(K, 0);
  vector<bool> B(N, false);
  vector<vector<int> > A(K, vector<int>(N, 0));
  int tmp, ans = 0;

  for (size_t i = 0; i < K; i++) {
    cin >> d[i];
    for (size_t j = 0; j < d[i]; j++) {
      cin >> tmp;
      A[i][tmp - 1] = 1;
    }
  }

  for (size_t i = 0; i < N ; i++) {
    for (size_t j = 0; j < K; j++) {
      if (A[j][i] == 1) {
        B[i] = true;
      }
    }
  }

  for (size_t i = 0; i < N; i++) {
    if (B[i] == false) {
      ans += 1;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll T[2];
ll A[2],B[2];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T[0]>>T[1];
	cin>>A[0]>>A[1];
	cin>>B[0]>>B[1];
	
	ll X=T[0]*A[0]+T[1]*A[1];
	ll Y=T[0]*B[0]+T[1]*B[1];
	
	if(X==Y) {
		cout<<"infinity"<<endl;
		return;
	}
	
	if(A[0]>B[0]) {
		if(X>Y) return _P("0\n");
	}
	else {
		if(Y>X) return _P("0\n");
	}
	
	ll P=abs(A[0]-B[0]);
	ll Q=abs(A[1]-B[1]);
	ll D=abs(X-Y);
	ll Z=P*T[0];
	if(Z%D==0) {
		cout<<Z/D*2<<endl;
	}
	else {
		cout<<1+Z/D*2<<endl;
	}
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };

int main() {

	int w, h, n;
	cin >> w >> h >> n;
	vector<int> x(n);
	vector<int> y(n);
	vector<int> a(n);
	rep(i, n) cin >> x.at(i) >> y.at(i) >> a.at(i);

	int d[100][100];

	rep(i, w) {
		rep(j, h) {
			d[i][j] = 1;
		}
	}

	rep(i, n) {
		if (a.at(i) == 1) {
			rep(k, h) {
				for (int j = 0; j < x.at(i); j++) {
					d[j][k] = 0;
				}
			}
		}
		if (a.at(i) == 2) {
			rep(k, h) {
				for (int j = x.at(i); j < w; j++) {
					d[j][k] = 0;
				}
			}
		}
		if (a.at(i) == 3) {
			rep(k, w) {
				for (int j = 0; j < y.at(i); j++) {
					d[k][j] = 0;
				}
			}
		}
		if (a.at(i) == 4) {
			rep(k, w) {
				for (int j = y.at(i); j < h; j++) {
					d[k][j] = 0;
				}
			}
		}
	}
	int ans = 0;
	rep(i, w) {
		rep(j, h) {
			ans += d[i][j];
		}
	}

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

Measured memory_bytes: 256
import numpy as np


def main():
    N = int(input())

    ans = np.zeros(10050, int)

    for x in range(1, 105):
        for y in range(1, 105):
            for z in range(1, 105):
                fx = x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x
                if fx < 10050:
                    ans[fx] += 1
    for i in range(N):
        print(ans[i+1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 26936
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void readentry(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int main() {
	ll n, a, b; readentry(n), readentry(a), readentry(b);
	if ((b - a) % 2 == 0) 
	{
		std::cout << (b - a) / 2 << std::endl;
	}
	else 
	{
		std::cout << min(a + b - 1, 2 * n - a - b + 1) / 2 << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
using namespace std;

using ll = long long;

template <typename T, const T id>
class CHT {
	struct line {
		T a, b;
		line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
		T get(T x) { return a * x + b; }
	};
	struct node {
		line l;
		node *lch, *rch;
		node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
		~node() {
			if (lch) delete lch;
			if (rch) delete rch;
		}
	};

private:
	const int n;
	const vector<T> pos;
	node *root;

public:
	CHT(const vector<T>& pos_) : n(pos_.size()), pos(pos_), root(nullptr) {}
	~CHT() {
		if (root) delete root;
	}
	void insert(T a, T b) {
		line l(a, b);
		root = modify(root, 0, n, l);
	}
	T get(T x) const {
		int t = lower_bound(pos.begin(), pos.end(), x) - pos.begin();
		//assert(t < n && pos[t] == x);
		return sub(root, 0, n, t);
	}

private:
	node* modify(node *p, int lb, int ub, line& l) {
		if (!p) return new node(l);
		if (p->l.get(pos[lb]) >= l.get(pos[lb]) && p->l.get(pos[ub - 1]) >= l.get(pos[ub - 1])) return p;
		if (p->l.get(pos[lb]) <= l.get(pos[lb]) && p->l.get(pos[ub - 1]) <= l.get(pos[ub - 1])) {
			p->l = l;
			return p;
		}
		int c = (lb + ub) / 2;
		if (p->l.get(pos[c]) < l.get(pos[c])) swap(p->l, l);
		if (p->l.get(pos[lb]) <= l.get(pos[lb]))
			p->lch = modify(p->lch, lb, c, l);
		else
			p->rch = modify(p->rch, c, ub, l);
		return p;
	}
	T sub(node *p, int lb, int ub, int t) const {
		if (!p) return id;
		if (ub - lb == 1) return p->l.get(pos[t]);
		int c = (lb + ub) / 2;
		if (t < c) return max(p->l.get(pos[t]), sub(p->lch, lb, c, t));
		return max(p->l.get(pos[t]), sub(p->rch, c, ub, t));
	}
};


int main() {
	int Q;
	int N;
	ll C;
	cin >> N >> C;
	vector<ll> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	vector<ll> dp(N);
	dp[0] = 0;
	ll Score0 = H[0] * H[0] + C;
	ll Score1 = (H[0] - 1) * (H[0] - 1) + C - 1;


	CHT<ll, - (1LL << 60)> ct(H);
	ct.insert(-(Score1 - Score0), -Score0);

	for (int i = 1; i < N; i++)
	{
		dp[i] = -ct.get(H[i]) + H[i] * H[i];
		Score0 = H[i] * H[i] + C + dp[i];
		Score1 = (H[i] - 1) * (H[i] - 1) + C - 1 + dp[i];

		ct.insert(-(Score1 - Score0), -Score0);
	}

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

}

Measured memory_bytes: 14336
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        k: usize,
        x: i64,
    }
    let mut ans = vec![];
    for i in 0..k {
        ans.push(x-i as i64);
        ans.push(x+i as i64)
    }
    ans.sort();
    ans.dedup();
    for i in 0..ans.len() {
        print!("{} ", ans[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans=INF;
    for(ll i=-100;i<=100;i++){
        ll sum=0;
        rep(j,n){
            sum+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<iomanip>
#include<string>
#include<math.h>
#define MOD 1000000007

using namespace std; 
int main(){
    bool flag=true;
    string s,S="";
    string ss[4]={"maerd","remaerd","esare","resare"};
    cin>>s;
    for(int i=s.length()-1;i>=0;i--){
        S+=s[i];
    }
    
    int i=0;
    while(1){
        switch(S[i]){
            case 'm':{
                for(int j=0;j<5;j++){
                    if(S[i+j]!=ss[0][j])flag=false;
                }
                i+=5;
                break;
            }
            case 'e':{
                for(int j=0;j<5;j++){
                    if(S[i+j]!=ss[2][j])flag=false;
                }
                i+=5;
                break;
            }
            case 'r':{
                bool check1=true,check2=true;
                for(int j=0;j<7;j++){
                    if(S[i+j]!=ss[1][j])check1=false;
                }
                for(int j=0;j<6;j++){
                    if(S[i+j]!=ss[3][j])check2=false;
                }
                if(check1){
                    i+=7;
                }else if(check2){
                    i+=6;
                }else{
                    flag=false;
                    i=S.length();
                }
                break;
            }
        }
        if(i>=S.length())break;
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray()[0];
            var count = 0;
            for(var i = N;0<i;i--)
            {
                if (0 < i && i < 10)
                {
                    count++;
                    continue;
                }
                if (99 < i && i < 1000)
                {
                    count++;
                    continue;
                }
                if (9999 < i && i < 100000)
                {
                    count++;
                    continue;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double area = w * h;
    cout << fixed << setprecision(10) << area / 2 << ' ' ;
    cout << (x == w / 2 && y == h / 2);
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    int n, x;
    VE m;
    int M;
    cin >> n >> x;
    REP(i ,n){
        cin >> M;
        m.push_back(M);
    }
    sort(m.begin(), m.end());
    int sum = 0;
    int cnt = 0;
    REP(i, m.size()){
        sum += m[i];
        cnt++;
    }
    cnt += (x - sum) / m[0];
    print(cnt);
}

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

int main(){
    ll n,k;
    cin>>n>>k;
    if(n%k==0){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring> 

using namespace std;

const int N = 2e5 + 10;

int n, T, p[N];
char s[N];
long long L, R, num[N][30];

long long fib(long long len, int c) {
    if (len <= n) return num[len][c];
    if (len <= n * 2) return num[n][c] + num[len - n][c];
    long long f1 = num[n][c], f2 = num[n][c] + num[T][c], l1 = n, l2 = n + T;
    while (len > l1 + l2) {
        long long t = f2;
        f2 += f1, f1 = t;
        t = l2, l2 += l1, l1 = t;
    }
    return f2 + fib(len - l2, c);
}

long long calc(long long len, int c) {
    if (len <= n) return num[len][c];
    if (n % T == 0) {
        long long re = 1ll * (len - n) / T * num[T][c] + num[n][c];
        len -= n, len %= T;
        return re + num[len][c];
    }
    else return fib(len, c);
}

int main() {
    scanf("%s%lld%lld", s + 1, &L, &R);
    n = strlen(s + 1) / 2;
    p[1] = 0;
    for (int j = 0, i = 2; i <= n; i ++) {
        for (; j && s[j + 1] != s[i];) j = p[j];
        if (s[j + 1] == s[i]) j ++;
        p[i] = j;
    }
    for (int i = 1; i <= n; i ++) {
        for (int j = 0; j < 26; j ++) num[i][j] = num[i - 1][j];
        num[i][s[i] - 'a'] ++;
    }
    T = n - p[n];
	for (int i = 0; i < 26; i ++) printf("%lld%c", fib(R, i) - fib(L - 1, i), i == 25 ? 10 : 32);
    return 0;
}

Measured memory_bytes: 27136
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
ll n, q, k, u, v, w, x[300005];
struct st {ll v,c;};
vector<st> a[300005];

void f(ll p, ll pr, ll q) {
	x[p] = q;
	for(ll i=0; i<a[p].size(); i++)
		if(a[p][i].v!=pr) f(a[p][i].v, p, q+a[p][i].c);
}

int main() {
	scanf("%lld", &n);
	while(--n) {
		scanf("%lld%lld%lld", &u, &v, &w);
		a[u].push_back({v,w});
		a[v].push_back({u,w});
	}
	scanf("%lld%lld", &q, &k);
	f(k, 0, 0);
	while(q--) {
		scanf("%lld%lld", &u, &v);
		printf("%lld\n", x[u]+x[v]);
	}
	return 0;
}

Measured memory_bytes: 20864
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
//password:+BdCHpO8dQvpo5fnV3/u
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;

int f(int n){
    for(int i=1;i<=n;i++){
        if(i*(i+1)/2==n) 
        {
            return i;
        }
        else if (i*(i+1)/2>n){
            return i-1;
        }
    }
}

int main() {
    ll n;
    scanf("%lld",&n);
    int cnt=0;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int qaq=0;
            while(n%i==0) n/=i,qaq++;
            cnt+=f(qaq);
        }
    }
    if(n>1) cnt++;
    cout<<cnt;
     return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t d;
    cin >> d;
    if(d==25){
        cout << "Christmas" << endl;
    }
    if(d==24){
      cout << "Christmas Eve" << endl;
    }
    if(d==23){
      cout << "Christmas Eve Eve" << endl;
    }
    if(d==22){
      cout << "Christmas Eve Eve Eve" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string NAME;
  
  cin >> NAME;
  
  int N;
   N = NAME.size();
  
  char c = NAME.at(N-1);
  
  if ( c != 's' ) {
    
    cout << NAME << 's' << endl;
  }
  
  else{
      cout << NAME << "es" << endl;
  }
}

Measured memory_bytes: 3596
#include <stdio.h>

int cmp(char[],char[]);

int main() {
  int n,i,j,k,m;
  char a[101][2],b[101][2],tmp[2];
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%s",a[i]);
    for(k=0; k<2; k++) b[i][k]=a[i][k];
  }
  for(i=0; i<n; i++) {
    for(j=n-1; j>i; j--) {
      if(a[j][1]<a[j-1][1]) {
	for(k=0; k<2; k++) tmp[k]=a[j][k];
	for(k=0; k<2; k++) a[j][k]=a[j-1][k];
	for(k=0; k<2; k++) a[j-1][k]=tmp[k];
      }
    }
  }
  for(i=0; i<n; i++) {
    m=i;
    for(j=i+1; j<n; j++) {
      if(b[j][1]<b[m][1]) m=j;
    }
    if(b[m][1]<b[i][1]) {
      for(k=0; k<2; k++) tmp[k]=b[i][k];
      for(k=0; k<2; k++) b[i][k]=b[m][k];
      for(k=0; k<2; k++) b[m][k]=tmp[k];
    }
  }
  int ck=1;
  for(i=0; i<n; i++) {
    if(a[i][0]!=b[i][0]) ck=0;
  }    
  for(i=0; i<n; i++) {
    if(i) printf(" ");
    printf("%c%c",a[i][0],a[i][1]);
  }
  printf("\nStable\n");
  for(i=0; i<n; i++) {
    if(i) printf(" ");
    printf("%c%c",b[i][0],b[i][1]);
  }
  if(ck) printf("\nStable\n");
  else printf("\nNot stable\n");
  return 0;
}


Measured memory_bytes: 612
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
 
 
	public void run() {
		Scanner sc = new Scanner(System.in);
		int A =sc.nextInt();
		String op =sc.next();
		int B =sc.nextInt();
		
		if(op.equals("+")){
		    System.out.println(A+B);
		}else if(op.equals("-")){
		    System.out.println(A-B);
		}
		
		
	}
		
}


Measured memory_bytes: 35560