akhauriyash/Code-Regression huggingface dataset:
//#include <ext/pb_ds/assoc_container.hpp> 
     //#include <ext/pb_ds/tree_policy.hpp> 
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define trace(x) cerr << #x << ": " << x << " " << endl;
     
    typedef int64_t ll;
     
    #define endl '\n'
    #define int ll
    ll mod=1e18;
    ll mod1=1e9+5;
     
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }
     
   //  using namespace __gnu_pbds;
     //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    //find_by_order(k)  returns iterator to kth element starting from 0;
    //order_of_key(k) returns count of elements strictly smaller than k;
    //erase,insert same as normal set
  

    int32_t main()
    {
        IOS
  
        int n,b;
        int c=0;
        cin>>n>>b;
        while(n)
        {
            c++;
            n/=b;
        }
        cout<<c;


    }       

Measured memory_bytes: 256
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

if M == 0:
    maxM = N
else:
    maxM = a[0] - 1
    for i in range(1, M):
        maxM = max(maxM, a[i] - a[i-1] - 2)
    maxM = max(maxM, N - a[-1])

dp = [0] * (maxM+1)
dp[1] = 1
if maxM > 1:
    dp[2] = 2
    if maxM > 2:
        for n in range(3, maxM+1):
            dp[n] = (dp[n-1] + dp[n - 2]) % 1000000007

if M == 0:
    print(dp[-1])
    exit()

if a[0] == 1:
    ans = 1
else:
    ans = dp[a[0] - 1]

if M > 1:
    for i in range(1, M):
        if a[i] - a[i - 1] == 1:
            ans = 0
        elif a[i] - a[i - 1] == 2:
            continue
        else:
            ans = ans * dp[a[i] - a[i - 1] - 2] % 1000000007
if N - a[-1] != 1:
    ans = ans * dp[N - a[-1] - 1] % 1000000007
print(ans)

Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep_r(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define resize(x, n) x.resize(n)
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MAX = 100000;
struct edge {
    ll from, to, weight;
    edge(ll f, ll t, ll w) : from(f), to(t), weight(w) { }
};
vector<vector<edge>> edges;
vector<vector<ll>> graph;
vector<bool> visited;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll n, k;

ll dp[2001][2001];

ll c(ll n, ll r) {
    if (n < r) return 0;
    if (dp[n][r] != -1) return dp[n][r];
    if (n == r || r == 0) return 1;
    if (r == 1) return dp[n][r] = n;
    return dp[n][r] = (c(n-1, r-1) + c(n-1, r)) % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    cin >> n;
    cin >> k;
    ll blue = k, red = n-k;
    for (ll i = 1; i <= k; i++) {
        ll answer = c(red+1, i) * c(blue-1, i-1) % mod;
        // printf("%lld回の場合 %lld\n", i, answer);
        cout << answer << "\n";
    }
}

Measured memory_bytes: 35032
for i in range (1000000000000000000000000):
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    elif op == "?":
        break


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

using namespace std;

#define int long long

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	solve();
	return 0;
}

int modexp (int a, int b, int m) {
	if (b == 0) return 1;
	int ans = modexp(a, b/2, m);
	ans = (ans * ans) % m;
	if (b & 1) ans = (ans * a) % m;
	return ans;
}
int mod = 1e9 + 7;
int n, m, k;
int inverse[(int) 2e5];
void solve() {
	inverse[(int) 2e5 - 1] = modexp((int) 2e5 - 1, mod - 2, mod);
	for (int i = 2e5 - 2; i >= 1; i--) {
		inverse[i] = modexp(i, mod - 2, mod);
	}
	cin >> n >> m >> k;
	int contri = 1;
	// contri = C(n * m - 2, k - 2)
	// a * (a - 1) * ... * (a - b + 1) / (1 * 2 * ... * b)
	for (int i = n * m - 2; i >= n * m - 2 - (k - 2) + 1; i--) {
		int j = i % mod;
		contri *= j, contri %= mod;
	}
	for (int i = 1; i <= k - 2; i += 1) {
		contri *= inverse[i], contri %= mod;
	}
	int ans = 0;
	for (int i = 1; i <= n; i += 1) {
		int s = (i * (i - 1)) / 2;
		s %= mod;
		s *= m, s %= mod;
		s *= m, s %= mod;
		s *= contri, s %= mod;
		ans += s, ans %= mod;
	}
	for (int i = 1; i <= m; i += 1) {
		int s = (i * (i - 1)) / 2;
		s %= mod;
		s *= n, s %= mod;
		s *= n, s %= mod;
		s *= contri, s %= mod;
		ans += s, ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll H, W;
int main() {
  cin.tie(0);
    cin >> H >> W;
    if (H < 3 && W < 3) {
      cout << 1 << endl;
      return 0;
    }
    ll ans = INF;
    rep(d, 1, H-1) {
      ll ps = W * d;
      ll t = (H-d) / 2;
      ll qff = W * t, qfs = W * ((H-d) - t);
      ll mi = min({ps, qff, qfs}), ma = max({ps, qff, qfs});
      ans = min(ans, ma - mi);

      ll qsf = (H-d) * (W/2), qss = (H-d) * (W - W/2);
      mi = min({ps, qsf, qss}), ma = max({ps, qsf, qss});
      ans = min(ans, ma - mi);
    }
    swap(H, W);
    rep(d, 1, H-1) {
      ll ps = W * d;
      ll t = (H-d) / 2;
      ll qff = W * t, qfs = W * ((H-d) - t);
      ll mi = min({ps, qff, qfs}), ma = max({ps, qff, qfs});
      ans = min(ans, ma - mi);

      ll qsf = (H-d) * (W/2), qss = (H-d) * (W - W/2);
      mi = min({ps, qsf, qss}), ma = max({ps, qsf, qss});
      ans = min(ans, ma - mi);
    }

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



Measured memory_bytes: 256
n = int(input())

a = []
for i in range(n):
    s, p =  input().split()
    a.append([s, int(p), i+1])


a = sorted(a, key=lambda x:x[1])
a = reversed(a)
a = sorted(a, key=lambda x:x[0])
    
 
for i in range(n):
    print(a[i][2])

Measured memory_bytes: 38384
A,K,Q = map(int,input().split())
A_list = [int(input()) for i in range(0,Q)]
A_count =[0]*A
A_flag =[0]*A
for x in A_list:
    A_count[x-1]+=1

for i,x in enumerate(A_count):
    point = K-Q+x
    if point >0:
        A_flag[i] = "Yes"
    else:
        A_flag[i] = "No"
for x in A_flag:
    print(x)

Measured memory_bytes: 9416
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());

	double a,b,c,res;

	cin >> a >> b >> c;

	c = c * (M_PI/180.0);

	double area,circum,h;
	//面積
	area = a * b * sin(c) / 2.0;

	//周
	double d;
	d = a*a + b*b - 2*a*b*cos(c);
	d = sqrt(d);
	circum = a + b + d;

	//aを底辺としたときの高さ
	//area =  a * h / 2.0;
	h = area * 2.0 / a; 

    cout << fixed << setprecision(5) << area << endl;
    cout << fixed << setprecision(5) << circum << endl;
    cout << fixed << setprecision(5) << h << endl;
	//std::printf("%.5f¥n", res);
	
	return 0;
}




Measured memory_bytes: 3508
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long ll;
const ll INF = 10000000000;
int main(){
  ll N;
  cin >> N;
  ll K;
  cin >> K;
  vector<ll> h(N);

  for(ll i = 0;i < N;i++)cin >> h[i];

  vector<ll> dp(N,INF);
  dp[0] = 0;

  for(ll i = 1;i < N;i++){
    for(ll j = 1;j <= K;j++){
      if(i-j >= 0){
        ll abs = max(h[i] - h[i-j],h[i-j] - h[i]);
        dp[i] = min(dp[i],dp[i-j]+abs);
      }
    }
  }

  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
M,K=gets.split.map(&:to_i)
if K >= 2**M || M==1 && K==1
  puts -1
else
  if K==0
    arr = []
    (0...2**M).each do |i|
      arr << i
      arr << i
    end
    puts arr * ' '
  else
    arr = (0...K).to_a + (K+1...2**M).to_a
    arr << K
    arr += arr[0...-1].reverse
    arr << K
    puts arr * ' '
  end
end

Measured memory_bytes: 9720
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i=0;
	int n,m,x;
	cin>>n>>m>>x;
	int a[n][m];
	int b[m];
	int c[n];
	memset(b,0,sizeof(b));
	int j;
	for(i=0;i<n;i++)
	{
		cin>>c[i];
		for(j=0;j<m;j++)
		cin>>a[i][j];
	}
	i=0;
	int d[n];
	int ans=INT_MAX;
	while(i<pow(2,n))
	{
		memset(d,0,sizeof(d));
		j=0;
		int y=i;
		while(i)
		{
			d[j++]=i%2;
			i/=2;
		}
		int p=0;
		memset(b,0,sizeof(b));
		for(j=0;j<n;j++)
		{
			if(d[j]==1)
			{
			 p+=c[j];
			 int q;
			 for(q=0;q<m;q++)
			 b[q]+=a[j][q];
			}
		}
		for(j=0;j<m;j++)
		if(b[j]<x)
		break;
		if(j==m)
		ans=min(ans,p);
		i=y;
		i++;
		//cout<<i<<endl;
	}
	if(ans!=INT_MAX)
	cout<<ans<<endl;
	else
	cout<<-1<<endl;
}

Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> city(N + 1);
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    ++city[a];
    ++city[b];
  }
  FOR(i, 1, N + 1) cout << city[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll N;
void dfs(string s, char mx){
  if(s.size()==N)
    cout<<s<<endl;
  else{
    for(char c='a'; c<=mx; c++)
      dfs(s+c, c==mx ? mx+1: mx);
  }
}
int main(){
  cin>>N;
  dfs("",'a');
}


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

using namespace std;

void solve() {
    int x, a, y, b, c, v, u; cin >> x >> y >> a >> b >> c;
    vector<pair<int, int> > vt;
    for (int i = 0; i < a; i++)
        cin >> v, vt.push_back({v, 2});
    for (int i = 0; i < b; i++)
        cin >> v, vt.push_back({v, 1});
    for (int i = 0; i < c; i++)
        cin >> v, vt.push_back({v, 0});
    sort(vt.rbegin(), vt.rend());
    long long ans = 0;
    int haveAlso = 0;
    for (auto e : vt) {
        v = e.first, u = e.second;
        if (u == 2 && x > 0)
            x--, ans += v;
        if (u == 1 && y > 0)
            y--, ans += v;
        if (u == 0)
            haveAlso++, ans += v;
        if (haveAlso == x + y) {
            cout << ans; return;
        }
    }
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int n = scan.nextInt();
		int k = scan.nextInt();
		for (int i = 0; i < n; i++) {
			list.add(scan.nextInt());
		}
		int ans = 0;
		int index = list.size();
		list.sort(null);
		for (int i = 0; i < k; i++) {
			ans = ans + list.get(index - 1);
			index--;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
string weth[3] = {"Sunny", "Cloudy", "Rainy"};
 
int main(){
	string s;
	cin >> s;
	for(int i=0;i<3;i++){
		if (s == weth[i]){
			if(i == 2){
				cout << weth[0] << endl;
				break;
			}else{
				cout << weth[i+1] << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

a, b, c = rm()
if a+b < c:
    print(b*2 + a + 1)
else:
    print(b + c)




Measured memory_bytes: 12480
#include<stdio.h>
int f[1005]={0};
int d[1005]={0};
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++){
		scanf("%d",&d[i]);
		for(int j=1;j<=d[i];j++){
			int x;
			scanf("%d",&x);
			f[x]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) if(!f[i]) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1736
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();

        if(a[a.length-1] == b[0] && b[b.length-1] == c[0]){
            System.out.println("YES");
        } else {
            System.out.println("NO");

        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 22612
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	vector<int>ti(13);
	for (int i = 0; i < N; i++) {
		ti[v[i]]++;
		if (ti[v[i]] == 3) {
			cout << 0 << endl;
			return 0;
		}
	}
	if (ti[0]) {
		cout << 0 << endl;
		return 0;
	}
	if (ti[12] == 2) {
		cout << 0 << endl;
		return 0;
	}
	if (N > 13) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 0;
	for (int i = 0; i < pow(2, N); i++) {
		vector<int>box;
		box.push_back(0);
		for (int j = 0; j < N; j++) {
			if (i >> j & 1) {
				box.push_back(v[j]);
			}
			else {
				box.push_back(-v[j]);
			}
		}
		sort(box.begin(), box.end());
		int bag = 100;
		for (int i = 0; i < N; i++) {
			bag = min(bag, box[i + 1] - box[i]);
		}
		bag = min(bag, box[0] + 24 - box[N]);
		ans = max(ans, bag);
	}
	cout << ans << 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 SIZE(a) ((int)(a).size())

// Adam Polak, Michal Glapa
const int N = 100005;
int n1,n2;          // INPUT
vector<int> g[N];   // INPUT
int m1[N], m2[N];   // OUTPUT
bool in_vc1[N], in_vc2[N]; // OUTPUT (Vertex Cover)
bool vis[N];

bool dfs(int u) {
	if (u<0) return true;
	if (vis[u]) return false; else vis[u]=true;
	for(int v : g[u])
		if (dfs(m2[v])) { m1[u] = v; m2[v] = u; return true; }
	return false;
}

int matching() {
	REP(i,n1) m1[i] = -1;
	REP(i,n2) m2[i] = -1;
	bool changed;
	do {
		changed = 0;
		REP(i,n1) vis[i] = false;
		REP(i,n1) if (m1[i] < 0) changed |= dfs(i);
	} while(changed);
	REP(i, n1) if (m1[i] != -1) { //Vertex Cover
		if (vis[i]) in_vc2[m1[i]] = true; // Vertex Cover
		else in_vc1[i] = true; // Vertex Cover
	}
	int siz = 0;
	REP(i,n1) siz += (m1[i] != -1);
	return siz;
}

int X1[N], Y1[N];
int X2[N], Y2[N];

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

	cin >> n1;
	n2 = n1;
	REP(i, n1) cin >> X1[i] >> Y1[i];
	REP(i, n2) cin >> X2[i] >> Y2[i];

	REP(i, n1) REP(j, n2) {
		if (X1[i] < X2[j] && Y1[i] < Y2[j]) {
			g[i].push_back(j);
		}
	}

	cout << matching() << '\n';

	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int Y;
  cin >> N >> Y;
  
  for(int i = 0; i <= N ; i++){
    int j = (Y-1000*N-9000*i)/4000;
    int k = N - i -j;
    if ( j >= 0 && k >= 0){
      if(10000*i + 5000*j + 1000*(N - i - j) == Y ){
        cout << i << " " << j << " " << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
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;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin>>N;

  double t[N+1];
  int sumt=0;
  t[0]=0;
  rep(i,N){
    int tt;
    cin>>tt;
    t[i+1]=t[i]+tt;
    sumt+=tt;
  }

  double maxv[2*sumt+1];

  rep(i,2*sumt+1){
    maxv[i]=min(((double)i)/2,((double)(2*sumt-i))/2);
  }

  rep(i,N){
    double v; cin>>v;
    rep(j,2*sumt+1){
      if(j<2*t[i]){
        chmin(maxv[j],v+(2*t[i]-j)/2);
      }
      else if(j>2*t[i+1]){
        chmin(maxv[j],v+(j-2*t[i+1])/2);
      }
      else{
        chmin(maxv[j],v);
      }
    }
  }

  double ans=0;
  rep(i,2*sumt+1){
    ans+=maxv[i];
  }

  cout<< ans/2 <<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 512
import Control.Applicative

main = do
    [a,b] <- (map read . words) <$> getLine
    putStrLn $ solve a b

solve a b
  | a == b = "Draw"
  | a == 1 = "Alice"
  | b == 1 = "Bob"
  | otherwise = if a < b then "Bob" else "Alice"


Measured memory_bytes: 508
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let nr=new Array(t.n())
  nr.fill(0)
  for(let i=0;i<n;i++){
    let jl=t.n()
    for(let j=0;j<jl;j++){
      nr[t.n()-1]++
    }
  }
  let ans=0
  for(let i=0;i<nr.length;i++){
    if(nr[i]==n)ans++
  }
  t.o(ans)
}
main()

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

#define ALPHABET 26

void zero(int *);

int main(){
  char moji[1201];
  int ans[ALPHABET];
  int i;
  

  zero(ans);

  scanf("%[^!]", moji);
  for(i=0; moji[i] != '\0'; ++i){
    if(moji[i] >= 65 && moji[i] <= 90)
      moji[i] += 32;
    ++ans[moji[i] - 'a'];
  }

  for(i = 0;i < ALPHABET; i++)
    printf("%c : %d\n",'a' + i ,ans[i]);
}

void zero(int *x){
  int *p = x;
  for(;p < x + ALPHABET;p++){
    *p = 0;
  }
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vb = vector<bool>;
using vs = vector<string>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const ld eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl;})

int main(){
	cin.sync_with_stdio(0);

	ll n;
	cin >> n;

	vl a(n);
	vl b(n);
	vl c(n);
	vl ha(n);
	vl hb(n);
	vl hc(n);

	FOR(i,0,n){
		cin >> a[i] >> b[i] >> c[i];
	}
	
	ha[0] = a[0];
	hb[0] = b[0];
	hc[0] = c[0];

	FOR(i,1,n){
		ha[i] = a[i] + max(hb[i - 1], hc[i - 1]);
		hb[i] = b[i] + max(ha[i - 1], hc[i - 1]);
		hc[i] = c[i] + max(ha[i - 1], hb[i - 1]);
	}

	cout << max(ha[n - 1], max(hb[n - 1], hc[n - 1])) << endl;
}


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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N, M;
        {int[] a = in.ii(); N = a[0]; M = a[1];}
        int t = 0;
        int f = 0;
        int[] x = new int[N+1];
        boolean[] y = new boolean[N+1];
        for(int i = 0; i < M; i++){
            String[] a = in.ss();
            int p = Integer.parseInt(a[0]);
            String s = a[1];
            if(!y[p]){
                if(s.equals("AC")){
                    y[p] = true;
                    t++;
                    f += x[p];
                } else {
                    x[p]++;
                }
            }
        }
        out.println(t+" "+f);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 47912
#include <iostream>
  #include <string>
  #include <algorithm>
  using namespace std;
  
  int main() {
    string a, b;
    
    cin >> a >> b;
    string ab[2];
    ab[0] = string(stoi(b), a[0]);
    ab[1] = string(stoi(a), b[0]);
    
    sort(ab, ab+2);
  
    cout << ab[0] << endl;
    return 0;
  }


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int n;
	while (n = readln.chomp.to!int, n) {
		dchar[dchar] tr;
		foreach (i; 0..n) {
			auto a = readln.split;
			tr[a[0][0]] = a[1][0];
		}
		string str = "";
		foreach (i; 0..readln.chomp.to!int) {
			str ~= readln.chomp;
		}
		str.translate(tr).writeln;
	}
}

Measured memory_bytes: 2320
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll tx; cin>>tx; while(tx--)
typedef long long int ll;
int main() {
    FIO;
    //test
    {
        ll n,k,i,u,v,flag=1,as;
        cin>>n>>k;
        bool vis[n+1];
        ll a[n+1];
        for(i=1;i<=n;i++){
            vis[i]=false;
            cin>>a[i];
        }
        vector<ll>res;
        v=1;
        while(flag==1){
            v=a[v];
            if(vis[v]){
                flag=0;
                u=v;
            }
            else{
            vis[v]=true;
            res.push_back(v);
            }
        }
        ll len;
        i=0;
        //cout<<u<<endl;
        while(res[i]!=u){
            i++;
        }
        v=i;
        //cout<<v<<endl;
        len=res.size()-v;
        //cout<<len<<endl;
        if(k<=v){
            cout<<res[k-1]<<endl;
        }
        else{
        k-=v;
        as=k%len;
        ll pv;
        pv=(k+len-1);
        pv%=len;
        cout<<res[v+pv]<<endl;
        }
    }
	return 0;
}


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

int main() {
    std::string n;
    std::cin >> n;
    int sum = 0;
    for (char c : n) {
        int i = c - '0';
        sum += i;
    }
    if (sum % 9 == 0) {
        std::cout << "Yes";
    }
    else {
        std::cout << "No";
    }
}

Measured memory_bytes: 3724
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AOJ.Volume5
{
    static class CardGame
    {
        public static void Main()
        {
            Solve(int.Parse(System.Console.ReadLine()));
        }
        static Func<Func<T, F, T>, T> FoldLeft<T, F>(this IEnumerable<F> ien, T init)
        {
            return new Func<Func<T, F, T>, T>(func =>
            {
                foreach (var i in ien) {
                    init = func(init, i);
                }
                return init;
            }
            );
        }
        static void Solve(int n)
        {
            if (n != 0)
            {
                var score = new int[n].Select(x => System.Console.ReadLine().Trim().Split(' ').Select(_ => int.Parse(_)).ToArray()).FoldLeft(new int[] { 0, 0 })((init, ien) =>
                {
                    return (ien.First() == ien.Last()) ? new int[] { init[0] + ien.First(), init[1] + ien.Last() } : ((ien.First() < ien.Last()) ? new int[] { init[0], init[1] + ien.First() + ien.Last() } : new int[] { init[0] + ien.First() + ien.Last(), init[1] });
                });
                System.Console.WriteLine(score[0].ToString() + ' ' + score[1].ToString());
                Solve(int.Parse(System.Console.ReadLine()));
            }
        }
    }
}

Measured memory_bytes: 9844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,ab,x,y,sum[4];
    cin>>a>>b>>ab>>x>>y;
    if(x>y)
    {
        sum[0]=ab*x*2;
        sum[1]=ab*y*2+a*(x-y);



    }
    else
    {
        sum[0]=ab*y*2;
        sum[1]=ab*x*2+b*(y-x);



    }
    sum[2]=a*x+b*y;
    sort(sum,sum+3);
    cout<<sum[0];//<<" "<<sum[1]<<" "<<sum[2];
}


Measured memory_bytes: 256
a,b,c = input().split()
d = 0
if a == b:
    if a != c:
        d +=1
if a == c:
    if b != c:
        d +=1
if c == b:
    if a != c:
        d +=1
if d>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long K = sc.nextLong();
    
    long[] t = new long[100000+1];
    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      t[a] += b;
    }
    int i = 1;
    long count = 0;
    while (i < t.length && count+t[i] < K) {
      count += t[i];
      i++;
    }
    System.out.println(i);
  }
}

Measured memory_bytes: 87228
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int x, h;


int main() {
    while (cin >> x >> h) {
        if (x == 0 && h == 0) break;
        double dx = x; double dh = h;
        
        cout << fixed << setprecision(9) << dx*dx + dx*sqrt(dx*dx+dh*dh*4) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define N 200005
#define endl '\n'

using namespace std;

int n,A,B,C,D;
string s;

inline void init()
{
    cin >> n >> A >> B >> C >> D >> s;
    --A,--B,--C,--D;
}

inline void solve()
{
    bool Aflag=true,Bflag=true;
    if(D>C){
        for(int i=B+1;i<=D;++i){
            if(s[i-1]=='#' && s[i]=='#')
                Bflag=false;
        }
        for(int i=A+1;i<=C;++i){
            if(s[i-1]=='#' && s[i]=='#')
                Aflag=false;
        }
        if(Aflag==Bflag && Aflag==true)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    else{
        Aflag=false;


        
        set<int> S;
        for(int i=A+1;i<C;++i){
            if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
                if(i>=B && i<=D)
                    Aflag=true;
            }
        }

        for(int i=A+1;i<=C;++i){
            if(s[i-1]=='#' && s[i]=='#')
                Aflag=false;
        }

        for(int i=B+1;i<=D;++i){
            if(s[i-1]=='#' && s[i]=='#')
                Bflag=false;
        }
        if(Aflag==Bflag && Aflag==true)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

int main()
{
   // cin.tie(0),ios_base::sync_with_stdio(false);
    init();
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<deque<ll>> A(N, deque<ll>(N-1));
    rep(i,N){
        rep(j,N-1){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    bool flag = true;
    ll ans = 0;
    while(flag){
        ans++;
        flag = false;
        vector<ll> memo(N);
        rep(i,N){
            if(memo[i]) continue;
            if(A[i].empty())continue;
            ll t = A[i].front();
            if(memo[t]) continue;
            if(A[t].empty())continue;
            ll u = A[t].front();
            if(i == u){
                flag = true;
                memo[i] = 1;
                memo[t] = 1;
                A[i].pop_front();
                A[t].pop_front();
            }
        }
    }
    rep(i,N){
        if(!A[i].empty()){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans-1 << endl;
}

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

// Numeric Constants
#define N 1000000007
#define maxs 200005
#define mins 1005
#define eps 1e-14
#define imax 2000000200
#define llmax 1000000002000000000ll
#define pi 3.141592653589793

// Others
#define ll long long
#define pb push_back
#define gc getchar_unlocked
#define iosbase ios_base::sync_with_stdio(false)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppi pair<pair<int,int>,int>
#define ppl pair<pll,ll>
#define vi vector<int>
#define sc scanf
#define pr printf
#define lld I64d
#define F first
#define S second
#define siter set<int>::iterator
#define p_pq priority_queue
#define ub upper_bound
#define lb lower_bound

ll fun(ll a,ll b,ll c){
	ll t1=c/2;
	ll t2=c/2;
	if(c&1){
		t2++;
	}
	return abs(a*b*t1-a*b*t2);
}

int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	ll diff=llmax;
	diff=min(diff,fun(a,b,c));
	diff=min(diff,fun(a,c,b));
	diff=min(diff,fun(b,c,a));
	cout<<diff<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);

  int S = A * B;
  int T = C * D;
  if (T < S) {
    printf("%d\n", S);
  } else {
    printf("%d\n", T);
  }
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long LL;
LL arr[200005];
inline LL mabs(LL x) {return x > 0 ? x : -x;}
int main() {
	int n;
	LL sum = 0, x = 0, ans = (int) 1e16;
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%lld", &arr[i]), sum += arr[i];
	for (int i = 1; i < n; i ++) x += arr[i], ans = min(ans, mabs(x - (sum - x)));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			int len = nums.length;
			int[] A = new int[ len ];
			int i, len2 = len-1;

			StringBuilder output = new StringBuilder( 100+1 );									
			for( i=0; i<len; i++ ) {
				A[i] = Integer.parseInt( nums[i] );
				output.append( A[i]+" "  );
			}
			output.deleteCharAt( output.lastIndexOf( " " ) );
			output.append( "\n"  );

			int key;
			int j, k;
 			for( i=1; i<len; i++ ) {
				key = A[i];
				j = i - 1;
				while( 0 <= j && key < A[j] ) {
					A[ j+1 ] = A[j];
					j--;
				}
				A[ j+1 ] = key;
				for( k=0; k<len; k++ ) {
					output.append( A[k]+" "  );
				}
				output.deleteCharAt( output.lastIndexOf( " " ) );
				output.append( "\n"  );
			}
			System.out.print( output  );
			
 			kb.close();
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 22912
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int h,w;
  int i,j;

  for(;;){

    cin>>h>>w;

    if(h==0&&w==0){
      break;
    }

    for(i=0;i<h;i++){
      cout<<"#";
      for(j=1;j<w-1;j++){
        if(i==0||i==h-1){
          cout<<"#";
        }else{
          cout<<".";
        }
      }
      cout<<"#"<<endl;
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>
#define N 100
int main()
{
  int cnt=0,flag,i,a,A[N],n,j;
  flag = 1;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  scanf("%d",&A[i]);
  while(flag)
  {
    flag = 0;
    for(j=n-1;j>=1;j--)
    {
      if(A[j] < A[j-1])
      {
        a = A[j];
        A[j] = A[j-1];
        A[j-1] = a;
        flag = 1;
        cnt++;
      }
    }
  }
  for(i=0;i<n;i++)
  {
    printf("%d",A[i]);
    if(i!=n-1)
      printf(" ");
  }
  printf("\n%d\n",cnt);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = numeric_limits<int>::max() / 2;

struct Edge{
    int to,cost;
    Edge(int to,int cost): to(to), cost(cost){}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool operator < (const Edge &e, const Edge &f){
    return e.cost > f.cost;
}

vector<int> dijkstra(const Graph &g, int s){
    vector<int> d(g.size(),INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0,s)); // P(dis, pos)
    while(!que.empty()){
        int dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if(d[v]<dist) continue;
        for(const auto &e: g[v]){
            if(d[e.to]<=d[v]+e.cost) continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}

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

    int k;cin>>k;
    Graph g(k);
    for(int i=0;i<k;i++){
        int next= (i+1)%k;
        g[i].push_back(Edge(next,1));
        next=(i*10)%k;
        g[i].push_back(Edge(next,0));
    }
    vector<int> d=dijkstra(g,1);
    cout<<d[0]+1<<endl;
}


Measured memory_bytes: 6780
N = int(input())
weight = input().split()
weight = [int(x) for x in weight]
answer = 100000
T = 0
for i in range(N):
  S1 = 0
  S2 = 0
  for j in range(N):
    if j <= i:
      S1 = S1 + weight[j]
    else:
      S2  = S2 + weight[j]
  if answer > abs(S1 - S2):
    answer = abs(S1 - S2)

print(answer)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int temp = a;
        a = b;
        b = temp;
        temp = a;
        a = c;
        c = temp;
        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=1e5+5;
int aa[M],bb[M],a[M],b[M],ind[M];
bool cmp(int p,int q)
{
	return bb[p]<bb[q];
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>aa[i];
	for(int i=1;i<=n;i++)
		cin>>bb[i];
	for(int i=1;i<=n;i++)
		ind[i]=i;
	sort(ind+1,ind+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		b[i]=bb[ind[i]];
		a[i]=aa[ind[i]];
	}
	set<pair<int,int> > act,inact;
	for(int i=2;i<=n;i++)
		inact.insert({a[i],i});
	int swp=0;
	for(int i=1;i<=n;i++)
	{
		if(inact.find({a[i],i})!=inact.end())
			inact.erase({a[i],i});
		if(act.find({b[i],i})!=act.end())
			act.erase({b[i],i});
		if(a[i]<=b[i])
			continue;
		while(sz(inact))
		{
			auto p = *(inact).begin();
			if(p.ff<=b[i])
			{
				inact.erase(inact.begin());
				act.insert({b[p.ss],p.ss});
			}
			else
				break;
		}
		if(sz(act)==0)
		{
			cout<<"No\n";
			return 0;
		}
		swp++;
		auto p = *(--act.end());
		act.erase(p);
		swap(a[i],a[p.ss]);
		inact.insert({a[p.ss],p.ss});
	}
	if(swp<=n-2)
	{
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,N,s,e;
    bool yoyaku =true;
    cin >> a >> b >> N;
    int S[N],E[N];
    for(int i =0;i<N;i++){
        cin >> S[i] >> E[i];
    }
    for(int i=0;i<N;i++){
        if(S[i]<b&&E[i]>a){
            yoyaku =false;
            break;
        }
    }
    if(yoyaku){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N; string S; cin >> N >> S;
    if(N % 2 == 0){
        int mid = N/2;
        for(int i = 0; i < mid; i++){
            if(S[i] != S[i+mid]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

int32_t main()
{
	FastIO;
	int ac=0,wa=0,tle=0,re=0;
	int t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		if(s=="AC") ac++;
		if(s=="WA") wa++;
		if(s=="TLE") tle++;
		if(s=="RE") re++;
	}
	cout<<"AC"<<" x "<<ac<<nl;
	cout<<"WA"<<" x "<<wa<<nl;
	cout<<"TLE"<<" x "<<tle<<nl;
	cout<<"RE"<<" x "<<re<<nl;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="Sunny")
    cout<<"Cloudy";
  else if(s=="Cloudy")
  {
    cout<<"Rainy";
  }
  else if(s=="Rainy")
  {
   cout<<"Sunny";
  }
  else
  {
    cout<<"Cloudy";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

// 組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] / (fac[k] * fac[n - k]);
}


ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end());
	ll l = b[n / 2 - 1];
	ll r = b[n / 2];
	rep(i, n) {
		if (a[i] <= l)cout << r << endl;
		else {
			cout << l << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin>>S>>T;
  int A, B;
  cin>>A>>B;
  string U;
  cin>>U;
  if(S==U){
    A--;
  }
  if(T==U){
    B--;
  }
  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  vector<long long> a(4);
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  long long max = a[1]*a[3];
  
  for(int i = 0;i < 4;i++){
    for(int j=i+1;j<4;j++){
    if((i==0 && j==1)||(i==2&&j==3))continue;
    if(max < a[i]*a[j]){
      max = a[i]*a[j];
    }
    }
  }
    
  cout << max << endl;
 
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();

			long tmp = 0;
			for (char c : s.toCharArray()) {
				tmp += (c - '0');
			}

			if (tmp % 9 == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 41028
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m);
    for(int i=0; i<m; i++) cin>>a[i]>>b[i];
    UnionFind uf(n);
    for(int i=0; i<m; i++){
        uf.merge(a[i]-1,b[i]-1);
    }
    vector<bool> find(n,false);
    for(int i=0; i<m; i++){
        find[a[i]-1]=true;
        find[b[i]-1]=true;
    }
    ll ans = 0;
    ll cnt = 0;
    for(int i=0; i<n; i++){
        if(!find[i]) cnt++;
    }
    if(cnt>0) ans++;
    for(int i=0; i<m; i++){
        ans = max(ans,uf.size(a[i]-1));
        ans = max(ans,uf.size(b[i]-1));
    }
    cout<<ans<<endl;
}

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

int N;
int a[100010];

int main()
{
    cin>>N;
    for (int i = 0; i < N; i++)
    {
        int x;
        cin>>x;
        x--;
        a[i]= x;
    }

    bool reach = false;
    int pos = 0;
    int cnt = 0;
    while(cnt<N){
        if(pos == 1){
            reach = true;
            break;
        }

        pos = a[pos];
        cnt++;

    }
    if(reach) cout << cnt << endl;
    else cout << "-1" << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
int main(){
    string s; cin>>s;
    for(ll i=0;i<s.length();i++)
        cout<<'x';
    
    return 0;
}


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

int main() {
	int a, b, c; cin >> a >> b >> c;
  	if(a == 5 && b == 5 && c == 7) {
    	cout << "YES" << endl;
    }
  	else if(a == 5 && b == 7 && c == 5) {
    	cout << "YES" << endl;
    }
  	else if(a == 7 && b == 5 && c == 5) {
    	cout << "YES" << endl;
    }
  	else {
		cout << "NO" << endl;
    }
  return 0;
}


Measured memory_bytes: 3532
val = input().split(" ")

if int(val[0]) == int(val[1]):
  print(int(val[0]) + int(val[1]))
elif int(val[0]) > int(val[1]):
  if int(val[0]) % int(val[1]) == 0:
    print(int(val[0]) + int(val[1]))
  else:
    print(int(val[1]) - int(val[0]))
elif int(val[0]) < int(val[1]):
  if int(val[1]) % int(val[0]) == 0:
    print(int(val[0]) + int(val[1]))
  else:
    print(int(val[1]) - int(val[0]))

Measured memory_bytes: 3064