akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   string ss;
   int ans = 0, l;
   f(i,1,n+1){
      ss = to_string(i);
      l = ss.size();
      if(l & 1) ans++;
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int x,y,z;
  cin >> x>> y >> z;
  cout<<z<<" "<<x << " " << y<< endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 100;
const int MAXM = 1e5;
const int INF = 1e9;

bool dp[MAXN + 1][MAXM + 1];
int dpW[MAXN + 1][MAXM + 1];
int w[MAXN + 1], v[MAXN + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void init(int n) {
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= MAXM; j++) {
			if(j > 0) dp[i][j] = false, dpW[i][j] = INF;
			else dp[i][j] = true, dpW[i][j] = 0;
		}
}

int main() {
	fast_io();
//	freopen("input/dp_e.txt", "r", stdin);
	
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}

	init(n);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= MAXM; j++) {
			dp[i][j] |= dp[i - 1][j];
			dpW[i][j] = min(dpW[i][j], dpW[i - 1][j]);
			if(j - v[i] >= 0 and w[i] + dpW[i - 1][j - v[i]] <= k) {
				dp[i][j] |= dp[i - 1][j - v[i]];
				dpW[i][j] = min(dpW[i][j], w[i] + dpW[i - 1][j - v[i]]);
			}
		}
	}
	
	int ans = 0;
	for(int i = MAXM; i >= 1; i--) {
		if(dp[n][i]) { ans = i; break; }
	}
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 49536
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        long A = Long.parseLong(scanner.next());
        long B = Long.parseLong(scanner.next());
        Long[] X = new Long[N];
        for (int i = 0; i < N; i++) {
            X[i] = Long.parseLong(scanner.next());
        }
        scanner.close();

        long walkCost = A;
        long tpCost = B;

        long totalCost = 0;
        for (int i = 0; i < N - 1; i++) {
            long current = X[i];
            // 次への移動、walk と tp どっちがいいか
            long next = X[i + 1];
            long walk = (next - current) * walkCost;
            totalCost += Math.min(walk, tpCost);
        }

        System.out.println(totalCost);
    }
}


Measured memory_bytes: 48364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

ll gcd(ll _n1, ll _n2){
	if(_n1 < _n2){ll tmp = _n1; _n1 = _n2; _n2 = tmp;}
	if(_n1 == _n2 || _n2 == 0){return _n1;}
	return gcd(_n2, _n1%_n2);
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	ll x = gcd(n, m);
	print(n*m/x)
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 2e5;
vector<int> es[MAX_V];
int st, en; //端点
vector<int> d(MAX_V, 0);

void dfs(int now, int pre){
    if(pre == -1) d[now] = 0;
    else d[now] = d[pre]+1;
    for(auto &e: es[now]){
        if(e == pre) continue;
        dfs(e, now);
    }
}

int tree_diameter(){
    dfs(0, -1);
    int ret = -1;
    rep(i, MAX_V){
        if(chmax(ret, d[i])) st = i;
    }
    dfs(st, -1);
    ret = -1;
    rep(i, MAX_V){
        if(chmax(ret, d[i])) en = i;
    }
    return ret;
}

vector<int> sz[2];
bool flag = true;

void dfs2(int now, int pre, int g){
    int s = 0, cnt = 0;
    for(auto &e: es[now]){
        if(e == pre) continue;
        elif(sz(es[e]) == 1 && e != g) s++;
        else cnt++, dfs2(e, now, g);
    }
    if(cnt >= 2) flag = false;
    sz[0].pb(s);
}

int main(){
    int N;
    cin >> N;
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    int r = tree_diameter();
    dfs2(st, -1, en);
    if(!flag) {cout << -1 << endl; return 0;}
    rep3(i, r, 0) sz[1].pb(sz[0][i]);
    vector<int> ans[2];
    rep(k, 2){
        int now = N;
        for(auto &e: sz[k]){
            ans[k].pb(now-e);
            rep3(i, now, now-e+1) ans[k].pb(i);
            now -= e+1;
        }
    }
    rep(k, 2) reverse(all(ans[k]));
    int use = 0;
    rep(i, N){
        if(ans[0][i] < ans[1][i]) break;
        elif(ans[0][i] > ans[1][i]) {use = 1; break;}
    }
    for(auto &e: ans[use]) cout << e << ' '; cout << endl;
}

Measured memory_bytes: 18936
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

int main(void) {
	int n;
	pair<int, int> ab[200000];

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d %d", &ab[i].first, &ab[i].second);
	}

	sort(&ab[0], &ab[n], [](pair<int, int>& a, pair<int, int>& b) {
		return a.second < b.second;
	});

	int time = 0;
	for(int i = 0; i < n; i++) {
		time += ab[i].first;
		if(time > ab[i].second) {
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 1664
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve2(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve2(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[] weights = new int[n];
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = scanner.nextInt();
            values[i] = scanner.nextInt();
        }

        // dp[i] denote maximum sum of values when total weights is i
        long[] dp = new long[w + 1];

        for (int i = 0; i < n; i++) {
            for (int j = w; j >= 0; j--) {
                if (j-weights[i] >=0) {
                    dp[j] = Math.max(dp[j], dp[j-weights[i]] + values[i]);
                }
            }
        }

        long ans = 0;
        for (int i = 0; i <= w; i++) {
            ans = Math.max(ans, dp[i]);
        }

        writer.println(ans);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<cmath>

int main(){
    int A;
    long long B,N;
    long long ans;
    std::cin>>A>>B>>N;
    ans=(A*N)/B-(N/B)*A;
    // for(long long x=B-1;x<=N;x+=B){
    //     long long buf=(A*x)/B-(x/B)*A;
    //     if(ans<buf){
    //         ans=buf;
    //     }
    // }
    long long buf=((N/B)-1)*B+B-1;
    buf=(A*buf)/B-(buf/B)*A;
    if(ans<buf){
        ans=buf;
    }
    std::cout<<ans;
}

Measured memory_bytes: 3628
c0 = gets.split.map(&:to_i)
c1 = gets.split.map(&:to_i)
c2 = gets.split.map(&:to_i)

a0 = 0
b0 = c0[0]
b1 = c0[1]
b2 = c0[2]
a1 = c1[0] - b0
a2 = c2[0] - b0

if a1 + b1 == c1[1] && a1 + b2 == c1[2] && a2 + b1 == c2[1] && a2 + b2 == c2[2]
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
# include<stdio.h>
using namespace std;

# define WHITE 0
# define GREY  1
# define BLACK 2

int M[100][100];
int color[100], d[100], f[100];
int n, tt = 0;

void dfs_visit(int u) {
	color[u] = GREY;
	d[u] = ++tt;
	for (int v = 0; v < n; v++) {
	    if ( M[u][v] == 0) continue;
		if (color[v] == WHITE)  dfs_visit(v);
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs() {
    for (int i = 0; i < n; i++) color[i] = WHITE;
	for (int i = 0; i < n; i++) {
	    if ( color[i] == WHITE ) dfs_visit(i);
	}
}

int main() {
    int u, v, k;
	scanf("%d", &n);
	
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) M[i][j] = 0;
    }
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		u--;
		for (int j = 0; j < k; j++) {
			scanf("%d", &v);
			v--;
			M[u][v]++;
		}
	}
	dfs();
	for (u = 0; u < n; u++) {
	    printf("%d %d %d\n", u+1, d[u], f[u]);
	}
	return 0;
}


Measured memory_bytes: 2620
import java.util.Scanner;

public class Main {

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

		int count = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26272
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int A,B,C,D,E;
    std::cin >> A>>B>>C>>D>>E;
    int last = 0;
    for (auto elem : {A,B,C,D,E}) {
        if (elem % 10 != 0 and 10 - elem % 10 > last) {
            last = 10 - elem % 10;
        }
    }

    int ans = 0;
    if (A % 10 == 0) {
        ans += A / 10 * 10;
        last = 0;
    } else {
        ans += A / 10 * 10 + 10;
    }
    if (B % 10 == 0) {
        ans += B / 10 * 10;
    } else {
        ans += B / 10 * 10 + 10;
    }
    if (C % 10 == 0) {
        ans += C / 10 * 10;
    } else {
        ans += C / 10 * 10 + 10;
    }
    if (D % 10 == 0) {
        ans += D / 10 * 10;
    } else {
        ans += D / 10 * 10 + 10;
    }
    if (E % 10 == 0) {
        ans += E / 10 * 10;
    } else {
        ans += E / 10 * 10 + 10;
    }
    std::cout << ans - last << std::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>
#define ll long long
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define iiii tuple<int, int, int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define rep(i, a, b) for (auto i = a; i != b; i += 1 - 2 * (a > b))

using namespace std;

void solve() {
    int n;
    cin >> n;
    map<string, int> cnt;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    int mx = -1;
    for (auto& i : cnt) mx = max(mx, i.se);
    for (auto& i : cnt)
        if (mx == i.se) cout << i.fi << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

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

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

Measured memory_bytes: 23808
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

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

    for(int i=111; i<=999; i+=111){
        if(i >= x){
            x = i;
            break;
        }
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

    ans = min(n, m/2);
    if (n < m/2) {
        m -= n*2;
        ans += m/4;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

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

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

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



int main(){
    cin >> N;
    vector<ll> v(N);
    map<ll, ll> mp, mn;
    REP(i,N) {cin >> v[i]; ++mp[v[i]];}
    ll sum = 0;
    for(auto it = mp.begin(); it != mp.end(); ++it){
        ll n = it->second;
        sum += n*(n-1)/2;
    }
    for(auto u:v){
        auto it = mp.find(u);
        ll n = it->second;
        if(n == 1) mn[u] = sum;
        else mn[u] = sum - (n-1);
    }
    for(int i = 0; i < N; ++i){
        auto it = mn.find(v[i]);
        cout << it->second << "\n";
    }
    return 0;
}

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


int main(){
    long long int n,a,b;
    cin>>n>>a>>b;


    long long int ans;
    ans=(n-2)*b-(n-2)*a+1;

    if(ans<=0){
        cout<<0<<endl;
    }else{
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

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

ll op(ll a, ll b) {
  return max(a, b);
}

ll e() {
  return -1;
}

int target;
bool f(ll x) {
  return x < target;
}

signed main() {
  init();
  ll N, Q;
  cin >> N >> Q;
  vll A(N);
  cin >> A;
  segtree<ll, op, e> seg(A);

  rep(i, Q) {
    ll t, l, r;
    cin >> t >> l >> r;
    l--;

    if (t == 1) seg.set(l, r);
    if (t == 2) COUT(seg.prod(l, r));
    if (t == 3) {
      target = r;
      COUT(seg.max_right<f>(l) + 1);
    }
  }

  return 0;
}

Measured memory_bytes: 8996
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT
 
#define sz(x) ((int)x.size())
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1e5;
#define FILENAME ""
const double eps = 1e-6;
const int maxn = 1001;
 
struct q
{
    int a, b, c;
    q(int _a, int _b, int _c) {
        a = _a;
        b = _b;
        c = _c;
    }    
};

char a[1001][1001];

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

int n, m;

bool valid (int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("dijkstra.in", "r", stdin);
    //freopen("dijkstra.out", "w", stdout);
    cin >> n >> m;
    queue <q> s;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            char x;
            cin >> x;
            a[i][j] = x;
            if (x == '#') {
                q q1(i, j, 0);
                s.push(q1);
            }
        }
    }
    ll ans = 0;
    while (!s.empty()) {
        q v = s.front();
        ans = max(ans, (ll)v.c);
        s.pop();
        for (int i = 0; i < 4; i++) {
            int nx = v.a + dx[i];
            int ny = v.b + dy[i];
            if (valid(nx, ny) && a[nx][ny] == '.') {
                a[nx][ny] = '#';
                q q1(nx, ny,  v.c + 1);
                s.push(q1);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 13328
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

int n;
vii ts[18];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>n;
    REP(i,0,n-1){
    	int x;
    	cin>>x;
    	REP(j,1,x){
    		int a,b;
    		cin>>a>>b;
    		ts[i].pb({a-1, b});
		}
	}
	
	int ans = 0;
	for(int mask=0; mask<(1<<n); mask++){
		bool fail = false;
		for(int i=0; i<n; i++){
			if(mask & (1<<i)){ // honest
				for(int j=0; j<ts[i].size(); j++){
					int a = ts[i][j].F;
					int cp = ts[i][j].S;
					if(cp == 0 && (mask & (1<<a))){
						fail = true;
					}
					if(cp == 1 && !(mask & (1<<a))){
						fail = true;
					}
				}
			}
		}
		if(!fail){
//			printf("can %d\n",mask);
			ans = max(ans, __builtin_popcount(mask));
		}
	}
	
	cout << ans << endl;
    
    return 0;
}

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

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

  bool good = true;
  for (int i = 0; i < 3; i++)
  {
    if (S[i] == S[i + 1])
    {
      good = false;
      break;
    }
  }

  cout << (good ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 256
import sys

class Dice(object):
	def __init__(self, data):
		self.dice=data
	def roll_n(self):
		self.dice=(self.dice[1],self.dice[5],self.dice[2],
					self.dice[3],self.dice[0],self.dice[4])
	def roll_e(self):
		self.dice=(self.dice[3],self.dice[1],self.dice[0],
					self.dice[5],self.dice[4],self.dice[2])
	def roll_w(self):
		self.dice=(self.dice[2],self.dice[1],self.dice[5],
					self.dice[0],self.dice[4],self.dice[3])				
	def roll_s(self):
		self.dice=(self.dice[4],self.dice[0],self.dice[2],
					self.dice[3],self.dice[5],self.dice[1])
	def get_top(self, id):
 		return self.dice[id-1]

data=Dice([int(i) for i in sys.stdin.readline().split()])
order=sys.stdin.readline().strip()
for i in order:
	if i=='N':
		data.roll_n()
	elif i=='E':
		data.roll_e()
	elif i=='S':
		data.roll_s()
	elif i=='W':
		data.roll_w()
print(data.get_top(1))

Measured memory_bytes: 6752
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,h))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)



Measured memory_bytes: 3064
#include <iostream>
	#include <stdio.h>
	#include <cmath>
	#include <algorithm>
	#include <climits>
	#include <vector>
	#include <iomanip>
	#include <string>
	#include <queue>
	#include <numeric>
	#include <functional>
	using namespace std;

	int main() {
		long N, M;
		cin >> N >> M;
		long count = sqrt(M);
		long gcd = 0;
		for (long i = 1; i <= count;++i) {
			if (!(M%i)) {
				long quotient1 = M / i;
				if (N <= quotient1 && gcd < i)gcd = i;
				long quotient2 = M / (M/i);
				if (N <= quotient2 && gcd < (M/i))gcd = (M/i);
			}
		}
		cout << gcd << endl;
	}


Measured memory_bytes: 256
from bisect import bisect_left
import random
import time
import math


#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
#初期解
T = []
for _ in range(D):
    t = random.randrange(26)
    T.append(t)


last_day = [[-1] for _ in range(26)]
for d in range(D):
    test = T[d]
    last_day[test].append(d)
for i in range(26):
    last_day[i].append(D)


T0 = 5000
time_start = time.perf_counter()
while True:
    time_now = time.perf_counter()
    if time_now - time_start > 1.82:
        break
    #時間を正規化して温度を設定
    time_n = (time_now - time_start) / 1.82
    T1 = T0 ** (1 - time_n)
    #ランダムな日のテストをランダムに入れ替え
    d = random.randrange(365)
    q = random.randrange(26)
    old = T[d]
    T[d] = q
    #日程dでの元のテストold
    l = last_day[old]
    ind_old = l.index(d)
    dd_left = l[ind_old] - l[ind_old-1] - 1
    dd_right = l[ind_old+1] - l[ind_old] - 1
    dd = l[ind_old+1] - l[ind_old-1] - 1
    dif_old = C[old] * (((dd_left * (dd_left + 1)) // 2) + ((dd_right * (dd_right + 1)) // 2) - ((dd * (dd + 1)) // 2))
    #日程dでのテストq
    l = last_day[q]
    ind_q = bisect_left(last_day[q],d)
    dd_left = d - l[ind_q-1] - 1
    dd_right = l[ind_q] - d - 1
    dd = l[ind_q] - l[ind_q-1] - 1
    dif_q = C[q] * (((dd * (dd + 1)) // 2) - ((dd_left * (dd_left + 1)) // 2) - ((dd_right * (dd_right + 1)) // 2))
    #変更による差
    dif_s = dif_old + dif_q - S[d][old] + S[d][q]
    if (dif_s > 0) or (math.exp(dif_s / T1) > random.random()):
        del last_day[old][ind_old]
        last_day[q].insert(ind_q,d)
    else:
        T[d] = old
for d in range(365):
    print(T[d] + 1)



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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

//#define	MOD 1000000007
#define	MOD 998244353
#define MAX 510000

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

ll	MPl(ll x, ll y) {
	return (x+y)%MOD;
}

ll	MMi(ll x, ll y) {
	return (x-y+MOD)%MOD;
}

ll	MMul(ll x, ll y) {
	return (x*y)%MOD;
}

// Array
vector<ll> fac(MAX, 0);
vector<ll> finv(MAX, 0);
vector<ll> inv(MAX, 0);

void	DivInit() { // fac, finv, inv
	fac.at(0) = 1;
	fac.at(1) = 1;
	finv.at(0) = 1;
	finv.at(1) = 1;
	inv.at(1) = 1;
	for (int i=2; i<MAX; i++) {
		fac.at(i) = (fac.at(i-1)*i) %MOD;
		inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
		finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD; 
	}
}

ll	MDiv(ll x, ll y) {
	if (1!=inv.at(1))
		DivInit();
	return (x*inv.at(y))%MOD;
}

ll	MComb(ll N, ll K) {
	if (1!=inv.at(1))
		DivInit();
	if (N<K)
		return 0;
	if ((N<0)||(K<0))
		return 0;
	return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

void unique_count(vector<ll> &a, vector<vector<ll>> &b) {
	// erase(b.begin(), b.end());
	for (auto i=0; i<a.size(); i++)
		if ((i>0)&&(a.at(i)==a.at(i-1)))
			b.back().at(1)++;
		else
			b.push_back({a.at(i), 1});
	return;
}

int	main() {
	ll N, S;
	cin >>N >>S;
	vector<ll> A(N+1, 0);
	Rep1(i, N)
		cin >>A.at(i);
	//
	Sort(A);
	vector<vector<ll>> SS(N+1, vector<ll> (S+1, 0));
	SS.at(0).at(0)=1;
	Rep1(i, N) {
		ll AA=A.at(i);
		// Include this or not
		Rep0(k, S+1) {
			if (0==SS.at(i-1).at(k))
				continue;
			// Not include, still option to pick (but not add)
			SS.at(i).at(k)=MPl(SS.at(i).at(k), MMul(SS.at(i-1).at(k), 2));
			// Include, no option not to pick
			if (k+AA<=S)
				SS.at(i).at(k+AA)=MPl(SS.at(i).at(k+AA), SS.at(i-1).at(k));
		}
	}
	cout <<SS.at(N).at(S) <<endl;
	return 0;
}



Measured memory_bytes: 85496
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
int main (){
  int N;
  cin>>N;
  int minn;
  int maxx;
  vector<int>A(N);
  vector<int>B(N);
  rep(i,N){
    cin>>A[i];
    cin>>B[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2==0){
    minn=A[N/2-1]+A[N/2];
    maxx=B[N/2-1]+B[N/2];
  }
  else{
    minn=A[(N+1)/2-1];
    maxx=B[(N+1)/2-1];
  }
  cout<<maxx-minn+1;
}


Measured memory_bytes: 4860
import sys
input = sys.stdin.readline
n = int(input())
ai = [0]*n
bi = [0]*n
cnt = 0
for i in range(n):
  a,b = map(int,input().split())
  ai[-(i+1)] = a
  bi[-(i+1)] = b
for i in range(n):
  if (ai[i] + cnt) % bi[i] != 0:
    cnt += bi[i] - (ai[i] + cnt) % bi[i]
print(cnt)

Measured memory_bytes: 10932
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, x; cin >> n >> x;
  vll a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, 1, n) {
    if (a[i-1] + a[i] > x) {
      ans += a[i-1] + a[i] - x;
      a[i] -= (a[i-1] + a[i] - x);
      if (a[i]<0) a[i] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
from collections import Counter
input = sys.stdin.readline

def main():
    a = input().strip()
    n = int(input())
    l = len(a)
    b = Counter(a)
    if len(b) == 1:
        c = (n * l) // 2
        print(c)
        exit()
    su = 0
    ans = []
    for i in range(1, l):
        if a[i] == a[i - 1]:
            su += 1
        else:
            ans.append(su + 1)
            su = 0
    ans.append(su + 1)
    rev = 0
    for j in ans:
        rev += j // 2
    if a[0] == a[-1]:
        dif = ans[0]//2 + ans[-1]//2 - (ans[0]+ans[-1])//2
        print(rev*n - dif*(n - 1))
    else:
        print(rev*n)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int num;
    cin >> num;
    map<int, int> prepared_map;
    for(int i = 0; i < num; i++) {
        int val;
        cin >> val;
        prepared_map[val]++;
    }

    bool flag = true;
    int mum;
    cin >> mum;
    for(int i = 0; i < mum; i++) {
        int val;
        cin >> val;
        if(!prepared_map[val]) { flag = false; break; }
        prepared_map[val]--;
    }

    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 12964
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	string st;
	cin >> n >> st;
	int ans=0;
	for(int k=0;k<n;k++){
		string s;
		for(int i=k;i<n;i++)
			s.push_back(st[i]);
		int N=s.size(),m=0;
		int z[N]={0};
		for (int i = 1, l = 0, r = 0; i < N; ++i) {
	        if (i <= r)
	            z[i] = min (r - i + 1, z[i - l]);
	        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	            ++z[i];
	        if (i + z[i] - 1 > r)
	            l = i, r = i + z[i] - 1;
	    }
	    for (int j = 0; j < N; ++j) {
            if (z[j] <= j) {
                ans = max(ans, z[j]);
            }
        }
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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 mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};

 

int main(){
    int h,w;cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(s[i][j]=='#') continue;
            queue<pair<int,P>> q;
            q.push(mp(0,mp(i,j)));
            vector<vector<int>> dp(h+1,vector<int> (w+1,INF));
            dp[i][j] = 0;
            while(!q.empty()){
                auto p = q.front();q.pop();
                int c = p.fs;
                int x = p.sc.sc,y = p.sc.fs;
                for (int k = 0; k < 4; k++) {
                    int ny = y + dy[k],nx = x + dx[k];
                    if(0<=ny&&ny<h&&0<=nx&&nx<w&&s[ny][nx]!='#'){
                        if(chmin(dp[ny][nx],c+1)){
                            q.push(mp(c+1,mp(ny,nx)));
                        }
                    }
                }
            }
            for (int l = 0; l < h; l++) {
                for (int r = 0; r < w; r++) {
                    if(dp[l][r] == INF) continue;
                    ans = max(ans, dp[l][r]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 103;
const int DIVISORS_CNT = 75;

int n;
int primeCnt[MAX_N];
int dp[MAX_N][DIVISORS_CNT + 1];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		int tmp = i;
		for (int j = 2; j * j <= i; j++)
		{
			while (tmp % j == 0)
			{
				tmp /= j;
				primeCnt[j]++;
			}
		}
		if (tmp != 1)
			primeCnt[tmp]++;
	}

	dp[1][1] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= DIVISORS_CNT; j++)
			for (int k = 0; k <= primeCnt[i]; k++)
			{
				if (j * (k + 1) > DIVISORS_CNT)
					break;
				dp[i + 1][j * (k + 1)] += dp[i][j];
			}
	cout << dp[n + 1][DIVISORS_CNT] << endl;
}

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


int main() {
  int N;
  double A;
  cin >> N;
  for(int i=0; i<N; i++){
    double a;
    cin >> a;
    A += 1/a;
  }
  A = 1/A;
  cout << A << endl;
  return 0;
  
}

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

using ll = long long;
using Pi = pair < int , int >;
constexpr int INF = (1 << 30) - 1; 
int N, K;
vector < int > G[2005];

int calcDelete(int prev, int node, int depth) {
    int ret = (depth > (K + 1) / 2);
    for ( auto &to : G[node] ) if ( to != prev ) ret += calcDelete(node, to, depth + 1);
    return ( ret );
}

int main()
{
    int A[2005], B[2005];
    cin >> N >> K;
    for ( int i = 0; i < N - 1; i++ ) {
        cin >> A[i] >> B[i]; --A[i], --B[i];
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }

    int minv = INF;
    if ( K % 2 == 0 ) {
        for ( int root = 0; root < N; root++ ) {
            minv = min(minv, calcDelete(-1, root, 0));
        }
    } else {
        for ( int i = 0; i < N - 1; i++ ) {
            minv = min(minv, calcDelete(B[i], A[i], 1) + calcDelete(A[i], B[i], 1));
        }
    }
    cout << minv << endl;

    return ( 0 );
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;
ll rec(ll n);

int main(void) {
    ll tmp, min, d, n, ans=0;
    
    cin >> tmp;
    min=tmp*4;
    cin >> tmp;
    min=min(min, tmp*2);
    cin >> tmp;
    min=min(min, tmp);
    cin >> d;
    cin >> n;
    
    if(min*2<=d) {
        ans=n*min;
    }else {
        if(n%2==0) {
            ans=n/2*d;
        }else {
            ans=(n-1)/2*d+min;
        }
    }
    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;


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

	if(A%2 == 1 && B%2 == 1) Yes;
	else No;

	return 0;
}


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

using namespace std;

int main() {
    int arr[3];
    for (int i = 0; i < 3; ++ i) cin >> arr[i];
    sort(arr, arr + 3);
    if ((arr[0] == arr[1] && arr[1] != arr[2]) || (arr[1] == arr[2] && arr[0] != arr[1])) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n;
    cin>>n;

    ll ans=0;
    for(ll i=1;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            ans+=j;
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
 
  // 入力
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  
  c=a+b;
  if(c<a-b)c=a-b;
  if(c<a*b)c=a*b;

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    int n,mid1,mid2;
    cin>>n;
    vector<int> vec(n),vec2(n);
    rep(i,n){
        cin>>vec[i];
        vec2[i]=vec[i];
    }
    sort(rall(vec2));
    mid1=vec2[n/2-1];
    mid2=vec2[n/2];
    rep(i,n){
        if(vec[i]<=mid2)cout<<mid1<<endl;
        else cout<<mid2<<endl;
    }
}

Measured memory_bytes: 4744
#include <stdio.h>

int main(){
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if(a < b){
        printf("a < b\n");
    }
    
    else if(a > b){
        printf("a > b\n");
    }
    
    else {
        printf("a == b\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] a = new int[N][M+1];
        int[] count = new int[M];
        int num = 0;

    for(int i=0;i<N;i++){
        a[i][0] = sc.nextInt();
        for(int j=1;j<=a[i][0];j++){
            a[i][j] = sc.nextInt();
            count[a[i][j]-1]++;
        }
    }
    for(int i=0; i<M; i++){
        if(count[i] == N){
            num++;
        }
    }
    System.out.println(num);
    }
}


Measured memory_bytes: 23044
#include <bits/stdc++.h>
#define ll                  long long
#define pb                  push_back
#define pf                  push_front
#define mp                  make_pair
#define in                  insert
#define sz(a)               (int)(a).size()
#define all(x)              (x).begin(), (x).end()
#define fore(i,a,b)         for(ll i=a; i<b; i+=1)
#define forr(i,a)           for(ll i=a; i>=0; i-=1)
#define forg(i,b,e,c)       for (ll i=(ll)b; i<(ll)e; i+=c)
#define ford(i,a)           for(auto i=a.begin(); i!=a.end(); i++) 
#define F first
#define S second
#define clr(a,val)          memset(a,val,sizeof (a))
#define min3(a, b, c)       min(min(a, b), c)
#define min4(a, b, c, d)    min(min(a, b), min(c, d))
#define max3(a, b, c)       max(max(a, b), c)
#define max4(a, b, c, d)    max(max(a, b), max(c, d))
#define endl "\n"
#define printV(arr)         fore(x,0,sz(arr)) cout << arr[x] <<" "; cout<<endl;
#define printR(arr,a,b)     fore(x,a,b) cout << arr[x] <<" "; cout<<endl;
#define setp(x)             fixed<<setprecision(x)
 
 
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll,ll> lll;
typedef vector<ii> vii;
typedef vector<lll> vlll;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<string> vs;
const int MAX=1e5+10;
const int MOD=1000000009;
const double pi=acos(-1);
const int dx[]={0,1,-1,0};
const int dy[]={-1,0,0,1};
const int dxc[]={0,1,-1,0,1,1,-1,-1};
const int dyc[]={-1,0,0,1,-1,1,-1,1};
 
ll min(ll a, ll b){
    if(a>b) return b;
    return a;
}
ll max(ll a, ll b){
    if(a>b) return a;
    return b;
}
 
ll gcd(ll a, ll b){
    while(b!=0){
        a%=b;
        swap(a,b);
    }
    return a;
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
bool isPrime(ll n){
    if(n<=1) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3; i*i<=n; i+=2){
        if(n%i==0) return false;
    }
    return true;
}
 
set<ll> gen(ll n){
    set<ll> divs;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            divs.insert(i);
            divs.insert(n/i);
        }
    }
    return divs;
}
 
map<ll, int> fact(ll n){
    map<ll, int> F;
    for(ll p = 2; p*p <= n; p++){
        while(n%p == 0){
            F[p]++;
            n /= p;
        }
    }   
    if(n > 1) F[n]++;
    return F;
}
 
ll sum(ll n){
    return (n*(n+1))/2;
}
 
ll binaryExp(ll a, ll b, ll c){
    if(b==0) return 1;
    if(b%2==0){
        ll temp=binaryExp(a,b/2,c);
        return (temp*temp)%c;
    }
    else{
        ll temp=binaryExp(a,b-1,c);
        return (temp*a)%c;
    }
}
 
bool isPal(string& cad){
    int p1=sz(cad)-1;
    fore(i,0,sz(cad)/2){
        if(cad[i]!=cad[p1]) return false;
        p1--;
    }
    return true;
}

double dis(double x1,double y1, double x2, double y2){
    double ff=pow(x2-x1,2)+pow(y2-y1,2);
    return sqrt(ff);
}

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string cad; cin>>cad;
    int hh=0;
    fore(i,0,sz(cad)){
        hh+=cad[i]-'0';
    }
    if(hh%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3776
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
A = np.array(read().split(),np.int64)

answer = 0
for n in range(63):
    B = (A >> n) & 1
    x = np.count_nonzero(B)
    y = N - x
    x *= y
    for _ in range(n):
        x *= 2
        x %= MOD
    answer += x
answer %= MOD
print(answer)

Measured memory_bytes: 38584