akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll w,h,n,ans=0,x,y,prex,prey;
int main()
{
	cin>>w>>h>>n;
	cin>>prex>>prey;
	for(ll i=1;i<n;i++){
		cin>>x>>y;
		if((prex<x&&prey<y)||(prex>x&&prey>y)) ans+=max(abs(x-prex),abs(y-prey));
		else ans+=(abs(x-prex)+abs(y-prey));
		prex=x;
		prey=y;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	cin >> s;
	int size=s.size();
	for(int i=0;i<size;i++){
		if(s[i]==s[i+1] && s[i+1]==s[i+2]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    L = sorted([lmi() for _ in range(n)], key=lambda x: x[0], reverse=True)
    # print(L)
    h = []
    ans = 0
    for day in range(1, m+1):
        while len(L) != 0 and L[-1][0] == day:
            latency, money = L.pop()
            heappush(h, [-money, latency])
        # print("{} {}".format(day, h))
        if len(h) != 0:
            minus_money, latency = heappop(h)
            ans += - minus_money
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 29868
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int main(void){
  int N;
  int L[128];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L, L+N);
  reverse(L, L+N);
  
  int L_sum = 0;
  for (int i = 1; i < N; i++) {
    L_sum += L[i];
  }
  if (L[0] < L_sum) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

template<int mod> struct modint {
  int v;
  modint(int a = 0) : v(((a % mod) + mod) % mod) {}
  modint operator+(const modint<mod> &b) const { return (v + b.v) % mod; }
  modint operator-(const modint<mod> &b) const { return (v - b.v + mod) % mod; }
  modint operator*(const modint<mod> &b) const { return (v * b.v) % mod; }
  modint operator/(const modint<mod> &b) const { return (v * b.inv().v) % mod; }
  modint<mod> inv() const { return pow(mod - 2); }
  modint<mod> pow(int t) const {
    modint e = v, c = 1;
    while (t) {
      if (t & 1) c *= e;
      t >>= 1;
      e *= e;
    }
    return c;
  }
  explicit operator int() { return v; }
  friend bool operator==(const modint<mod> &a, const modint<mod> &b) { return a.v == b.v; }
  friend bool operator!=(const modint<mod> &a, const modint<mod> &b) { return a.v != b.v; }
  friend modint<mod> &operator+=(modint<mod> &a, const modint<mod> &b) { return a = a + b; }
  friend modint<mod> &operator-=(modint<mod> &a, const modint<mod> &b) { return a = a - b; }
  friend modint<mod> &operator*=(modint<mod> &a, const modint<mod> &b) { return a = a * b; }
  friend modint<mod> &operator/=(modint<mod> &a, const modint<mod> &b) { return a = a / b; }
  friend std::ostream &operator<<(std::ostream &os, const modint<mod> &a) { return os << a.v; }
  friend std::istream &operator>>(std::istream &is, modint<mod> &a) {
    int v;
    is >> v;
    a = v;
    return is;
  }
};

main {
  modint<MOD> m;
  int n;
  cin >> m >> n;
  cout << m.pow(n) << endl;
}

Measured memory_bytes: 3124
from collections import deque  # dequeはappendleftができるので。

letter = ['z'] + [chr(i) for i in range(97, 123)]  # [0, a, b, c, ... , z]というリスト

N = int(input())

i = 0
n_24 = deque()

while N > 0:
    n_24.appendleft(N % 26)
    if N%26== 0:
        N -= 26
    N = N // 26

ans = ''

for dig in (n_24):
    ans += letter[dig]

print(ans)

Measured memory_bytes: 9460
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,x;
    while(1){
        int ans=0;
        cin >> n >> x;
        if(n==0 && x==0){break;}
        for(int i=1;i<n+1;i++){
            for(int j=i+1;j<n+1;j++){
                for(int k=j+1;k<n+1;k++){
                    if(i+j+k==x){ans++;}
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if(k>=n)k=n;
  cout << k*x+(n-k)*y << endl;
  return 0;
}


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

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

    if(B - A <= 0){
        cout << "delicious" << endl;
    }
    else if(B - A <= X){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int h, w;
  cin >> h >> w;
  char a[100][100];
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
  for (int i = 0; i < 2*h; i++) {
    for (int j = 0; j < w; j++) {
      cout << a[i/2][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from collections import  Counter
N = INT()
S = [input() for _ in range(N)]

S = Counter(S)
print(f"AC x {S['AC']}")
print(f"WA x {S['WA']}")
print(f"TLE x {S['TLE']}")
print(f"RE x {S['RE']}")

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

#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]); if(i!=n-1) cout << " ";} cout << endl;
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    ll P[110];
    rep(i,0,N){
        cin >> P[i];
    }
    sort(P, P+N);
    ll ans = 0;
    ll c1 = 0, c2 = 0, c3 = 0;
    rep(i,0,N){
        if(P[i] <= A) c1++;
        if(P[i] >= A+1 && P[i] <= B) c2++;
        if(P[i] >= B+1) c3++;
    }
    ans = min(c1, min(c2,c3));
    print(ans);
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
bbottom=[]
btop=[]
for i in range(n):
  if i%2==0:
    bbottom.append(a[i])
  else:
    btop.append(a[i])
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
print(*ans)
       


Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n, k;
    long long int count=0;
    scanf("%lld%lld", &n, &k);
    if(k == 0){
        printf("%lld\n", n*n);
        return 0;
    }
    for(int b = k+1; b <=n; b++){
        count += (b-k) * (n / b);
        if(n%b >= k)count += (n % b) - k + 1;
    }

    printf("%lld\n", count);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
template<typename _Ty> void print(vector<_Ty>& v, char delim = ' ') { cout << v[0]; for (uint i = 1; i < v.size(); i++) cout << delim << v[i]; cout << endl; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int selectionSort(vector<int>& A) {
	int cnt = 0;
	int N = A.size();

	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj]) minj = j;
		}
		if (i != minj) {
			swap(A[i], A[minj]);
			cnt++;
		}
	}
	return cnt;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	int N;
	cin >> N;
	vector<int> A(N);
	cin >> A;

	int cnt = selectionSort(A);
	print(A);
	cout << cnt << endl;

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



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

void displayA(int A[], int N) {
	for (int i = 0; i < N - 1; i++)
		cout << A[i] << " ";
	cout << A[N - 1] << endl;
}


int selectionSort(int A[], int N) {
	int num_of_exchange = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if(i!=minj){
			int temp = A[i];
			A[i] = A[minj];
			A[minj] = temp;
			num_of_exchange++;
		}
	}
	return num_of_exchange;
}

int main() {
	int N;
	int A[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int num_of_exchange = selectionSort(A, N);

	displayA(A, N);

	cout << num_of_exchange << endl;

	return 0;
}

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

#define MOD (int)(1e9+7)

using namespace std;

typedef long long int Int;
int exist[150000];

int main(void)
{
    Int n;
    Int sum = 1;
    
    cin>>n;

    for(int i = 0;i < n;i++)
    {
	Int temp;
	cin>>temp;

	exist[temp]++;
    }
    if(exist[0] >= 2)
	exist[0] = 0;

    for(int i = 1;i < n;i++)
	if(exist[i] != 2)
	    exist[i] = 0;

    if(n % 2) {
	for(int i = 0;i < n;i += 2)
	{
	    sum = sum*exist[i]%MOD;
	}
    } else {
	for(int i = 1;i < n;i += 2)
	{
	    sum = sum*exist[i]%MOD;
	}
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;
 
signed main(){
    int a,b,k;cin>>a>>b>>k;
    if(a >= k){
        cout<<(a-k)<<" "<<b;
    }
    else{
        if(b >= (k-a)){
            cout<<0<<" "<<(b-(k-a));
        }
        else{
            cout<<0<<" "<<0 ;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int X; cin >> X;
  int x = X;
  int ans = 0;
  while(true) {
    if(x%360 == 0) {
      cout << ans+1 << endl;
      return 0;
    }
    ans++;
    x += X;
  }

  
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> vec;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vec.push_back(a);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int alice = 0, bob = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      alice += vec.at(i);
    } else {
      bob += vec.at(i);
    }
  }
  cout << alice - bob << endl;
  return 0;
}

Measured memory_bytes: 256
//求凸包，时间复杂度nlogn
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

const int maxn=100005;

int n,tot;//n为点的个数，tot为凸点的个数
struct point
{
    double x,y;
};
//int cmpp(point a,point b)
//{
//    return a.y<b.y;
//}
point p[maxn],CHP[maxn];//CHP为凸包最后所构成的点

bool cmp(point a,point b)//水平排序，按x从大到小排，如果x相同，按y从大到小排序
{
    return (a.x<b.x||(a.x==b.x&&a.y<b.y));
}

double xmul(point a,point b,point c)//叉积
{
    return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}

int cmpp(point A, point B)                     //竖直排序
{
	return (A.y<B.y || (A.y == B.y&&A.x<B.x));
}

void Andrew()
{
    sort(p,p+n,cmp);
    tot=0;

    for(int i=0; i<n; ++i) //计算下半个凸包
    {
        while(tot>1&&xmul(CHP[tot-2],CHP[tot-1],p[i])<0)
            --tot;
        CHP[tot++]=p[i];
    }

    int k=tot;
    for(int i=n-2; i>=0; --i) //计算上半个凸包
    {
        while(tot>k&&xmul(CHP[tot-2],CHP[tot-1],p[i])<0)
            --tot;
        CHP[tot++]=p[i];
    }

    if(n>1)//对于只有一个点的包再单独判断
        --tot;
}

point q[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
    {
        scanf("%lf%lf",&p[i].x,&p[i].y);
    }
    Andrew();
     int index;
     sort(p,p+tot,cmp);
     for(int i=0; i<tot; ++i)
     {
         q[i].x=CHP[i].x;
         q[i].y=CHP[i].y;
     }
   sort(q,q+tot,cmpp);
   for(int i=0;i<tot;i++)
   {
       if((q[0].x==CHP[i].x)&&(q[0].y==CHP[i].y))
       {
           index=i;
       }
   }
    printf("%d\n",tot);
    for(int i=0; i<tot; ++i)
    {
        printf("%d %d\n",(int)CHP[(i+index)%tot].x,(int)CHP[(i+index)%tot].y);
    }
    return 0;
}



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


int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h)
    cin >> s[i];
  vector<vector<vector<int>>> id(h, vector<vector<int>>(w, vector<int>(2)));
  vector<vector<int>> hl(h), vl(w);
  rep(i, h)
  {
    int c = 0, l = 0;
    rep(j, w)
      if (s[i][j] == '#')
      {
        hl[i].push_back(l);
        l = 0;
        c++;
      }
      else
      {
        l++;
        id[i][j][0] = c;
      }
    if (l != 0)
      hl[i].push_back(l);
  }
  rep(j, w)
  {
    int c = 0, l = 0;
    rep(i, h)
      if (s[i][j] == '#')
      {
        vl[j].push_back(l);
        l = 0;
        c++;
      }
      else
      {
        l++;
        id[i][j][1] = c;
      }
    if (l != 0)
      vl[j].push_back(l);
  }
  int ans = 0;
  rep(i, h)
    rep(j, w)
      if (s[i][j] == '.')
        ans = max(ans, hl[i][id[i][j][0]] + vl[j][id[i][j][1]] - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 255360
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	ll a, b, c, x, y, ans=0;
	cin >> a >> b >> c >> x >> y;
	ll shou=min(x, y);
	if(a+b<2*c){
		ans+=shou*(a+b);
	} else {
		ans+=shou*2*c;
	}
	if(x>y){
		if(a>2*c){
			x-=y;
			ans+=x*2*c;
		} else {
			x-=y;
			ans+=x*a;
		}
	} else {
		if(b>2*c){
			y-=x;
			ans+=y*2*c;
		} else {
			y-=x;
			ans+=y*b;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

ll x;

bool check(ll num)
{
    if(num%2==0)
    {
        if((6*num/2)+(5*num/2)>=x)
            return 1;
        return 0;
    }
    else
    {
        if( ( 6 * ((num/2)+1) ) + ( 5 * (num/2))>=x)
            return 1;
        return 0;
    }
}

ll bs(ll low,ll high,ll req)
{
    if(low>high)
        return req;
    ll mid=(low+high)/2;
    if(check(mid))
        return bs(low,mid-1,mid);
    return bs(mid+1,high,req);
}

int main()
{
    cin>>x;
    cout<<bs(0,1e15,0);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

vector<P> g[100005];
int main() {
  int n;
  cin >> n;
  rep(i,n-1){
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    g[a].emplace_back(b,c);
    g[b].emplace_back(a,c);
  }
  int m,k;
  cin >> m >> k;
  --k;
  vector<ll> d(n,1e18L);
  priority_queue<P,vector<P>,greater<P>> q;
  auto push = [&](int v, ll nd){
    if(d[v]<=nd)return;
    d[v]=nd;
    q.emplace(nd,v);
  };
  push(k,0);
  while(!q.empty()){
    int u = q.top().second;
    ll pd = q.top().first;
    q.pop();
    for(P p:g[u]) push(p.first,pd+p.second);
  }
  rep(i,m){
    int x,y;
    cin >> x >> y;
    --x; --y;
    cout << d[x]+d[y] << endl;
  }
}

Measured memory_bytes: 11120
#include<stdio.h>
#define MAX 2000000
int H,A[MAX+1];
void swap(int i,int j,int n,int n2){
    A[n]=j;
    A[n2]=i;
}
void maxHeapify(int i){
    int l,r,largest;
    l=2*i;
    r=2*i+1;
    
    if(l<=H && A[l]>A[i])largest=l;
    else largest=i;
    if(l<=H && A[r]>A[largest])largest=r;
    
    if(largest!=i){
        swap(A[i],A[largest],i,largest);
        maxHeapify(largest);
    }
}
int main(){
    int i,j;
    scanf("%d",&H);
    for(i=1;i<=H;i++){
        scanf("%d",&A[i]);
    }
    for(i=H/2;i>=1;i--){
        maxHeapify(i);
    }
    for(i=1;i<=H;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 4632
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N, i;
  int sum = 0;
  int sum2 = 0;
  int tmp;
  
  cin >> N;

  int *d = new int[N+1];
  
  
  for(i=1;i<=N;i++){
    cin >> d[i];
  }

  for(i=1;i<=N;i++){
    sum += d[i];
    sum2 += d[i]*d[i];
  }

  tmp = (sum*sum - sum2)/2;
  
  cout << tmp; 
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int a=sc.nextInt();
    	int b=sc.nextInt();

    	int sum=a+b;

    	if(sum>=10) {
    		System.out.println("error");
    	}else {
    		System.out.println(sum);
    	}
    }
}


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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; i <= n / r; i++) {
    if (i * r > n) break;
    for (int j = 0; j <= ((n - i * r) / g); j++) {
      int ij = r * i + g * j;
      if (ij > 3000) break;
      if ((n - ij) % b == 0) ans++;
    }
  }
  cout << ans << endl;
};


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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 7;

int n,m;
int x,y;
int u[N],comp[N];
int sz;

vector <int> g[N],rg[N];
vector <pair<int,int> > e;
vector <int> t;
map<pair<int,int>,int> ans;

void SCC (int v) {
    u[v] = 1;

    for (auto to : g[v])
        if (!u[to])
            SCC(to);
    t.pb(v);
}
void RSCC (int v) {
    comp[v] = sz;
    u[v] = 1;
    for (auto to : rg[v])
        if (!u[to])
            RSCC(to);
}
void dfs (int v) {
    u[v] = 1;
    for (auto to : g[v])
        if (!u[to])
            dfs(to);
}

main () {
    cin >> n >> m;

    for (int i = 1; i <= m; i ++) {
        cin >> x >> y;
        e.pb({x,y});
        g[x].pb(y);
        rg[y].pb(x);
    }
    for (int i = 1; i <= n; i ++)
        if (!u[i])
            SCC(i);

    reverse (t.begin(),t.end());
    memset(u,0,sizeof(u));

    for (auto to : t)
        if (!u[to]) {
            sz ++;
            RSCC(to);
        }

    for (int v = 1; v <= n; v ++) {
        for (int i = 1; i <= n; i ++)
            u[i] = 0;
        u[v] = 1;
        for (auto to : g[v]) {
            if (u[to])
                ans[{v,to}] = 1;
            dfs(to);
        }

        for (int i = 1; i <= n; i ++)
            u[i] = 0;

        reverse(g[v].begin(),g[v].end());

        u[v] = 1;

        for (auto to : g[v]) {
            if (u[to])
                ans[{v,to}] = 1;
            dfs(to);
        }
    }
    for (auto c : e) {
        if (comp[c.fr] != comp[c.sc]) ans[{c.fr,c.sc}] ^= 1;
        if (ans[{c.fr,c.sc}])
            puts("same");
        else
            puts("diff");
    }

}


Measured memory_bytes: 29040
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


signed main(){
    int d;
    while(cin >> d, d){
        int n, m;
        cin >> n >> m;
        VI vd(n), vk(m);
        vd[0] = 0;
        rep(i, 1, n) cin >> vd[i];
        rep(i, 0, m) cin >> vk[i];
        sort(ALL(vd));
        int ans = 0;
        rep(i, 0, m){
            int x = lb(ALL(vd), vk[i])-begin(vd);
            x %= n;
            if(vd[x] != vk[i]){
                int z = (x-1+n)%n;
                int d1 = vd[x]-vk[i];
                int d2 = vk[i]-vd[z];
                if(d1 < 0) d1 += d;
                if(d2 < 0) d2 += d;
                ans += min(d1, d2);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    cout<<fixed<<setprecision(12);
    int n;
    cin>>n;//回数
    int x[100]{};
    int y[100]{};
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>y[i];
    }//データセットに全て格納した
    //マンハッタン距離
    double S{};
    for(int i=0;i<n;i++)
    {
        S+=fabs(x[i]-y[i]);
    }
    double D{};
    for(int i=0;i<n;i++)
    {
        D+=(x[i]-y[i])*(x[i]-y[i]);
    }
    double L{};
    for(int i=0;i<n;i++)
    {
        L+=pow(fabs(x[i]-y[i]),3.0);
    }
    double H{};
    for(int i=0;i<n;i++)
    {
        if(i==0)H=fabs(x[i]-y[i]);
        else if(H<fabs(x[i]-y[i]))H=fabs(x[i]-y[i]);
        else continue;
    }
    cout<<S<<endl;
    cout<<sqrt(D)<<endl;
    cout<<pow(L,1.0/3.0)<<endl;
    cout<<H<<endl;
}


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

int main() {
  char N1,N2,N3,N4;    
  cin >> N1 >> N2 >> N3 >> N4;
  
  if(N1==N2 && N1==N3)  cout << "Yes" << endl;
  else if(N2==N4 && N3==N4)  cout << "Yes" << endl;
  else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1003, MOD = 1E9 + 7;
char a[N][N];
int  ans[N][N], n, m;
int main(int argc, char const *argv[])
{
	scanf("%d %d", &n, &m);
	getchar();
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			scanf("%c", &a[i][j]);
		}
		getchar();
	}
	ans[1][0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (a[i][j] == '#')
				continue;
			ans[i][j] = (1LL * ans[i][j - 1] + ans[i - 1][j]) % MOD;
		}
	}
	printf("%d", ans[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int mod = 998244353;
int n, len, sp;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int ksm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = x * x % mod)
		if(y & 1) res = res * x % mod;
	return res;
}
struct Poly
{
	int x[300005];
	int & operator[] (int p) {return x[p];}
	void fwt(int len)
	{
		for(int l = 2; l <= len; l <<= 1)
			for(int i = 0, m = l >> 1; i < len; i += l)
				for(int j = i, t; j < i + m; j ++)
					t = x[j + m], x[j + m] = (x[j] - t + mod) % mod, x[j] = (x[j] + t) % mod;
	}
	void ifwt(int len)
	{
		fwt(len); int ny = ksm(len, mod - 2);
		for(int i = 0; i < len; i ++) x[i] = x[i] * ny % mod;
	}
}E, P, S;
signed main()
{
	n = read(); len = (1 << n);
	for(int i = 0; i < len; i ++) sp += (P[i] = read());
	sp = ksm(sp, mod - 2);
	for(int i = 0; i < len; i ++) P[i] = P[i] * sp % mod;
	(-- P[0]) < 0 ? P[0] += mod : 0, S[0] = len - 1;
	for(int i = 1; i < len; i ++) S[i] = mod - 1;
	P.fwt(len); S.fwt(len);
	for(int i = 1; i < len; i ++) E[i] = S[i] * ksm(P[i], mod - 2) % mod;
	E.ifwt(len); int x = mod - E[0];
	for(int i = 0; i < len; i ++) printf("%lld\n", (x + E[i]) % mod);
	return 0;
}


Measured memory_bytes: 9472
#include "bits/stdc++.h"
using namespace std;
#define MAXN 1000000
#define ll long long

ll dp[MAXN + 1];
ll Odp[MAXN + 1];

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

	for (int i = 0; i < MAXN + 1;i++) {
		dp[i] = i;
		Odp[i] = i;
	}
	// n := n???????????£?????¢???
	// p := ??£?????¢?????°
	// n = 1 p = 1 ?????´???????????????
	// n = 2, p = 2*3*4/6 = 4??????
	ll p = 4;
	for (int n = 2; p <= MAXN;n++) {
		 p = n*(n + 1)*(n + 2) / 6;
		 //cout << n << " " << p << endl;
		for (int i = 0; i + p <= MAXN;i++) {
			dp[i + p] = min(dp[i + p], dp[i] + 1);
			if (p % 2 == 1) {
				Odp[i + p] = min(Odp[i + p], Odp[i] + 1);
			}
		}
	}
	int N;
	while (cin >> N,N) {
		cout << dp[N] << " " << Odp[N] << endl;
	}

}

Measured memory_bytes: 18712
N = int(input())
A = [int(x) for x in input().split()]

n = sum(1 for a in A if a < 0)
s = sum(abs(a) for a in A)
m = min(abs(a) for a in A)

if n % 2 == 0:
    print(s)
else:
    print(s - 2 * m)

Measured memory_bytes: 14412
def convert(s):
    if s == 'S' or s == 'o':
        return 1
    else:
        return -1


n = int(input())
s = input()

cands = [['S', 'S'], ['S', 'W'], ['W', 'S'], ['W', 'W']]

for cand in cands:
    for i in range(1, len(s)-1):
        if cand[-1] == 'S':
            if s[i] == 'o' and cand[-2] == 'S':
                cand.append('S')
            elif s[i] == 'x' and cand[-2] == 'S':
                cand.append('W')
            elif s[i] == 'o' and cand[-2] == 'W':
                cand.append('W')
            else:
                cand.append('S')
        else:
            if s[i] == 'o' and cand[-2] == 'S':
                cand.append('W')
            elif s[i] == 'x' and cand[-2] == 'S':
                cand.append('S')
            elif s[i] == 'o' and cand[-2] == 'W':
                cand.append('S')
            else:
                cand.append('W')
    if (convert(cand[0]) * convert(cand[-1]) * convert(cand[1]) * convert(s[0]) == 1) and \
            (convert(cand[0]) * convert(cand[-1]) * convert(cand[-2]) * convert(s[-1]) == 1):
        print(''.join(cand))
        exit()

print(-1)


Measured memory_bytes: 6644
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

// #define DEBUG

typedef long long LL;
const int maxn = 8;
bool g[maxn][maxn];
int a[maxn];


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifdef DEBUG
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	int n, m;
	int u, v;
	
	scanf("%d %d", &n, &m);
	rep(i, 0, m) {
		scanf("%d %d", &u, &v);
		--u; --v;
		g[u][v] = g[v][u] = true;
	}
	
	rep(i, 0, n)
		a[i] = i;
	
	int ans = 0;
	
	do {
		bool flag = true;
		u = 0;
		for (int i=1; i<n; ++i) {
			v = a[i];
			if (!g[u][v]) {
				flag = false;
				break;
			}
			u = v;
		}
		ans += flag;
		// #ifdef DEBUG
		// for (int i=0; i<n; ++i)
			// printf("%d ", a[i]+1);
		// putchar('\n');
		// #endif
	} while (next_permutation(a+1, a+n));
	
	printf("%d\n", ans);
	
	// #ifdef DEBUG
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin >> x >> n;
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  vector<int> p(n);
  for(auto &a: p) cin >> a;
  for(int i=0; i<=n; i++){
    if(std::find(p.begin(), p.end(), x-i) == p.end()){
      cout << x - i << endl;
      break;
    }
    if(std::find(p.begin(), p.end(), x+i) == p.end()){
      cout << x + i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3576
unittest
{
	assert( [ "9 12" ].parse.expand.solve == 21 );
	assert( [ "19 0" ].parse.expand.solve == 19 );
	assert( [ "23 2" ].parse.expand.solve == 1 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return ( a + b ) % 24;
}


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

struct ModInt {
    using M = ModInt;

    static vector<M> fact, finv;
    static long long MOD;
    long long v;

    // normalize: [-MOD, MOD**2] -> [0, MOD)
    ModInt(const long long _v = 0) : v((_v < 0) ? _v % MOD + MOD : _v % MOD) {}

    M operator+(const M& x) const { return M(v + x.v); }
    M operator-(const M& x) const { return M(v - x.v); }
    M operator*(const M& x) const { return M(v * x.v); }
    M operator/(const M& x) const { return M(v * x.inv().v); }
    M& operator+=(const M& x) { return *this = *this + x; }
    M& operator-=(const M& x) { return *this = *this - x; }
    M& operator*=(const M& x) { return *this = *this * x; }
    M& operator/=(const M& x) { return *this = *this / x; }
    bool operator==(const M& x) const { return v == x.v; }
    bool operator!=(const M& x) const { return v != x.v; }
    friend istream& operator>>(istream& input, M& x) {
        return input >> x.v, x = M(x), input;
    }
    friend ostream& operator<<(ostream& output, const M& x) {
        return output << x.v;
    }
    inline M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    inline M inv() const { return this->pow(MOD - 2); }
    static void build(int n) {
        fact.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
        finv.assign(n + 1, fact[n].inv());
        for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
    }
    static M comb(int n, int k) {
        if (n < k || k < 0) return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int& x, int& y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
    ModInt::build(2 * 1e5);
    int n, a, b;
    cin >> n >> a >> b;
    ModInt ans = ModInt(2).pow(n) - 1;
    ModInt p = 1;
    for (int i = 0; i < a; i++) p *= n - i;
    ans -= p * ModInt::finv[a];
    ModInt q = 1;
    for (int i = 0; i < b; i++) q *= n - i;
    ans -= q * ModInt::finv[b];
    cout << ans << endl;
}

Measured memory_bytes: 3328
//#include </Users/piyush/Desktop/nodejs/first-app/CP/bits/stdc++.h>
 #include <bits/stdc++.h>
typedef long long ll;
using namespace std;


#define print(x) for(auto iuiuiuiuiui:x){ cout<<iuiuiuiuiui<<" ";}br;
#define pb(qwerty) push_back(qwerty)

#define br cout<<"\n"
//const int INF=1e9+5;
const ll INF=1e18L+5;


vector<vector<ll>> adj;
vector<bool> visted;
vector<ll> in_degree,dist;


void dfs(ll start){
    visted[start]=true;
    for(ll i:adj[start]){
        if(!visted[i]){
            dist[i]=max(dist[i],dist[start]+1);
            in_degree[i]-=1;
            if(in_degree[i]==0){
                dfs(i);
            }
        }
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,k;
    cin>>n>>k;

    adj.resize(n+1);        // 1 to n
    visted.assign(n+1,false);
    in_degree.assign(n+1,0);
    dist.assign(n+1,0);

    ll e1,e2;
    for(ll i=0;i<k;i++){
        cin>>e1>>e2;
        adj[e1].pb(e2);
        in_degree[e2]+=1;
    }

    for(ll i=1;i<=n;i++){
        if(!visted[i] and in_degree[i]==0){
            dfs(i);
        }
    }

    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans=max(ans,dist[i]);
    }

    cout<<ans;


}

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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            //String s = br.readLine();
            String[] str = br.readLine().split(" ");
            int h = Integer.parseInt(str[0]);
            int w = Integer.parseInt(str[1]);
            if(h == 0 || w == 0) break;
            for(int i=0;i<h; i++){
                System.out.print("");
                for(int j=0; j<w-1; j++){
                    if((j>0 && j<w-1) && (i>0 && i<h-1)){
                        System.out.print(".");
                    }else{
                        System.out.print("#");
                    }
                }
                System.out.println("#");
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 25936
import kotlin.math.ceil

fun main() {
    val (th, ts, ah, ast) = readInts()
    val tAttacks = ceil(ah.toDouble().div(ts)).toInt()
    val aAttacks = ceil(th.toDouble().div(ast)).toInt()

    println(if (tAttacks <= aAttacks) "Yes" else "No")
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 36388
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B)cout<<C<<endl;
    else if(B==C)cout<<A<<endl;
    else cout<<B<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length() / 2; i++) {
		if (s[i] != s[s.length() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < (s.length() - 1) / 4; i++) {
		if (s[i] != s[(s.length() - 1) / 2 -1- i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = (s.length() + 3) / 2 - 1; i < s.length(); i++) {
		if (s[i] != s[s.length() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {

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

	if n == 0 {
		fmt.Println(x)
		os.Exit(0)
	}

	//p := make([]int, n)
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		m[readInt()]++
	}

	_, ok := m[x]
	if !ok {
		fmt.Println(x)
		os.Exit(0)
	}
	a, b := x, x
	for {
		a--
		b++
		if a > -2 {
			_, ok := m[a]
			if !ok {
				fmt.Println(a)
				os.Exit(0)
			}
		}
		if b < 102 {
			_, ok := m[b]
			if !ok {
				fmt.Println(b)
				os.Exit(0)
			}
		}

	}

}


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

int main(){
    int N;
    int c[3][3]; 
    bool flag = true;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    int b1, b2, b3;
    b1 = c[0][0], b2 = c[1][0], b3 = c[2][0];
    if(c[0][1] - b1 == c[1][1] - b2 &&  c[2][1] - b3 == c[1][1] - b2){
        if(c[0][2] - b1 == c[1][2] - b2 &&  c[2][2] - b3 == c[1][2] - b2){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
}

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

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;

  string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for (int i = 0; i < S.size(); i++){
    for (int j = 0; j < alp.size(); j++){
      if (S.at(i) == alp.at(j)){
        j = (j+N)%26;
        S.at(i) = alp.at(j);
      }
    }
  }
  cout << S << endl;
}


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

int binarysearch(int *, int, int);

int main()
{
  int n, q, i, count = 0;
  int *s, *t;

  scanf("%d", &n);
  s = (int *)malloc(n*sizeof(int));
  for(i=0; i<n; i++) {
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  t = (int *)malloc(q*sizeof(int));
  for(i=0; i<q; i++) {
    scanf("%d", &t[i]);
  }

  for(i=0; i<q; i++) {
    if(binarysearch(s, n, t[i]))
      count++;
  }
  printf("%d\n", count);
  return 0;
}

int binarysearch(int *s, int n, int key)
{
  int mid, left = 0, right = n;

  while(left < right) {
    mid = (left + right)/2;
    if(s[mid] == key)
      return 1;
    else if(key < s[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 1188
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
#include<fstream>
#include<iostream>
using namespace std;

int main(){
  long h,w,num[10]={},a,b;
  int n,cnt=0;
  vector<pair<long,long>> p;
  scanf("%ld %ld %d",&h,&w,&n);
  for(int i=0;i<n;i++){
    scanf("%ld %ld",&a,&b);
    for(long j=max((long)1,a-2);j<=min(a,h-2);j++)
      for(long k=max((long)1,b-2);k<=min(b,w-2);k++)
        p.push_back(make_pair(j,k));
  }
  a=b=0;
  sort(p.begin(),p.end());
  p.push_back(make_pair(h+1,w+1));
  for(int i=0;i<p.size();i++){
    if(a==p[i].first&&b==p[i].second)
      cnt++;
    else{
      num[cnt]++;
      cnt=1;
      a=p[i].first;
      b=p[i].second;
    }
  }
  num[0]=(h-2)*(w-2);
  for(int i=1;i<=9;i++)
    num[0]-=num[i];

  //ofstream fout("out2.txt");
  for(int i=0;i<10;i++)
    cout << num[i] << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double t = h*30+m*0.5-m*6;
    if(t>180) t=360-t;
    double c = a*a+b*b-2*a*b*cos(t*M_PI/180);
    cout << setprecision(10) << sqrt(c) << "\n";
    return 0;
}

Measured memory_bytes: 4204
// Aizu Vol-5 0538: IOIOI
// 2017.9.1 bal4u@uu

#include <stdio.h>

char s[1000003];

int main()
{
	int n, m, ans, len;
	char *p, *e;

	while (scanf("%d", &n) && n) {
		scanf("%d%s", &m, s);
		p = s, e = s + m, len = 0, ans = 0;
		while (p < e) {
			if (*p == 'I' && *(p+1) == 'O') len++, p += 2;
			else {
				if (len > 0) {
					if (*p == 'O') len--;
					if (len >= n) ans += len - n + 1;
					len = 0;
				}
				p++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1580
n = int(input())
s = input()
lr = ["" for i in range(2*n)]
sm = 0
for i in range(2*n):
    if s[i] == "W":
        if sm%2 == 0:
            lr[i] = "R"
            sm -= 1
        else:
            lr[i] = "L"
            sm += 1
    else:
        if sm%2 == 0:
            lr[i] = "L"
            sm += 1
        else:
            lr[i] = "R"
            sm -= 1
    if sm < 0:
        print(0)
        exit()
if sm != 0:
    print(0)
    exit()

def f(x,y):
    r = 1
    for i in range(y):
        r = (r * (x-i))%(10**9+7)
    return r


suml = 0
sumr = 0
sp = "R"
ans = 1
lr.append("L")
for i in range(2*n+1):
    if sp == "R" and lr[i] == "L":
        ans = (ans * f(suml,sumr)) % (10**9+7)
        suml = suml - sumr
        sumr = 0
    if lr[i] == "L":
        suml += 1
    elif lr[i] == "R":
        sumr += 1
    sp = lr[i]

for i in range(1,n+1):
    ans = (ans * i)%(10**9+7)
print(ans)

Measured memory_bytes: 5224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,x; cin >> n >> x;
	if(x==1||x==2*n-1){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
		for(int i=0;i<2*n-1;i++){
			cout << (x-i-n+(2*n-1)*2-1)%(2*n-1)+1 << endl;
		}
	}
}

Measured memory_bytes: 1664
def s_print(s, line):
    a, b = map(int, line.split()[1:])
    print(s[a:b + 1])
    return s


def s_reverse(s, line):
    a, b = map(int, line.split()[1:])
    return s[:a] + s[a:b + 1][::-1] + s[b + 1:]


def s_replace(s, line):
    ls = line.split()
    a, b = map(int, ls[1:3])
    rep = ls[-1]
    return s[:a] + rep + s[b + 1:]


func_dict = {'pri': s_print, 'rev': s_reverse, 'rep': s_replace}

s, q = input(), int(input())
while q:
    line = input()
    s = func_dict[line[:3]](s, line)
    q -= 1

Measured memory_bytes: 7784
using System;

namespace PrintaRectangle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			while (true) {
				string[] tmp = Console.ReadLine ().Split (" ".ToCharArray ());
				int height, Wide;

				height = int.Parse (tmp [0]);
				Wide = int.Parse (tmp [1]);
				if (height == 0 && Wide == 0)
					break;

				for (int i = 0; i < height; i++) {
					for (int j = 0; j < Wide; j++) {
						Console.Write ("#");
					}
					Console.Write ("\n");
				}
				Console.Write ("\n");
			}
		}
	}
}

Measured memory_bytes: 5288