akhauriyash/Code-Regression huggingface dataset:
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll inf = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = int> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%inf; }a = a * a%inf; b >>= 1; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%inf; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], inf - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % inf)*inv[n - r] % inf; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int n = in();
	bool gre = 0;
	ll ans = 0;
	REP (i,n) {
		int x = in();
		if (x&&gre) {ans++;x--;}
		ans += x / 2;
		gre = x % 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

def maxxorsum(A):
    N = len(A)
    low = 0
    for i in xrange(59, -1, -1):
        mi = low
        m = -(1 << 60)
        for j in range(low, N):
            if A[j] & (1 << i) and A[j] > m:
                mi = j
                m = A[j]
        if m == -(1 << 60):
            continue

        A[low], A[mi] = A[mi], A[low]
        mi = low
        for j in xrange(N):
            if j != mi and A[j] & (1 << i):
                A[j] ^= A[mi]
        low += 1

    ans = 0
    for x in A: ans ^= x
    return ans

def solve(N, A):
    base = 0
    for x in A:
        base ^= x

    baseneg = ~base
    for i, x in enumerate(A):
        A[i] &= baseneg
    return 2 * maxxorsum(A) + base

print solve(rri(), rrm())


Measured memory_bytes: 45348
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
template<typename T>inline void read(T&x)
{
	T ll=1;
    T res=0;
	char ch=getchar();
    while(!isdigit(ch))
    {
		if(ch=='-')
		ll=-1;
		ch=getchar();
	}
    while(isdigit(ch))
	res=(res<<3)+(res<<1)+ch-'0',ch=getchar();
    x=res*ll;
}
template<typename T>void print(T x)
{
    if(x<0)putchar('-'),x=-x;
    if(x<10)
    putchar(x+'0');
    else
    {
        print(x/10);
        putchar(x%10+'0');
    }
}
int main()
{
	int n,m;
	int t[101],p[101],x[101];
	read(n);
	rep(i,1,n)
		read(t[i]);
	read(m);
	rep(i,1,m)
		read(p[i]),read(x[i]);
	rep(i,1,m)
	{
		long long ans=0;
		rep(j,1,n)
		{
			if(j==p[i])ans+=x[i];
			else ans+=t[j];
		}
		print(ans);
		puts("");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	deque<char> deq;
	int Q;
	cin >> Q;
	
	REP(i, S.size()) deq.push_back(S[i]);
	bool flip = false;
	while (Q--) {
		int x;
		cin >> x;
		if (x == 1) {
			flip ^= 1;
		}
		else {
			int F;
			string C;
			cin >> F >> C;
			--F;
			if (flip ^ F) deq.push_back(C[0]);
			else deq.push_front(C[0]);
		}
	}
	
	string ans;
	while (!deq.empty()) {
		ans.push_back(deq.front());
		deq.pop_front();
	}
	if (flip) reverse(ALL(ans));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1412
hp_t, at_t, hp_a, at_a = list(map(int, input().split()))

if(hp_t%at_a == 0 ):
    # 青木の攻撃回数
    num_a = hp_t // at_a
else:
    num_a = hp_t // at_a + 1

if(hp_a%at_t == 0 ):
    # 高橋の攻撃回数
    num_t = hp_a // at_t
else:
    num_t = hp_a // at_t + 1

if(num_a >= num_t):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9152
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		AdjacencyList[] tree = new AdjacencyList[n]; //adjacency list

		for (int i = 0; i < n; i++) {
			tree[i] = new AdjacencyList();
		}

		for (int i = 0, a, b; i < n - 1; i++) {
			a = scanner.nextInt() - 1;
			b = scanner.nextInt() - 1;
			tree[a].add(b);
			tree[b].add(a);
		}
		int[] distance = new int[n];
		for (int i = 1; i < n; i++) {
			distance[i] = -1;
		}
		dfs(tree, 0, distance);
		int even = 0;
		for (int i = 0; i < n; i++) {
			if (distance[i] % 2 == 0)
				even++;
		}

		if (even <= n / 3) {
			for (int i = 0; i < n; i++) {
				if (distance[i] % 2 == 0) {
					System.out.print(poll(0, 0, 0, n));
				} else {
					System.out.print(poll(1, 2, 0, n));
				}
				System.out.print(i == n - 1 ? "\n" : " ");
			}
		} else if (n - even <= n / 3) {
			for (int i = 0; i < n; i++) {
				if (distance[i] % 2 != 0) {
					System.out.print(poll(0, -1, -1, n));
				} else {
					System.out.print(poll(1, 2, 0, n));
				}
				System.out.print(i == n - 1 ? "\n" : " ");
			}
		} else {
			for (int i = 0; i < n; i++) {
				if (distance[i] % 2 == 0) {
					System.out.print(poll(1, 0, -1, n));
				} else {
					System.out.print(poll(2, 0, -1, n));
				}
				System.out.print(i == n - 1 ? "\n" : " ");
			}
		}

	}

	static void dfs(AdjacencyList[] tree, int v, int[] distance) {
		for (int nv : tree[v]) {
			if (distance[nv] < 0) {
				distance[nv] = distance[v] + 1;
				dfs(tree, nv, distance);
			}
		}
	}

	static int[] number = { 3, 1, 2 };

	static int poll(int first, int second, int third, int n) {
		if (number[first] <= n) {
			number[first] += 3;
			return number[first] - 3;
		}
		return poll(second, third, first, n);
	}

}

class AdjacencyList extends ArrayList<Integer> {
}


Measured memory_bytes: 183156
object Main {
  def main(args: Array[String]): Unit = {
    val Array(_1, _2, _3, _4, _5, _6, _*) = io.StdIn.readLine().split(" ").map(_.toInt)
    val dice = Dice(_1, _2, _3, _4, _5, _6)
    println(
      io.StdIn.readLine().foldLeft(dice) { case (d, c) => d.roll(Direction(c)) }.upSide
    )
  }

  case class Dice(upSide: Int, southSide: Int, eastSide: Int, westSide: Int, northSide: Int, downSide: Int) {
    import Direction._
    def spinClockwise: Dice = Dice(upSide, eastSide, northSide, southSide, westSide, downSide)
    def spinCounterclockwise: Dice = Dice(upSide, westSide, southSide, northSide, eastSide, downSide)
    def roll(direction: Direction): Dice = direction match {
      case North =>
        Dice(southSide, downSide, eastSide, westSide, upSide, northSide)
      case South =>
        Dice(northSide, upSide, eastSide, westSide, downSide, southSide)
      case West =>
        Dice(eastSide, southSide, downSide, upSide, northSide, westSide)
      case East =>
        Dice(westSide, southSide, upSide, downSide, northSide, eastSide)
    }
  }

  sealed trait Direction
  object Direction {
    case object North extends Direction
    case object South extends Direction
    case object West extends Direction
    case object East extends Direction

    def apply(c: Char): Direction = c match {
      case 'N' => North
      case 'S' => South
      case 'E' => East
      case 'W' => West
      case _ => throw new Exception
    }
  }
}

Measured memory_bytes: 44204
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

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

const int INF = 1 << 30;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y)
{
	return ((y%4==0&&y%100!=0)||y%400==0);
}

#define debug(a, b, c) for(int i = 0; i < b; i++){for(int j = 0; j < c; j++){printf("%3d", a[i][j]);}puts("");}puts("-----------------------------------------");

int main()
{
	string ring, search;
	int num, cnt = 0;

	cin >> search;
	cin >> num;

	for(int i = 0; i < num; i++)
	{
		cin >> ring;
		ring += ring.substr(0,search.size());

		for(int j = 0; j < ring.size(); j++)
		{
			if(search == ring.substr(j, search.size()))
			{
				cnt++;
				break;
			}
		}
	}
	
	cout << cnt << endl; 
}

Measured memory_bytes: 1212
def f():
  n=int(input())
  l=[list(map(int,input().split())) for i in range(n-1)]+[[0,0,1]]
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      now=a+s-(-max(0,now-s)//d)*d
    print(now)
if __name__=="__main__":
  f()

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

template <typename QvQ> inline QvQ Min(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max(QvQ a,QvQ b){if(a>b) return a;return b;}

#define inf 2147483647
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f

#define ll long long
#define rei register int
#define inv inline void
#define ull unsigned long long
#define il inline

#define bl putchar(' ')
#define ed putchar('\n')
#define test cout<<"this:" 

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

template <typename QvQ>inv read(QvQ &x){
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
int n;
char a[100005];
int main()
{
	read(n);
	scanf("%s",a+1);
	int ans=1,dq=a[1];
	for(rei i=2;i<=n;++i)
	{
		if(a[i]==dq) continue;
		++ans,dq=a[i];
	}
	write(ans);
	return 0;
}

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



double fast_pow(double n,int exp){

if(exp==0) return 1;
if(exp==1) return n;
double temp=fast_pow(n,exp/2);
temp=(temp*temp);
if(exp%2==1)
temp=(temp*n);
return temp;

}

int main(){

   
    int n,k;
    cin>>n>>k;
    double ans = 0;
    for(int i=1;i<=n;i++){
       // cout<<temp<<endl;
        int haha = 1;

        while(haha*i < k) haha*=2;

        ans+=(1/(double)n)*fast_pow(0.5,log2(haha));
     //   cout<<temp<<endl;
    }
    cout<<fixed<<setprecision(10)<<ans;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  auto res = unique(all(a));
  int k = res-a.begin();
  if(k%2 == 0) k--;
  cout << k << endl;
  return 0;
}


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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 2e5 + 9, M = 100 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void READ() {
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
}

int n, arr[M], tot, part, ans = OO;
int main() {
//	READ();
	OUTPUT();
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
		tot += arr[i];
	}
	part = arr[0];
	tot -= arr[0];
	for (int i = 1; i < n; i++) {
		ans = min(ans, abs(tot - part));
		part += arr[i];
		tot -= arr[i];
	}
	cout << ans;

	return 0;

}


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

int main()
{
	int N, K, X, Y;
	cin >> N >> K;
	cin >> X >> Y;
	int ans;
	if (N > K) {
		ans = K*X + (N - K)*Y;
	}
	else if (N <= K) {
		ans = N*X;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        ll num[200005];
        for(int i=0; i<n; i++)
            scanf("%lld",&num[i]);
        int r=0;
        ll sum0 = 0,sum1 = 0,ans = 0;
        for(int l=0; l<n; l++)
        {
            while((sum0^num[r])==(sum1+num[r])&&r<n)
            {
                sum0 ^= num[r];
                sum1 += num[r++];
            }
            ans+=(r-l);
            sum0 ^= num[l];
            sum1 -= num[l];
        }
        printf("%lld\n",ans);
    }
    return 0;
}

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


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& a : A){
    cin >> a;
  }

  double ans = 0;
  for(auto& a : A){
    ans += (1/(double)a);
  }

  cout << fixed << setprecision(5) << 1 / ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int h,n,sumv=0;
	cin>>h>>n;
	for (int i=1;i<=n;i++)
	{
		int k;
		cin>>k;
		sumv+=k;
	}
	if (sumv>=h)  cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;  
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll temp = gcd(a, b); return temp ? (a / temp * b) : 0; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> point) { ll x = get<0>(point), y = get<1>(point); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }
void out_sequence(vector<ll> &out) { REP(i, (int)out.size()) { cout << out[i]; if (i == (int)out.size() - 1) cout << endl; else cout << " "; } }



int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll A, B; cin >> A >> B;
  cout << (A-1)*(B-1) << endl;

	return 0;
}

//*/

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
W = [input() for i in range(n)]

ans = 'Yes'
if len(W) != len(set(W)):
    ans = 'No'
else:
    for i in range(n - 1):
        if W[i][-1] != W[i + 1][0]:
            ans = 'No'
            break

print(ans)        

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

int main()
{
    int a,b,c;
    cin >> a;
    if(a == 1){
        cout << "Hello World" << endl;
        return 0;
    }
    cin >> b >> c;

    cout << b + c << endl;

    return 0;
}

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

int ans=0;
bool S[25];
bool T[25];
int a[13];
vector<int>V;
signed main(){
	int n;cin>>n;
	for(int i=0;i<n;i++){
		int k;cin>>k;
		a[k]++;
		}
	S[0]=true;	
	int sum=0;	
	for(int i=0;i<=12;i++){
		if(i==0&&a[i]){puts("0");return 0;}
		if(a[i]>=3){puts("0");return 0;}
		if(a[i]==2){S[i]=S[24-i]=true;}
		if(a[i]==1){sum++;V.push_back(i);}
		}		
	for(int i=0;i<(1<<sum);i++){
		int o=12;
		for(int j=0;j<24;j++)T[j]=S[j];
		for(int j=0;j<sum;j++){
			if(i&(1<<j))T[V[j]]=true;
			else T[24-V[j]]=true;
			}
		for(int i=0;i<24;i++){
			for(int j=i+1;j<24;j++){
				if(T[i]&&T[j]){o=min({o,j-i,24-(j-i)});}
				}
			}
		ans=max(ans,o);
		}	
	cout<<ans<<endl;	
	}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int abfinder(char *s){
	char *p=s;
	int cont=0;
	while(1){
		if((p=strstr(p,"AB"))==NULL){
			break;
		}
		p++;
		cont++;
	}
	return cont;
}

int main(){
	int n;
	int i,cont=0,startb=0,enda=0,both=0;
	char s[12];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s);
		cont+=abfinder(s);
		if(s[0]=='B'){
			startb++;
		}
		if(s[strlen(s)-1]=='A'){
			enda++;
		}
		if(s[0]=='B' && s[strlen(s)-1]=='A'){
			both++;
		}
	}
	if(startb==n)startb--;
	if(enda==n)enda--;
	if(startb==both && enda==both && both>0)startb--;
	if(startb<=enda){
		cont+=startb;
	}else{
		cont+=enda;
	}
	printf("%d\n",cont);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x, count int
	)
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i < a+1; i++ {
		for j := 0; j < b+1; j++ {
			for k := 0; k < c+1; k++ {
				if i*500+j*100+k*50 == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 1768
#include <stdio.h>

void Do(int n){
  if(n > 10) Do(n / 10);
  if(n % 10 == 1) printf("9");
  else printf("1");
}

int main(void){
  int n;
  scanf("%d", &n);
  Do(n);
  printf("\n");
  return 0;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c =='u' || c =='o' || c =='e'){
    cout << "vowel"<< endl;
  }else{
    cout << "consonant"<< endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int get(int x)
{
	return ((x+1)>>1&1)^(x&1?0:x);
}
signed main()
{
	int A,B;
	cin>>A>>B;
	cout<<(A^get(A)^get(B))<<endl;
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int r; cin >> r;
	println(r*r);
}


Measured memory_bytes: 256
/// https://github.com/hatoo/competitive-rust-snippets
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules !get {([$t:ty]) => {{let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace().map(|t| t.parse::<$t>() .unwrap () ) .collect ::<Vec <_ >>() } } ;([$t :ty ] ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !([$t ] ) ) .collect ::<Vec <_ >>() } ;($t :ty ) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;line .trim () .parse ::<$t >() .unwrap () } } ;($($t :ty ) ,*) =>{{let mut line :String =String ::new () ;stdin () .read_line (&mut line ) .unwrap () ;let mut iter =line .split_whitespace () ;($(iter .next () .unwrap () .parse ::<$t >() .unwrap () ,) *) } } ;($t :ty ;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($t ) ) .collect ::<Vec <_ >>() } ;($($t :ty ) ,*;$n :expr ) =>{(0 ..$n ) .map (|_ |get !($($t ) ,*) ) .collect ::<Vec <_ >>() } ;}
#[allow(unused_macros)]
macro_rules !debug {($($a :expr ) ,*) =>{eprintln !(concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) ;} }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let mut input: Vec<u8> = get!([u8]);
    input.sort();
    if input == [5, 5, 7] {
        println!("YES");
    }else{
        println!("NO");
    }
}

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

main(){
  char S[100];
  for(int ii=0;ii<100;ii++){
    S[ii]=0;
  }
  int N;
  cin >> S;
  for(int ii=0;ii<100;ii++){
    if(S[ii]==0){N=ii; break;}
  }
  int ans=0;
  for(int ii=0;ii<N;ii++){
    if(ii%2==1 && S[ii]=='R')ans=1;
    else if(ii%2==0 && S[ii]=='L')ans=1;
  }
  if(ans==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC107();
}

void ABC107(){
    int h,w,i,j,k=0,count=0;
    cin>>h>>w;
    char c;
    char a[h][w],b[h][w];
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>a[i][j];
            if(a[i][j]=='.')count++;
        }
        if(count==w){
            i--;
            h--;
        }
        count=0;
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cerr<<a[i][j];
        }
        cerr<<endl;
    }
    count=0;
    cerr<<h<<w<<endl;
    for(j=0;j<w;j++){
        for(i=0;i<h;i++){
            if(a[i][j]=='.')count++;
        }
        if(count!=h){
            for(i=0;i<h;i++){
                b[i][j-k]=a[i][j];
            }
        }
        if(count==h){
            k++;
        }
        count=0;
    }
    cerr<<h<<w<<endl;
    for(i=0;i<h;i++){
        for(j=0;j<w-k;j++){
            cout<<b[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void sorter(long long lol[][2], long long n)
{
  auto ptr = (pair<long long, long long>*) lol;
  sort(ptr, ptr+n);
}
int main() 
{
	long long n , m ;
	cin >> n >> m ;
	long long lol[n][2] ;
	for(long long i = 0 ; i < n ; i++)
		cin >> lol[i][0] >> lol[i][1] ;
	sorter(lol , n);
	long long cost = 0 , i = 0;
	while(m!=0)
	{
		pair<long long, long long> z = *(((pair<long long, long long>*) lol) + i);
		if(z.second<m)
		{
			m-= z.second;
			cost+=z.second*z.first;
		}
		else
		{
			cost+=m*z.first;
			m = 0;
		}
		i++;
	}
	cout << cost ;
	return 0;
}

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

int main(){
	int n,m,ret;
	string s;
	while(cin >> n >> m && n && m){
		ret = 0;
		vector<pair<string,int> > st(n);
		for(int i=0;i<n;i++)
			cin >> st[i].first >> st[i].second;
		while(m--){
			cin >> s;
			for(int i=0;i<n;i++){
				bool flag = true;
				for(int j=0;j<st[i].first.size();j++){
					if(st[i].first[j]=='*')continue;
					if(st[i].first[j]!=s[j])flag = false;
				}
				if(flag)ret += st[i].second;
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 932
n = gets.to_i
@memo = {}

def countCheck(remain)
  return 0 if remain == 0
  return @memo[remain] if @memo[remain]
  min = 1000000000
  sixVal = 1
  nineVal = 1
  while sixVal <= remain do
    min = [min,1+countCheck(remain-sixVal)].min
    sixVal *= 6
  end
  while nineVal <= remain do
    min = [min,1+countCheck(remain-nineVal)].min
    nineVal *= 9
  end

  @memo[remain] = min
end

puts countCheck(n)


Measured memory_bytes: 32508
def main():
    n, y = map(int, input().split())
    for i in range(n + 1):
        for j in range(n + 1):
            k = n - i - j
            if k < 0:
                continue
            if i * 10000 + j * 5000 + k * 1000 == y:
                print(i, j, k)
                return
    print(-1, -1, -1)


if __name__ == '__main__':
    main()


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

string pad_line(int W) {
  string ret = "";
  for (int i = 0; i < W + 2; i++) {
    ret = ret + "#";
  }
  return ret;
}

string pad(string s) {
  return "#" + s + "#";
}


int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H + 2);
  for (int i = 0; i < H + 2; i++) {
    if (i == 0 || i == H + 1) {
      cout << pad_line(W) << endl;
	  continue;      
    }
    string x;
    cin >> x;
    cout << pad(x) << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  bool B=true;
  map<int,int>C;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]!=0)B=false;
    C[A[i]]++;
  }
  if(B){puts("Yes");return 0;}
  if(N%3!=0){puts("No");return 0;}
  int k=0;
  vector<pair<int,int>>E(3);
  for(pair<int,int>D:C){
    k++;if(k>=4){puts("No");return 0;}
    E[k-1].first=D.first;E[k-1].second=D.second;
  }
  if(k==2){if(E[0].first==0&&E[0].second*2==E[1].second){puts("Yes");return 0;}}
  else if(E[0].second==E[1].second&&E[1].second==E[2].second&&((E[0].first^E[1].first)^E[2].first)==0){puts("Yes");return 0;}
  puts("No");
}

Measured memory_bytes: 7104
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next()); 
        int m = Integer.parseInt(sc.next());
        int[][] a = new int[n][m];
        int[] b = new int[m];
        int[] c = new int[n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                a[i][j] = Integer.parseInt(sc.next());
        for (int i = 0; i < m; i++)
            b[i] = Integer.parseInt(sc.next());
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                c[i] += a[i][j] * b[j];
        for (int i = 0; i < n; i++)
            System.out.println(c[i]);
    }
}


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

int main(int argc, char const *argv[])
{
    int N;
    int A;
    cin>>N>>A;
    
    if (N%500<=A) {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
//
//  main.c
//  uafh
//
//  Created by x19012xx on 2019/10/03.
//  Copyright © 2019 AIT. All rights reserved.
//
//
//#include <stdio.h>
//
//#define MaxTower 4
//#define MaxFloor 3
//#define MaxRoom 10
//
//int main(void){
//    int RoomMember[MaxTower][MaxFloor][MaxRoom];
//
//    int InTower,InFloor,InRoom,InMember;
//
//    int n,x,y,z;
//
//    //初期化
//    for(x=0;x<MaxTower;x++){
//        for(y=0;y<MaxFloor;y++){
//            for(z=0;z<MaxRoom;z++){
//                RoomMember[x][y][z]=0;
//            }
//        }
//    }
//
//        //読み込み
//        scanf("%d",&n);
//        for(x=0;x<n;x++){
//            scanf("%d %d %d %d",&InTower,&InFloor,&InRoom,&InMember);
//            RoomMember[InTower-1][InFloor-1][InRoom-1] = InMember;
//        }
//
//        //印刷
//
//        for(x=0;x<MaxTower;x++){
//            for(y=0;y<MaxFloor;y++){
//                for(z=0;z<MaxRoom;z++){
//                    printf(" %d",RoomMember[x][y][z]);
//                }
//                if(x==3 && y==2){
//
//                }else{
//                    printf(" ");
//                }
//                printf("\n");
//            }
//            for(n=0;n<20;n++){
//                if(x==3){
//                    break;
//                }
//                printf("#");
//           }
//           if(x!=3){
//                printf(" ");
//                printf("\n");
//           }
//        }
//    }


int main(void){
    
    int i=0,j;
    int a[51],b[51],c[51];
    
    //成績取得
    a[0]=1;
    while(a[i] != -1 || b[i] != -1){
        i++;
        scanf("%d %d %d",&a[i],&b[i],&c[i]);
    }
    //成績判定
    for(j=1;j<i;j++){
        if(a[j]<0 || b[j]<0){
            printf("F\n");
        }else if(a[j]+b[j]>=80){
            printf("A\n");
        }else if(a[j]+b[j]>=65){
            printf("B\n");
        }else if(a[j]+b[j]>=50){
            printf("C\n");
        }else if(a[j]+b[j]>=30){
            if(c[j]>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");
        }
    }
}



Measured memory_bytes: 2080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int chocolate = x;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            for (int j = 1; j <= d; j += a)
                chocolate++;
        }
        System.out.println(chocolate);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define ll long long

ll n,x,b[50],p[50];

ll c(ll n,ll x){
    if(n==0)return 1;
    if(x==0||x==1)return 0;
    else if(x<=1+b[n-1])return c(n-1,x-1);
    else if(x==2+b[n-1])return 1+p[n-1];
    else if(x<=2+2*b[n-1])return 1+p[n-1]+c(n-1,x-2-b[n-1]);
    else if(x==3+2*b[n-1])return p[n-1]*2LL+1;
}

int main(){
    scanf("%lld %lld",&n,&x);
    b[0]=1;
    p[0]=1;
    for(int i=1;i<50;i++)p[i]=2*p[i-1]+1,b[i]=2*b[i-1]+3;
    printf("%lld\n",c(n,x));
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := []rune(Scanner()), []rune(Scanner()), []rune(Scanner())
	fmt.Println(string(a[0]-32) + string(b[0]-32) + string(c[0]-32))
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int dp[90][360][360];
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int T;
  cin>>T;
  while(T--){
    Int n;
    cin>>n;
    vector<Int> v(n);
    for(Int i=0;i<n;i++) cin>>v[i];
    if(n==1){
      cout<<v[0]<<endl;
      continue;
    }
    memset(dp,0,sizeof(dp));
    dp[1][v[0]][v[1]]=1;
    const Int W = 350;
    for(Int i=1;i<n-1;i++){
      for(Int j=0;j<W;j++){
	for(Int k=0;k<W;k++){
	  if(!dp[i][j][k]) continue;
	  dp[i+1][k][v[i+1]]=1;
	  if(k) dp[i+1][k-1][v[i+1]+j]=1;
	}
      }
    }

    Int ans=0;
    for(Int i=0;i<W;i++)
      for(Int j=0;j<W;j++)
	if(dp[n-1][i][j]) ans=max(ans,j);
    cout<<ans<<endl;
  }
  return 0;
}



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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double PI = 3.141592653589793238462643383279;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} init;

int N, K;
int a[110000];
vint G[110000];
int ans;
int dfs(int idx) {
    int ret = 1;
    rep(i, G[idx].size()) {
        int cur = dfs(G[idx][i]);
        if (cur == K) { if (idx != 1) { ans++; }}
        else { chmax(ret, cur + 1); }
    }
    return ret;
}
signed main() {
    cin >> N >> K;
    reps(i, N) { cin >> a[i]; }
    if (a[1] != 1) { a[1] = 1, ans++; }
    for (int i = 2; i <= N; i++) { G[a[i]].push_back(i); }
    dfs(1);
    cout << ans << endl;
}

Measured memory_bytes: 11392
#include <iostream>
#include <cstring>
#include <string>

const int MAXH = 10;
const int MAXW = 1000;
const int INF = MAXW * MAXW;

int a[MAXH][MAXW];
int f[MAXH][MAXW];

int calc(int n, int w, int sum) {
  int ans = 0;
  for (int j = 0; j < w; ++j) {
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      if (f[i][j] > sum) return INF;
      if (j < w - 1 && f[i][j] + f[i][j + 1] > sum) ok = false; 
    }
    if (ok) {
      for (int i = 0; i < n; ++i) {
        if (j < w - 1) f[i][j + 1] += f[i][j];
      }
    } else {
      ++ans;
    }
  }
  return ans;
}

int solve(int h, int w, int sum) {
  int min_count = h * w;
  int enum_num = 1 << (h - 1);
  for (int k = 0; k < enum_num; ++k) {
    memset(f, 0, sizeof(f));
    int tot = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        f[tot][j] += a[i][j];
      }
      if (i == h - 1 || ((k >> i) & 1)) ++tot;
    }

    int cur_count = tot - 1 + calc(tot, w, sum);
    if (cur_count < min_count) min_count = cur_count;
  }
  return min_count;
}

int main() {
  int h, w, sum;
  std::cin >> h >> w >> sum;
  std::string s;
  for (int i = 0; i < h; ++i) {
    std::cin >> s;
    for (int j = 0; j < w; ++j) {
      a[i][j] = s[j] - '0';
    }
  }
  std::cout << solve(h, w, sum) << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

int n, s, x, y, cnt, a[1000000];
ll ans;
PII A[1000000];

void ins(int i)
{
    ans += A[i].fi;
    int t = A[i].se;
    if (t < 0) t = -t;
    a[t]++;
    if (a[t] == 1)
        s++;
    if (A[i].se > 0)
        x++;
    else
        y++;
}

void del(int i)
{
    ans -= A[i].fi;
    int t = A[i].se;
    if (t < 0) t = -t;
    a[t]--;
    if (a[t] == 0)
        s--;
    if (A[i].se > 0)
        x--;
    else
        y--;
}

bool check()
{
    if (s < n)
        return 1;
    if (x == n || y == n)
        return 1;
    return 0;
}

int main()
{
    n = read();
    for (int i = 1; i <= n; i++)
    {
        A[++cnt] = MP(read(), i);
        A[++cnt] = MP(read(), -i);
    }
    sort(A + 1, A + cnt + 1);
    for (int i = 1; i <= n; i++)
        ins(i);
    if (check()) return printf("%lld\n", ans), 0;
    del(n);
    ins(n + 1);
    if (check()) return printf("%lld\n", ans), 0;
    ll ans2 = 1e18;
    ins(n);
    for (int i = 1; i < n; i++)
    {
        del(i);
        if (check()) ans2 = min(ans2, ans);
        ins(i);
    }
    del(n);
    del(n + 1);
    ins(n + 2);
    if (check()) ans2 = min(ans2, ans);
    printf("%lld\n", ans2);
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b;
	cin >> a >> b;
	cout << max({a * b, a - b, a + b}) << '\n';
 	return 0;
}


Measured memory_bytes: 256
void main(){
	real a, b, h, m;
	readf("%s %s %s %s\n", &a, &b, &h, &m);
	double angle = abs( PI/6*(h+m/60) - PI*m/30  );
	double ans = sqrt( a^^2 + b^^2 -2*a*b*cos(angle) );
	writefln("%.23f", ans);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

int sumDigit(int num)
{
    int sum = 0;
    while (num > 0) {
        int mod = num % 10;
        sum += mod;
        num /= 10;
    }
    return sum;
}

int main(int argc, const char * argv[]) {
    int N;
    int minv = 100000000;
    
    cin >> N;
    for (int i = 1; i < N; i++) {
        int sum1 = sumDigit(N - i);
        int sum2 = sumDigit(i);
        minv = min(minv, sum1 + sum2);
    }
    
    cout << minv << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author otsuhata
 */
public class Main {
     public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r = sc.nextInt();
    
    if(0 < W && W <= 100 && 0 < H && H <= 100 && 0 < r && r <= 100 
             && -100 <= x && x <= 100 && -100 <= y && y <= 100) {
        if(x + r <= W && y + r <= H && x - r >= 0 && y - r >= 0) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }        
    }else {
        System.out.println("Please enter appropriate number.");
    }
  }
}

Measured memory_bytes: 26264
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

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

	vector<pll> ans;
	priority_queue<ll> que_l;
	priority_queue<ll, vector<ll>, greater<ll>> que_r;
	ll sum_l = 0, sum_r = 0, sum_b = 0;

	rep(i, q) {
		int type;
		cin >> type;
		if(type == 1) {
			ll a, b;
			cin >> a >> b;
			sum_b += b;
			if(que_l.size() < que_r.size()) {
				if(a <= que_r.top()) {
					que_l.push(a);
					sum_l += a;
				}
				else {
					ll tmp = que_r.top();
					que_r.pop();
					sum_r -= tmp;
					que_l.push(tmp);
					sum_l += tmp;
					que_r.push(a);
					sum_r += a;
				}
			}
			else {
				if(que_r.empty() || que_l.top() <= a) {
					que_r.push(a);
					sum_r += a;
				}
				else {
					ll tmp = que_l.top();
					que_l.pop();
					sum_l -= tmp;
					que_r.push(tmp);
					sum_r += tmp;
					que_l.push(a);
					sum_l += a;
				}
			}
		}
		else {
			if(que_l.size() == que_r.size()) {
				ans.push_back(pll(que_l.top(), sum_r - sum_l + sum_b));
			}
			else {
				ans.push_back(pll(que_r.top(), sum_r - sum_l - que_r.top() + sum_b));
			}
		}
	}
	for(auto p : ans) {
		cout << p.first << ' ' << p.second << endl;
	}
}


Measured memory_bytes: 5868
#include <iostream>
#include <algorithm>
#include <numeric>

int main() {
  int X, Y;
  std::cin >> X >> Y;

  for (int n_cranes = 0; n_cranes <= X; ++n_cranes) {
    if (n_cranes * 2 + (X - n_cranes) * 4 == Y) {
      std::cout << "Yes\n";
      return 0;
    }
  }

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


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int main()
{
    double a,b,c,d,s;
    scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
    s=sqrt((a-c)*(a-c)+(b-d)*(b-d));
    printf("%.8lf\n",s);
    return 0;
}



Measured memory_bytes: 2128