akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  int ans = 0;
  if (m1 != m2) {
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}


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


int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n-2;i++)
    {
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1000+5;
ll n[8][maxn];
ll sum[8];
ll a[maxn],b[maxn],c[maxn];
int N,M;
int main()
{
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
	for(int j=1;j<=N;j++)
		for(int i=0;i<(1<<3);i++)
		{
			if((i&(1<<0))!=0)n[i][j]+=a[j];
			else n[i][j]-=a[j];
			if((i&(1<<1))!=0)n[i][j]+=b[j];
			else n[i][j]-=b[j];
			if((i&(1<<2))!=0)n[i][j]+=c[j];
			else n[i][j]-=c[j];
		}
	ll ans=-1e14;
	for(int i=0;i<8;i++)
	{
		sort(n[i]+1,n[i]+N+1);
		for(int j=N;j>N-M;j--)
			sum[i]+=n[i][j];
		ans=max(sum[i],ans);
	}
	printf("%lld\n",ans);
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

struct Time{
    int h, m;
};

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    Time t1, t2;
    int k;
    cin >> t1.h >> t1.m >> t2.h >> t2.m >> k;
    
    int ans = (t2.h-t1.h)*60 + (t2.m-t1.m) - k;

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

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int MAXN=131072,MAXM=30000000;
int P;
#define L 1048576
#define real long double
#define eps 1e-9
char _buf[L],*S,*T,_buf1[L],*S1=_buf1;
inline char gc()
{
	if(S==T)
	{
		T=(S=_buf)+fread(_buf,1,L,stdin);
		if(S==T)return 0;
	}
	return *S++;
}
template<class T> void get(T &x)
{
	char c;
	for(c=gc();(c<'0'||c>'9')&&c!='-';c=gc());
	bool b=0;
	if(c=='-')
	{
		b=1;
		c=gc();
	}
	for(x=c^'0',c=gc();c>='0'&&c<='9';c=gc())x=(x<<3)+(x<<1)+(c^'0');
	if(b)x=-x;
}
inline void pc(char c)
{
	if(S1==_buf1+L)
	{
		fwrite(_buf1,1,L,stdout);
		S1=_buf1;
	}
	*S1++=c;
}
void out(ll x)
{
	if(x>9)out(x/10);
	pc(x%10^'0');
}
int Pow(int x,int y)
{
	int s=1;
	for(;y;y>>=1,x=(ll)x*x%P)if(y&1)s=(ll)s*x%P;
	return s;
}
int A(int x)
{
	return x<0?-x:x;
}
int a,b,v,w,t;
int main()
{
	cin>>a>>v>>b>>w>>t;
	if((ll)(v-w)*t<A(a-b))puts("NO");
	else puts("YES");
	fwrite(_buf1,1,S1-_buf1,stdout);
	return 0;
}

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

#define int long long

signed main() {
	string s, t;
	cin >> s >> t;
	vector<int> adj[26];
	for(int i = 0; i < s.length(); i++) {
		int x = s[i]-'a';
		adj[x].push_back(i);
	}
	int ct = 0;
	int prev;
	int y = t[0]-'a';
	if(!adj[y].empty()) {
		prev = adj[y][0];	
	}
	else {
		cout << -1 << endl;
		return 0;
	}
	int var;
	for(int i = 1; i < t.length(); i++) {
		int x = t[i]-'a';
		
		if(adj[x].empty()) {
			cout << -1 << endl;
			return 0;
		}
		if(adj[x][adj[x].size()-1] <= prev) {
			ct++;
			prev = adj[x][0];
//			cout << ct << " " << prev << endl;
		}
		else {
			var = *upper_bound(adj[x].begin(), adj[x].end(), prev);
			prev = var;
//			cout << ct << " " << prev << endl;
		}
	}
	cout << ct*s.length()+prev+1 << endl;
	return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
	while(n & n-1) n --;
  	Cout(n);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	if(a>=k)
	{
		ans=k;
	}
	else if(a+b>=k)
	{
		ans=a;
	}
	else
	{
		ans=a-(k-a-b);
	}
	cout<<ans<<endl;
	return 0;
	
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * The Number of Island
 */
public class Main {

	final static int LAND = 1;
	final static int VISITED = -1;

	final static int[] V = { 1, -1, 0, 0 };
	final static int[] H = { 0, 0, 1, -1 };

	static Queue<Integer> xs, ys;
	static int count;

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

		while (true) {

			// load map
			int[][] map = new int[12][12];
			xs = new ArrayDeque<Integer>();
			ys = new ArrayDeque<Integer>();

			for (int i = 0; i < 12; i++) {
				line = br.readLine();
				for (int j = 0; j < 12; j++) {
					map[i][j] = line.charAt(j) - '0';
				}
			}

			// solve
			count = 0;
			for (int i = 0; i < 12; i++) {
				for (int j = 0; j < 12; j++) {
					if (map[i][j] == LAND) {
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							visit(map);
						}
						count++;
					}
				}
			}

			// output.
			System.out.println(count);

			// next map
			line = br.readLine();
			if (line == null) {
				break;
			} else {
				continue;
			}
		}
		//
	}

	public static void visit(int[][] map) {

		int x, y;
		x = xs.remove();
		y = ys.remove();

		map[x][y] = VISITED;

		// next choices
		for (int i = 0; i < 4; i++) {
			int xv, yh;
			xv = x + V[i];
			yh = y + H[i];
			if (xv >= 0 && xv < 12 && yh >= 0 && yh < 12 && map[xv][yh] == LAND) {
				xs.add(xv);
				ys.add(yh);
			}
		}
	}
}

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

int main() {
	int n, a[100000];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	map<int, int> mp;
	for (int i = 0; i < n; ++i) {
		mp[a[i]]++;
	}

	int ans = 0;
	for (auto i : mp) {
		int x = i.first;
		int y = i.second;
		if (y < x) ans += y;
		else ans += y - x;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>

int main() {

  int n;
  std::cin >> n;
  std::vector<int> s(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> s[i];
  }
  int q;
  std::cin >> q;
  std::vector<int> t(q, 0);
  for (int i = 0; i < q; i++) {
    std::cin >> t[i];
  }

  int count = 0;
  for (auto i : t) {
    for (auto j : s) {
      if (i == j) {
        count++;
        break;
      }
    }
  }

  std::cout << count << std::endl;
}



Measured memory_bytes: 3112
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



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

  int h,a;
  cin >> h >> a;
  int ans = (h+a-1)/a;
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int main()
{
	int n, s = -10;
	while(cin >> n && n)
	{
		string res;
		bool sign = 0 < n, k = true;
		n = abs(n);

		while(0 < n)
		{
			int t = n % 10;
			
			if(sign == k) res = char(t + '0') + res;
			else
			{
				res = char((10 - t) % 10 + '0') + res;
				if(t != 0) n += 10;
			}

			k = !k;
			n /= 10;
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll a[333333];
ll b[333333];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll ans=0; bool eq=1;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i]>>b[i];
		if(a[i]!=b[i])
		{
			eq=0;
		}
	}
	if(eq) cout<<0<<'\n';
	else
	{
		vector<ll> vec;
		for(int i=0;i<n;i++)
		{
			if(a[i]<=b[i])
			{
				ans+=b[i];
			}
			else
			{
				vec.pb(b[i]);
			}
		}
		sort(vec.begin(),vec.end());
		if(!vec.empty())
		{
			for(int i=1;i<vec.size();i++)
			{
				ans+=vec[i];
			}
		}
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 2688
/*
  AtCoder Beginner Contest 101
  C - Minimization
*/

#include<iostream>
#include<string>
#include<cmath>
using namespace std;

unsigned int N, K;

int main() {
  scanf("%u%u", &N, &K);
  
  string buf;
  getline(cin, buf);

  printf("%u\n", (uint)ceil((double)(N - 1) / (double)(K - 1)));
	return 0;
}

Measured memory_bytes: 256
/**
*    author : HikaruEgashira
*    created: 08.29.2020 21:19:00
**/
use proconio::input;

#[proconio::fastout]
fn my_ans_is_tle() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let a: Vec<i64> = a;

    let mod_value = 1000000007;

    let sum = (0..n - 1)
        .map(|na| a[na] * (na + 1..n).map(|nb| a[nb]).sum::<i64>())
        .sum::<i64>()
        % mod_value;

    println!("{}", sum);
}

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let (n, a): (usize, Vec<i64>) = (n, a);
    let mod_value = 1000000007;

    // 累積和を求める
    // b[i + 1] = b[i] + a[i]
    let b = a.iter().fold(vec![], |mut bi: Vec<i64>, ai| {
        bi.push(bi.last().unwrap_or(&0) + ai);
        bi
    });

    let sum = (0..n).fold(0, |acc, ni| {
        let sum = (b[n - 1] - b[ni]) % mod_value;
        (acc + a[ni] * sum) % mod_value
    });

    println!("{}", sum);
}


Measured memory_bytes: 7456
#include<iostream>
using namespace std;
void selectionSort(int*,int);
int main(void){
    int N,i;
    cin >> N;
    int *A;
    A = new int[N];
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    selectionSort(A,N);
    delete[] A;
    return 0;
}
void selectionSort(int *A,int N){
    int i,j,minj;
    int count = 0;
    for(i=0;i<N-1;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i!=minj){
            count++; 
            swap(A[i],A[minj]);
        }
    }
    for(i=0;i<N;i++){
        if(i>0){
            cout << ' ';
        }
        cout << A[i];
    }
    cout << '\n' << count << '\n';
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int ans1=b-a;
		if(ans1<0)ans1=Integer.MAX_VALUE;
		int ans2=1+(b+a);
		if(ans2<1)ans2=Integer.MAX_VALUE;
		int ans3=1+(-b-a);
		if(ans3<1)ans3=Integer.MAX_VALUE;
		int ans4=2+(-b+a);
		if(ans4<2)ans4=Integer.MAX_VALUE;
		int ans=Math.min(ans1, ans2);
		ans=Math.min(ans,ans3);
		ans=Math.min(ans,ans4);
		System.out.println(ans);
		
			
			
			
		
		}
		
	}





Measured memory_bytes: 9680
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <list>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iterator> 
#include <limits>

#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define ALL(a) (a).begin(),(a).end()
#define RALL(A) (a).rbegin(),(a).rend()
#define PB push_back
#define MP make_pair

#define dump(x) cerr << #x << " = " << (x) << endl;

using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

int H, W, A, B;
const int MAX_H = 100000;
const int MAX_W = 100000;
const int MOD = 1e9 + 7;

LL fact[MAX_H + MAX_W + 10];
void fact_mod(int n) {
    REP(i, n) {
        if (i == 0) {
            fact[i] = 1;
        } else {
            fact[i] = ((fact[i-1] % MOD) * i) % MOD;
        }
    }
}

LL power_mod(int a, int b, int p) {
    if (b == 0) {
        return 1;
    }
    if (b % 2 == 0) {
        LL d = power_mod(a, b / 2, p);
        return (d * d) % p;
    } else {
        return (a * power_mod(a, b - 1, p)) % p;
    }
}

LL comb_mod(int n, int r) {
    LL res = fact[n];
    LL a = power_mod(fact[n - r], MOD - 2, MOD);
    LL b = power_mod(fact[r], MOD - 2, MOD);
    res = res * a % MOD;
    res = res * b % MOD;
    return res;
}

int main(int argc, char const* argv[])
{
    cin >> H >> W >> A >> B;
    LL ans = 0;
    fact_mod(H + W);
    REP(i, H - A) {
        //cout << i << endl;
        int v = B - 1 + i;
        int w = i;
        int x = H + W - B - 2 - i;
        int y = W - B - 1;
        //cout << v << " " << w << " " << x << " " << y << endl;
        //cout << "vw:" << comb_mod(v, w) << " " << "xy:" << comb_mod(x, y) << endl;
        ans += (comb_mod(v, w) % MOD) * (comb_mod(x, y) % MOD) % MOD;
    }
    cout << ans % MOD<< endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++)
	{
		if (i % 2)
		{
			if ((b % 2) && b > 0)b--;
			a += b / 2;
			b /= 2;
		}
		else
		{
			if ((a % 2) && a > 0)a--;
			b += a / 2;
			a /= 2;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int a,b,c=0,d=1;
scanf("%d",&a);
scanf("%d",&b);
  for(;;){
  if(b<=d){break;}
    else {d=d+a-1;
          c++;
         }
  }
  printf("%d",c);
return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

#define MAX_N 40

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

  ll n, k;
  cin >> n >> k;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  vector<vll> dp(MAX_N+1, vll(2, -1));
  dp[0][0] = 0;
  for(int i = 0; i<MAX_N; i++){
    ll num = 0;
    ll mask = 1LL<<(MAX_N-i-1);
    REP(i, n){
      if(a[i]&mask)
        num++;
    }

    ll cost0 = num*mask;
    ll cost1 = (n-num)*mask;

    if(dp[i][1] != -1)
      dp[i+1][1] = dp[i][1]+max(cost0, cost1);


    if(dp[i][0] != -1 && (k&mask))
      dp[i+1][1] = max(dp[i+1][1],dp[i][0]+cost0);

    if(dp[i][0] != -1){
      if(k&mask)
        dp[i+1][0] = dp[i][0]+cost1;
      else
        dp[i+1][0] = dp[i][0]+cost0;
    }



  }

  cout << max(dp[MAX_N][1], dp[MAX_N][0]) << endl;
}


Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger mod = BigInteger.valueOf((long) (Math.pow(10, 9) + 7));
		
		BigInteger a = BigInteger.valueOf(9).modPow(BigInteger.valueOf(n), mod).multiply(BigInteger.valueOf(2)).mod(mod);
		BigInteger b = BigInteger.valueOf(8).modPow(BigInteger.valueOf(n), mod);
		BigInteger c = a.subtract(b).add(mod).mod(mod);
		BigInteger e = BigInteger.valueOf(10).modPow(BigInteger.valueOf(n), mod);
		BigInteger ans = e.subtract(c).add(mod).mod(mod);
		System.out.println(ans.longValue());
	}
}

Measured memory_bytes: 35876
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
 	string s;
  	cin>>s;
  	if(s=="AAA"||s=="BBB")no;
  	else yes;
}








Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <list>
using namespace std;
const int INF = 1 << 30;
const int NIL = -1;
const int MAXV = 10005;
const int MAXE = 100005;

struct Edge {
	int to, next;
	Edge() { next = -1; }
} edge[MAXE];

list<int> ans;
int head[MAXE];
int indegree[MAXV];
bool vis[MAXV];
int cnt;

void bfs(int u)
{
	queue<int> q;
	vis[u] = true;
	q.push(u);
	while (!q.empty())
	{
		u = q.front();
		q.pop();
		ans.push_back(u);
		for (int i = head[u]; i != NIL; i = edge[i].next)
		{
			u = edge[i].to;
			if (!vis[u] && --indegree[u] == 0)
			{
				vis[u] = true;
				q.push(u);
			}
		}
	}
	
}

void topologicalSort(int n)
{
	for (int i = 0; i < n; ++i)
		vis[i] = false;

	for (int i = 0; i < n; ++i)
	{
		if (indegree[i] == 0 && !vis[i])
			bfs(i);
	}
}

void add(int u, int v)
{
	edge[cnt].to = v;
	edge[cnt].next = head[u];
	head[u] = cnt++;
}


int main(void)
{
	
	int V, E, s, t;
	scanf("%d%d", &V, &E);
	cnt = 0;
	memset(head, NIL, sizeof(int) * (E + 1));
	for (int i = 0; i < E; ++i)
	{
		scanf("%d%d", &s, &t);
		++indegree[t];
		add(s, t);
	}
	topologicalSort(V);
	for (list<int>::iterator it = ans.begin(); it != ans.end(); ++it)
		printf("%d\n", *it);
	return 0;
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
int n,m,a;
int main()
{
	cin>>n>>m;
   for(int i=1;i<=m;i++)
   {
   	cin>>a;
   	n-=a;
   }
   if(n>=0) cout<<n;
   else cout<<"-1"; 
	return 0;
}

Measured memory_bytes: 3676
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
A = inp.shift() * 1
B = inp.shift() * 1
if (A == B) {
    ans = 'Draw'
} else {
    if (A == 1) {
        ans = 'Alice'
    } else if (B == 1) {
        ans = 'Bob'
    } else if (A > B) {
        ans = 'Alice'
    } else {
        ans = 'Bob'
    }
}
console.log(ans)


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

int main(void){
    int n, a[100], count = 0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    bool flag = true;

    while(flag){
        flag = false;
        for(int i = n-1; i > 0; --i){
            if(a[i] < a[i-1]){
                swap(a[i], a[i-1]);
                count++;
                flag = true;
            }
        }
    }
    for(int i = 0; i < n-1; ++i) cout << a[i] << ' ';
    cout << a[n-1] << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
using namespace std;

int main (void)
{
	char data[1001];
	int i, sum;

	while (scanf("%s", data)!=EOF && data[0] != '0'){
		sum = 0;
		for (i=0; data[i] != '\0'; i++)
			sum += data[i] - '0';

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

Measured memory_bytes: 968
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100
//---------------------

ll n;

int main(){
	cin >> n;
	ll dp[MAXN];
	if(n == 0) {PRT(0);return 0;}
	if(n%2) PRT(0);
	else {
		dp[0] = 1;
		dp[1] = 5;
		int id = 1;
		while(dp[id]<(n/2)){
			dp[id+1] = dp[id]*5;
			id++;
		}
		
		ll num = 0;
		REP1(i,id){
			num += (n/2)/dp[i];
		}
		PRT(num);
	}
	return 0;
}









Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, A[50], B[50], C[50], MA, MB, dp[50][500][500];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N >> MA >> MB;
    REP(i, N) { cin >> A[i] >> B[i] >> C[i]; }

    REP(i, N + 1) REP(j, 500) REP(k, 500) { dp[i][j][k] = INF; }

    dp[0][0][0] = 0;
    REPS(i, N) REP(j, 500) REP(k, 500) {
        if (j - A[i - 1] < 0 || k - B[i - 1] < 0) {
            dp[i][j][k] = dp[i - 1][j][k];
            continue;
        }
        dp[i][j][k] = min(dp[i - 1][j][k],
                          dp[i - 1][j - A[i - 1]][k - B[i - 1]] + C[i - 1]);
    }

    int ans = INF;
    int c = 1;
    while (MA * c <= N * 10 && MB * c <= N * 10) {
        ans = min(ans, dp[N][MA * c][MB * c]);
        c++;
    }
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 82176
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int p[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt()-1;
			p[a[i]] = i;
		}
		TreeSet<Integer> x = new TreeSet<Integer>();
		int l[] = new int[n];
		int r[] = new int[n];
		for(int i=0;i<n;i++) {
			x.add(p[i]);
			if(x.first()==p[i]) {
				l[i] =p[i]+1;
			}
			else {
				int lower = x.lower(p[i]);
				l[i] = p[i]-lower;
			}
			if(x.last()==p[i]) {
				r[i] = n-p[i];
			}
			else {
				int high = x.higher(p[i]);
				r[i] = high-p[i];
			}
		}
		long ans = 0;
		for(int i=0;i<n;i++) {
			ans+=(long) l[i]*r[i]*(i+1);
		}
		System.out.println(ans);
		
	}
}


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

using namespace std;

int main(){
    int n, m;
    cin>>n>>m;
    vector<int> arr(n, 0);
    for(int i =0;i< n;i++)cin>>arr[i];
    map<int, int> mp;
    map<int, int> roads;
    for(int i =0;i< n;i++)mp[i] = arr[i];
    for(int i = 0;i< m;i++){
        int a, b;
        cin>>a>>b;
        a--;
        b--;
        if(arr[a] == arr[b]){
            mp[a]++;
            mp[b]++;
        }
        mp[a] = max(mp[a], arr[b]);
        mp[b] = max(mp[b], arr[a]);
        roads[a] ++;
        roads[b]++;
    }
    int count = 0;
    for(int i= 0;i< n;i++){
        if(mp[i] == arr[i] || roads[i] == 0)count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 12500
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int X = Integer.parseInt(scan.next());

        if( X == 3 ||  X == 5 ||  X == 7) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
}


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

int main() {
	bool flg = false;
	string S, T;
	cin >> S >> T;

	T += T;

	for (int i = 0; i < S.size(); i++) {
		string U = "";
		for (int j = 0; j < S.size(); j++) {
			U += T[i + j];
		}
		if (U == S) flg = true;
	}

	if (flg) {
		puts("Yes");
	}
	else {
		puts("No");
	}
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    A=[list(map(int,input().split())) for _ in range(3)]
    for _ in range(int(input())):
        b = int(input())
        for i,j in product(range(3),repeat=2):
            if A[i][j]==b:
                A[i][j] = 0

    flag = 0
    flag |= any(all(A[i][j]==0 for i in range(3)) for j in range(3))
    flag |= any(all(A[i][j]==0 for j in range(3)) for i in range(3))
    flag |= all(A[i][i]==0 for i in range(3))
    flag |= all(A[i][2-i]==0 for i in range(3))
    print("Yes" if flag else "No")
resolve()

Measured memory_bytes: 38384
n,k=map(int,input().split())
*a,=filter(lambda x:x%k==0,range(1,n+1))
if k%2:
  print(len(a)**3)
else:
  *b,=filter(lambda x:x%k==k//2,range(1,n+1))
  print((len(a)**3)+(len(b)**3))

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

int main(){
  int n, m; cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for(int i=0; i<n; ++i){
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  double x = 0.25 * (double)sum / (double)m;
  string res = "Yes";
  if(a[n-m] < x) res = "No";
  cout << res << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	int c = 0;
	bool ok = false;
	for (int i = 0; i < n; i++) {
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2) {
			c++;
			if (c == 3) ok = true;
		}
		else c = 0;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, K;
	cin >> A >> B >> K;
	vi P;
	FOR(i, 1, min(A, B) + 1)
	{
		if (A % i == 0 && B % i == 0)
		{
			P.push_back(i);
		}
	}
	so(P);
	rev(P);
	cout << P[K - 1] << endl;
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  list<ll> ans;
  if(n % 2 == 0) {
    for(ll i = 0; i < n; i++) {
      if(i % 2 != 0) {
        ans.push_front(a[i]);
      } else {
        ans.push_back(a[i]);
      }
    }
  } else {
    for(ll i = 0; i < n; i++) {
      if(i % 2 != 0) {
        ans.push_back(a[i]);
      } else {
        ans.push_front(a[i]);
      }
    }
  }
  for(ll x : ans) {
    cout << x << " ";
  }
  cout << endl;
  return 0;
}

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

int main()
{
    char a;
    int ans = 0;
    a = getchar();
    while (a != EOF) {
        if ('0' <= a && a <= '9') {
            int num = a - '0';
            a = getchar();
            while ('0' <= a && a <= '9') {
                num *= 10;
                num += a - '0';
                a = getchar();
            }
            ans += num;
        } else {
            a = getchar();
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3048
N,x=map(int,input().split())
A=list(map(int,input().split()))
A2=A[::-1]

ANS=0
for i in range(1,N):
    if A[i]+A[i-1]>x:
        ANS+=(A[i]+A[i-1]-x)
        if A[i]>=A[i]+A[i-1]-x:
            A[i]-=(A[i]+A[i-1]-x)
        else:
            A[i]=0



ANS2=0
for i in range(1,N):
    if A2[i]+A2[i-1]>x:
        ANS2+=(A2[i]+A2[i-1]-x)
        if A2[i]>=A2[i]+A2[i-1]-x:
            A2[i]-=(A2[i]+A2[i-1]-x)
        else:
            A2[i]=0

print(min(ANS,ANS2))

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

int main() {
  int n;
  cin >> n;
  int m = 3 * n;
  vector<int> a(m);
  for (int i = 0; i < m; i ++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());

  LL ans = 0;
  for (int i = m - 2; i >= n; i -= 2) {
    ans += a.at(i);
  }

  cout << ans << endl;
}


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

#define FOR(i, n) for(int i = 0; i < n; i++) 

#define pow CHANGETHENAMESTUPID

using namespace std;

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

void load() {

}

void solve() {
	char c; scanf("%c", &c);
	printf("%c\n", c + 1);
}

int main() {
	load();
	solve();
	return 0;
}


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

typedef long long ll;
#define MAXN 100005
#define MOD 998244353
const int INF = 1e9 + 5;

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

    int L;
    cin >> L;

    double len = L / (double)3;
    cout << fixed << setprecision(12) << len * len * len << '\n';

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>
#include <set>
#include <cassert>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;

const int MAXN = 10;
const int INF = 1e3;

template<typename T1, typename T2> inline void chkmin(T1 & a, const T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chkmax(T1 & a, const T2 b) { if (a < b) a = b; }

int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(0), cout.tie(0);
    // freopen("input.txt", "r", stdin);
    long long x, cur = 100;
    cin >> x;
    int cnt = 0;
    while (cur < x) {
    	cur += cur / 100;
    	++cnt;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  string s;
  int zero_count = 0;
  int one_count = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++){
    if (s[i] == '0'){
      zero_count += 1;
    }else{
      one_count += 1;
    }
  }
  cout << 2*min(zero_count, one_count) << endl;
  return 0;
}

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

typedef pair<int, int> pInt;

int main() {
	int n,k;
	cin >> n >> k;

	int pas[n+1];
	for(int i=0; i<k; i++) {
		int m;
		cin >> m;
		for(int j=0; j<m; j++) {
			int bunny;
			cin >> bunny;
			pas[bunny] = i;
		}
	}
	
	int r;
	cin >> r;
	
	bool bad[n+1];
	memset(bad, false, sizeof(bad));
	for(int i=0; i<r; i++) {
		int p,q;
		cin >> p >> q;
		if(pas[p] == pas[q])
			bad[p] = bad[q] = true;
	}
	
	cout << count(bad+1, bad+n+1, true) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1172
import math
a, b = map(int, input().split())
c = set(range(math.ceil(a*100/8), math.ceil((a + 1)*100/8)))
d = set(range(math.ceil(b*10), math.ceil((b + 1)*10)))
if len(c & d) == 0:
  print(-1)
else:
  print(min(c & d))
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

string d[4] = {"maerd", "remaerd", "esare", "resare"};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    int n = s.length();
    int i = 0;
    bool isexist = true;
    while(i < n) {
        int t = 0;
        rep(j, 4) {
            int k = d[j].length();
            bool ok = true;
            for (int m = 0; m < k; ++m) {
                if (d[j][m] != s[i + m]) ok = false;
            }
            if (ok) chmax(t, k);
        }
        if (t == 0) {
            isexist = false;
            break;
        }
        i += t;
    }

    if (isexist) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

int main() {
  size_t N;
  int T;

  std::cin >> N >> T;

  const int INF=1e9;
  int res=INF;
  for (size_t i=0; i<N; ++i) {
    int c, t;
    std::cin >> c >> t;
    if (t <= T && c < res)
      res = c;
  }
  if (res < INF)
    return !printf("%d\n", res);

  printf("TLE\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rnr(i, a, b) for(int i = int(a); i >= int(b); i--)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    ll a[n]; rep(i, n) cin >> a[i];
    //he have 1000 [yen]
    int minv_i = 0, minv = a[0];
    vector<Pint> ans;
    for(int i = 1; i < n; ++i) {
        if(minv < a[i]) {
            ans.pb(mp(minv_i, i));
        }
        minv = a[i];
        minv_i = i;
    }
    ll money = 1000;
    for(auto i : ans) {
        ll numStock = money / a[i.first];
        money -= numStock * a[i.first];
        money += numStock * a[i.second];
    }
    cout << money << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;
const LL INV = (N + 1LL) / 2LL;

LL tot = 1LL,sum = 0;
LL dp[3005][3005],tmp[3005][3005];
LL a[3005];

int main(){
	LL n,q,u,v;
	cin >> n >> q;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			if(a[i] > a[j]) dp[i][j] = 1;
		}
	}
	while(q --){
		cin >> u >> v;
		for(LL i = 1;i <= n;i ++){
			if(i == u || i == v) continue;
			tmp[u][i] = (INV * ((dp[u][i] + dp[v][i]) % N)) % N;
			tmp[i][u] = (INV * ((dp[i][u] + dp[i][v]) % N)) % N;
			tmp[v][i] = (INV * ((dp[v][i] + dp[u][i]) % N)) % N;
			tmp[i][v] = (INV * ((dp[i][v] + dp[i][u]) % N)) % N;
		}
		for(LL i = 1;i <= n;i ++){
			if(i == u || i == v) continue;
			dp[u][i] = tmp[u][i]; dp[i][u] = tmp[i][u];
			dp[v][i] = tmp[v][i]; dp[i][v] = tmp[i][v];
		}
		tmp[u][v] = (INV * ((dp[u][v] + dp[v][u]) % N)) % N;
		tmp[v][u] = (INV * ((dp[v][u] + dp[u][v]) % N)) % N;
		dp[u][v] = tmp[u][v]; dp[v][u] = tmp[v][u];
		tot = (tot * 2) % N;
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = i + 1;j <= n;j ++){
			sum = (sum + dp[i][j]) % N;
		}
	}
	cout << (sum * tot) % N << '\n';
	return 0;
}
//

Measured memory_bytes: 141312
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
string s;
const int maxN = 2e5 + 10;
int dp[maxN];
int nxt[26];
int trans[maxN];
int let[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> s;
    for (int i = 0; i < 26; i++) {
        nxt[i] = s.size();
    }
    for (int i = s.size() - 1; i >= 0; i--) {
        dp[i] = 1e9;
        for (int j = 0; j < 26; j++) {
            if (dp[i] > dp[nxt[j]] + 1) {
                trans[i] = nxt[j];
                let[i] = j;
            }
            dp[i] = min(dp[i], dp[nxt[j]] + 1);
        }
        nxt[s[i] - 'a'] = i;
    }
    int who = 0;
    for (int j = 0; j < 26; j++) {
        if (dp[nxt[j]] < dp[nxt[who]]) {
            who = j;
        }
    }
    string ans;
    int c = nxt[who];
    ans += (char)(who + 'a');
    while (c != s.size()) {
        ans += (char)(let[c] + 'a');
        c = trans[c];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
using PP = pair<int, int>;

int n;
multiset<int, greater<int>> st;

bool rec() {
  priority_queue<PP> q;
  q.push(PP(n, 2e9));
  while (!q.empty()) {
    PP p = q.top(); q.pop();
    int lev = p.first;
    int mx = p.second;
    
    auto it = st.lower_bound(mx);
    if (it == st.end()) return false;
    int a = *it;
    st.erase(it);
    for (int p = lev - 1; p >= 0; --p) {
      q.push(PP(p, a - 1));
    }
  }
  return true;
}

int main() {
  cin >> n;
  for (int i = 0; i < (1 << n); ++i) {
    int a;
    cin >> a;
    st.insert(a);
  }
  
  cout << (rec() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 13692
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int>ans(N, 0);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        ans[a - 1]++;
        ans[b - 1]++;
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def sa(c,d):
    
    if c>d:
        nn=c//d
        c2=c-d*nn
        if c2<d:
            return c2,d
        else:
            return d,c2
    else :
        nn=d//c
        c2=d-c*nn
        if c2<c:
            return c2,c
        else:
            return c,c2

a,b,c,d=map(int,input().split())

mp=c*d

c1=c
d1=d
for i in range(10**18):
    c2,d2=sa(c1,d1)
#    print("c1,d1,c2,d2",c1,d1,c2,d2)    
    if c2<=0:
        break
    c1=c2
    d1=d2

mcm=int(mp/c1)

ac2=(a-1)//c
ad2=(a-1)//d
am2=(a-1)//mcm

bc2=b//c
bd2=b//d
bm2=b//mcm
#print(mcm,ac2,bc2,ad2,bd2,am2,bm2)     

icnt=(bc2-ac2)+(bd2-ad2)-(bm2-am2)
icnt=(b+1-a)-icnt

print(icnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int tmp[SIZE], a[SIZE];
    for( int i = 0; i < n; ++i ) {
        cin >> a[i];
        tmp[i] = a[i];

    }
    sort( tmp, tmp + n, greater<>() );
    int tmx = tmp[1];
    int mx = tmp[0];
    for( int i = 0; i < n; ++i ) {
        if( a[i] == mx ) cout << tmx;
        else cout << mx;
        cout << endl;

    }
    return 0;
}


Measured memory_bytes: 3200