akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  double h, a;
  cin >> h >> a;
  cout << ceil(h / a) << endl;
}


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

const int maxn = 300005;
int a[maxn], top, n, K;

int main() {
    scanf("%d%d", &K, &n);
    if (!(K&1)) {
        printf("%d ", K / 2);
        rep (i, 2, n) printf("%d ", K);
        return 0;
    }
    rep (i, 1, n) a[i] = (K + 1) / 2;
    top = n;
    rep (i, 1, n / 2)
        if (a[top] == 1) top--;
        else {
            a[top]--;
            while (top < n) a[++top] = K;
        }
    rep (i, 1, top) printf("%d ", a[i]);
    
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N, K;
int rec[220][220];
int ansf = 0;

//primal-dual
struct edge { ll to, cap, cost, rev; };

const int MAX_V = 220;
int V;
vector<edge>G[MAX_V];
ll dist[MAX_V];
ll ans = inf;
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost) {
	edge fe = { to,cap,cost,(int)G[to].size() };
	edge toe = { from,0,-cost,(int)G[from].size() };
	G[from].pb(fe);
	G[to].pb(toe);
}

ll min_cost_flow(int s, int t, int f) {
	ll res = 0;
	while (f > 0) {
		//Bellman-Ford
		for (int i = 0; i < V; i++)dist[i] = inf;
		dist[s] = 0;

		for (int i = 0; i < V - 1; i++) {
			for (int j = 0; j < V; j++) {
				for (int k = 0; k < G[j].size(); k++) {
					edge &e = G[j][k];
					if (dist[j] == inf)continue;
					if (e.cap > 0 && dist[e.to] > dist[j] + e.cost) {
						dist[e.to] = dist[j] + e.cost;
						prevv[e.to] = j;
						preve[e.to] = k;
					}
				}
			}
		}

		if (dist[t] == inf)return -1;

		//s-t最短路に沿って目いっぱい流す
		ll d = f;
		for (int v = t; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d * dist[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}

		//答えの記録&使われているマスをチェック
		if (ans > res) {
			ans = res;
			for (int i = 0; i < 220; i++)for (int j = 0; j < 220; j++)rec[i][j] = 0;
			for (int i = 1; i <= N; i++) {
				for (int j = 0; j < G[i].size(); j++) {
					edge e = G[i][j];
					if (e.cap == 0)rec[i][e.to] = 1;
				}
			}
		}
	}
	return res;
}
//primal-dual　ここまで


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


	cin >> N >> K;
	V = 2 * N + 2;
	for (int i = 1; i <= N; i++)add_edge(0,i,K,0);
	for (int i = N + 1; i <= 2 * N; i++)add_edge(i,2*N+1,K,0);
	for (int i = 1; i <= N; i++) {
		for (int j = N+1; j <= 2*N; j++) {
			int A;
			cin >> A;
			add_edge(i,j,1,-A);
		}
	}
	min_cost_flow(0, 2 * N + 1, 60 * 60);


	puts(-ans);
	for (int i = 1; i <= N; i++) {
		for (int j = N+1; j <= 2*N; j++) {
			if(rec[i][j])cout << "X";
			else cout << ".";
		}
		puts("");
	}


	return 0;
}

Measured memory_bytes: 3640
package main

import "fmt"

func main() {

	var n, m int
	fmt.Scan(&n, &m)

	var p int
	var s string
	q := make(map[int]bool, n)
	sumPenaQ := make(map[int]int, n)
	var sumPena int
	var sumAC int
	for i := 0; i < m; i++ {
		fmt.Scan(&p, &s)

		if q[p] == true {
			continue
		}

		if s == "AC" {
			sumAC++
			sumPena += sumPenaQ[p]
			q[p] = true
		} else { // "WA"
			sumPenaQ[p]++
		}
	}
	fmt.Println(sumAC, sumPena)
}


Measured memory_bytes: 8320
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <time.h>
using namespace std;

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
//#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const LL mod = 1000000007;
const LL MAX = 13;

int h, w, od, B[MAX];
string S[MAX];
bool P[MAX][MAX];
vector <int> A;

int cnt(int mask)
{
	int res = 0;
	REP(i, MAX)
		if (mask & (1 << i))
			++res;
	return res;
}

void rec1(int unused, int r)
{
	if (r == (h >> 1))
	{
		od = -1;
		REP(i, h)
			if (unused & (1 << i))
				od = i;
		if (od > -1)
		{
			A.push_back(od);
			B[r++] = od;
		}
		REP(mask, 1 << w)
		{
			if (cnt(mask) != (w >> 1))
				continue;
			vector <int> C, D;
			REP(j, w)
				if (mask & (1 << j))
					C.push_back(j);
				else
					D.push_back(j);
			do
			{
				bool ok = true;
				if (w & 1)
				{
					REP(i, r)
						if (S[A[i]][D.back()] != S[B[i]][D.back()])
						{
							ok = false;
							break;
						}
				}
				if (!ok)
					continue;
				REP(i, w >> 1)
				{
					REP(j, r)
						if (S[A[j]][C[i]] != S[B[j]][D[i]] || S[A[j]][D[i]] != S[B[j]][C[i]])
						{
							ok = false;
							break;
						}
						if (!ok)
							break;
				}
				if (!ok)
					continue;
				cout << "YES";
				exit(0);
			} while(next_permutation(ALL(D)));
		}
		if (od > -1)
			A.pop_back();
		return;
	}
	REP(i, h)
		if ((unused & (1 << i)) && P[i][A[r]])
		{
			B[r] = i;
			rec1(unused ^ (1 << i), r + 1);
		}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	cin >> h >> w;
	REP(i, h)
		cin >> S[i];
	REP(i, h)
		REP(j, h)
	{
		string T1 = S[i], T2 = S[j];
		sort(ALL(T1));
		sort(ALL(T2));
		P[i][j] = T1 == T2;
		/*int C1[26][26], C2[26][26];
		REP(k, 26)
			REP(l, 26)
			C1[k][l] = C2[k][l] = 0;
		REP(k, w)
		{
			C1[S[i][k] - 'a'][S[j][k] - 'a']++;
			C2[S[j][k] - 'a'][S[i][k] - 'a']++;
		}		
		REP(k, 26)
			REP(l, 26)
			if (C1[k][l] != C2[k][l])
				P[i][j] = false;*/
	}
	REP(mask, 1 << h)
	{
		if (cnt(mask) != (h >> 1))
			continue;
		A.clear();
		REP(i, h)
			if (mask & (1 << i))
				A.push_back(i);
		rec1(((1 << h) - 1) ^ mask, 0);
	}
	cout << "NO";
	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(_) for _ in input().split()]
mc=[0,abs(h[0]-h[1])]
for i in range(2,n):mc.append(min(mc[i-2]+abs(h[i-2]-h[i]),mc[i-1]+abs(h[i-1]-h[i])))
print(mc[n-1])

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll trans[n+1],vis[n+1];
	for(ll i=1;i<=n;i++)cin>>trans[i],vis[i]=0;
	deque<ll> path;
	ll cur=1,lim=-1;
	while(1)
	{
		if(vis[cur])
		{
			lim=cur;
			break;
		}
		path.pb(cur);
		vis[cur]=1;
		cur=trans[cur];
	}
	if(k<sz(path))
	{
		cout<<path[k]<<"\n";
		return 0;
	}
	while(path.front()!=lim)path.pop_front(),k--;
	k%=sz(path);
	cout<<path[k]<<"\n";
	return 0;
}

Measured memory_bytes: 7920
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 5 * 1000 * 100 + 47;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	LL a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
	{
		cout << 0 << endl;
		return 0;
	}

	LL ans = min(min(a * b, a * c), b * c);
	cout << ans << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 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;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/
string A[101];
int main() {
    int H, W; cin >> H >> W;
    rep(i, H) cin >> A[i];
    map<char, int> cnt;
    rep(i, H) rep(j, W) cnt[A[i][j]]++;

    if (H % 2 == 0 && W % 2 == 0) {
        for (auto x : cnt) if (x.second % 4) {
            cout << "No" << endl;
            return 0;
        }
    }

    if (H % 2 && W % 2) {
        map<int, int> c;
        for (auto x : cnt) c[x.second % 4]++;
        // cout << c[0] << ' ' << c[1] << ' ' << c[2] << ' ' << c[3] << endl;
        if (c[3] || c[1] != 1) {
            cout << "No" << endl;
            return 0;
        }
        if (c[2] > (H-1) / 2 + (W-1) / 2) {
            cout << "No" << endl;
            return 0;
        }
    }

    if (W % 2) swap(H, W);
    
    if (W % 2 == 0 && H % 2) {
        map<int, int> c;
        for (auto x : cnt) c[x.second % 4]++;
        // 例えば3*4なら、2個余るものが二つあるということは、4つ分の文字を表す。
        if (c[1] || c[3] || c[2] > W / 2) {
            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;
  string op;
  cin >> a >> op >> b;
  
  if (op == "+") {
    cout << a + b << endl;
  }
  else if (op == "-") {
    cout << a - b << endl;
  }
}

Measured memory_bytes: 3604
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include<limits.h>
#include<iomanip>
#include<bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e8
typedef long long ll;
using namespace std;

ll lis[61];
int main() {
    ll n; cin >> n;
    ll mod = 1000000007;
    rep(i,n) {
        ll a; cin >> a;
        bitset<60> b(a);
        string s = b.to_string();
        reverse(ALL(s));
        rep(i,s.size()) {
            if(s[i]=='1') lis[i]++;
        }
    }
    ll ans = 0;
    rep(i,61) {
        ll x = 1;
        REP(j,1,i+1) {
            x*=2;
            x %= mod;
        }
        ll x2 = lis[i]*(n-lis[i]);
        x2 %= mod;
        ans += x2*x;
        ans%=mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>


int parent[100005];
int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int > A(N+M-1), B(N+M-1);
  std::vector<int > in[100005], out[100005], in2[100005];
  for (int i=0; i<N+M-1; i++){
    scanf("%d", &A[i]);
    scanf("%d", &B[i]);
    A[i]--;
    B[i]--;
    out[A[i]].push_back(B[i]);
    in[B[i]].push_back(A[i]);
    in2[B[i]].push_back(A[i]);
  }
  int root;
  for (int i=0; i<N; i++){
    if (in[i].size()==0){
      root=i;
      break;
    }
  }
  std::vector<int> order;
  order.push_back(root);
  std::queue<int> queue;
  queue.push(root);
  while(queue.size()>0){
    int v = queue.front();
    queue.pop();
    for (int vv : out[v]){
      in[vv].erase(std::find(in[vv].begin(), in[vv].end(), v));
      if (in[vv].size()==0){
	order.push_back(vv);
	queue.push(vv);
      }
    }
  }
  std::reverse(order.begin(), order.end());
  int num[100005], ans[100005];
  int counter=0;
  for (int p : order){
    num[p]=counter;
    //printf("num[%d]=%d\n", p, counter);
    counter++;
  }
  for (int i=0; i<order.size(); i++){
    int v = order[i];
    int nummin=100005;
    int minindex=-2;
    if (i==order.size()-1){
      ans[v]=0;
    } else {
      for (int p : in2[v]){
	if (num[p]<nummin){
	  nummin=num[p];
	  minindex = p;
	}
      }
      ans[v]=minindex+1;
      //printf("ans[%d]=%d\n", v, ans[v]);
    }
  }
  for (int i=0; i<N; i++){
    printf("%d\n", ans[i]);
  }
  
  return 0;
  
}
 

Measured memory_bytes: 21360
#include <iostream>

using namespace std;

int main(){
        int n,ans=1;
        int h[25];
        cin>>n;

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

        for(int i=1; i<n; i++){
                for(int j=0;j<i;j++){
                        if(h[j]>h[i]) break;
                        if(j==i-1) ans++;
                }
        }

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


Measured memory_bytes: 256
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

if N >= M:
    print(0)
    exit()

ruisekisa = [0]*(M-1)
for i in range(0,M-1,1):
    ruisekisa[i]=X[i+1]-X[i]

ruisekisa.sort()
print(sum(ruisekisa[0:M-N]))


Measured memory_bytes: 85324
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n,q;cin>>n;
    ll arr[100001]={0};
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        ll x;cin>>x;
        sum+=x;
        arr[x]++;
    }
    cin>>q;
    for(ll i=1;i<=q;i++)
    {
        ll a,b;cin>>a>>b;
        if(arr[a]==0)
        {
            cout<<sum<<endl;
            continue;
        }
        sum=sum-arr[a]*a+arr[a]*b;
        cout<<sum<<endl;
        arr[b]+=arr[a];
        arr[a]=0;
    }
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

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

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 4428
# 099A

# N回目(数値）：標準入力
N = int(input())

# 1~999回目：ABC001~ABC999
# 1000~1998回目：ABD001~ABD999
# N回目のコンテストの名前の最初の3文字を出力

if N < 1000:
    print('ABC')
elif 1000 <= N <= 1998:
    print('ABD')

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define ll long long
#define W(x) cerr << "\033[31m"<< #x << " = " << x << "\033[0m" << endl;
 
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;
ll oo2 = 1ll*oo*oo;  
 
const int N = 10005;
int n, m;
vi a(10);
int tb[N];
int aux[N];
string ret = "";
 
int mapeia(int num) {
    if(num == 2 or num == 3 or num == 5) return 5;
    if(num == 1) return 2;
    if(num == 4) return 4;
    if(num == 6 or num == 9) return 6;
    if(num == 8) return 7;
    return 3;
}
 
int f(int k) {
    if(k == n) return 0;
    if(tb[k] != -1) return tb[k];
 
    int ans = -oo;
    for(int j = 0; j < m; j++) {
        if(k + mapeia(a[j]) <= n) {
            int tmp = f(k+mapeia(a[j])) + 1;
            if(tmp > ans) {
                ans = tmp;
                aux[k] = a[j];
            }
			if(tmp == ans) {
				if(aux[k] < a[j]) aux[k] = a[j], ans = tmp;
			}
        }
    }
 
    tb[k] = ans;
    return ans;
}
 
void build(int k) {
    if(k == n) return;
 
    W(aux[k]); W(k);
    ret += to_string(aux[k]);
    build(k+mapeia(aux[k]));
}
 
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        scanf("%d", &a[i]);
    }
    memset(tb, -1, sizeof tb);
    f(0);
    build(0);
    cout << ret << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long W,H,x,y;
  cin >> W >> H >> x >> y;
  long long A;
  if (W%2 == 0 || H%2 == 0){
    A = W*H/2;
  }
  long double B;
  B = W*H/2;

  if (W%2 == 0 && H%2 == 0){
    if (W/2 == x && H/2 == y){
      cout << A << ' ' << 1 << endl;
    }
    else {
      cout << A << ' ' << 0 << endl;
    }
  }
  else if (W%2 == 0 || H%2 == 0){
    cout << A << ' ' << 0 << endl;
  }
  else {
    cout << fixed << setprecision(15) << B+0.5 << ' ' << 0 << endl;
  }
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
using namespace std;
int main(){
	int flag=0;
	string s;
	while(getline(cin,s))
	for(int i=0; i<s.length(); i++){
		if(s[i+1]==s[i]) flag++;
	}
	if(flag==0)cout <<"Good";
	else cout<<"Bad";
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: chars,
        b: chars,
    }
    let mut ans = "EQUAL";

    if a.len() > b.len() {
        ans = "GREATER"
    } else if a.len() < b.len() {
        ans = "LESS"
    } else {
        for i in 0..a.len() {
            if a[i] > b[i] {
                ans = "GREATER";
                break;
            } else if a[i] < b[i] {
                ans = "LESS";
                break;
            }
        }
    }
    println!("{}", ans);
}


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

int main(){
    ll n;
    cin >> n;
    ll ans = pow(10,13);
    for(ll i = 1; i*i <= n;i++){
        if(n%i != 0)continue;
        ll j = n/i;
        ans = min(ans,i+j-2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  ll a, b, c ;
  cin >> a >> b >> c ;
  ll d = a*b ;
  ll e = b*c ;
  ll f = c*a ;
  if(a%2==0 || b%2==0 || c%2==0){
    cout << 0 <<endl ;
  }
  else{
    cout << min({d,e,f}) <<endl ;
  }


  return 0 ;
}




Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [0]*(K+1)

for i in range(K):
    if dp[i]==0:
        for j in a:
            if i+j<=K:
                dp[i+j] = 1

print("First" if dp[K]==1 else "Second")

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

ll N, K;
vector<ll> u, v;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (max({a, b, c}) == a)
        cout << "A" << endl;
    else if (max({a, b, c}) == b)
        cout << "B" << endl;
    else
        cout << "C" << endl;
}


Measured memory_bytes: 3076
N, K = map(int, input().split())

if K%2 == 0: #Kが偶数の時
    a = N//K
    b = (N+K//2)//K
    ans = a ** 3 + b ** 3
else: #Kが奇数の時3
    a = N//K
    ans = a ** 3

print (ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int x;

	repc(i, 1, 10000) {
		cin >> x;
		if (x == 0) break;
		printf("Case %d: %d\n", i, x);
	}




	return 0;
}



Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		int num = Integer.valueOf(s);

		while (true) {
			boolean flag = isSosu(num);
			if (flag) {
				System.out.println(num);
				r.close();
				return;
			}
			++num;
		}
	}

	public static boolean isSosu(int value) {
		for (int i = 2; i < value; ++i) {
			if (value % i == 0) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 20820
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let (n, k) = input!(f64, f64);
    let _a = input!(u32,);
    println!("{}", ((n - 1.) / (k - 1.)).ceil());
}


Measured memory_bytes: 4352
#include <stdio.h>
#define N 1000000
#define Q 50000
main(){
  int s[N], t[Q];
  int i, j, right, left, center, a, b, count = 0;
  scanf("%d", &a);
  for(i=0;i<a;i++)
    {
      scanf("%d", &s[i]);
    }
  scanf("%d", &b);
  for(j=0;j<b;j++)
    {
    scanf("%d", &t[j]);
    left = 0;
    right = a;
    while(left <= right)
     {
      center = (left + right) / 2;
      if(t[j] == s[center])
       {
	count += 1;
        break;
       }
      else if(t[j] > s[center])
        left = center + 1;
      else if(t[j] < s[center])
        right = center - 1;
     }
   }
   printf("%d\n", count);
   return 0;
    }
    

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
int main(){
  ll N;
  cin >> N;
  vector<ll> v(N);
  FOR(i,0,N)cin >> v[i];
  SORT(v);
  cout << v[0];
  FOR(i,1,N){
    cout << " " << v[i];
  }
  cout << endl;
}


Measured memory_bytes: 18320
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i+1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        self.add(key, value - self[key])

mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
bit = Bit(max(A)+1)
ans = 0
for i, a in enumerate(A):
    ans += i - bit.sum(a+1)
    bit.add(a, 1)
ans *= K
from itertools import combinations
cnt = 0
for a, b in combinations(A, 2):
    if a!=b:
        cnt += 1
cnt *= K*(K-1)//2
ans += cnt
print(ans%mod)


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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll dp[105][100100]={0};

ll w[105]; ll v[105];



int main(){
   ll n,W;
   cin>>n>>W;
   
   rep(i,n)cin>>w[i]>>v[i];
   
   for(int i=0;i<n;i++){
       for(int j=0;j<=W;j++){
            if(j-w[i]>=0)chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);

            chmax(dp[i+1][j],dp[i][j]);
       }
   }
   cout<<dp[n][W]<<endl;



}

Measured memory_bytes: 81612
import java.util.*
fun readint()=readLine()!!.toInt()
fun readll()=readLine()!!.toLong()
fun readstring()=readLine()!!
fun readlint()=(readLine()!!.split(" ").map{it.toInt()}).toIntArray()
fun readlll()=(readLine()!!.split(" ").map{it.toLong()}).toLongArray()

fun solve() {
    val s = readstring();
    var mi = s.length;
    var c = 0;
    for (i in 0 until s.length) {
        if (i % 2 == 0 && s[i] == '1') {
            c++;
        }
        if (i % 2 == 1 && s[i] == '0') {
            c++;
        }
    }
    if (c < mi) {
        mi = c;
    }
    c = 0;
    for (i in 0 until s.length) {
        if (i % 2 == 0 && s[i] == '0') {
            c++;
        }
        if (i % 2 == 1 && s[i] == '1') {
            c++;
        }
    }
    if (c < mi) {
        mi = c;
    }
    println(mi);
}
fun main(args: Array<String>) {
    val t = 1;
    repeat(t) {
        solve();
    }
}

Measured memory_bytes: 34316
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int i = 0;
                while (true) {
                        int N = sc.nextInt();
                        if (N == 0) {
                                break;
                        }
                        System.out.println("Case "+ ++i + ": " + N);
                }
        }
}


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

using namespace std;

int main()
{
    int n;
    string s[110];
    int vis[110];
    while(cin>>n){
        map<string,int> mp;
        int flag=1;
        string b="",c="";
        for(int i=0;i<n;i++){
            cin>>s[i];
            if(mp[s[i]]){
                flag=0;
            }
            mp[s[i]]=1;
        }
        if(flag==0){
            printf("No\n");
        }
        else{
            int f=1;
            for(int i=0;i<n-1;i++){
                int ss=s[i].size();
                if(s[i][ss-1]!=s[i+1][0]){
                    f=0;
                    break;
                }
            }
            if(f){
                printf("Yes\n");
            }
            else printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int sum(int n)
{
    int x=0;
    while(n)
    {
        x+=n%10;n/=10;
    }
    return x;
}
int main()
{
    int n,a,b,x; long long int cnt=0;
    cin >> n >> a >> b;
    n++;
    while(n--)
    {
        x= sum(n);
        if(x>=a&&x<=b)cnt+=n;
    }
    cout << cnt << endl;
    return 0;
}


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) (v).begin(),(v).end()
#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 N, M;
vector<int> s, t;
vector<int> g[600], rg[600];

double e[600], ef[600], dp[600];

int main() {
	cin >> N >> M;
	s.resize(M);
	t.resize(M);
	REP(i, M) {
		scanf("%d %d", &s[i], &t[i]);
		
		s[i]--; t[i]--;
		g[s[i]].push_back(t[i]);
		rg[t[i]].push_back(s[i]);
	}
	
	e[N - 1] = 0;
	for (int i = N - 2; i >= 0; i--) {
		for (int v : g[i]) e[i] += e[v];
		e[i] /= g[i].size();
		e[i]++;
	}
	
	REP(i, N) {
		memset(dp, 0, sizeof(dp));
		dp[i] = 1;
		for (int j = i - 1; j >= 0; j--) {
			for (int v : g[j]) dp[j] += dp[v];
			dp[j] /= g[j].size();
		}
		ef[i] = dp[0];
	}
	
	double ans = e[0];
	
	REP(i, M) {
		if (g[s[i]].size() == 1) continue;
		double sum = 0;
		for (int v : g[s[i]]) if (v != t[i]) sum += e[v];
		sum /= g[s[i]].size() - 1;
		sum++;
		double diff = sum - e[s[i]];
		double cur = diff * ef[s[i]] + e[0];
		chmin(ans, cur);
	}
	
	printf("%.15f\n", ans);
	
	return 0;
}



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

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

    long long int ans = 0;
    for(int bit = 0; bit < (1 << (s.length()-1)); bit++){
        long long int coans = 0;
        long long int cocoans = s[0]-'0';
        for(int i = 0; i < s.length()-1; i++){
            if(bit & (1 << i)){
                coans += cocoans;
                cocoans = s[i+1]-'0';
            }else{
                cocoans *= 10;
                cocoans += s[i+1]-'0';
            }
        }
        coans += cocoans;
        ans += coans;
    }

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

Measured memory_bytes: 3572
#include<stdio.h>

int main(void)
{
   int n, l, i, f, j, g;
   char s[100][101], c;

   scanf("%d%d",&n,&l);
   for(i=0;i<n;i++)
      scanf("%s",&s[i]);

   for(i=0;i<n-1;i++)
      for(j=i+1;j<n;j++){
         f=0;
         while(s[i][f]==s[j][f])
            f++;
         if(s[i][f]>s[j][f])
            for(g=0;g<l;g++){
               c=s[i][g];
               s[i][g]=s[j][g];
               s[j][g]=c;
            }
      }

   for(i=0;i<n;i++)
      printf("%s",s[i]);
   printf("\n");
   return 0;
}

Measured memory_bytes: 128
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
using namespace std;


int main(){

    int a,b,x;

    cin>>a>>b>>x;
    //scanf("%d%s%d",&i,&x,&j);

    if(a+b>x&&a<=x){
        std::cout<<"YES";
    }else{
        std::cout<<"NO";
    }
       // printf("%d",i+j);
       //cout<<i+j<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    double n; cin >> n;
    int a, b, c;
    for(int i=1; i<=3500; i++){
        for(int j=1; j<=3500; j++){
            double d = n*i*j/(4*(double)i*j - n*i - n*j);
                if(d == (int)d && d > 0){
                    a = i, b = j, c = d;
                }
        }
    }
    cout << a << " " << b << " " << c << ln;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

int main() {
    string S;
    int K;
    cin >> S;
    cin >> K;
    string S2 = S + S;

    ll cnt1 = 0;
    ll cnt2 = 0;
    char now = S[0];
    ll temp = 1;
    for(ll i = 0; i < S.size()-1; ++i) {
        if (S[i] == S[i+1]) temp++;
        else{
            cnt1 += temp / 2;
            now = S[i+1];
            temp = 1;
        }
    }
    
    if (temp == S.size()) {
        cout << K * S.size() / 2 << endl;
        return 0;
    }

    cnt1 += temp / 2;

    now = S2[0];
    temp = 1;
    for (ll i = 0; i < S2.size()-1; ++i) {
        if (S2[i] == S2[i+1]) temp++;
        else {
            cnt2 += temp / 2;
            now = S2[i+1];
            temp = 1;
        }
    }
    cnt2 += temp / 2;

    cout << cnt1 + (K-1) * (cnt2 - cnt1) << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

"""
ABピザの購入数(0~2 * max(X, Y)で全探索)
"""
min_price = 10 ** 10
for i in range(2 * max(X, Y) + 1):
    c_price = C * i
    a_price = A * max(0, (X - i//2))
    b_price = B * max(0, (Y - i//2))
    min_price = min(min_price, a_price+b_price+c_price)
print(min_price)


Measured memory_bytes: 41692
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int x1,y1,x2,y2;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    int x3,y3,x4,y4;
    x3=x2-(y2-y1);
    y3=y2+(x2-x1);
    x4=x3-(y3-y2);
    y4=y3+(x3-x2);
    printf("%d %d %d %d\n",x3,y3,x4,y4);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
list = []
for i in range(int(N/2)+1):
    A = i+1
    B = N / A
    if A > B:
        break
    #print(A,B,int(A)*int(B))
    if int(A) * int(B) == N:
        if len(str(int(A))) >= len(str(int(B))):
            list.append(len(str(int(A))))
        else:
            list.append(len(str(int(B))))
#print(list)
print(min(list))

Measured memory_bytes: 3064
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}



int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  vector<pair<ll, ll>> LRs(N);
  vector<pair<ll, ll>> RLs(N);
  REP(i, N) {
    cin >> LRs[i].first >> LRs[i].second;
    LRs[i].first--;
    RLs[i].second = LRs[i].first;
    RLs[i].first = LRs[i].second;
  }
  sort(ALL(RLs));
  sort(ALL(LRs));
  
  vector<ll> lls(N + 1), lrs(N + 1);
  vector<ll> rls(N + 1), rrs(N + 1);
  lls[0] = 0;
  lrs[0] = 1000 * 1000 * 1000;
  rls[N] = 0;
  rrs[N] = 1000 * 1000 * 1000;
  REP(i, N) {
    lls[i + 1] = max(lls[i], LRs[i].first);
    lrs[i + 1] = min(lrs[i], LRs[i].second);
  }

  REP(i, N) {
    int j = N - i - 1;
    rls[j] = max(rls[j + 1], LRs[j].first);
    rrs[j] = min(rrs[j + 1], LRs[j].second);
  }
  // cout << lls << " " << lrs << endl;
  // cout << rls << " " << rrs << endl;


  ll res = 0;
  REP2(i, 1, N) {
    res = max(res, lrs[i] - lls[i] + rrs[i] - rls[i]);
  }


  ll tmp = 0;
  pair<ll, ll> tmp_p;
  REP(i, N) {
    tmp = max(tmp, LRs[i].second - LRs[i].first);
    if (tmp == (LRs[i].second - LRs[i].first)) {
      tmp_p = LRs[i];
    }
  }
  ll tmp_l = 0;
  ll tmp_r = 1000 * 1000 * 1000;
  ll diff_cnt = 0;
  REP(i, N) {
    if (LRs[i] != tmp_p) {
      tmp_l = max(tmp_l, LRs[i].first);
      tmp_r = min(tmp_r, LRs[i].second);
      diff_cnt++;
    }
  }

  if (diff_cnt > 0) {
    res = max(res, tmp + max<ll>(0, tmp_r - tmp_l));
  }
  cout <<  res << endl;;
}


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

using namespace std;
#define N 101010
#define F first
#define S second

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


int n, v[N], c[N], lst[N];

void crivo(){
	for(int i=2; i<N; i++){
		if(!lst[i]){
			for(int j=i; j<N; j+=i) lst[j]=i;
		}
	}
}

void f(int x){
	int p;
	while(x!=1){
		p = lst[x];
		int cnt=0;
		while(x%p==0) x/=p, cnt++;
		c[p] = max(c[p], cnt);
	}
}

int main(){
	
	crivo();
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		scanf("%d", &v[i]);
		f(v[i]);
	}
	int ans=0;
	for(int a = 0; a<n; a++){
		
		int aux=1;
		for(int i=2; i<N; i++){
			if(!c[i]) continue;
			for(int k=0; k<c[i]; k++){
				aux = (aux*1LL*i)%v[a];
			}
		}
		
		aux = (aux - 1 + v[a])%v[a];
		ans+=aux;
	}
	
	printf("%d\n", ans);
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String abc = sc.next();
    if (abc.contains("a") && abc.contains("b") && abc.contains("c")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll x, n;
    	cin>>x>>n;
    	set<ll> st;
    	rep(i, 102)	st.insert(i);
    	ll y;
    	rep(i, n){
    		cin>>y;
    		st.erase(st.find(y));
    	}
    	set<ll>::iterator itr = st.lower_bound(x);
    	ll a = *itr;
    	--itr;
    	ll b = *itr;
    	if(abs(x - a) < abs(x - b))	cout<<a;
    	else cout<<b;
    }
}

Measured memory_bytes: 3624
#include<iostream>

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

  for(int i = n - 1; i > 0; i--){
    std::cout << a[i] << " ";
  }
  std::cout << a[0] << std::endl;
  
  return 0;
}



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

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for(int i=0; i<N; i++) scanf(" %lld", &A[i]);

    long long sum = 0;
    for(int i=0; i<N; i++) sum += A[i];
    if(sum % (N*(N+1)/2) != 0){
        printf("NO\n"); return 0;
    }
    sum /= N*(N+1)/2;

    bool flag = true;
    for(int i=0; i<N-1; i++){
        if((A[i] + sum - A[i+1]) % N != 0) flag = false;
        if(A[i] + sum - A[i+1] < 0) flag = false;
    }
    if((A[N-1] + sum - A[0]) % N != 0) flag = false;
    if(A[N-1] + sum - A[0] < 0) flag = false;

    if(flag == true) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const long long maxn=(1e5+10);
long long n,m,v,p;
long long a[maxn];
bool check(int pos)
{
	if(pos<p)
		return true;
	long long sum=0;
	int del=pos-p+1;//not include itself 
	for(int i=pos-1;i>=0;i--)
	{
		if(del==0)
			break;
		if(a[i]-a[pos]>m)
			return false;
		sum+=(a[i]-a[pos]);
		--del;
	}
	return sum<=(n-v)*m;
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	sort(a,a+n);
	reverse(a,a+n);
//	for(int i=0;i<n;i++)
//		printf("%d ",a[i]);
//	printf("\n");
	long long lbound=0,rbound=n-1;
	while(lbound<rbound)
	{
		long long mid=(lbound+rbound+1)/2;
		if(check(mid))
			lbound=mid;
		else
			rbound=mid-1;
	}
	printf("%d\n",lbound+1);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
long long solve(long long x,long long n)
{
    long long sjx;
    if(n%x==0)
        return n*2-x;
    sjx = n/x*x*2+solve(n%x,x);
    return sjx;
}
int main()
{
    long long n,x;
    long long sjx;
    scanf("%lld%lld",&n,&x);
    sjx = solve(x,n-x)+n;
    printf("%lld\n",sjx);
    return 0;
}

Measured memory_bytes: 128
N = input()
_list = input().split(" ")
_list = [int(x) for x in _list]
eve = [x for x in _list if x % 2==0]
ans = []
for x in eve:
    if x % 3 == 0 or x % 5 == 0:
        ans.append(True)
if len(eve) == len(ans):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064