akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=200005;	    

void solve(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A%2==0||B%2==0||C%2==0){
    cout<<0;
  }
  else{
    cout<<min({A*1ll*B,B*1ll*C,A*1ll*C});
  }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



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

public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int n=cin();
		long[]arr=splitL();
		long ans=0;
		for(int i=1;i<n;i++)
		{
			if(arr[i]>=arr[i-1])
				continue;
			ans=ans+arr[i-1]-arr[i];
			arr[i]=arr[i-1];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 68900
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int k,n; cin >> k >> n;
	vi a(n); rep(i,n) cin >> a[i];
	int ans = k;
	int mx = 0;
	rep(i,n-1) mx = max(mx,a[i+1]-a[i]);
	mx = max(mx,k+a[0]-a[n-1]);
	ans -= mx;
	cout << ans << endl;
}




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

const int INF = 1e6;

int main()
{
	int N;
	cin >> N;
	vector<int> d(N + 1, INF);
	queue<int> q;
	d[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int p = q.front(); q.pop();
		if (p + 1 <= N && d[p + 1] == INF) {
			d[p + 1] = d[p] + 1;
			if (p + 1 == N) {
				cout << d[p + 1] << endl;
				return 0;
			}
			q.push(p + 1);
		}
		for (int i = 6; p + i <= N; i *= 6) if (d[p + i] == INF) {
			d[p + i] = d[p] + 1;
			if (p + i == N) {
				cout << d[p + i] << endl;
				return 0;
			}
			q.push(p + i);
		}
		for (int i = 9; p + i <= N; i *= 9) if (d[p + i] == INF) {
			d[p + i] = d[p] + 1;
			if (p + i == N) {
				cout << d[p + i] << endl;
				return 0;
			}
			q.push(p + i);
		}
	}
	return 0;
}


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

using namespace std;

typedef long long int lli;

int n, m, par[100001];

int root(int x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = root(par[x]);
    }
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    par[x] = y;
}

int main() {
    int x, y, z;

    for (int i=0; i<100001; i++) par[i] = i;

    cin >> n >> m;
    for (int i=0; i<m; i++) {
        cin >> x >> y >> z;
        unite(x, y);
    }

    int ans = 0;
    vector<bool> used(100001, false);
    for (int i=1; i<=n; i++) {
        int idx = root(i);
        if (!used[idx]) {
            ans++;
            used[idx] = true;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
#pragma GCC optimize "O3"
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

const int LOG = 8;
const int MAX = 100002;
int can[1<<(LOG+1)][100003];

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	std::cin >> n;
	VI V(n+1), W(n+1);
	REP(i, 1, n+1){
		std::cin >> V[i] >> W[i];
	}

	REP(i, 1, 1<<(LOG+1)){
		if(i > n) break;

		int id = i;
		FOR(mask, 1<<(LOG+1)){
			int v = i;
			int ind = 0;
			int price = 0;
			int value = 0;
			while(v > 0){
				if(mask & (1<<ind)) price += W[v], value += V[v];
				v >>= 1;
				ind++;
			}

			if(price < MAX && can[id][price] < value){
				can[id][price] = value;
			}
		}

		REP(j, 1, MAX) can[id][j] = std::max(can[id][j], can[id][j-1]);
	}

	int q;
	std::cin >> q;
	FOR(_, q){
		int v, l;
		std::cin >> v >> l;

		if(v < (1<<(LOG+1))){
			std::cout << can[v][l] << "\n";
			continue;
		}

		VI vec;
		while(v >= (1<<(LOG+1))){
			vec.push_back(v);
			v>>=1;
		}

		int best = 0;
		FOR(mask, 1<<SZ(vec)){
			int price = 0;
			int value = 0;
			FOR(j, SZ(vec)) if(mask & (1<<j)) value += V[vec[j]], price += W[vec[j]];
			if(price <= l) best = std::max(best, can[v][l-price]+value);
		}

		std::cout << best << "\n";
	}

	return 0;
}

Measured memory_bytes: 204952
using System;

class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());

        int O;
        for (int i = X; ; i++)
            if (IsPrime(i))
            {
                O = i;
                break;
            }

        Console.WriteLine(O);
    }

    static bool IsPrime(int a)
    {
        double sqrt = Math.Sqrt(a);
        for (int i = 2; i <= sqrt; i++)
            if (a % i == 0)
                return false;
        return true;
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define LL long long

using namespace std;

int main(){
	int N, W;
	int A[105], B[105];
	LL dp[100005],ans=-1;
	
	scanf("%d%d",&N,&W);
	for (int i=0;i<N;i++) scanf("%d%d",A+i,B+i);
	
	for (int i=1;i<=W;i++) dp[i]=-1;
	dp[0]=0;
	
	for (int i=0;i<N;i++){
		for (int j=W;j>=A[i];j--){
			if (dp[j-A[i]]==-1) continue;
			dp[j] = max(dp[j],dp[j-A[i]] + B[i]); 
		}
	}
	
	for (int i=0;i<=W;i++) ans=max(ans,dp[i]);
	
	printf("%lld\n",ans);
	
	return 0;
}


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

int main() {
	// your code goes here
    long long n,d,a;
    cin>>n>>d>>a;
    vector<pair<long long,long long>>monsters;
    int x,h;
    for(int i=0;i<n;i++)
    {
        cin>>x>>h;
        monsters.emplace_back(x,h);
    }
    sort(monsters.begin(),monsters.end());
    vector<long long>change(n+1);
    long long ans=0;
    for(int i=0,j=0;i<n;i++)
    {
        while(j<n&&monsters[j].first<=monsters[i].first+2*d)
            j++;
        int bombs=max(((monsters[i].second-change[i]*a+a-1)/a),0LL);
        ans+=bombs;
        change[i]+=bombs;
        change[j]-=bombs;
        change[i+1]+=change[i];
    }
    cout<<ans;
	
	return 0;
}


Measured memory_bytes: 6512
using System;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] L = new int[N];
        int max = 0;
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
            L[i] = cin.nextInt();
            max = Math.Max(max, L[i]);
            sum += L[i];
        }

        if (sum - max > max)
        {
            Console.WriteLine("Yes");
            return;
        }

        Console.WriteLine("No");
    }
}


class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CSwaps {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        vector<int> A(N), B(N);
        REP(i,0,N) in >> A[i];
        REP(i,0,N) in >> B[i];

        vector<int> index(N);
        REP(i,0,N) {
            index[i] = i;
        }
        sort(all(index), [&](int a, int b) -> bool {
            return B[a] < B[b] || B[a] == B[b] && A[a] <= A[b];
        });
        set<pair<int, int>> aIndex; // A[i], i
        REP(i,0,N) {
            aIndex.insert({-A[i], i});
        }
        int cnt = 0;
        REP(k,0,N) {
            const int i = index[k];
            aIndex.erase({-A[i], i});
            if (A[i] <= B[i]) continue;
            auto itr = aIndex.lower_bound({-B[i], 0});
            if (itr == aIndex.end()) {
                out << "No" << "\n";
                return;
            }
            const int j = itr->second;
            aIndex.erase(itr);
            swap(A[i], A[j]);
            aIndex.insert({-A[j], j});
            cnt++;
        }
        if (cnt > N - 2) {
            out << "No" << "\n";
            return;
        } else {
            out << "Yes" << "\n";
            return;
        }
    }
};


signed main() {
    CSwaps solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define ll long long
#define MOD 1000000007
#define maxlen 100005

#define fastio ios_base::sync_with_stdio(false);
#define fastcin cin.tie(NULL);

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

    int scr[n];
    for(int i=0;i<n;i++)
        cin >> scr[i];

    int r2=a,r3=a+1,r4=b,r5=b+1;

    int ans1=0,ans2=0,ans3=0;

    for(int i=0;i<n;i++){
        if( scr[i] <= r2){
            ans1++;
        }else if( scr[i] >= r5 ){
            ans3++;
        }else{
            ans2++;
        }
    }

    cout << min(min(ans1,ans2),ans3) << "\n";


}


Measured memory_bytes: 256
import statistics
import math

N = int(input())
A_B = [[int(i) for i in input().split(' ')] for n in range(N)]

t = list(zip(*A_B))

A_sta = statistics.median(t[0])
B_sta = statistics.median(t[1])

if N % 2 == 0:
    count = int(2 * (B_sta - A_sta) + 1)
else:
    count = B_sta - A_sta + 1

print(count)

Measured memory_bytes: 59816
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

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



//--------------8---------------->> coding space <<-----------------8-------------//

void yes() { puts("Yes"); exit(0); }
void no() { puts("No"); exit(0); }


int main() {
	int N, M, K;
	cin >> N >> M >> K;
	for_(x,0,N+1) {
		int a = x * M;
		for_(y,0,M+1) {
			int b = a + (N-x) * y - x * y;
			if (b == K) yes();
		}
	}
	no();
}
//--------------8---------------->> coding space <<-----------------8-------------//

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

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
ll a[105],b[105];
ll dp[105][100005];
ll n , w;
ll solve(int i,ll rem){
 if(i==n)
    return 0;

 if(dp[i][rem]!=-1)
      return dp[i][rem];

  ll ch1=solve(i+1,rem);
  ll ch2=0;
  if(rem>=a[i]){
    ch2=solve(i+1,rem-a[i])+b[i];
  }
  return dp[i][rem]=max(ch1,ch2);
}
int main()
{
    fast();
    n=lD();w=lD();
    for(int i=0;i<n;++i){
        a[i]=lD();b[i]=lD();
    }
    memset(dp,-1,sizeof dp);
    cout<<solve(0,w);
}


Measured memory_bytes: 85664
let () =
  let h, w, d = Scanf.scanf "%d %d %d\n" (fun h w d -> h, w, d) in
  let xs = Array.make (h * w) 0 in
  let ys = Array.make (h * w) 0 in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      Scanf.scanf "%d " (fun a ->
      xs.(a - 1) <- j;
      ys.(a - 1) <- i)
    done
  done;
  let dp = Array.make (h * w) 0 in
  for i = 0 to h * w - d - 1 do
    dp.(i + d) <- dp.(i) + abs (xs.(i + d) - xs.(i)) + abs (ys.(i + d) - ys.(i))
  done;
  let q = Scanf.scanf "%d\n" (fun q -> q) in
  for i = 0 to q - 1 do
    Scanf.scanf "%d %d\n" (fun l r ->
      Printf.printf "%d\n" (dp.(r - 1) - dp.(l - 1)))
  done

Measured memory_bytes: 7040
import java.util.Scanner

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = Integer.parseInt(sc.next());
  var m = n
  var a = 0
  for (i in 0..n-1) {
    val c = Integer.parseInt(sc.next());
    m = Math.min(m, c)
    if (m >= c) {
      a += 1
    }
  }
  println(a)
}

Measured memory_bytes: 51384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(i=a;i<n;i++)
#define test(a) cout << "*" << a << endl
int main (){
  int n,i;
  
  cin >> n >> i;
  
  cout << n+1-i << endl;;
  

}

Measured memory_bytes: 256
/*Remember: The Struggle Is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int a,b;
    cin>>a>>b;

    if(b==1)
    {
        cout<<0;
        return;
    }

    b-=a;

    if(b<=0)
        cout<<1;
    else
    {
        --a;
        cout<<1+(b/a)+(b%a!=0);
    }
}

int32_t main()
{
    fast();

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

    return 0;
}



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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, M)
    {
        cin >> B[i];
    }
    vector<ll> sumA(N + 1), sumB(M + 1);
    sumA[0] = 0;
    REP(i, N)
    {
        sumA[i + 1] = sumA[i] + A[i];
    }
    sumB[0] = 0;
    REP(i, M)
    {
        sumB[i + 1] = sumB[i] + B[i];
    }
    ll ans = 0;
    ll indexB = M;
    REP(i, N + 1)
    {
        ll totalTime = sumA[i];
        while(indexB >= 0 && totalTime + sumB[indexB] > K)
        {
            indexB--;
        }
        if (indexB < 0)
        {
            break;
        }
        if (totalTime + sumB[indexB] <= K)
        {
            ans = max(ans, i + indexB);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 9596
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N,a;
  cin >> N;
  vector<pair<int, int> > s(N);
  for (int i = 0; i < N; i++){
    cin >> a;
    s[i].first = a;
    s[i].second = i + 1;
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < N - 1; i++){
    cout << s[i].second << " "; 
  }
  
  cout << s[N-1].second <<  endl;

}


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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

int n, q;
// value, weight
vector<pair<int, int>> c;
vector<vector<int>> partial;
void dfs(int v){
    if(v >= sz(partial)) return;
    if(v == 1){
        partial[v][c[v].s] = c[v].f;
    }
    else{
        for(int i = 0; i <= 1e5; ++i){
            partial[v][i] = max(partial[v][i], partial[v/2][i]);
            if(i + c[v].s <= 1e5) partial[v][i + c[v].s] = max(partial[v][i + c[v].s], partial[v/2][i] + c[v].f);
        }
    }
    int k = 0;
    for(int i = 0; i <= 1e5; ++i){
        k = max(k, partial[v][i]);
        partial[v][i] = k;
    }
    dfs(v << 1);
    dfs((v << 1) | 1);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    partial.assign(sqrt(n) + 2, vector<int>(1e5 + 1, 0));
    c.assign(n + 1, {-1, -1});
    for(int i = 1; i <= n; ++i){
        cin >> c[i].f >> c[i].s;
    }
    // cout << sz(partial) << "\n";
    dfs(1);
    // for(auto i : partial){
        // for(int j = 0; j < 20; ++j) cout << i[j] << " ";
        // cout << "\n";
    // }
    cin >> q;
    while(q--){
        int u, l;
        cin >> u >> l;
        if(u < sz(partial)){
            cout << partial[u][l] << "\n";
        }
        else{
            // cout << u << " " << l << "\n";
            vector<int> ta;
            while(u >= sz(partial)){
                ta.pb(u);
                u /= 2;
            }
            // for(auto i : ta) cout << i << " ";
            // cout << "\n" << u << "\n";
            int mx = 0;
            for(int i = 0; i < (1 << sz(ta)); ++i){
                int cost = 0, value = 0;
                for(int j = 0; j < sz(ta); ++j){
                    if((i >> j) & 1){
                        cost += c[ta[j]].s;
                        value += c[ta[j]].f;
                    }
                }
                // cout << i << " " << cost << " " << value << "\n";
                if(cost > l) continue;
                else mx = max(value + partial[u][l - cost], mx);
            }
            cout << mx << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 206268
MOD = int(1e9+7)


def main():
    S = input()
    x = [1] * 6
    for i in range(1, 6):
        x[i] = (x[i-1] * 10) % 13
    dp = [[0] * 13 for _ in range(len(S)+1)]
    dp[0][0] = 1
    for i, c in enumerate(S[::-1]):
        m = x[i % 6]
        if c == "?":
            for j in range(13):
                for k in range(10):
                    dp[i+1][(j+m*k) % 13] += dp[i][j]
            for j in range(13):
                dp[i+1][j] %= MOD
        else:
            for j in range(13):
                dp[i+1][(j+m*int(c)) % 13] = dp[i][j]
    print(dp[len(S)][5])


if __name__ == "__main__":
    main()


Measured memory_bytes: 62300
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 1e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 

v32 dp(LIM,-1);

int32_t main()
{
	IOS;
    int v,w,W;
    cin>>n>>W;
    // cout<<dp[100]<<endl;
    dp[0]=0;
    forn(i,n){
        cin>>w>>v;
        for(int j=LIM-1;j>=0;j--){
            if(j+v<LIM && dp[j]!=-1 && dp[j]+w<=W){
                dp[j+v]=(dp[j+v]==-1)?dp[j]+w:min(dp[j+v],dp[j]+w);
            }
        }
    }
    // dbg(dp[0]);
    // dbg(dp[3]);
    //first non -1 v
    for(int i=LIM-1;i>=0;i--){
        if(dp[i]!=-1){
            cout<<i<<ln;
            break;
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;
ll n, m;
int T;
ll max_l(ll x, ll y) { return x > y?x:y; }
ll f(ll n) {
    switch (n % 4) {
    case 0:return n;
    case 1:return 1;
    case 2:return n + 1;
    case 3:return 0;
    }
}

int main()
{
    cin >> n >> m;
    ll ans = f(max_l(0, n - 1)) ^ f(m);
    cout << ans<< endl;
   
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
const int MAXN=205;
int n;
int e[MAXN][MAXN];
int grp[MAXN];
int main()
{
	cin>>n;
	bool flag=false; 
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			char k;
			cin>>k;
			e[i][j]=k-'0'; 
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) 
	{
		queue<int> xtq; 
		memset(grp,0,sizeof(grp));
		int cnt=1;
		grp[i]=1;
		xtq.push(i);
		bool tmp=true;
		while(!xtq.empty())
		{
			int u=xtq.front();
			xtq.pop();
			for(int j=1;j<=n;j++)
			{
				if(e[u][j])
				{
					if((grp[j]==grp[u]-1||grp[j]==grp[u]+1)&&grp[j]!=0)
						continue;
					if(grp[j]!=0)
						tmp=false;
					else
					{
						grp[j]=grp[u]+1;
						xtq.push(j);
						cnt=max(cnt,grp[j]);
					}
				}
			}
		}
		ans=max(ans,cnt);
		if(tmp==true)
			flag=true;
	}
	if(!flag)
		cout<<-1<<endl;
	else 
		cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int h,w;
	cin >> h >> w;
	string s;
	int x=0,y=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> s;
			if(s=="snuke"){
				cout << (char)('A'+j) << 1+i << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100100;
int i,j,k,n,m,ch,ff,nls,ans;
int A[N],B[N],a[N],b[N],Ls[N],f[N],z[N];
void R(int &x) {
	ff=x=0;
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int getf(int x) {
	if (f[x]==x) return x;
	return f[x]=getf(f[x]);
}
int find(int x) {
	int l=1,r=nls,mid;
	while (l<r) {
		mid=(l+r)>>1;
		if (Ls[mid]==x) return mid;
		if (Ls[mid]<x) l=mid+1;
		else r=mid-1;
	}
	return l;
}
int main() {
	R(n);n++;
	for (i=1;i<n;i++) {
		R(A[i]);
		a[i]=A[i];
		A[n]^=A[i];
	}
	a[n]=A[n];
	for (i=1;i<n;i++) {
		R(B[i]);
		b[i]=B[i];
		B[n]^=B[i];
	}
	b[n]=B[n];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for (i=1;i<=n;i++) if (a[i]!=b[i]) return puts("-1"),0;
	a[n+1]=-1;
	for (i=1;i<=n;i++) if (a[i]!=a[i+1]) Ls[++nls]=a[i];
	for (i=1;i<=n;i++) A[i]=find(A[i]),B[i]=find(B[i]);
	for (i=1;i<=nls;i++) f[i]=i;
	for (i=1;i<n;i++) if (A[n]==B[i]) ans=-1;
	ans+=n-1;
	for (i=1;i<n;i++) {
		if (A[i]!=B[i]) {
			z[A[i]]=z[B[i]]=1;
			if (getf(A[i])!=getf(B[i])) f[f[A[i]]]=f[B[i]];
		}
		else ans--;
	} 
	for (i=1;i<=nls;i++) if (getf(i)==i && z[i]) ans++;
	printf("%d\n",max(0,ans));
}

Measured memory_bytes: 4480
n=int(input())
hqx=[]
hqy=[]
for i in range(n):
    x,y=map(int,input().split())
    hqx.append((x,i))
    hqy.append((y,i))
hqx.sort()
hqy.sort()
prex,prexi=hqx[0]
prey,preyi=hqy[0]
edges=[]#(cost,v1,v2)
for i in range(1,n):
    x,xi=hqx[i]
    y,yi=hqy[i]
    edges.append((x-prex,prexi,xi))
    edges.append((y-prey,preyi,yi))
    prex,prexi=x,xi
    prey,preyi=y,yi
edges.sort()

frag=list(range(n+1))
fragnum=[0]*(n+1)

def takefrag(p):
    stock=[]
    while frag[frag[p]]!=frag[p]:
        stock.append(p)
        p=frag[p]
    p=frag[p]
    for i in stock:
        frag[i]=p
    return p

count=0
ans=0
for i in range(2*n):
    cost,a,b=edges[i]
    f1,f2 = map(takefrag,(a,b))
    if f1!=f2:
        count+=1
        f1,f2 = min(f1,f2),max(f1,f2)
        frag[f1]=f2
        ans+=cost
    if count==n-1:
        break

print(ans)

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

int main()
{
	std::string s;
	std::cin >> s;
	std::string result;
	char c = 'a';

	for (int i = 0; i < 4; i++) {
		if (s[i] == c) {
			result = "Bad";
			break;
		}
		else {
			c = s[i];
		}
	}
	if (result != "Bad")result = "Good";
	std::cout << result;

    return 0;
}



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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define forall(i, a, b) for(int i=a; i < b; i++)
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,constant) memset(a, constant, sizeof(a))
#define mp make_pair
#define checkbit(n,b) ( (n >> b) & 1)
#define sort(a) sort(all(a))
#define PI acos(-1.0)
#define DEBUG 0

int main ()

{
    fast;
    
    string s;
    cin >> s;
    
    if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
    
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

int main()
{
  int n;
  cin >> n;
  int a[110];
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }
  int mean = sum / n;
  int x = 0;
  int y = 0;
  for (int i = 0; i < n; i++)
  {
    x += (a[i] - mean) * (a[i] - mean);
    y += (a[i] - mean - 1) * (a[i] - mean - 1);
  }
  cout << min(x, y) << "\n";
}

Measured memory_bytes: 256
class PQueue
  def initialize(n, opr)
    @ar = Array.new(n)
    @c = 0
    eval %Q{
      def push(x)
        i = @c
        @c += 1
        while (i > 0)
          parent = (i - 1) / 2
          break unless x #{opr} @ar[parent]
          @ar[i] = @ar[parent]
          i = parent
        end
        @ar[i] = x
      end
 
      def pop
        ans = @ar[0]
        @c -= 1
        x = @ar[@c]
        i = 0
        while (i * 2 + 1 < @c)
          a = i * 2 + 1
          b = a + 1
          a = b if b < @c && @ar[b] #{opr} @ar[a]
          break unless @ar[a] #{opr} x
          @ar[i] = @ar[a]
          i = a
        end
        @ar[i] = x
        ans
      end
    }
  end
end

N = gets.to_i
A = gets.split.map(&:to_i)
 
q = PQueue.new(N, :<)
totB = 0
A.take(N).each do |a|
  q.push a
  totB += a
end

fs = [totB]
A[N, N].each do |a|
  q.push a
  fs << fs.last + a - q.pop
end

q = PQueue.new(N, :>)
totC = 0
A.drop(N * 2).each do |a|
  q.push a
  totC += a
end

ls = [totC]
A[N, N].reverse_each do |a|
  q.push a
  ls << ls.last + a - q.pop
end

puts fs.zip(ls.reverse).map{|a, b| a - b}.max


Measured memory_bytes: 32328
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REVFOR(i,s,t) for(int i=s;i>=t;i--)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define NEWMAT(N, M, ini) MAT(N, vector<lint>(M, ini))
#define MOD 1000000007

#define lint_in(A) lint A; cin >> A

typedef long long lint;
typedef pair<lint, lint> P;
typedef vector<lint> V;
typedef vector<vector<lint>> MAT;
bool lessPair(const P& l, const P& r){return l.second < r.second;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);

  lint_in(N);lint_in(M);

  vector<V> edges = vector<V>(N);

  REP(i, M) {
    lint_in(s);lint_in(t);
    edges[s-1].push_back(t-1);
  }

  vector<double> dp = vector<double>(N);
  dp[N-1] = 0.0;

  REVFOR(s,N-2,0) {
    double tmp = 0;

    REP(t, edges[s].size()) {
      tmp += dp[edges[s][t]];
    }

    tmp /= edges[s].size();
    tmp += 1;
    dp[s] = tmp;
  }

  double res = dp[0];

  REP(i, N-1) {
    if(edges[i].size() == 1) continue;

    lint j = edges[i][0];
    FOR(k, 1, edges[i].size()) {
      if(dp[j] < dp[edges[i][k]]) j = edges[i][k];
    }

    // PRINT(i);
    // PRINT(j);
    vector<double> dp2 = vector<double>(N);
    dp2[N-1] = 0.0;

    REVFOR(s,N-2,0) {
      double tmp = 0;

      REP(t, edges[s].size()) {
        if(s==i && edges[s][t]==j) continue;
        tmp += dp2[edges[s][t]];
      }
      if(s==i) {
        tmp /= edges[s].size()-1;
      } else {
        tmp /= edges[s].size();
      }

      tmp += 1;
      dp2[s] = tmp;
    }
    // PRINT(dp2[0]);

    // EACHPRINT(dp2, double);
    // PRINT("");

    if(dp2[0] < res) res = dp2[0];
  }
  PRINT(res);

  return 0;
}


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

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

const int dm = 1 << 21;
char dn[dm], *di = dn, dt;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) *di++ = (*(C + i));
	*di++ = '\n';
}

const int K = 19;
const int KM = 1 << (K - 1);
int laz[1 << K];
int zero = 2e9;
void update(int L, int R, int X, int A, int l, int r) {
	if (r <= L || R <= l) return;
	if (L <= l && r <= R) {
		laz[A] = min(laz[A], X);
		return;
	}
	update(L, R, X, A * 2, l, (l + r) / 2);
	update(L, R, X, A * 2 + 1, (l + r) / 2, r);
}

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


	int N = getint(), Q = getint();
	int S[200000], T[200000], X[200000];
	rep(i, N) {
		S[i] = getint();
		T[i] = getint();
		X[i] = getint();
	}
	int D[200002];
	D[0] = -zero;
	D[Q + 1] = zero;
	rep1(i, Q) D[i] = getint();
	rep(i, 1 << K) laz[i] = zero;

	rep(i, N) {
		int L = lower_bound(D, D + Q + 2, S[i] - X[i]) - D;
		int R = lower_bound(D, D + Q + 2, T[i] - X[i]) - D;
		if (L < R) update(L, R, X[i], 1, 0, KM);
	}
	rep1(i, KM - 1) {
		laz[i * 2] = min(laz[i * 2], laz[i]);
		laz[i * 2 + 1] = min(laz[i * 2 + 1], laz[i]);
	}
	rep1(i, Q) {
		if (laz[KM + i] == zero) { 
			*di++ = '-';
			*di++ = '1';
			*di++ = '\n';
		}
		else putint(laz[KM + i]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();

        long a = (long) (k * Math.pow((double) k - 1, (double) n - 1));
        System.out.println(a);
    }
}


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

using namespace std;

int main() {
    int h, w, i, j, ans;
    cin >> h >> w;
    char t;
    int g[1001][1001];
    int arrs[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
    vector<pair<int, int> > pts;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            cin >> t;
            if (t == '.') g[i][j] = 0;
            else {
                g[i][j] = 1;
                pts.push_back(make_pair(i, j));
            }
        }
    }
    ans = 0;
    while (pts.size() != 0) {
        vector<pair<int, int> > newPts;
        for (auto &pt : pts) {
            int x = pt.first, y = pt.second;
            for (int k = 0; k < 4; k++) {
                if (x + arrs[k][0] < 0 || x + arrs[k][0] > h - 1 || y + arrs[k][1] < 0 || y + arrs[k][1] > w - 1
                  || g[x + arrs[k][0]][y + arrs[k][1]] != 0) {
                    continue;
                }
                g[x + arrs[k][0]][y + arrs[k][1]] = 1;
                newPts.push_back(make_pair(x+arrs[k][0], y+arrs[k][1]));
            }
        }
        pts = newPts;
        ans++;
    }
    cout << ans - 1;
    return 0;
}

Measured memory_bytes: 16872
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 305;

int a[maxn][maxn];
int n,m;

bool not_choose[maxn];
int ptr[maxn],cnt[maxn];
bool check(int lim) {
    for(int i=1; i<=m; i++)not_choose[i]=false;
    for(int i=1; i<=n; i++)ptr[i]=1;
    while(1) {
        for(int i=1; i<=m; i++)cnt[i]=0;
        for(int i=1; i<=n; i++) {
            while(ptr[i]<=m&&not_choose[a[i][ptr[i]]])ptr[i]++;
            if(ptr[i]>m)return false;
            cnt[a[i][ptr[i]]]++;
        }
        bool sign=0;
        for(int i=1; i<=m; i++)if(cnt[i]>lim) {
                sign=1;
                break;
            }
        if(!sign)return true;
        for(int i=1; i<=n; i++)if(cnt[a[i][ptr[i]]]>lim) {
                not_choose[a[i][ptr[i]]]=true;
                ptr[i]++;
            }
    }
    return false;
}

int main() {
  //  freopen("in.cpp","r",stdin);
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)cin>>a[i][j];
    int l=1,r=n,ans=r;
    while(l<=r) {
        int m=(l+r)>>1;
        if(check(m)) {
            ans=m;
            r=m-1;
        } else l=m+1;
    }
    cout<<ans<<endl;
    return 0;
}


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

public class Main{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] ABT = br.readLine().split(" ");
int A = Integer.parseInt(ABT[0]);
int B = Integer.parseInt(ABT[1]);
int T = Integer.parseInt(ABT[2]);
System.out.println((T/A)*B);
}
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    int M = 1;
    bool t = false;
    while(1) {
        if (M*(M-1)==2*N) {
            t = true;
            break;
        }
        else if (M*(M-1)<2*N) {
            M++;
        }
        else {
            break;
        }
    }

    if (t==false) {
        cout << "No" << endl;
    }
    else {
        vector<vector<int>> ans(M,vector<int>());
        int cnt = 1;
        rep(i,M) {
            for (int j=i+1; j<M; j++) {
                ans[i].push_back(cnt);
                ans[j].push_back(cnt);
                cnt++;
            }
        }
        cout << "Yes" << endl;
        cout << M << endl;
        rep(i,M) {
            cout << ans[i].size() << " ";
            rep(j,ans[i].size()) {
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 4332
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int x,y; cin>>x>>y;
	cout<<(x+y/2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;


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

    vector<Int> A(N);
    rep(i,N) cin >> A[i];

    Int all_xor = A[0];
    rep1(i,N-1) all_xor ^= A[i];

    if(all_xor != 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }


    
}


Measured memory_bytes: 1024
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
//        int n = sc.nextInt();
//        for (int i = 0;i<10000;++i)
//        {
//            if (1000 * i >= n)
//            {
//                System.out.println((1000*i) - n);
//                break;
//            }
//        }
        int n = sc.nextInt();
        int[] count = {0,0,0,0};
        for (int i = 0;i<n;++i)
        {
            String s = sc.next();
            if (s.equals("AC")) ++count[0];
            if (s.equals("WA")) ++count[1];
            if (s.equals("TLE")) ++count[2];
            if (s.equals("RE")) ++count[3];
        }
        System.out.println("AC x " + count[0]);
        System.out.println("WA x " + count[1]);
        System.out.println("TLE x " + count[2]);
        System.out.println("RE x " + count[3]);
        sc.close();
    }
}

Measured memory_bytes: 57884
function Main(input) {
	var input = input.split("\n");
	var i1 = input[0].split(" ");
	var i2 = input[1].split(" ");

    var d1 = new Date("2019/" + i1[0] + "/" + i1[1]);
    var d2 = new Date("2019/" + i2[0] + "/" + i2[1]);

    if (d1.getMonth() == d2.getMonth()) {
	    console.log(0);
    } else {
	    console.log(1);
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    rep(i, n) cin >> l.at(i) >> r.at(i);

    int answer = 0;
    rep(i, n) answer += r.at(i) - l.at(i) + 1;

    cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;
int x, y, z, a[100009], b[100009], c[100009];
vector<pair<int,int> > v ;
ll l[100009], r[100009];
priority_queue<int> q ;
int main()
{
    IO
    cin>>x>>y>>z;
    for(int i=1; i<=x+y+z; i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        v.push_back({b[i]-a[i],i});
    }
    sort(v.begin(),v.end());
    for(int i=1; i<=x+z; i++)
    {
        int a2=a[v[i-1].second], c2=c[v[i-1].second];
        if(q.size()<x)
        {
            q.push(c2-a2);
            l[i]=l[i-1]+a2;
        }
        else
        {
            if(!q.empty() && q.top()>c2-a2)
                l[i]=l[i-1]+q.top()+a2, q.pop(), q.push(c2-a2);
            else
                l[i]=l[i-1]+c2;
        }
    }
    while(!q.empty())
        q.pop();
   // return 0;
    for(int i=x+y+z; i>x; i--)
    {
        int b2=b[v[i-1].second], c2=c[v[i-1].second];
        if(q.size()<y)
        {
            q.push(c2-b2);
            r[i]=r[i+1]+b2;
        }
        else
        {
            if(!q.empty() && q.top()>c2-b2)
                r[i]=r[i+1]+q.top()+b2, q.pop(), q.push(c2-b2);
            else
                r[i]=r[i+1]+c2;
        }
    }
    ll mx=0;
    for(int i=x; i<=x+z; i++)
        mx=max(mx,l[i]+r[i+1]);
    cout<<mx;
    return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

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

const ll INF = 1LL << 60;


signed main() {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	if (c > d) {
		ll tmp = c;
		c = d;
		d = tmp;
	}
	ll r = c % d;
	ll e = c, f = d;
	while (r != 0) {
		e = f;
		f = r;
		r = e % f;
	}
	ll lcm = d * c / f;

		ll ans = b - a + 1;
		ll mid = b / c + b / d + (a - 1) / lcm - (a - 1) / c - (a - 1) / d - b / lcm;
		cout << ans - mid;
	
}


Measured memory_bytes: 256
//B - Unhappy Hacking (ABC Edit)
#include<bits/stdc++.h>
using namespace std;

int main()
{

string str="";
cin>>str;
for(int i=0;i<str.length();i++)
{
if(str[i]=='B' && i!=0)
{
    int count=0;
    int j=i;
    while(str[j]=='B')
        {str[j]='.';count++;j++;}
    
    for(int k=i-1;k>=0;k--)
    {
        if(count>0)
        {
            str[k]='.';
            count--;
        }
    }
    
    
    i=j-1;
}
if(str[i]=='B' && i==0)
{

    str[i]='.';
    
    
}
}

for(auto i:str)
if(i!='.')cout<<i;




return 0;
}


Measured memory_bytes: 256
def inpl():
    return list(map(int, input().split()))


def solve(N, m=5):
    tmp = (N // m) // 2
    if tmp > 0:
        t = solve(N, m * 5)
        return tmp + t
    else:
        return 0


N = int(input())

if N % 2 == 1:
    print(0)
else:
    print(solve(N))


Measured memory_bytes: 3060
def main():
    n, m = map(int, input().split())
    a = [1]*n
    f = [False]*n
    f[0] = True
    for _ in range(m):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        if f[x]:
            f[y] = True
        a[y] += 1
        a[x] -= 1
        if a[x] == 0:
            f[x] = False
    ans = 0
    for i in range(n):
        if f[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int x; cin>>x;
    if(x>=1200){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }

}

Measured memory_bytes: 256
s,t=input().split()
x=int(s)
y=int(t)
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
for i in range(7):
  if A[i]==x:
    s="A"
  if A[i]==y:
    t="A"
for i in range(4):
  if B[i]==x:
    s="B"
  if B[i]==y:
    t="B"
if x==2:
  s="C"
if y==2:
  t="C"
if s==t:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    let C = parseInt(arg[0].split(" ")[2]);
    const D = parseInt(arg[0].split(" ")[3]);
    
    let i = 0;
    
    while(A > 0 && C > 0) {
        if(i % 2 === 0) {
            C -= B;
        } else {
            A -= D;
        }
        i++;
    }
    
    if(A > C) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29624