akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n,m;
    cin >> n >> m;
    pair<long long, long long>a[n];
    for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second;
    long long ans=0;
    sort(a,a+n);
    for(int i=0;i<n;i++){
        long long com=min(m,a[i].second);
        ans+=a[i].first*com;
        m-=com;
        if(m==0) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int t,c=0;
  scanf("%d",&t);
  for(int i=1; i<=t; i++){
    if(i%2){
        //printf("%d\n",i);
        c++;
    }
  }
  //printf("%d\n",c);
  printf("%f",(double)c/t);
  return 0;
}


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

#include <iostream>
#include <vector>
// #include <map>
#include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	while (1) {
		int sum = 0;
		string s;
		cin >> s;
		if (s == "0") {
			break;
		}
		for (int i = 0; i < s.size(); i++) {
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}



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

using namespace std;

int main()
{
    int k,x;
    cin>>k>>x;
    int minn=(x-k+1 > -1000000 ? x-k+1 : -1000000);
    int maxx=(x+k-1 < 1000000 ? x+k-1 :1000000 );
    int i=minn;
    while(i<=maxx)
    {
      cout<<i<<" ";
      i++;
    }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3768
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

N, M, K = map(int, readline().split())
u = UnionFind(N + 1)
friends_cnt = [0 for i in range(N + 1)]
for i in range(M):
    a, b = map(int, readline().split())
    u.unite(a, b)
    friends_cnt[a] += 1
    friends_cnt[b] += 1
for i in range(K):
    c, d = map(int, readline().split())
    if u.is_same(c, d):
        friends_cnt[c] += 1
        friends_cnt[d] += 1

for i in range(1, N + 1):
    print(u.get_size(i) - friends_cnt[i] - 1)

Measured memory_bytes: 9828
S = input()

if (S[0] =='R' and S[1] == 'R') and (S[1] == 'R' and S[2] == 'R'):
    print(3)
elif (S[0] == 'R' and S[1] == 'R') or (S[1] == 'R' and S[2] == 'R'):
    print(2)
else:
    if 'R' in list(S):
        print(1)
    else:
        print(0)


Measured memory_bytes: 61672
N,M = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(M) ]

up = [ set([]) for i in range(N)]
dw = [ set([]) for i in range(N)]

for l,r,d in li:
  dw[l-1].add(r-1)
  up[r-1].add(l-1)

S = []
for n in range(N):
  if ( len(up[n])==0 ):
    S.append(n)
L = []
for i in range(N+M):

  if ( len(S)==0 ):
    break
  n = S.pop()
  L.append(n)
  for r in dw[n]:
    up[r].discard(n)
    if ( len(up[r]) == 0 ):
      S.append(r)
  dw[n]=set()

BREAK=False
if (sum([len(s) for s in up])>0):
    BREAK=True

dwl = [ set([]) for i in range(N)]
for l,r,d in li:
  dwl[l-1].add((r-1,d))

dis = [-1]*N

for n in L:
  if (BREAK):
    break
  if (dis[n]==-1):
    dis[n]=0
  for r,d in dwl[n]:
    if (dis[r]==-1):
        dis[r]=dis[n]+d
    else:
        if not (dis[r]==dis[n]+d):
            BREAK=True
            break
if (BREAK):
    print ("No")
else:
    print ("Yes")


        


Measured memory_bytes: 135588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	string go = "", back = "";
	rep(i, tx - sx) go += 'R', back += 'L';
	rep(i, ty - sy) go += 'U', back += 'D';
	string ans = go + back + "DR" + go + "UL" + "UL" + back + "DR";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N = ii()
    d = lmis()
    print(sum(d[i]*d[j] for i in range(N) for j in range(i+1, N)))

main()


Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
    int a, b, c, d, e, k;
    scanf("%d\n %d\n %d\n %d\n %d\n %d", &a, &b, &c, &d, &e, &k);
    
   if(b-a <= k && c-a <= k && d-a <= k && e-a <= k && c-b <= k && d-b <= k && e-b <= k && d-c <= k && e-c <= k && e-d <= k)
       printf("%s", "Yay!");
    else
        printf("%s", ":(");
   
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i,k) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e5 + 7;
const ll INF = 1e18;

ll n, d, a;
vector<pair<ll, ll>> pos; 
ll tot, ans;

map <ll, ll> cek;

ll t[N * 4], lazy[N * 4];
 
void push(int v, ll range) {
    t[v*2] += lazy[v] * ((range + 1) / 2);
    lazy[v*2] += lazy[v];
    t[v*2+1] += lazy[v] * (range / 2);
    lazy[v*2+1] += lazy[v];
    lazy[v] = 0;
}
 
void update(int v, int tl, int tr, int l, int r, ll addend) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
        t[v] += addend * (ll)(r - l + 1);
        lazy[v] += addend;
    } else {
        push(v, tr - tl + 1);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), addend);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
        t[v] = t[v*2] + t[v*2+1];
    }
}
 
ll query(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return 0;
    if (l <= tl && tr <= r)
        return t[v];
    push(v, tr - tl + 1);
    int tm = (tl + tr) / 2;
    return query(v*2, tl, tm, l, min(r, tm)) + query(v*2+1, tm+1, tr, max(l, tm+1), r);
}


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

    cin >> n >> d >> a;
    for (int i=1;i<=n;i++){
        ll tm1, tm2;
        cin >> tm1 >> tm2;
        cek[tm1] = max(cek[tm1], tm2);
    }
    pos.pb(mp(0, 0));
    for (auto x : cek){
        pos.pb(x);
    }
    n = pos.size() - 1;

    for (int i=1;i<=n;i++){
        update(1, 1, n, i, i, pos[i].se);
    }

    for (int i=1;i<=n;i++){
        ll sisa = query(1, 1, n, i, i);
        if (sisa > 0){
            ll atk = (sisa + a - 1) / a;
            ans += atk;
            atk *= a;
            auto it = upper_bound(pos.begin(), pos.end(), mp(pos[i].fi + d + d, INF));
            int last = (int)(it - pos.begin()) - 1;
            update(1, 1, n, i, last, -atk);
        }
    }
    cout << ans << el;

    return 0;
}

Measured memory_bytes: 28908
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x<a.x;
//        return z>a.z;
    }
};

vector<int> v[55];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[500515];
int o[500515];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[11];
int j[55];

stack<int> s;
queue<int> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
//list<int> l;
//string r[111],r2;
char r[10];


bool as(P a,P b)
{
   // if(a.x!=b.x)
        return a.x<b.x;
    //return a.y>b.y;
}

void f(int a)
{
    if(l[a]) return;
    if(l[o[a]]) l[a]=l[o[a]]+1;
    else f(o[a]);
}

int g(int n,int m)
{
    if(n==m) return n;
    if(l[n]<l[m]) swap(n,m);
    if(l[n]==l[m]) return g(o[n],o[m]);
    else return g(o[n],m);

}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;l[t]=o[t],t++)
        scanf("%d",&o[t]);
    sort(o+1,o+a+1);
    for(int t=1;t<=a;p[o[t]]=t,t++);
    for(int t=1;t<=a;t++)
        if((p[l[t]]%2)!=(t%2)) k++;
    printf("%d",k>>1);

}


Measured memory_bytes: 5760
#	ABC 064: C [beta]

N = int(input())

scores = list(map(int, input().split()))
for i in range(N):
  scores[i] = scores[i] // 400
  if scores[i] > 8:
    scores[i] = 8

color=0

for i in range(8):
  if i in scores:
    color += 1
    
free = scores.count(8)

max_colors = color+ free

if color == 0:
  color += 1

print(color, max_colors)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
	int a,b,c,d,e,f,i,out=0;
	scanf("%d%d",&a,&b);
	c=(int)(a/0.08),d=(int)((a+1)/0.08)+1;
	e=(int)(b/0.1),f=(int)((b+1)/0.1)+1;
	//printf("c=%d d=%d e=%d f=%d\n",c,d,e,f);
	if(c<=e)c=e;
	if(d>=f)d=f;
	for(i=c;i<=d;i++){
		e=(int)(i*0.08);
		f=(int)(i*0.1);
		if(e==a&&f==b){
			out=i;
			break;
		}
	}
	if(out)printf("%d\n",out);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  string str;

  cin>>str;

  for(int i=0;i<str.length()-1;i++){
    if(str[i]=='A'&&str[i+1]=='C'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

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




Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

dp = [0,abs(h[1]-h[0])]
for i in range(2,n):
    dp.append(min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])))

print(dp[n-1])

Measured memory_bytes: 55144
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var d = int.Parse(_[1]);
            var i = d * 2 + 1;

            var ans = n % i == 0 ? (n / i) : ((n / i) + 1);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
using namespace std;
 
#define MOD 12
typedef vector<int> Vec;
 
int N,M;
 
bool rec(int idxT,int idxS,Vec &T,Vec &S){
    if(idxT == N && idxS == M) return 1;
    if(idxT == N || idxS == M) return 0;
    bool res = false;
    if(idxT+1 <= N && T[idxT] == S[idxS]){
        res |= rec(idxT+1,idxS+1,T,S);
    }
    if(idxT+2 <= N && (T[idxT]+1)%MOD == S[idxS]){
        res |= rec(idxT+2,idxS+1,T,S);
    }
    if(idxT-1 >= 0 && (T[idxT]-1+MOD)%MOD == S[idxS]){
        res |= rec(idxT-1,idxS+1,T,S);
    }
    return res;
}
 
int main(){
    int Tc;
    map<string,int> mp = {
        {"A",0},{"A#",1},
        {"B",2},
        {"C",3},{"C#",4},
        {"D",5},{"D#",6},
        {"E",7},
        {"F",8},{"F#",9},
        {"G",10},{"G#",11},
    };
    string in;
    cin >> Tc;
    while(Tc--){
        cin >> N >> M;
        Vec T(N);
        for(int i = 0 ; i < N ; i++){
            cin >> in;
            T[i] = mp[in];
        }
        reverse(T.begin(),T.end());
        Vec S(M);
        for(int i = 0 ; i < M ; i++){
            cin >> in;
            S[i] = mp[in];
        }
        reverse(S.begin(),S.end());
        bool can = rec(0,0,T,S) | rec(1,0,T,S);
        cout << (can ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 7084
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cstring>
#include <iostream>
#include <sstream>
#include <queue>
#include <vector>

using namespace std;

static const int INF = 1 << 30;

void solve(int N, int M, std::vector<int>& u, std::vector<int>& v, int S, int T) {
	vector<int> vis(N * 3);
	vector<vector<int>> e(N * 3);
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < 3; ++j) {
			e[u[i] * 3 + j].emplace_back(v[i] * 3 + ((j + 1) % 3));
		}
	}
	vector<int> q(1, S * 3);
	vis[S * 3] = 1;
	int ans = -1;
	for (int t = 0; !q.empty(); ++t) {
		vector<int> nq;
		for (int node: q) {
			if (node == T * 3) {
				ans = t / 3;
				break;
			}
			for (int next : e[node]) {
				if (!vis[next]) {
					vis[next] = 1;
					nq.emplace_back(next);
				}
			}
		}
		q = nq;
	}
	cout << ans << endl;
}

int main() {
	int N, M, S, T;
	std::cin >> N >> M;
	std::vector<int> u(M), v(M);
	for (int i = 0; i < M; i++) {
		std::cin >> u[i] >> v[i];
		u[i]--, v[i]--;
	}
	std::cin >> S >> T;
	--S, --T;
	solve(N, M, u, v, S, T);
	return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(sz(s) <= k)
		cout << s << '\n';
	else 
		cout << s.substr(0, k) + "..." << '\n';
	
	
	return 0;
}






Measured memory_bytes: 3660
H,W = map(int,input().split())
L = [input() for i in range(H)]
X = [False for i in range(W)]
Y = [False for i in range(H)]

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "#" :
            X[x] = True
            Y[y] = True

for y in range(H) :
    if Y[y] == True :
        ANS = []
        for x in range(W) :
            if X[x] == True :
                ANS.append(L[y][x])
        print("".join(ANS))


Measured memory_bytes: 3064
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val ds = in.readLine().split("\\s+").map(_.toInt)

    val sum = ds.sum

    System.out.println(
      ds.map { d =>
        (sum - d) * d
      }.sum / 2
    )
  }
}


Measured memory_bytes: 25644
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		int ans=0;
		for(int i = 1;i<=n;i++) {
			if(i.ToString().Length%2==1){ans++;}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n;
char s[120000];
int b[120000];
int a[120000];

int main() {
	scanf("%d %s", &n, s);
	for (int i = 0; i < n; ++i)
		b[i] = (s[i] == 'x' ? 1 : 0);
	b[n] = b[0];
	b[n + 1] = b[1];
	for (int i = 0; i < 8; ++i) {
		a[0] = (i) & 1;
		a[1] = (i >> 1) & 1;
		a[2] = (i >> 2) & 1;
		for (int i = 3; i < n; ++i)
			a[i] = (a[i - 3] ^ b[i - 2] ^ b[i - 1]);
		a[n] = a[0];
		a[n + 1] = a[1];
		int fl = 0;
		for (int i = 1; i <= n; ++i) {
			if (b[i] != (a[i] ^ a[i + 1] ^ a[i - 1]))
				fl = 1;
		}
		if (!fl) {
			for (int i = 0; i < n; ++i) {
				if (a[i] == 0)
					printf("S");
				else
					printf("W");
			}
			printf("\n");
			return 0;
		}
	}
	cout << -1 << "\n";
	return 0;
}




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

using namespace std;

int main(){
	int W, H, N;
	vector<int> x, y, a;
	int x1, x2, y1, y2;
	int b;

	cin >> W >> H >> N;
	x1 = 0, x2 = W, y1 = 0, y2 = H;

	for(int i = 0; i < N; i++){
		int xi, yi, ai;
		cin >> xi >> yi >> ai;
		x.push_back(xi);
		y.push_back(yi);
		a.push_back(ai);
	}

	for(int i = 0; i < N; i++){
		switch(a[i]){
			case 1:
				if(x[i] < x1) continue;
				x1 = x[i];
				break;
			case 2:
				if(x[i] > x2) continue;
				x2 = x[i];
				break;
			case 3:
				if(y[i] < y1) continue;
				y1 = y[i];
				break;
			case 4:
				if(y[i] > y2) continue;
				y2 = y[i];
				break;
			default: break;
		}
	}

	if(x2-x1 < 0 || y2-y1 < 0) b = 0;
	else b = (x2-x1)*(y2-y1);

	// b = (x2-x1)*(y2-y1);
	// b = (b < 0) ? 0 : b;
	cout << b << endl;

	return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

tha = (math.pi / 6)*h+(math.pi / 360)*m
thb = (math.pi / 30)*m
th = abs(tha-thb)

costh = math.cos(th)

c = (a**2 + b**2 - 2*a*b*costh)**(0.5)

print(c)

Measured memory_bytes: 9504
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, m;
  int counter[SIZE] = {};

  cin >> n >> m;

  for(int i=0;i<n;i++){
    int k, a;
    cin >> k;
    for(int j=0;j<k;j++) {
      cin >> a;
      counter[a-1]++;
    }
  }

  int ans = 0;

  for(int i=0;i<m;i++){
    ans += counter[i] == n;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
  int A, B, C, D;
  scanf("%d %d %d %d", &A, &B, &C, &D);
  
  while(1){
    C -= B;
    if(C <= 0){
      printf("Yes\n");
      return 0;
    }
    A -= D;
    if(A <= 0){
      printf("No\n");
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
    
int main() {
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy" << endl;
    else if (s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using namespace std;


bool is_ok(long long a, long long b, long long c){
    return (a!=b&&b!=c&&a!=c) && a+b+c > 2*max(max(a,b),c);
}

int main(int argc, const char** argv) {
    vector<long long> L;
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
       long long a;
       cin>>a;
       L.push_back(a);
    }
    long long cnt = 0;
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                if(is_ok(L[i],L[j],L[k])){
                    //cout<<i<<j<<k<<"\n";
                    cnt++;
                }
            }
        }
    }

    cout<<cnt;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int n;
    cin>>n;
    ll a, minv, maxv;
    cin>>a;
    maxv = -2001001001;
    minv = a;
    rep(i, n-1) {
        cin>>a;
        if (a - minv > maxv) maxv = a - minv;
        if (a < minv) minv = a;
    }
    cout<<maxv<<endl;
}


Measured memory_bytes: 3212
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	public static final int TYPES = 26;
	
	public static long calc(final int D, int[] cs, int[][] ss, int[] answers) {
		int[] lasts = new int[TYPES];
		
		long score = 0;
		for(int i = 0; i < D; i++) {
			final int type = answers[i];
			
			score += ss[i][type];
			lasts[type] = i + 1;
			
			for(int j = 0; j < TYPES; j++) {
				score -= cs[j] * ((i + 1) - lasts[j]);
			}
		}
		
		return score;
	}
	
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			
			final int D = sc.nextInt();
			
			int[] cs = new int[TYPES];
			for(int i = 0; i < TYPES; i++) {
				cs[i] = sc.nextInt();
			}
			
			int[][] ss = new int[D][TYPES]; 
			for(int i = 0; i < D; i++) {
				for(int j = 0; j < TYPES; j++) {
					ss[i][j] = sc.nextInt();
				}
			}
			
			int[] answers = new int[D];
			for(int i = 0; i < D; i++) {
				answers[i] = sc.nextInt() - 1;
			}
			
			final int M = sc.nextInt();
			for(int i = 0; i < M; i++) {
				final int d = sc.nextInt() - 1;
				final int q = sc.nextInt() - 1;
				
				answers[d] = q;
				
				System.out.println(calc(D, cs, ss, answers));
			}
			
			/*
			for(int i = 0; i < D; i++) {
				System.out.println((i % TYPES) + 1);
			}
			*/
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 56084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string S, T, U;
int a,b,c;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
	int A,B,M; cin >> A >> B >> M;
    vi a(A),b(B); rep(i,A) cin >> a[i]; rep(i,B) cin >> b[i];
    vi x(M),y(M),c(M); rep(i,M) cin >> x[i] >> y[i] >> c[i];
    vi as = a, bs = b;
    sort(all(as)); sort(all(bs));
    int ans = as[0] + bs[0];
    rep(i,M) {
        int tmp = 0;
        tmp += a[x[i]-1];
        tmp += b[y[i]-1];
        tmp -= c[i];
        chmin(ans,tmp);
    }
    cout << ans << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

bool isstrswap(string s, string t) {
    int l = min(s.size(), t.size());
    for(int i=0;i<l;i++) {
        bool con1 = true, con2 = true;
        for(int j=0;j<i;j++) {
            if(s.at(j)!=t.at(j)) con1 = false;
        }
        if(s.at(i)>=t.at(i)) con2 = false;
        if(con1&&con2) return true;
    }

    bool con3 = true, con4 = true;
    for(int i=0;i<l;i++) {
        if(s.at(i)!=t.at(i)) con3 = false;
    }
    if(s.size()>=t.size()) con4 = false;
    if(con3&&con4) return true;

    return false;
}

int main(void) {
    int n, l;
    cin >> n >> l;

    vector<string> s(n);
    for(int in=0;in<n;in++) {
        cin >> s.at(in);
    }

    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            if(!isstrswap(s.at(i), s.at(j))) swap(s.at(i), s.at(j));
        }
    }

    for(auto is:s) cout << is;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3592
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    (26)
#define EPS         (1e-10)
#define INF         (1000000005LL)
#define MOD         (1000000007LL)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
// ciling(x/y) = (x+y-1)/y

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    string s;cin >> s;
    map<char, int> m;
    for(auto c : s) m[c]++;
    for(auto kv : m) if(kv.second%2 == 1){cout << "No" << endl;return 0;}
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
nn = 2002002
P = 10**9+7
fa = [1]
for i in range(1, nn): fa.append(fa[-1] * i % P)
f = lambda a, b: fa[a+b+2] * pow(fa[a+1] * fa[b+1], P-2, P) % P - 1
r1, c1, r2, c2 = map(int, input().split())
print((f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1)) % P)

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

using namespace std;

typedef long long ll;

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

    vector<int> b(n + 1), w(n + 1);
    for (int i = 0; i < n; ++i) {
        b[i + 1] = b[i];
        w[i + 1] = w[i];
        if (s[i] == '#') b[i + 1]++;
        if (s[i] == '.') w[i + 1]++;
    }

    int ans = n + 1;
    for (int i = 0; i < n; ++i) {
        int cnt = b[i] + w[n] - w[i + 1];
        ans = min(ans, cnt);
    }

    cout << ans << endl;
}

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


int main() {
  int n ;
  cin >> n ;
  string s ;
  cin >> s ;
  int k ;
  cin >> k ;
  
  
  string a ;
  for(int i=0;i<n ;i++){
    if(s.at(i)!=s.at(k-1)){
      a+='*';
    }
    else{
      a+=s.at(i);
    }
  }
  
  cout << a <<endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IO
import qualified Data.IntMap as M
import Control.Monad

type Vertex = (Int, Int)
type Neighbor = M.IntMap Int
type Graph = M.IntMap Neighbor

main = do
  n <- readLn :: IO Int
  edge <- (\[x,y,z] -> zip3 x y z) . transpose <$> replicateM (n-1) getIntListBC
  [q, k] <- map read . words <$> getLine :: IO [Int]
  query <- (\[x,y] -> zip x y) . transpose <$> getInt2DListBC
  mark <- newArray (1, n) False :: IO (IOUArray Int Bool)
  weight <- newArray (1, n) 0 :: IO (IOUArray Int Int)
  let graph = foldl makeGraph (M.empty) edge
      kNeighbors = M.toList . fromJust $ M.lookup k graph
  writeArray mark k True
  foldM (search graph weight k) mark kNeighbors
  ans <- mapM (readWeight weight k) query
  putStr . unlines . map show $ ans

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

makeGraph :: Graph -> (Int, Int, Int) -> Graph
makeGraph graph (x, y, z) = let nX = M.lookup x graph
                                nY = M.lookup y graph
                                vX = if nX == Nothing
                                       then M.insert x (addNeighbor (y, z) M.empty) graph
                                       else M.insert x (addNeighbor (y, z) $ fromJust nX) graph
                            in if nY == Nothing
                                 then M.insert y (addNeighbor (x, z) M.empty) vX
                                 else M.insert y (addNeighbor (x, z) $ fromJust nY) vX

addNeighbor :: (Int, Int) -> Neighbor -> Neighbor
addNeighbor (i, weight) ne = M.insert i weight ne

readEdge :: Graph -> (Int, Int) -> Int
readEdge graph (i, j) = let ne = fromJust $ M.lookup i graph
                        in fromJust $ M.lookup j ne

--始点k 前pre 現在i
search :: Graph -> IOUArray Int Int -> Int -> IOUArray Int Bool -> Vertex -> IO (IOUArray Int Bool)
search graph weight pre mark (i, w) = do
  isMark <- readArray mark i
  case isMark of
    True -> do
      return mark
    False -> do
      writeArray mark i True
      let ne = M.toList . fromJust $ M.lookup i graph
      wSum <- readArray weight pre
      writeArray weight i (wSum + w)
      return =<< foldM (search graph weight i) mark ne

readWeight :: IOUArray Int Int -> Int -> (Int, Int) -> IO Int
readWeight weight k (x, y) = do
  kx <- readArray weight x
  ky <- readArray weight y
  return $ kx + ky

Measured memory_bytes: 88188
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>

using namespace std;

typedef long long int ll; 

int main(void)
{
	ll k;
	cin >> k;

	ll ans=0;
	for(ll x=1;x<=k;x++)
	{
		for(ll y=1;y<=k;y++)
		{	
			ll t1 = __gcd(x,y);
			for(ll z=1;z<=k;z++)
			{
				ll t2 = __gcd(t1,z);
				ans+=t2;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  s += t;
  reverse(s.begin(), s.end());
  string u = s;
  for(int i = 0; i < n; i++) {
    string tmp = s.substr(i, n);
    u = min(u, tmp);
  }

  int cnt = 1;
  for(int i = 0; i < n - 1; i++) {
    if(u[i] == u[i + 1]) {
      cnt++;
    } else {
      break;
    }
  }
  ll num = cnt * (ll)pow(2, min({n, k - 1, (ll)16}));
  if(n < num) {
    for(int i = 0; i < n; i++) {
      cout << u[0];
    }
  } else {
    for(int i = 0; i < num; i++) {
      cout << u[0];
    }
    for(int i = cnt; i < n - num + cnt; i++) {
      cout << u[i];
    }
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005

struct Edge{
	Edge(int arg_to,int arg_dist){
		to = arg_to;
		dist = arg_dist;
	}
	int to,dist;
};

int N;
int color[SIZE];
vector<Edge> G[SIZE];

void dfs(int node_id,int pre){

	for(int i = 0; i < G[node_id].size(); i++){

		int child = G[node_id][i].to;
		if(child == pre)continue;

		if(G[node_id][i].dist%2 == 0){

			color[child] = color[node_id];

		}else{

			color[child] = 1-color[node_id];
		}
		dfs(child,node_id);
	}
}

int main(){

	scanf("%d",&N);

	int from,to,dist;

	for(int loop = 0; loop < N-1; loop++){

		scanf("%d %d %d",&from,&to,&dist);
		from--;
		to--;

		dist %= 2;
		G[from].push_back(Edge(to,dist));
		G[to].push_back(Edge(from,dist));
	}

	color[0] = 0;

	dfs(0,-1);

	for(int i = 0; i < N; i++){

		printf("%d\n",color[i]);
	}

	return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>

int A[5000001];
int H;

int left(int i)
{
    return i * 2;
}

int right(int i)
{
    return i * 2 + 1;
}

void maxHeapify(int A[], int i)
{
    int l, r;
    int largest;
    l = left(i);
    r = right(i);

    if(l <= H && A[l] > A[i])
        largest = l;
    else
        largest = i;

    if(r <= H && A[r] > A[largest])
        largest = r;

    if(largest != i){
        int t = A[i];
        A[i] = A[largest];
        A[largest] = t;
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(int A[])
{
    int i;
    for(i = H / 2; i > 0; i--)
        maxHeapify(A, i);
}

int main(void)
{
    int i;

    scanf("%d", &H);

    for(i = 1; i <= H; i++){
        int t;
        scanf("%d", &t);
        A[i] = t;
    }

    buildMaxHeap(A);

    for(i = 1; i <= H; i++){
        printf(" %d", A[i]);
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 2552
/**
*    created: 09.07.2020 22:51:45
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int a, b;
    cin >> a >> b;
    if (a == 1 && b == 1) cout << "Draw" << endl;
    else if (a == 1) cout << "Alice" << endl;
    else if (b == 1) cout << "Bob" << endl;
    else {
        if (a == b) cout << "Draw" << endl;
        else if (a < b) cout << "Bob" << endl;
        else cout << "Alice" << endl;
    }
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  int N, K, H[200000];
  cin >> N >> K;
  rep(i, N){
    cin >> H[i];
  }
  sort(H, H + N);
  ll ans = 0;
  if(K < N){
    rep(i, N - K){
      ans = ans + H[i];
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 1024
N,M=map(int, input().split())
results = [[0,0] for i in range(N)]
wa=0
ac=0
for i in range(M):
    P,S=map(str, input().split())
    P = int(P) - 1
    if S == 'AC':
        if results[P][0] == 0:
            wa += results[P][1]
            results[P][1] = 0
            ac += 1
            results[P][0] += 1
    else:
        results[P][1] += 1

print("{0} {1}".format(ac,wa))

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

int N;
const int MAX_N = 100010;
int a[2*MAX_N], b[2*MAX_N];

bool chk(int x){
    for(int i=1;i<=2*N-1;i++){
        b[i] = (a[i] >= x);
    }
    int L = 0, R = 2*N;
    for(int i=N-1;i>=1;i--){
        if(b[i]==b[i+1]){
            L = i;
            break;
        }
    }
    for(int i=N+1;i<=2*N-1;i++){
        if(b[i]==b[i-1]){
            R = i;
            break;
        }
    }
 
    if(L==0&&R==2*N){
        return (N%2>0)?b[N]:!b[N];
    }else if(N-L < R-N){
        return b[L];
    }else{
        return b[R];
    }
}

int main(){
    scanf("%d",&N);
    for(int i=1;i<=2*N-1;i++){
        scanf("%d",&a[i]);
    }

    int lo=1, hi=2*N-1, mid;
    while(lo+1<hi){
        mid = (lo+hi)/2;
        if(chk(mid)){
            lo = mid;
        }else{
            hi = mid;
        }
    }
    printf("%d\n",lo);
    return 0;
}


Measured memory_bytes: 1792
# coding: utf-8

w,h,N=list(map(int,input().split()))

rect=[0,w,0,h]
for i in range(N):
    x,y,a=list(map(int, input().split()))
    rect[a-1]=(lambda c,r,p:[r,c][p*(c-r)<0])([x,y][a>2],rect[a-1],[1,-1][a%2])

length=lambda x:[x,0][x<0]
print(length(rect[1]-rect[0])*length(rect[3]-rect[2]))

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

#define LLINF (1LL<<60)
typedef long long ll;

//C++14 (GCC 5.4.1)
int howsgs(ll s,ll N){
    if(s>N)return 0;
    ll ret=0;
    ll st=s,c;
    bool is3=false,is5=false,is7=false;
    while(st){
        c=st%10;
        if(c==3)is3=true;
        if(c==5)is5=true;
        if(c==7)is7=true;
        st/=10;
    }
    if(is3&&is5&&is7)ret++;

    ret+=howsgs(s*10+3,N);
    ret+=howsgs(s*10+5,N);
    ret+=howsgs(s*10+7,N);
    return ret;
}

int main() {
    ll N;
    cin >>N;
    ll ans=howsgs(0,N);
    cout << ans <<endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  set<char>s1;
  for(int i=0;i<s.length();i++)
  {
    s1.insert(s[i]);
  }
  if(s1.size()==2)
    cout<<"Yes";
  else
    cout<<"No";
}
    

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

using namespace std;

typedef long long ll;

#define maxn 105

int const inf = 0x3f3f3f3f;

int x[maxn],y[maxn];
int max_x = 0,min_y = inf;

int n,m;
int X,Y;

bool check(int mid){

	if((mid > X && mid <= Y) && mid > max_x && mid <= min_y) return true;

	else 
		
		return false;
}

int main(){

	while(cin >> n >> m >> X >> Y)
	{

		max_x = -101;
		min_y = inf;

		for(int i = 1;i <= n;i++)
		{
			scanf("%d",&x[i]);
			max_x = max(max_x,x[i]);
		}

		for(int i = 1;i <= m;i++)
		{
			scanf("%d",&y[i]);
			min_y = min(min_y,y[i]);
		}

		bool flag = false;

		for(int i = X + 1;i <= Y;i++)
		{
			if(check(i))
			{
				flag = true;
				break;
			}
		}

		if(flag) puts("No War");
		else puts("War");

	}

	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        string[] In = Console.ReadLine().Split(' ');
        int a = int.Parse(In[0]);
        int b = int.Parse(In[1]);
        int h = int.Parse(In[2]);
        int m = int.Parse(In[3]);
        double dh = 30 * h + 0.5 * m;
        double dm = 6 * m;
        double d = Math.Abs(dh - dm);
        double c2;
        if (d == 0)
        {
            c2 = b - a;
            Console.WriteLine(Math.Abs(c2));
        }
        else
        {
            c2 = a * a + b * b - 2 * a * b * Math.Cos(d * Math.PI / 180);
            Console.WriteLine("{0:####.##########}", Math.Sqrt(c2));

        }
    }
}

Measured memory_bytes: 27844
/*input
e
*/

#include <iostream>

using namespace std;

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

	if(c=="a" || c=="e" || c=="i" || c=="o" || c=="u"){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ld w, h, x, y;
	cin>>w>>h>>x>>y;
	ld ans = (w*h)/2;
	cout<<fixed<<setprecision(12)<<ans<<" ";
	if(x*2 == w && y*2 == h){
		cout<<'1'<<endl;
	} else {
		cout<<"0"<<endl;
	}
}

Measured memory_bytes: 3784