akhauriyash/Code-Regression huggingface dataset:
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(ReadLine());
			var s = ReadLine();

			var insertIndex = 0;
			var index = 0;
			var count = 0;
			while(index < s.Length)
			{
				if(s[index] == '(')
				{
					count++;
				}
				else
				{
					count--;
				}

				if(count == -1)
				{
					s = s.Insert(insertIndex, "(");
					count = 0;
					index++;
				}

				index++;
			}
			insertIndex = s.Length;
			index = s.Length - 1;
			count = 0;
			while (index >= 0)
			{
				if (s[index] == ')')
				{
					count++;
				}
				else
				{
					count--;
				}

				if (count == -1)
				{
					s = s.Insert(insertIndex, ")");
					count = 0;
				}

				index--;
			}

			WriteLine(s);
		}
	}
}


Measured memory_bytes: 11092
/*  
    |\_/|
    |* *|
    \_+_/
*/
#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 str1;

  cin>>str1;

  cin>>str1;

  char c=str1[0];

  cin>>str1;

  cout<<'A'<<c<<"C"<<endl;
  
  return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int cnt = 0;
  for (char c : s) {
    if (c == 'x') cnt++;
  }
  cout << (cnt >= 8 ? "NO" : "YES") << endl;
  return 0;
}

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

using namespace std;

struct r_{
	int xx;
	int xy;
	int yx;
	int yy;
	void mod100k(){
		xx = xx % 100000;
		xy = xy % 100000;
		yx = yx % 100000;
		yy = yy % 100000;
	}
};

r_ route[200][200];

int main(){
	
	int w, h;
	
	while(true){
		cin >> w >> h;
		if(w == 0 && h == 0){
			break;
		}
		
		for(int i = 0; i < w; i++){
			for(int j = 0; j < h; j++){
				route[i][j].xx = 0;
				route[i][j].xy = 0;
				route[i][j].yx = 0;
				route[i][j].yy = 0;
			}
		}
		
		for(int i = 0; i < w; i++){
			route[i][0].xx = 1;
		}
		
		for(int j = 1; j < h; j++){
			route[0][j].yy = 1;
		}
		
		for(int i = 1; i < w; i++){
			for(int j = 1; j < h; j++){
				route[i][j].xx = route[i - 1][j].xx + route[i - 1][j].yx;
				route[i][j].yx = route[i - 1][j].yy;
				route[i][j].xy = route[i][j - 1].xx;
				route[i][j].yy = route[i][j - 1].yy + route[i][j - 1].xy;
				route[i][j].mod100k();
			}
		}
		int ans = (route[w - 1][h - 1].xx + route[w - 1][h - 1].xy + route[w - 1][h - 1].yx + route[w - 1][h - 1].yy) % 100000;
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, ans = 0;
    map<ll, ll> cnt;

    cin >> N;
    vint a(N);
    rep(i, N)
    {
        cin >> a[i];
        cnt[a[i] - 1]++;
        cnt[a[i] + 1]++;
        cnt[a[i]]++;
    }

    for (auto i : cnt)
    {
        chmax(ans, i.second);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a; i<b; i++)

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

int main(){
    int flag=1;
    string s;
    cin>>s;
    if(s.size()==6&&s[2]==s[3]&&s[4]==s[5])
    {
        REP(i,0,6){
        if(s[i]<96){
            flag=0;
            break;
        }
      }
       if(flag)
        cout<<"Yes"<<endl;
       else
        cout<<"No"<<endl;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, c, k;
    cin >> n >> c >> k;
    vll t(n);
    rep(i, n){
        cin >> t[i];
    }
    sort(ALL(t));
    ll ans = 1;
    ll bus = t[0] + k;
    ll cap = 1;
    rep(i, n){
        if(bus < t[i] || cap > c){
            ans++;
            bus = t[i] + k;
            cap = 1;
        }
        cap++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;cin >> n;
    long long inp[n],ans =1;
    fo(i,n){
        cin >> inp[i];
        if(inp[i]==0){
            cout << 0 <<"\n";
            return 0;
        }
    }
    long double cc=0;
    fo(i,n){
        cc += log10(inp[i]);
    }
    if(cc>18.1){
        cout << -1 << "\n";
        return 0;
    }
    fo(i,n){
        ans *= inp[i];
    }
    if(ans > 1000000000000000000){
        cout <<-1;
        return 0;
    }
    cout << ans;
    return 0;
}

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

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

    vector<int> ans(n);
    ans[0] = t / h[0] + 1;
    int longest = h[0], st = 0;
    for(int i = 1; i < n; ++i) {
        st += h[i - 1];
        longest = max(longest, h[i]);
        const int tt = max(0, t - st);
        if(tt % longest >= h[i]) {
            ans[i] = min(ans[i - 1], tt / longest + 2);
        } else {
            ans[i] = min(ans[i - 1], tt / longest + 1);
        }
    }

    for(int i = 0; i < n; ++i) {
        cout << ans[i] << '\n';
    }
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N;
	cin >> N;
	int a[N];
	int cnt_even = 0;
	rep(i, 0, N) {
		cin >> a[i];
		if(a[i] % 2 == 0) cnt_even++;
	}

	if(cnt_even == N) cout << "second" << endl;
	else cout << "first" << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <limits>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for(auto& fi: f){
    for(auto& x :fi){
      cin >> x;
    }
  }
  vector<vector<int>> p(n, vector<int>(11));
  for(auto& pi: p){
    for(auto& x: pi){
      cin >> x;
    }
  }

  int ans = numeric_limits<int>::min();

  for(int b = 1; b < (1 << 10); ++b){
    int cur = 0;
    for(int i = 0; i < n; ++i){
      int co_open = 0;
      for(int j = 0; j < 10; ++j){
        if((b >> j) & 1 & f[i][j]){
          ++co_open;
        }
      }
      cur += p[i][co_open];
    }
    if(ans < cur) ans = cur;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m,i,x,y,correct=0,wrong=0;
    string s;
    cin>>n>>m;
    map<ll,ll> m1,m2;
    for(i=0;i<m;i++){
        cin>>x>>s;
        if(m1[x]==0){
            if(s=="WA")
                m2[x]+=1;
            else{
                wrong+=m2[x];
                correct+=1;
                m1[x]=1;
            }
        }
    }
    cout<<correct<<" "<<wrong<<endl;
    return 0;
}


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


int main(){
	int n;
	int m[100],a[100],b[100];
	while(cin>>n&&n){
		for(int i=0;i<n;i++)cin>>m[i]>>a[i]>>b[i];
		char *ans="OK";
		for(int i=0;i<n;i++){
			int s=0;
			for(int j=0;j<n;j++){
				if(a[j]<=a[i]&&a[i]<b[j])s+=m[j];
			}
			if(150<s)ans="NG";
		}
		for(int i=0;i<n;i++){
			int s=0;
			for(int j=0;j<n;j++){
				if(a[j]<=b[i]-1&&b[i]-1<b[j])s+=m[j];
			}
			if(150<s)ans="NG";
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mmax(a,b,c) max(a,max(b,c))
#define mmin(a,b,c) min(a,min(b,c))
#define M 1000000007
#define V vector
#define F(a,b,c) for (a=b;a<=c;++a)
#define I cin
#define O cout
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second

ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return res;
}

int main() {
    I.sync_with_stdio(false);
    I.tie(0);
    ll a;
    long double b, p;
    I>>a>>b;
    p = a * b;
    O << (ll)p;
    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <map>
#define rep(i,n) for(int i=0; i<(n); ++i)

using ll = long long;

std::map<ll, int> mp;

void replace_key(ll ko, ll kn) {
    int v = mp[ko];
    mp.erase(ko);
    if (mp.find(kn) != mp.end() && mp[kn] > 0)
        mp[kn] += v;
    else
        mp[kn] = v;
}

int main() {
    int n; std::cin >> n;
    rep(i,n) {
        int k; std::cin >> k;
        ++mp[k];
    }
    ll sum=0;
    for (auto m : mp) sum += m.first * m.second;
    int q; std::cin >> q;
    rep(i,q) {
        int b, c; std::cin >> b >> c;
        int vb = mp[b];
        sum += (c - b) * vb;
        replace_key(b, c);
        std::cout << sum << std::endl;
    }
    return 0;
}

Measured memory_bytes: 7476
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

ll dp[22][(1ll<<22)];

ll helper(ll i, ll j, vector<vector<ll> >& v){
    if(i==v.size()){
        if(j==0) return 1;
        else return 0;
    }
    if(dp[i][j]!=-1) return dp[i][j];
    ll ans = 0;
    for(ll w=0; w<v.size(); w++){
        if(((1ll<<w)&j)&&v[i][w]){
            ans+=helper(i+1, (j^(1ll<<w)), v);
            ans%=mod;
        }
    }
    return dp[i][j] = ans;
}

int main(){
    cpp();
    ll n;
    cin>>n;
    memset(dp, -1, sizeof dp);
    vector<vector<ll> > v(n, vector<ll>(n));
    for(ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            cin>>v[i][j];
        }
    }
    cout<<helper(0, ((1ll<<n)-1) , v);
    return 0;
}






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



int main() {
	int A, B;
	cin >> A >> B;

	int X = A + B;
	int Y = A - B;
	int Z = A * B;

	int ans = max(X, Y);
    int C = max(ans, Z);

	cout << C << endl;
	
}



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

int main(){
  string S;
  int a, z, N;
  cin >> S;
  N = S.length();
  for (int i = 0; i < N; i++){
    if (S.at(i) == 'A'){
      a = i;
      break;
    }
  }
    for (int i = 0; i < N; i++){
    if (S.at(N-i-1) == 'Z'){
      z = N - i;
      break;
    }
  }
  cout << z-a << endl;
}

Measured memory_bytes: 640
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    x = int(input())
    ans = 8
    for i in range(400, 2000, 200):
        if i <= x <= i+199:
            break
        ans -= 1

    print(ans)

if __name__ == '__main__':
	main()


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

int main(){
    // x: 最初の座標
    // k: 移動回数
    // d: 1回で移動できる距離
    ll x,k,d; cin >> x >> k >> d;

    //原点に近づくための回数
    ll num = (abs(x)/d);

    //cout << num << endl;

    //numがk以上の場合と未満の場合
    if(num > k){
        
        cout << abs(x) - k*d << endl;
    }else{

        //kの残り回数
        k -= num;

        //kが偶数か奇数で場合分け
        if(k%2 == 0){
            cout << abs(x) - num*d << endl;
        }else if(k%2 == 1){
            cout << (ll)(abs(abs(x) - (num+1)*d) + 0.01) << endl;
        }
    }

}

Measured memory_bytes: 3548
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int bricks[] = new int[n];
    for (int i=0; i<n; i++) {
      bricks[i] = sc.nextInt();
    }
    
    int result = 0;
    int brickCount = 1;
    for (int i=0; i<n; i++) {
      if (bricks[i]==brickCount) {
        brickCount++;
      }
      else {
        result++;
      }
    }
    
    if (brickCount==1) {
      result = -1;
    }
    System.out.println(result);
        
  }
}

Measured memory_bytes: 65168
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
if(s.length()>=4)
{
if(s[0]=='Y' && s[1]=='A'&&s[2]=='K' &&s[3]=='I'){
cout<<"Yes";return 0;}
}
cout<<"No";}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

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

  bool ng = a[0] != 0;
  FOR(i, 1, n) {
    if (a[i] - a[i - 1] >= 2)
      ng = true;
  }

  if (ng) {
    cout << -1 << endl;
    return 0;
  }

  ll count = 1;
  ll init = a[0];
  ll ans = 0;
  REP(i, n - 1) {
    if (a[i] < a[i + 1]) {
      count++;
    } else {
      ans += init - 1 + count;
      init = a[i + 1];
      count = 1;
    }
  }
  ans += init - 1 + count;
  cout << ans << endl;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    long long N; std::cin >> N;
    long long ans(N*(N+1)*(N+2)/6);
    {
        int u, v;
        for(int i(0), i_len(N-1); i < i_len; ++i){
            std::cin >> u >> v;
            if(u > v) std::swap(u, v);
            ans -= u * (N - v + 1);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 3616
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        final int N = scan.nextInt();
        int[] B = new int[N + 1];
        for (int i = 1; i < N; i++) {
            B[i] = scan.nextInt();
        }
        B[0] = Integer.MAX_VALUE;
        B[N] = Integer.MAX_VALUE;
        scan.close();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.min(B[i], B[i + 1]);
        }
        int ans = Arrays.stream(A).sum();
        System.out.println(ans);
    }
}

Measured memory_bytes: 26964
#include<stdio.h>

int main(void)
{
  int a,b,c,d,ans;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a < b)
    {
      ans = a;
    }
  else
    {
      ans = b;
    }
  if(c < d)
    {
      ans += c;
    }
  else
    {
      ans += d;
    }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int area(int x, int y){
    return x * y;
}

int round(int x, int y){
    int ans = 0;
    ans = x * 2 + y * 2;
    return ans;
}

int main(void){
    int height = 0;
    int width = 0;
    scanf("%d %d", &height, &width);
    printf("%d %d\n", area(height, width), round(height, width));

    return 0;
}



Measured memory_bytes: 2032
#include <algorithm>
#include <list>
#include <cmath>
#include <cassert>
#include <deque>
#include <iostream>
#include <vector>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>

using namespace std;

typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pii;

const int SZ = 100 + 100;

ll n;
ll x[SZ];

int solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    ll ans = 1e17;
    ll res;
    for (ll cur = 0; cur < 101; ++cur) {
        res = 0;
        for (int i = 0; i < n; ++i) {
            res += (x[i] - cur) * (x[i] - cur);
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}

int main() {
    ios_base::sync_with_stdio(false);

    //freopen("input.txt", "r", stdin);

    solve();

    return 0;
}


Measured memory_bytes: 256
from math import atan2, pi

N = int(input())
engines = []
total_X = total_Y = 0
for i in range(N):
  x, y = map(int, input().split())
  engines.append((atan2(y, x), x, y)) # (theta, x, y)
  total_X += x
  total_Y += y

engines.sort()
ans2 = 0
l = r = 0
X = engines[0][1]
Y = engines[0][2]

for l in range(N):
  theta = engines[l][0]
  xl, yl = engines[l][1:]
  while r + 1 - l < N \
      and (theta <= engines[(r+1)%N][0] < theta+pi \
           or theta <= engines[(r+1)%N][0]+2*pi < theta+pi):
    r += 1
    X += engines[r%N][1]
    Y += engines[r%N][2]
  ans2 = max(ans2, X**2+Y**2, (total_X-X)**2+(total_Y-Y)**2)
  while r + 1 - l < N \
      and (theta <= engines[(r+1)%N][0] <= theta+pi \
           or theta <= engines[(r+1)%N][0]+2*pi <= theta+pi):
    r += 1
    X += engines[r%N][1]
    Y += engines[r%N][2]
  ans2 = max(ans2, X**2+Y**2, (total_X-X)**2+(total_Y-Y)**2)
  X -= xl
  Y -= yl

print(ans2 ** 0.5)

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

int main() {
  int l, n;
  cin >> l >> n;
  int sum = 0;
  REP(i, n) {
    int p,  w;
    cin >> p >> w;
    sum += p * w;
  }
  sum = -sum;
  if (sum == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << 1 << endl;
  cout << ((sum < 0) ? -1 : 1)<< " " <<  abs(sum) << endl;
}

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

using namespace std;

int main()
{
	long double ans;
	long double n, m, d;
	cin >> n >> m >> d;
	long double hantei;
	if(abs(d)<0.5) hantei = n;
	else hantei = 2.0 * (n-d);
	ans = (m-1) * hantei / (n * n);
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int k,i;
string s;
int main()
{
    cin>>k;
    cin>>s;
    if(s.size()<=k)
        cout<<s;
    else
    {
        for(i=0;i<k;i++)
            cout<<s[i];
        cout<<"...";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

const string impossible = "impossible";

double get( double x1, double y1, double x2, double y2 ) {
    return x1 * x2 + y1 * y2;
}

double get_abs( double x, double y ) {
    return sqrt( x * x + y * y );
}

bool check( double a, double b ) {
    return a < b || fabs( a - b ) < 1e-9;
}

int main() {
    double D;
    while ( cin >> D ) {
        if ( D < 1e-9 ) break;
        double px, py, vx, vy;
        cin >> px >> py >> vx >> vy;
        double a = get( -px, -py, vx, vy ) / get_abs( px, py ) / get_abs( vx, vy );
        double t = D + 1;
        if ( fabs( a - 1.0 ) < 1e-9 ) {
            t = get_abs( px, py );
        } else if ( fabs( a + 1.0 ) < 1e-9 ) {
            t = 2.0 - get_abs( px, py );
        }
        if ( check( t, D ) ) {
            printf("%.10f\n", t);
        } else {
            cout << impossible << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
vector<int> A;

int main() {
    int N, ans, next_B;
    cin>>N;
    ans = 0; next_B = 1;
    A.resize(N);
    REP(i, 0, N){
        cin >> A[i];
    }
    REP(i, 0, N){
        if(A[i]==next_B){
            next_B++;
        }else{
            ans++;
        }
    }
    if(ans == N){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll max = 100000;
char s[100];
int main(){
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<PP,vector<PP>,greater<PP>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

int main(){
  ll n;cin>>n;
  vi v(n);
  rep(i,n)cin>>v[i];
  ll w=0,k=1,ans=0;
  while(w<n){
    while(v[w]!=k&&w<n)w++;
    if(w>=n)break;
    ans++;
    w++;
    k++;
  }
  if(ans==0)ans=n+1;
  cout<<n-ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll x = 4 * a * b;
    ll y = c - a - b;
    if (y > 0 && x < y * y) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define MAX_V 100000
#define N MAX_V
using namespace std;
typedef long long ll;
int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];
int n,m;
void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++) if(!used[v]) dfs(v);
  
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]) rdfs(vs[i],k++);
  return k;
}

void mk_G(){
  int k=scc();
  vector <int> tmp[N],rtmp[N];
  for(int i=0;i<n;i++){
    for(int j=0;j<G[i].size();j++)
      if(cmp[i]!=cmp[G[i][j]]) tmp[cmp[i]].push_back(cmp[G[i][j]]);
    for(int j=0;j<rG[i].size();j++)
      if(cmp[i]!=cmp[rG[i][j]]) rtmp[cmp[i]].push_back(cmp[rG[i][j]]);
    G[i].clear();
    rG[i].clear();
  }
  n=k;
  for(int i=0;i<k;i++) G[i]=tmp[i],rG[i]=rtmp[i];
}
 
ll calc(int pos){
  if(used[pos]) return 1;
  used[pos]=1;
  ll res=1;
  for(int i=0;i<rG[pos].size();i++)res=res*calc(rG[pos][i])%mod;
  return (res+1)%mod;
}
 

int main(){
  cin>>n>>m;
  V=n;
  for(int i=0,a,b;i<m;i++)cin>>a>>b,add_edge(a-1,b-1);
  mk_G();
  ll ans=1;
  memset(used,0,sizeof(used));
  for(int i=0;i<n;i++) if(!G[i].size())ans=ans*calc(i)%mod;
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 12712
import sys
sdin = sys.stdin.readline


# 入力
n = int(sdin())
a = list(map(int, sdin().split()))
b = list(map(int, sdin().split()))

ans = 0

# バケットソートする
for k in range(29):
    a_nex = [[],[]]
    b_nex = [[],[]]
    for ai in a:
        a_nex[(ai & (1<<k)) >> k].append(ai)
            
    for bj in b:
        b_nex[(bj & (1<<k)) >> k].append(bj)
    

    a = []
    b = []
    for i in range(2):
        a = a + a_nex[i]
        b = b + b_nex[i]
        
    mask = pow(2,k+1) - 1
    a_mask = [ai & mask for ai in a]
    b_mask = [bj & mask for bj in b]
    
    base = pow(2,k)
    itr = [n]*4
    count = 0
    for ai in a_mask:
        border = [
                base - ai,
                2*base - ai,
                3*base - ai,
                4*base - ai
        ]
        
        for i in range(4):
            while 0 < itr[i] and border[i] <= b_mask[itr[i] - 1]:
                itr[i] -= 1
            
            
        count += ((itr[1] - itr[0]) + (itr[3]) - itr[2])
    
    if count & 1:
        ans += base
    
    
print(ans)

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

int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    ll ansa,ansb;
    if (a-k>0) {
        ansa=a-k;
        ansb=b;
    } else if (b-(k-a)>0) {
        ansa=0;
        ansb=b-(k-a);
    } else {
        ansa=0;
        ansb=0;
    }
    cout << ansa << ' ' << ansb << endl;
}

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

int gcd(int a,int b){
    if(b>a){
        int t;
        t = a;
        a = b;
        b = t;
    }
    if(a%b==0){
        return b;
    }
    else{
        return(gcd(b,a%b));
    }
}

int main(){
    int k;
    cin>>k;
    int sum = 0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                int a = gcd(i,j);
                sum = sum + gcd(a,l);
            }
        }
    }
    cout<<sum<<endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> list = new ArrayList<String>();
		list.add("a");
		list.add("i");
		list.add("u");
		list.add("e");
		list.add("o");
		String s = sc.next();
		if (list.contains(s)) {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 21588
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

#define mid ((l+r)>>1)

using namespace std;

const long long MOD=1e9+7;

long long qpow(long long a,int k)
{
	long long ans=1;
	while(k)
	{
		if(k&1)
		{
			ans=(ans*a)%MOD;
		}
		a=(a*a)%MOD;
		k>>=1;
	}
	return ans;
}

long long ans[1000009];

int main()
{
	int n;
	scanf("%d",&n);
	ans[0]=ans[1]=ans[2]=0;
	ans[3]=1;
	for(int i=4;i<=n;i++)
	{
		ans[i]=1;
		for(int j=3;i-j>2;j++)
		{
			ans[i]+=ans[i-j];
			ans[i]=ans[i]%MOD;
		}
	}
	printf("%lld",ans[n]);
	return 0;
}

Measured memory_bytes: 1736
n = int(input())
a = [int(e) for e in input().split()]
c= [0]*(n+1)
def nc2(n):
    return n*(n-1)//2
for i in range(0,n):
    c[a[i]] += 1
sum = 0
for i in range(1,n+1):
    sum += nc2(c[i])
for i in range(0,n):
    print(sum - nc2(c[a[i]])+nc2(c[a[i]]-1)) 

Measured memory_bytes: 24748
from collections import Counter
n = int(input())
d = {}
for i in range(n):
    if i == 0:
        d = Counter(input())
    else:
        tmp = Counter(input())
        tmp2 = {}
        for k,v in d.items():
            if k in tmp:
                tmp2[k] = min(d[k],tmp[k])
        d = tmp2

ans = ""
for k,v in d.items():
    ans += v*k

print(''.join(map(str, sorted(ans))))


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int a[100][100];
int n;
int m;

int main(){
  cin.tie(0);
ios::sync_with_stdio(false);
  cin >> n;
  vector<int> d(n);
  rep(i,n){
    cin >> d[i];
  }
  cin >> m;
  int t[m];
  rep(i,m)cin >> t[i];
  sort(d.begin(),d.end());
  rep(i,m){
    auto it=lower_bound(d.begin(),d.end(),t[i]);
    if(*it==t[i]){
      d.erase(it);
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
return 0;}

Measured memory_bytes: 1792
import bisect
n = int(input())
s = input()
D = [[] for _ in range(10)]
for i in range(n):
  D[int(s[i])].append(i)
ans = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      if D[i] != []:
        l = D[i][0]
        t = bisect.bisect_right(D[j], l)
        if t < len(D[j]):
          m = D[j][t]
          q = bisect.bisect_right(D[k], m)
          if q < len(D[k]):
            ans += 1
print(ans)

Measured memory_bytes: 4456
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<set>
#include<string>
#include<sstream>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

ll Pow(ll a, ll b){
    ll ans = 1;
    while (b){
        if (b & 1) ans *= a;
        a *= a;
        b >>= 1;
    }
    return ans;
}

int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b){
    return a * 1ll / gcd(a, b) * b;
}

int main(){
    int n;
    scanf("%d", &n);
    int p;
    int cnt = 0;
    for (int i = 1; i <= n; i ++ ){
        scanf("%d", &p);
        if (p != i) cnt ++;
    }
    if (cnt == 0 || cnt == 2) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define ll long long

int main(void){
	int N, M;
	cin >> N >> M;
	vector<ll> a(N), b(M);
	for (auto& ai : a) cin >> ai;
	for (auto& bi : b) cin >> bi;
	vector<ll> c = convolution<>(a, b);
	for (auto ci : c) cout << ci << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 27280
#include <bits/stdc++.h>
using namespace std;
int b;
long long p;
long long n[51][51], r[51][51], pot[51][51], nt[51][51];
const int MOD = 1000000007;
int main()
{
    cin >> b >> p;
    for(int i = 0; i < b; i++)
    {
    	for(int j = 0; j < b; j++)
    	{
    		cin >> n[i][j];
		}
		pot[i][i] = 1;
	}
	for(long long i = 1; i <= p; i*=2)
	{
		if((i&p) != 0)
		{
			for(int j = 0; j < b; j++)
			{
				for(int k = 0; k < b; k++)
				{
					r[j][k] = 0;
					for(int l = 0; l < b; l++)
					{
						r[j][k] += n[j][l] * pot[l][k];
						r[j][k] %= MOD;
					}
				}
			}
			for(int j = 0; j < b; j++)
			{
				for(int k = 0; k < b; k++)
				{
					pot[j][k] = r[j][k];
				}
			}
		}
		for(int j = 0; j < b; j++)
		{
			for(int k = 0; k < b; k++)
			{
				nt[j][k] = 0;
				for(int l = 0; l < b; l++)
				{
					nt[j][k] += n[j][l] * n[l][k];
					nt[j][k] %= MOD;
				}
			}
		}
		for(int j = 0; j < b; j++)
		{
			for(int k = 0; k < b; k++)
			{
				n[j][k] = nt[j][k];
			}
		}
	}
	long long z = 0;
	for(int j = 0; j < b; j++)
	{
		for(int k = 0; k < b; k++)
		{
			z += r[j][k];
			z %= MOD;
		}
	}
	cout << z << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, 0, n) {
        cin >> a[i];
    }
    sort(begin(a), end(a));
    int ans = 0;
    double tar = *rbegin(a) / 2.0;

    double dff = 1e+10;
    REP(i, 0, n) {
        if (dff > abs(a[i] - tar)) {
            dff = abs(a[i] - tar);
            ans = a[i];
        }
    }
    cout << *rbegin(a) << " " << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	static int a,b,c,d,n;
	static int x() {
		int h = n/a;
		if(n%a!=0)h++;
		return h*b;
	}
	static int y() {
		int h = n/c;
		if(n%c!=0)h++;
		return h*d;
	}
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 while(sc.hasNext()) {
			 n = sc.nextInt();
			 a = sc.nextInt();
			 b = sc.nextInt();
			 c = sc.nextInt();
			 d = sc.nextInt();
			 
			 if(x()<y())
				 System.out.println(x());
			 else
				 System.out.println(y());
	  }	 
	}
}


Measured memory_bytes: 26304
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  int N;
  string s,t;
  cin >> N >> s >> t;
  int ans = 0;
  for(int i=1;i<=N;i++){
    string a = s.substr(N-i,i);
    string b = t.substr(0,i);
    if(a==b){
      ans = i;
    }
  }
  cout << 2*N-ans << endl;
}

Measured memory_bytes: 256
S = str(input())

while len(S) > 0:
  if S[-5:] == 'dream' or S[-5:] == 'erase':
    S = S[:-5]
  elif S[-6:] == 'eraser':
    S = S[:-6]
  elif S[-7:] == 'dreamer':
    S = S[:-7]
  else:
    break

if len(S) == 0:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> cnt(N);
  for (int i = 0; i < Q; i++) {
    int A;
    cin >> A;
    --A;
    cnt[A]++;
  }
  vector<int> score(N);
  for (int i = 0; i < N; i++) {
    score[i] = K- (Q - cnt[i]);
  }
  for (int i = 0; i < N; i++) {
    if (score[i] > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

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

vector<unsigned long> ans;

void dfs(unsigned long now, unsigned long prev, unsigned long col, const vector<vector<pair<unsigned long, unsigned long>>>& edge){
    ans[now] = col;
    for(const auto& i : edge[now]){
        if(i.first != prev){
            dfs(i.first, now, col ^ i.second, edge);
        }
    }
}

int main() {
    unsigned long N;
    cin >> N;
    ans = vector<unsigned long>(N);
    vector<vector<pair<unsigned long, unsigned long>>> edge(N);
    for(unsigned long i = 1, a, b, c; i < N; ++i){
        cin >> a >> b >> c;
        edge[--a].emplace_back(--b, c &= 1);
        edge[b].emplace_back(a, c);
    }
    dfs(0, 0, 0, edge);
    for(const auto i : ans)cout << i << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll p=1,q=1;
    for(int i=0; i<n; i++){
        ll t,a;
        cin >> t >> a;
        ll x,y;
        x=(p+t-1)/t;
        y=(q+a-1)/a;
        p=t*max(x,y);
        q=a*max(x,y);
        //cout << p << " " << q << endl;
    }
    cout << p+q << endl;
}

Measured memory_bytes: 3632
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt() * 2;
		int arr[] = new int[n];
		for(int i = 0; i < n;i++) {
			arr[i] = in.nextInt();
		}		
		Arrays.sort(arr);
		int result = 0;
		for(int i = 1; i < n; i+=2) {
			result += Math.min(arr[i] , arr[i-1]);
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int a, b, h;
    cin >> a >> b >> h;

    cout << (a + b) * h / 2 << endl;

    return 0;
}

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

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int w, h, x, y; scan(w, h, x, y);

    double area = 0.5 * w * h;
    bool b = 2 * x == w && 2 * y == h;
    // writeln(area, " ", b);
    writefln("%.6f %d", area, b ? 1 : 0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  
  if(1 <= A && A <= 9 && 1 <= B && B <= 9){
  	cout << A*B << endl;
  }else{
  	cout << -1 << endl;
  }
}

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

typedef double dbl;
dbl x[4], y[4];
bool point(dbl x[], dbl y[], int n) {
	dbl nx[3], ny[3];
	for (int i = 0, j = 0; i < 4; i++) {
		if (i != n) {
			nx[j] = x[i];
			ny[j++] = y[i];
		}
	}
	dbl S, s[3];
	S = fabs((nx[1] - nx[0])*(ny[2] - ny[0]) - (ny[1] - ny[0])*(nx[2] - nx[0])) / 2.0;
	for (int i = 0; i < 3; i++) {
		nx[i] -= x[n]; 
		ny[i] -= y[n];
	}
	for (int i = 0; i < 3; i++) {
		s[i] = fabs(nx[i] * ny[(i + 1) % 3] - ny[i] * nx[(i + 1) % 3]) / 2.0;
	}
	if (fabs(S - s[0] - s[1] - s[2]) < 1e-10) return true;
	else return false;
}
int main() {
	char c;
	while (cin >> x[0] >> c >> y[0]) {
		int ok = 1;
		for (int i = 1; i < 4; i++) {
			cin >> c >> x[i] >> c >> y[i];
		}
		for (int i = 0; i < 4; i++) {
			if (point(x, y, i)) {
				cout << "NO\n";
				ok = 0;
				break;
			}
		}
		if(ok) cout << "YES\n";
	}
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> vec(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    vec[a].pb(b);
    vec[b].pb(a);
  }

  vector<bool> used(n,false);
  deque<int> d;

  d.pb(0);
  used[0]=true;
  auto search = [&](int p){
    for(auto to : vec[p]){
      if(!used[to]){
        used[to]=true;
        return to;
      }
    }
    return -1;
  };
  int r;
  while( (r = search(d.front())) != -1) d.push_front(r);
  while( (r = search(d.back())) != -1) d.push_back(r);

  vector<int> res;
  for(auto i: d) res.pb(i);
  int s = res.size();
  cout << s << endl;
  rep(i,s) cout << res[i]+1 << " \n"[i==s-1];

  return 0;
}


Measured memory_bytes: 7288
n = int(input())
a = list(map(int,input().split()))
s = 1
x = 0
y = 0
for i in range(n):
    s *= a[i]
    if a[i] == 0:
        y += 1
    if s > 1000000000000000000:
        s = 0
        x += 1

if y != 0:
    print(0)
else:
    if x != 0:
        print(-1)
    else:
        print(s)


Measured memory_bytes: 84800
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=0,num=0,l=0; 
    string x; cin>>n>>x;
    vector<ll> c(n+1,0),p;
    for(ll i=1;i<=n;i++){
        if(n%i==0 && n/i%2) p.push_back(i);
    }
    ll N=p.size();
    ll k,t1,t2;
    rep(i,N){
        while(l<p[i]){
            num=(num*2+x[l]-'0')%mod;
            l++;
        }
        k=num+1;
        for(int j=p[i];j<n;j++){
            t1=x[j]-'0';
            t2=(x[j%p[i]]-'0'+j/p[i])%2;
            if(t1!=t2){
                if(t2) k--;
                break;
            }
        }
        rep(j,i)if(p[i]%p[j]==0 && p[i]/p[j]%2)
        k=(k-c[p[j]])%mod;
        c[p[i]]=k;
        ans=(ans+k*2*p[i]%mod)%mod;
        //cout<<p[i]*2<<" "<<k<<endl;
    }
    cout<<(mod+ans)%mod<<endl;
}


Measured memory_bytes: 5224
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int co=999999999;
	for(int i=-100;i<=100;i++)
	{
		int temp=0;
		for(int j=0;j<n;j++)
		{
			temp+=(arr[j]-i)*(arr[j]-i);
		}
		co=min(temp,co);
	}
	cout << co;
}

Measured memory_bytes: 256
/*
  How many Divisors?
*/

#include <stdio.h>

int main(void)
{
    int a, b, c;
    int count;
    scanf("%d %d %d", &a, &b, &c);

    count = 0;
    for (int i=a; i<=b; i++) {
        if (c % i == 0) count++;
    }
    printf("%d\n", count);
    return (0);
}



Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 10001
#define PI 3.1415926535897932384
#define F first
#define S second
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
  
// Function to find postorder traversal. 

  
// Driver code 
int main() 
{ 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout); 
#endif
ll n;
cin>>n;
map <int,int> m;
if(n%2==0) {
    cout<<-1;
    return 0;
}
ll ans=1;
ll k=7;
ll g=k%n;
m[7]++;
while(g and ans<n){
 k=(k*10)%n;
    g=(k+g)%n;
    if(m.find(g)!=m.end()) {
        cout<<-1;
        return 0; 
    }
    else m[g]++;
    //cout<<k<<" "<<g<<endl;
    ans++;
}
cout<<ans;

    return 0; 
} 

Measured memory_bytes: 50452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  long long sum = 0;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    sum += x;
  }
 	
  cout << max(-1ll, n - sum) << "\n";
  return 0;
}

Measured memory_bytes: 3608
while true
  a, b = gets.split.map(&:to_i)
  break if a == 0 and b == 0
  map = Array.new(a + 1){ Array.new(b + 1, 0) }
  n = gets.to_i
  n.times do
    x, y = gets.split.map(&:to_i)
    map[x][y] = nil
  end

  map[1][1] = 1
  1.upto(a) do |x|
    1.upto(b) do |y|
      next unless map[x][y]
      map[x][y + 1] += map[x][y] if y + 1 <= b and map[x][y + 1]
      map[x + 1][y] += map[x][y] if x + 1 <= a and map[x + 1][y]
    end
  end
  puts map[a][b]
end

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

int main(){
	int mountain[10];
	for(int i=0; i<10; i++){
		cin >> mountain [i];
	}
	sort(mountain,mountain+10);
	cout << mountain [9] << endl << mountain[8] << endl << mountain[7] << endl;	
    return 0;
}

Measured memory_bytes: 1176
def gcd(a, b):
  return gcd(b, a%b) if b else a

def lcm(a, b):
  return a*b//gcd(a, b)

n = int(input())
ans = 1
for i in range(n):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Measured memory_bytes: 3060