akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int dist[100001], dist2[100001];

void dfs(int v, int p, int d, const vector<vector<int>> &G) {
    dist[v] = d;
    for (auto &u : G[v]) {
        if (u == p) continue;
        dfs(u, v, d + 1, G);
    }
}

void dfs2(int v, int p, int d, const vector<vector<int>> &G) {
    dist2[v] = d;
    for (auto &u : G[v]) {
        if (u == p) continue;
        dfs2(u, v, d + 1, G);
    }
}

int main() {
    int n, a, b; cin >> n >> a >> b;
    a--; b--;
    vector<vector<int>> G(n);
    vector<int> k(n,0);
    for (int i = 0; i < n-1; i++) {
        int v, u;
        cin >> v >> u;
        v--; u--;
        G[v].push_back(u);
        G[u].push_back(v);
        k[u]++;
        k[v]++;
    }
    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }
    dfs(a, -1, 0, G);
    dfs2(b, -1, 0, G);
    constexpr int INF = 1e9 + 6;
    int ans = 0,ans2 = INF;
    for (int i = 0; i < n; i++) {

        if (k[i] == 1) {
            if (dist[G[i][0]] < dist2[G[i][0]]) {
                ans = max(ans, dist2[G[i][0]]);
            }
            else if (dist[G[i][0]] == dist2[G[i][0]]) {
                ans2 = min(ans2, dist2[G[i][0]]);
            }
        }
    }
    if (ans2 != INF) ans = max(ans, ans2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int a, b, c; std::cin >> a >> b >> c;
  if ( a + b + c >= 22 ) std::cout << "bust" << std::endl;
  else std::cout << "win" << std::endl;
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int a[105];

int main()
{
	int n;
	cin >> n;
	REP(i, n)
	{
		cin >> a[i];
	}

	cout << a[n - 1];
	IREP(i, n - 2)
	{
		cout << " " << a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
	int n,k;
  vector<int> v;
  ll avgval = 0, sum1 = 0, sum2 = 0;
	cin >> n;
  rep(i,n) {
    cin >> k;
    v.push_back(k);
    avgval += k;
  }
  avgval /= n;
  rep(i,n) {
    sum1 += (v.at(i) - avgval) * (v.at(i) - avgval);
  }

  rep(i,n) {
    sum2 += (v.at(i) - avgval - 1) * (v.at(i) - avgval - 1);
  }
  ll ans = sum1 < sum2 ? sum1 : sum2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    var n = readLine()!!.toInt()
    var v = readLine()!!.split(" ").map(String::toInt)
    var c = readLine()!!.split(" ").map(String::toInt)
    var f = 0

    for(bit in 0..(1 shl n)){
        var tmp = 0
        for(i in 0..n-1){
            if (((bit shr i) and 1)==1){
                tmp+= v[i] - c[i]
            }
        }

        if (tmp > f) f=tmp
    }

    println(f)
}

Measured memory_bytes: 36064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

bool is_ok(const set<int> ng, int v) {
  while (v != 0) {
    if (ng.count(v % 10) != 0) return false;
    v /= 10;
  }
  return true;
}


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

  int n, k;
  cin >> n >> k;
  set<int> ng;
  rep(i, k) {
    int d; cin >> d;
    ng.insert(d);
  }

  int ans = 0;
  for (int i = n; i < n * 100; i++) {
    if (is_ok(ng, i)) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct RSQandRAQ {
	int n;
	vector<int>d, lazy;
	RSQandRAQ(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, 0);
		lazy.assign(2 * n, 0);
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			d[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k] += lazy[k] / 2;
				lazy[2 * k + 1] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}
	void add(int a, int b, int x, int k=1, int l=0, int r=-1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] += (r - l)*x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k, l, (l + r) / 2);
			add(a, b, x, 2 * k + 1, (l + r) / 2, r);
			d[k] = d[2 * k] + d[2 * k + 1];
		}
	}
	int getSum(int a, int b, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l&&r <= b)return d[k];
		else {
			int vl, vr;
			vl = getSum(a, b, 2 * k, l, (l + r) / 2);
			vr = getSum(a, b, 2 * k + 1, (l + r) / 2, r);
			return vl + vr;
		}
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RSQandRAQ seg(n);
	rep(z, 0, q) {
		int com; cin >> com;
		if (com) {
			int s, t; cin >> s >> t;
			cout << seg.getSum(s - 1, t) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.add(s - 1, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 7032
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

const int _N = 200000;
int tree[_N+1];
int n,m,q;

/// BIT

void add(int i, int v){
	i++;
	while(i<=n){
		tree[i] += v;
		i+=i&-i;
	}
}
int sum(int i){
	i++;
	int s = 0;
	while(i>=1){
		s += tree[i];
		i-=i&-i;
	}
	return s;
}

///

// O(N log^2 N)

int main() {
	omajinai;
	cin >> n >> m >> q;
	REP(i, n)add(i, 1);
	int having = 1; // living
	REP(i, m){
		int p;
		cin >> p;
		int f = n-i; // >= 1
		if(p%2)p = -p+f*101;
		p+=having;
		p %= f;
		if(!p) p = f;
		// binary search i-th person in circle
		int low=0, high=n - 1;
		while(low<high){
			int mid = (low + high) / 2;
			if(sum(mid)<p) low = mid + 1;
			else high = mid;
		}
		add(low, -1);
		having = p;
	}
	REP(i, q){
		int x;
		cin >> x;
		int s = sum(x);
		if(x > 0) s -= sum(x-1);
		cout << s << endl;
	}
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define endl "\n";
#define p push_back
typedef long long ll;

int main()
{IOS
ll a,i,j,k=0,sum=0,count=0,f=0,d=0,z=0;
cin>>a;
sum=a*a;
count=a*a*a;
cout<<sum+count+a
;





return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = 0;
		if(a < b) {
			if(b < c) {
				ans = a + b + c * 10;
			} else {
				ans = a + b * 10 + c;
			}
		} else {
			if(a < c) {
				ans = a + b + c * 10;
			} else {
				ans = a * 10 + b + c;
			}
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21204
#include <cstdio>
#include <iostream>

int main()
{
    int N;
    scanf("%d", &N);
    int f = 0;
    int tmp = N;
    while (true) {
        f += tmp % 10;
        if (tmp < 10) {
            break;
        }
        tmp /= 10;
    }
    if (N % f == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

a = l()
po = sum(a)
a.sort(reverse = True)
co = 0
for i in range(N):
    if a[i] >= po/(4*M):
        co += 1
if co >= M:
    print("Yes")
else:
    print("No")






Measured memory_bytes: 38484
# coding: utf-8
n = int(input())
hs = list(map(int, input().split()))
n = 1
for i, h in enumerate(hs, 1):
    if i == 1:
        continue
    is_exist = False
    for j in hs[:i-1]:
        if j > h:
            is_exist = True
            break
    if not is_exist:
        n += 1

print(n)

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  double N;
  cin>>N;
  print(N*PI*2);
  return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll N, i, Div, sum;
string S;
int main()
{
    cin >> N;
    for(i=1;i<=N;i++)
    {
        sum += i;
        for(Div=2*i;Div<=N;Div+=i)
        {
            sum += Div;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3644
n = int(input())
new_w = input()
w = [new_w]
w_str = list(new_w)
f = False
k = False
final_w = w_str[-1]
for i in range(n - 1):
    new_w = input()
    for j in w:
        if new_w == j:
            k = True
    w.append(new_w)
    if k:
        f = True
    w_str = list(new_w)
    if final_w != w_str[0]:
        f = True
    else:
        final_w = w_str[-1]
if f:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
int i,v;std::string s;
int P() {
  i++;
  if(s[i]=='T')return 1;
  if(s[i]=='F')return 0;
  if(isalpha(s[i]))return v>>(s[i]-'a')&1;
  if(s[i]=='-')return !P();
  int l=P();
  i++;int o=s[i];if(o=='-')i++;
  int r=P();i++;
  if(o=='*')return l&r;
  if(o=='+')return l|r;
  if(o=='-')return l<=r;
}
int main() {
  while(std::cin>>s){
    if(s=="#")break;
    bool k=true;
    for(v=0;v<(1<<11);v++) {
      i=-1;int l=P();
      i++;
      if(l!=P()){k=false;break;}
    }
    std::cout<<(k?"YES\n":"NO\n");
  }
  return 0;
}

Measured memory_bytes: 1216
N = int(input())
A = [int(x) for x in input().split()]
count = 0
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    if A[i] != A[minj]:
        count += 1
print(' '.join([str(x) for x in A]))
print(count)


Measured memory_bytes: 5608
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 3e5 + 5;

int cnt[N];

int main(){
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    for(int i = 0 ; i < q ; ++i){
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    for(int i = 1 ; i <= n ; ++i){
        cnt[i] -= q,
        cnt[i] += k;
        if(cnt[i] > 0)
            puts("Yes");
        else puts("No");
    }
}

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

int main(){
  int N, Y;
  cin >> N >> Y;
  int A = -1;
  int B = -1;
  int C = -1;
  int z;
  for(int x = 0; x <= N; x++){
    for(int y = 0; y + x <= N; y++){
      z = N - x - y;
      if(x * 10000 + y * 5000 + z * 1000 == Y){
        A = x;
        B = y; 
        C = z;
      }
    }
  }
  cout << A << " " << B << " " << C << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100005
#define ll long long
#define ld double
#define mod 998244353
using namespace std;
ll inf = 1e17;
int cal(ll a, ll b)
{
	if(a < b) return 0;
	if(b < 0) return 0;
	while(1)
	{
		if(!a && !b) return 1;
		if(a % 2 < b % 2) return 0;
		a /= 2, b /= 2; 
	}
}
int main()
{
	int n;
	cin>>n;
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		ll x, y;
		cin>>x>>y;
		x += inf;
		ll n1 = 1;
		while(n1 <= x + y)
		{
			if(cal(x, n1 - y)) ans ^= n1;
			n1 <<= 1;
		}	
	}
	cout<<ans - inf;
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

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

int main() {
    int n;
    cin >> n;
    map<int, int> v;
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        v[k]++;
    }
    if(n%2 == 0){
        for (int i = 0; i < n/2; ++i) {
            if(v[i*2+1] != 2){
                cout << 0 << "\n";
                return 0;
            }
        }

    }else {
        if(v[0] != 1){
            cout << 0 << "\n";
            return 0;
        }
        for (int i = 1; i <= n/2; ++i) {
            if (v[i*2] != 2){
                cout << 0 << "\n";
                return 0;
            }
        }
    }
    cout << pow_(2, n/2, INF) << "\n";
    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;

char s[100011];
int n;

int main()
{
    int i,j,k;
    
    scanf("%s",s);
    n=strlen(s);
    
    int ans=0;
    i=0;j=n-1;
    while(i<j)
    {
        if(s[i]==s[j])
        {
            i++;j--;
            continue;
        }
        
        if(s[i]=='x')
        {
            ans++;
            i++;
            continue;
        }
        if(s[j]=='x')
        {
            ans++;
            j--;
            continue;
        }
        
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main()
{    
    int n;
    cin >> n;
    vector<int> p(n);

    rep(i,n) cin >> p[i];
    int ans = n;
    int low = p[0];
    for(int i = 1; i < n ; i++)
    {
        if(p[i] > low)
        {
            --ans;
        }
        else low = p[i];
    }

    cout << ans << endl;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int MOD = (int)1e9 + 7;
const int N = 200000 + 5;
int fac[N], inv[N];
int pow(int x, int n) {
	int y = 1;
	while(n) {
		if(n&1) y = (ll)y*x%MOD;
		x = (ll)x*x%MOD;
		n >>= 1;
	}
	return y;
}
int C(int x, int y) {
	return (ll)fac[x+y] * inv[x] % MOD * inv[y] %MOD;
}
int main(){
	int h,w,a,b;
	cin >> h >> w >> a >> b;
	if(a>=h || b >=w) {
		cout << 0 <<endl;
		return 0;
	}
	int len = h + w + 1;
	fac[0] = inv[0] = 1;
	rep(i,1,len) {
		fac[i] = (ll)i * fac[i-1] % MOD;
		inv[i] = pow(fac[i], MOD - 2);
	}
	int ans = 0;
	rep(i,1,h-a+1) {
		ans = (ans + (ll)C(i-1,b-1)*C(h-i, w-b-1)) % MOD;	
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<map>
#include<utility>

using namespace std;

long long B[10];
map<pair<int, int>, int> cells;

int main() {
  int H, W;
  int N;

  scanf("%d", &H);
  scanf("%d", &W);
  scanf("%d", &N);

  for (int i = 0; i < 10; i++) {
    B[i] = 0;
  }

  int a, b;
  int len = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    scanf("%d", &b);

    for (int dx = -2; dx < 1; dx++) {
      for (int dy = -2; dy < 1; dy++) {
        bool f = false;
        int x = a + dx, y = b + dy;
        if (x <= 0 || y <= 0 || x > H - 2 || y > W - 2) continue;
        if (cells.find(make_pair(x, y)) != cells.end())
          cells[make_pair(x, y)] += 1;
        else {
          cells[make_pair(x, y)] = 1;
          len += 1;
        }

        //for (int j = 0; j < len; j++) {
        //  if (cells[j][0] == x && cells[j][1] == y) {
        //    cells[j][2] += 1;
        //    f = true;
        //    break;
        //  }
        //}
        //if (!f) {
        //  cells[len][0] = x;
        //  cells[len][1] = y;
        //  cells[len][2] = 1;
        //  len += 1;
        //}
        //printf("%d %d\n", x, y);
      }
    }
  }

  for (auto j = cells.begin(); j != cells.end(); ++j) {
    B[j->second] += 1;
  }

  B[0] = (((long long)H - 2) * ((long long)W - 2)) - len;


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

  return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC";
  }
  else if(r < 2800){
    cout << "ARC";
  }
  else{
    cout << "AGC";
  }
  cout << endl;
}


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

vector<int> ele;

int dp[3001][3001]; // we dont need a third dimension which specifies whose turn it is..
int solve(int i,int j,int turn){

	if(i>j) return 0;

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

	if(turn==1) return dp[i][j]=max(ele[i]+solve(i+1,j,0),ele[j]+solve(i,j-1,0));
	else return dp[i][j]=min(solve(i+1,j,1),solve(i,j-1,1));
}

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

    ele.resize(n+1,0);
    int sum=0;
    for (int i = 1; i <=n; ++i) cin>>ele[i],sum+=ele[i];
    memset(dp,-1,sizeof dp);
	int x=solve(1,n,1);
	int y=sum-x;
	cout<<x-y;

}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int h = ri(), w = ri();
	std::string s[h];
	for (int i = 0; i < h; i++) std::cin >> s[i];
	int left[h][w];
	{
		for (int i = 0; i < h; i++) {
			int last = -1;
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') last = j;
				else left[i][j] = last;
			}
		}
	}
	int right[h][w];
	{
		for (int i = 0; i < h; i++) {
			int last = w;
			for (int j = w - 1; j >= 0; j--) {
				if (s[i][j] == '#') last = j;
				else right[i][j] = last;
			}
		}
	}
	int up[h][w];
	{
		for (int i = 0; i < w; i++) {
			int last = -1;
			for (int j = 0; j < h; j++) {
				if (s[j][i] == '#') last = j;
				else up[j][i] = last;
			}
		}
	}
	int down[h][w];
	{
		for (int i = 0; i < w; i++) {
			int last = h;
			for (int j = h - 1; j >= 0; j--) {
				if (s[j][i] == '#') last = j;
				else down[j][i] = last;
			}
		}
	}
	int res = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
		// std::cerr << up[i][j] << " ";
			if (s[i][j] == '#') continue;
			res = std::max(res, std::abs(down[i][j] - up[i][j]) + std::abs(right[i][j] - left[i][j]) - 2);
		}
		// std::cerr << std::endl;
	}
	std::cout << res - 1 << std::endl;
	return 0;
}


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

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

using ll = long long;
using pll = pair<ll, ll>;

const ll mod = 1000000007;

const ll MAXN = 1000001;
ll dp[MAXN][4];

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

    dp[0][0] = 1;

    rep (i, N)
    {
        dp[i + 1][0] = dp[i][0] * 8;
        dp[i + 1][0] %= mod;

        dp[i + 1][1] = dp[i][0] + dp[i][1] * 9;
        dp[i + 1][1] %= mod;

        dp[i + 1][2] = dp[i][0] + dp[i][2] * 9;
        dp[i + 1][2] %= mod;

        dp[i + 1][3] = dp[i][1] + dp[i][2] + dp[i][3] * 10;
        dp[i + 1][3] %= mod;
    }

    cout << dp[N][3] << endl;

    return 0;
}


Measured memory_bytes: 34700
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}
ll modexpo(ll a, ll b, ll m) {if (b == 0) {return 1;} else if (a == 1) {return 1;} if (b % 2 == 0) {ll t = modexpo(a, b / 2, m); t = (t * t) % m; return t;} else {ll t = modexpo(a, b / 2, m); t = (t * t) % m; t = (t * a) % m; return t;}}

ll sum[404][404];
ll dp[404][404];

ll fn(ll l, ll r, ll a[]) {
	if (l > r) {
		return 1e18;
	}
	if (l == r) {
		return 0;
	}
	if (dp[l][r] != -1) {
		return dp[l][r];
	}
	ll ans = 1e18;
	for (ll i = l; i < r; i++) {
		ll op1 = fn(l, i, a);
		ll op2 = fn(i + 1, r, a);
		ll op3 = sum[l][i] + sum[i + 1][r];
		ans = min(ans, op1 + op2 + op3);
	}
	dp[l][r] = ans;
	return ans;
}

int main() {

	// taskkill /IM "cp.exe" /F
	fast
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
//#endif

	ll n;
	cin >> n;
	ll a[n];
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		ll s = 0;
		for (int j = i; j <= n; j++) {
			s += a[j];
			sum[i][j] = s;
		}
	}

	cout << fn(0, n - 1, a);





}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;

    vector<i64> l(N),r(N);
    rep(i,0,N) cin >> l[i] >> r[i];

    i64 bottom=0,left_uniform=0,right_uniform=0;
    multiset<i64> left_diverse={-l[0]},right_diverse={l[0]};
    rep(i,1,N){
        left_uniform-=r[i]-l[i];
        right_uniform+=r[i-1]-l[i-1];

        if(left_uniform-*left_diverse.begin()<=l[i] and l[i]<=right_uniform+*right_diverse.begin()){
            left_diverse.insert(-l[i]+left_uniform);
            right_diverse.insert(l[i]-right_uniform);
        }else if(l[i]<left_uniform-*left_diverse.begin()){
            bottom+=(left_uniform-*left_diverse.begin())-l[i];

            left_diverse.insert(-l[i]+left_uniform);
            left_diverse.insert(-l[i]+left_uniform);
            right_diverse.insert(left_uniform-*left_diverse.begin()-right_uniform);
            left_diverse.erase(left_diverse.begin());
        }else{
            bottom+=l[i]-(right_uniform+*right_diverse.begin());

            right_diverse.insert(l[i]-right_uniform);
            right_diverse.insert(l[i]-right_uniform);
            left_diverse.insert(-(right_uniform+*right_diverse.begin())+left_uniform);
            right_diverse.erase(right_diverse.begin());
        }
    }

    cout << bottom << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 11264
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
    void solve(){
        int n;
        cin>>n;
        
        int m=(1<<n);
        multiset<int > mt;
        
        rep(i,0,m){
			 int x;
			 cin>>x;
			 mt.insert(x * -1);
		}
		
		vi v;
		v.pb(*mt.begin());
		mt.erase(mt.begin());
		
		
		rep(i,0,n){			
			vi nax;
			
			rep(j,0,sz(v)){
				if(mt.ub(v[j]) == mt.end()){
					 cout<<"No"<<endl;
					 return;
				}
				
				else{
					nax.pb(*(mt.ub(v[j])));
					mt.erase(mt.ub(v[j]));			
				}			
			}
			
			rep(j,0,sz(nax))
			  v.pb(nax[j]);		 
		}
		
		cout<<"Yes\n";
         
      
     }
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


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

const int N = 200005;
const int INF = 1000000000;

int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

int n,a[N],rmq[2][N][20],bin[20],lg[N];

struct Data
{
    int l,r,x,y;

    bool operator < (const Data &p) const
    {
        return a[x] > a[p.x];
    }
};

std::priority_queue<Data> Q;

void pre()
{
    for (int i = 1; i <= n; i += 2) 
    	rmq[1][i][0] = i;
    for (int i = 2; i <= n; i += 2) 
    	rmq[0][i][0] = i;
    bin[0] = 1;
    for (int i = 1; i <= 17; i++) 
    	bin[i] = bin[i - 1] * 2;
    for (int i = 1; i <= n; i++) 
    	lg[i] = log(i) / log(2);
    for (int j = 1; j <= lg[n]; j++)
        for (int i = 1; i + bin[j] - 1 <= n; i++)
            rmq[0][i][j] = a[rmq[0][i][j - 1]] < a[rmq[0][i + bin[j - 1]][j - 1]] ? rmq[0][i][j - 1] : rmq[0][i + bin[j - 1]][j - 1],
            rmq[1][i][j] = a[rmq[1][i][j - 1]] < a[rmq[1][i + bin[j - 1]][j - 1]] ? rmq[1][i][j - 1] : rmq[1][i + bin[j - 1]][j - 1];
}

int getMn(int ty,int l,int r)
{
    int w = lg[r - l + 1];
    return a[rmq[ty][l][w]] < a[rmq[ty][r - bin[w] + 1][w]] ? rmq[ty][l][w] : rmq[ty][r - bin[w] + 1][w];
}

Data get(int l,int r)
{
    int p = getMn(l & 1, l, r - 1), q = getMn((p & 1) ^ 1, p + 1, r);
    return (Data){l,r,p,q};
}

int main()
{
    n = read();
    a[0] = INF;
    for (int i = 1; i <= n; i++) 
    	a[i] = read();
    pre();
    Q.push(get(1,n));
    for (int i = 1; i <= n / 2; i++)
    {
        Data u = Q.top();
        Q.pop();
        int l = u.l, r = u.r, x = u.x, y = u.y;
        printf("%d %d ",a[x],a[y]);
        if (l < x - 1) 
        	Q.push(get(l,x - 1));
        if (x + 1 < y - 1) 
        	Q.push(get(x + 1, y - 1));
        if (y + 1 < r) 
        	Q.push(get(y + 1, r));
    }
}

Measured memory_bytes: 35060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		//ABC081A
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int out = 0;

		if( a == 0) out =1;
		// 出力
		System.out.println(out);

		sc.close();
	}
}


Measured memory_bytes: 26968
def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    a = set([A[0]])
    print(A[0], end="")
    for i in range(1, N):
        if A[i] not in a:
            print("", A[i], end="")
            a.add(A[i])
    print()


resolve()



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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1


double Rec[302][302][302] = {};
int N,a,t[3] = {};
double dp_rec( int t1, int t2, int t3 ){
    if( Rec[t1][t2][t3] >= 0.0 ) return Rec[t1][t2][t3];
    if( (t1 + t2 + t3) == 0 ) return 0.0;

    double ret = 0.0;
    if( t1>0 ) ret += dp_rec(t1-1,t2,t3) * t1;
    if( t2>0 ) ret += dp_rec(t1+1,t2-1,t3) * t2;
    if( t3>0 ) ret += dp_rec(t1,t2+1,t3-1) * t3;
    ret += N;
    ret /= (t1+t2+t3);
    return Rec[t1][t2][t3] = ret;
}


int main() {


    Scd(N);
    Rep(i,N){
        Scd(a);
        t[--a]++;
    }
    Rep(i,N+2)
    Rep(j,N+2)
    Rep(k,N+2)
        Rec[i][j][k] = -1.0;
    printf("%.14lf\n", dp_rec(t[0],t[1],t[2]));

    return 0;
}



Measured memory_bytes: 215552
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        List<Integer> lst = new ArrayList<Integer>();
        while(input.hasNext()){
        	int a = input.nextInt();
        	if(a == 0){
        		System.out.println(lst.get(lst.size()-1));
        		lst.remove(lst.size()-1);
        	}else{
        		lst.add(a);
        	}
        }
    }    
}

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

int main(){
    int n;
    cin >> n;
    vector<string> v(n);

    int num = 0;
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        v[i] = s;
        for(int i=0; i<s.size()-1; i++){
            if(s[i] == 'A' && s[i+1] == 'B') num++;
        }

        if(s[0] == 'B' && s[s.size()-1] == 'A') c3++;
        else if(s[0] == 'B') c2++;
        else if(s[s.size()-1] == 'A') c1++;
    }

    int ans = 0;

    if(c1 == 0 || c2 == 0 || c3 == 0){
        //どれかがない場合を特別視

        if(c1 == 0 && c2 != 0 && c3 != 0){
            ans = min(c2, c3);
            if(c3 > c2) ans += c3 - c2;
        }

        if(c2 == 0 && c1 != 0 && c3 != 0){
            ans = min(c1, c3);
            if(c3 > c1) ans += c3 - c1;
        }

        if(c1 != 0 && c2 != 0 && c3 == 0){
            ans = min(c1, c2);
        }

        if(c1 == 0 && c2 == 0 && c3 != 0){
            ans = c3 - 1;
        }

        ans += num;
        cout << ans << endl;
        return 0;
    }

    else {
        //c3について計算
        if(c3 > 0) ans += c3 - 1;
        //c3に繋げられるか
        if(c1 >= 1 && c2 >= 1 && c3 >= 1){
            ans += 2;
            c1--;
            c2--;
        }
        //あまったc1, c2について計算
        ans += min(c1, c2);

        ans += num;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
	int i=1, x=1;
	while ( x != 0)
	{
		scanf("%d",&x);
		if (x != 0)
		{
			printf("Case %d: %d\n", i, x);
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 2140
import sys
input=sys.stdin.readline

import collections
def main():
    N,W = map(int, input().split())
    I = collections.deque()
    for _ in range(N):
        I.append(tuple(map(int, input().split())))

    MV = N*(10**3) + 1
    dp = [[0]*MV for _ in range(N+1)]
    inf = 2*10**9
    for j in range(MV):
        dp[0][j] = inf
    dp[0][0] = 0
    
    for i in range(N):
        w,v = I.popleft()
        for j in range(MV):
            if j < v:
                dp[i+1][j] = dp[i][j]
            else:
                dp[i+1][j] = min(dp[i][j], dp[i][j-v] + w)
    ans = 0
    for j in range(MV):
        if dp[N][j] <= W:
            ans = j
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 118000
<?php

function gcd($x, $y) {
    if ($y === 1) {
        return 1;
    }

    if ($y === 0) {
        return $x;
    }

    return gcd($y, $x % $y);
}

fscanf(STDIN, "%d", $k);

$sum = 0;
for ($a = 1; $a <= $k; ++$a) {
    for ($b = 1; $b <= $k; ++$b) {
        for ($c = 1; $c <= $k; ++$c) {
            $sum += gcd($a, gcd($b, $c));
        }
    }
}

echo $sum;


Measured memory_bytes: 16168
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++) {
        if(i%2!=0) {
            if(!(s[i]=='L' || s[i]=='U' || s[i]=='D')){
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(!(s[i]=='R' || s[i]=='U' || s[i]=='D')){
                cout << "No" << endl;
                return 0;
            }
        }

    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d, e;
  cin >> a;
  b = a % 100;
  c = b % 10;
  d = (b - c) / 10;
  e = (a - b) / 100;
  cout << c + d + e << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
   	
int main() {
	long long int n, sum = 0, total = 0;
	cin >> n;

	long long int a[n], x[n];

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		total = total + a[i];
	}

	for (int i = 1; i < n; i = i + 2)
	{
		sum = sum + 2*a[i];
	}

	x[0] = total - sum;

	for (int i = 1; i < n; i++)
	{
		x[i] = a[i-1]*2 - x[i-1];
 	}

 	for (int i = 0; i < n; i++)
 	{
 		cout << x[i] << " ";
 	}

	return 0;
}



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

using namespace std;

#define debug(x) cerr << endl << "DEBUG: (" << (#x) << " = " << x << ")" << endl;
#define debugArray(v) for (auto i : v) cerr << i << " "; cerr << endl;

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);

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

    int h, w, k;

    cin >> h >> w >> k;

    char mat[10][10];

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat[i][j];
        }
    }

    int ans = 0;

    for (int maskR = 0; maskR < (1 << h) - 1; maskR++) {
        for (int maskC = 0; maskC < (1 << w) - 1; maskC++) {
            int black = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (((maskR >> i) & 1) == 0 && ((maskC >> j) & 1) == 0 && mat[i][j] == '#') {
                        black++;
                    }
                }
            }

            if (black == k) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

const int N = 333;

int a[N][N];

int cnt[N];

int l[N];


int ban[N];

int n, m;

int get() {
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= n; i++) {
		while (ban[a[i][l[i]]]) {
			l[i] ++;
		}
		cnt[a[i][l[i]]]++;
	}
	int id = 0;
	for (int i = 1; i <= m; i++) {
		if (!ban[i] && (id == 0 || cnt[id] < cnt[i])) {
			id = i;
		}			
	}	
	return id;
}

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
	n = readInt(), m = readInt();
    for (int i = 1; i <= n; i++) {
    	for (int j = 1; j <= m; j++) {
    		a[i][j] = readInt();
    	}
    }
    for (int i = 1; i <= n; i++) {
    	l[i] = 1;
    }
    int res = 0;
    int ans = cnt[get()];
    while(res != m) {
    	int k = get();
    	ans = min(ans, cnt[k]);
    	ban[k] = 1;
    	res++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
/*A - Headphones */

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

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int ans = 0;
	int friends, conex;

	cin >> conex >> friends;

	if(friends != 1)
	{

		while(friends > 0){

			friends -= conex;
			
			if(friends > 0)
				friends++;

			ans++;
		}
	}



	cout << ans;


	return 0;
}

Measured memory_bytes: 3576
n,a,b = gets.strip.split(' ').map(&:to_i)

str = gets.strip
cj = 0
co = 0
str.each_char do |c|
  if c.eql? 'a'

    if cj + co + 1 <= a+b
      cj+=1
      puts "Yes"
    else
      puts "No"
    end
  elsif c.eql? 'b'

    if cj + co + 1 <= a+b and co + 1 <= b
      co+=1
      puts "Yes"
    else
      puts "No"
    end
  else
    puts "No"
  end
end


Measured memory_bytes: 2428