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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t x, y;
  std::cin >> x >> y;
  if (1 < std::abs(x - y)) {
    std::cout << "Alice" << std::endl;
  } else {
    std::cout << "Brown" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;
vector<ll>x,y;
ll n;

ll f()
{
  ll res=0;
  ll tmp,d;
  for(auto p:{1,-1}) 
  {
    for(auto q:{1,-1})
    {
     tmp=p*x[0]+q*y[0]+0;
     for(ll i=1;i<n;i++)
     {
      d=p*x[i]+q*y[i];
      res= max(res,d-tmp);
      tmp=min(tmp,d);
     }
    }
  }
  return res;
}

set<pair<ll,ll> >onee,twoo;

int main(){
FLASH;
cin>>n;
for(ll i=1;i<=n;i++)
{
  ll xx,yy;
  cin>>xx>>yy;
  x.pb(xx);
  y.pb(yy);
}
cout<<f()<<endl;

return 0;
} 


Measured memory_bytes: 6724
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

struct Point {
  int x, y;
};

istream& operator>>(istream& stream, Point& obj) {
  stream >> obj.x >> obj.y;
  return stream;
}

ostream& operator<<(ostream& stream, const Point& obj) {
  stream << obj.x << " " << obj.y;
  return stream;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<Point> student(n), check_point(m);
  auto manhattan_length = [](const Point& p1, const Point& p2) {return abs(p1.x - p2.x) + abs(p1.y - p2.y); };
  for (auto&& v : student) {
    cin >> v;
  }
  for (auto&& v : check_point) {
    cin >> v;
  }
  for (auto&& target : student) {
    auto min_length = manhattan_length(check_point.front(), target);
    int min_index = 0;
    for (int i = 1; i < check_point.size(); ++i) {
      auto length = manhattan_length(check_point[i], target);
      if (length < min_length) {
        min_length = length;
        min_index = i;
      }
    }
    cout << min_index + 1 << endl;
  }
  return 0;
}


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

int main(){
    int a,b,k,f=0;
    
    cin>>k;
    cin>>a>>b;
    
    for(int i=a;i<=b;i++){
        if(i%k==0){
            f=1;
            break;
        }
    }
    if(f==0){
        cout<<"NG\n";
    }else{
        cout<<"OK\n";     
    }
    return 0;
}            

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int n, k, q;
	cin >> n >> k >> q;
	vint cnt(n);
	rep(i, q) {
		int x;
		cin >> x;
		cnt[x - 1]++;
	}
	rep(i, n) {
		Yes(q - k < cnt[i]);
	}

	please AC;
}

Measured memory_bytes: 1024
def answer(arr):
    l,  m = [], []
    h = {}
    for num in arr:
        l.append(num)
    i = 0
    while True:
        i += 1
        h, m = {}, []
        for num in l:
            if h.has_key(num):
                h[num] += 1
            else:
                h[num] = 1

        for num in l:
            m.append(h[num])
        if l == m:
            print i - 1
            for r in l:
                print r,
            print
            break
        else:
            l = m[:]

while True:
    a = input()
    if a == 0:
        break
    answer([int(n) for n in raw_input().split()])

Measured memory_bytes: 4252
A,B,C = map(int,input().split())

A,B,C = sorted([A,B,C])

ans=0

if (A+B)%2==1:
    A+=1
    C+=1
    ans+=1

while A!=B or B!=C:
    if A<B:
        A+=2
    else:
        A+=1
        B+=1
    ans+=1

print(ans)


Measured memory_bytes: 38384
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    a_list = [int(input()) for _ in range(M)]

    p = 0
    steps=[]
    m = 0
    for a in a_list:
        if a != 1:
            steps.append((p, a-1))
            m = max(m, a-p)
        p = a + 1
    else:
        steps.append((p, N))
        m = max(m, N-p+1)

    dp=[0 for _ in range(m+1)]

    divider = 1000000007
    dp[0], dp[1] = 1, 1
    for i in range(2,m+1):
        dp[i]=(dp[i-1]+dp[i-2])%divider

    ans = 1
    for p, n in steps:
        if n < p:
            ans = 0
            break
        else:
            r = dp[n-p]
        ans = (ans*r)%divider 

    print(ans)
        

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc129","c",main)

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

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(),a.end());
	if(a[0]+a[1]==a[2])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
}

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

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

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


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
#define MOD 1000000007
string s[1005];
ll dp[1005][1005];
int main() {
    int h, w;
    cin>>h>>w;

    for(int i=0;i<h;i++) {
        cin>>s[i];
    }
    dp[0][0] = 1;
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) {
            if(s[i][j] == '#') {
                dp[i][j] = 0;
            } else {
                if(i!=0 && s[i-1][j] != '#') {
                    dp[i][j] = (dp[i-1][j] + dp[i][j])%MOD;
                }
                if(j != 0 && s[i][j-1] != '#') {
                    dp[i][j] = (dp[i][j-1] + dp[i][j])%MOD;
                }
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const int INF = 1001001001;

vector<int> tos[200005];
vector<int> ans;

void dfs(int v, int p = -1) {
    for (int u : tos[v]) {
        if (u == p)continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {

    int n, q;
    cin >> n >> q;

    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tos[a].push_back(b);
        tos[b].push_back(a);
    }
    ans.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0);
    rep(i, n) {
        cout << ans[i] << ' ';
    }
}


Measured memory_bytes: 23424
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define endl '\n'
#define MAX 100002
#define pii pair<int, int>
#define pll pair<long long, long long>


typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vec;

int main(){
    fast_cin();
    int n;
    map<string, int> m;
    cin>>n;
    rep(i, 0, n){
        string x;cin>>x;
        m[x]++;
    }
    cout<<m.size()<<endl;
}

Measured memory_bytes: 19104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;cin >> c;
    cout << char(c+1) << endl;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> p(n);
    rep(i, n)cin >> p[i];

    double sum[1010];
    sum[0] = 0.0;
    rep(i, 1001)sum[i+1] = sum[i] + i+1.0;

    vector<double> e(n);
    e[0] = sum[p[0]]/p[0];

    rep(i, n-1)e[i+1] = e[i] + sum[p[i+1]] / p[i+1];

    double ans = e[k-1];
    rep(i, n-k){
        ans = max(ans, e[i+k]-e[i]);
    }

    printf("%.9f", ans);

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v.at(i);
    }
    int c2, c4;
    rep(i, n)
    {
        if (v.at(i) % 2 == 0)
        {
            if (v.at(i) % 4 == 0)
            {
                c4++;
            }
            else
            {
                c2++;
            }
        }
    }

    int m = n - 2 * c4;
    if (m <= 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        if (m <= c2)
        {
            cout << "Yes" << endl;
        }
        else
        {

            cout << "No" << endl;
        }
    }
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll n, c, k;
	cin >> n >> c >> k;

	vector<ll> t;
	for(int i=0; i<n; i++){
		ll tmp;
		cin >> tmp;
		t.pb(tmp);
	}

	sort(t.begin(), t.end());

	ll ans = 1;
	ll x = t[0];
	ll cnt = 1;
	for(int i=1; i<n; i++){
		if(t[i] <= x + k && cnt < c){
			cnt++;
		}else{
			cnt = 1;
			x = t[i];
			ans++;
		}
	}

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


Measured memory_bytes: 1400
x,y = map(int,input().split())
d = {1:"a", 2:"c", 3:"a", 4:"b", 5:"a", 6:"b", 7:"a", 8:"a", 9:"b", 10:"a", 11:"b", 12:"a"}

if d[x]==d[y]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *h = map(int, read().split())
    if n == 1:
        print(h[0])
        sys.exit()
    r1 = h[0]
    r2 = h[-1]
    for i1 in range(n - 1):
        if h[i1] < h[i1 + 1]:
            r1 += (h[i1 + 1] - h[i1])
        elif h[i1] > h[i1 + 1]:
            r2 += (h[i1] - h[i1 + 1])
    r = max(r1, r2)
    print(r)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

// union-find
struct union_find {
    vector<int> data;

    union_find(int size) {data.resize(size,-1);}

    int find(int x) {
        if (data[x] < 0) {return x;}
        return data[x] = find(data[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) {return false;}
        if (data[x] > data[y]) swap(x,y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int size(int x) {return -data[find(x)];}
};

int main() {
    int n, m; cin >> n >> m;
    union_find uf(n);
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    int ans = -1;
    rep(i,n) {
        if (uf.data[i] < 0) ans = max(ans,-uf.data[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
let inputString = '';

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
process.stdin.on('end', function() {
    const input = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    const nums = input[1].split(' ').map(s => Number(s));

    console.log(minCost(nums));
});

const MAX = 1000; // Max length of the array
const VMAX = 10000; // Max volume of the stuff

const minCost = (arr) => {
  let answer = 0;

  const minimumWeightInAll = Math.min(...arr);
  const sorted = [...arr].sort((a, b) => a - b);
  const isUsedInLoops = new Array(arr.length).fill(false);
  
  const weightSortedIndexMap = new Array(VMAX + 1);
  for (let i=0; i<sorted.length; i++) {
    weightSortedIndexMap[sorted[i]] = i;
  }

  for (let i=0; i<arr.length; i++) {
    if (isUsedInLoops[i]) {
      continue;
    }

    let currentIndex = i;
    let sumWeightInLoop = 0;
    let minimumWeightInLoop = VMAX; // will be the base of swappings
    let elementNumInCurrentLoop = 0;
    while (true) {
      isUsedInLoops[currentIndex] = true;
      elementNumInCurrentLoop++;
      const v = arr[currentIndex];

      minimumWeightInLoop = Math.min(minimumWeightInLoop, v);

      sumWeightInLoop += v;

      currentIndex = weightSortedIndexMap[v];
      if (isUsedInLoops[currentIndex]) {
        break;
      }
    }
    // swapping only in the loop
    const costInLoop = sumWeightInLoop + (elementNumInCurrentLoop - 2) * minimumWeightInLoop;
    // swapping with the num out of the loop
    const costWithNumOutOfLoop = sumWeightInLoop + minimumWeightInLoop  + (elementNumInCurrentLoop + 1) * minimumWeightInAll;
    answer += Math.min(costInLoop, costWithNumOutOfLoop);
  }

  return answer;
};


Measured memory_bytes: 18064
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <list>

using namespace std;
int main()
{
    int n, a, b, ans;
    cin >> n;
    if (n == 1){
        cout << "Hello World" << endl;
    }
    else if(n == 2){
        cin >> a >> b;
        ans = a + b;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
int main() {
  uint64_t N;
  cin >> N;
  vector<pair<uint64_t, uint64_t>> Num;
  Num.push_back(make_pair(1, N));
  if (N % 2 == 0) {
    Num.push_back(make_pair(2, N / 2));
  }
  for (uint64_t i = 3; i * i <= N; i++) {
    if (N % i == 0) {
      Num.push_back(make_pair(i, N / i));
    }
  }
  vector<uint64_t> res;
  for (auto itr = Num.begin(); itr != Num.end(); ++itr) {
    res.push_back(itr->first + itr->second - 2);
  }
  sort(res.begin(), res.end());
  cout << res[0] << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MOD 1000000007
#define INF 1000000000000000000

#define MI modint<MOD>
template<int mod>struct modint{
	int x;
	modint():x(0){}
	modint(LL n):x(n>=0?n%mod:(mod-(-n)%mod)%mod){}
	modint &operator+=(const modint &n){if((x+=n.x)>=mod)x-=mod;return *this;}
	modint &operator-=(const modint &n){if((x+=mod-n.x)>=mod)x-=mod;return *this;}
	modint &operator++(){*this+=1;return *this;}
  modint &operator--(){*this-=1;return *this;}
	modint &operator*=(const modint &n){x=(int)((LL)x*n.x%mod);return *this;}
	modint &operator/=(const modint &n){*this*=n.inv();return *this;}
	modint operator-()const{return modint(-x);}
	modint operator+(const modint &n)const{return modint(*this)+=n;}
	modint operator-(const modint &n)const{return modint(*this)-=n;}
	modint operator++(int){modint ret(*this);*this+=1;return ret;}
  modint operator--(int){modint ret(*this);*this-=1;return ret;}
	modint operator*(const modint &n)const{return modint(*this)*=n;}
	modint operator/(const modint &n)const{return modint(*this)/=n;}
	bool operator<(const modint &n)const{return x<n.x;}
	bool operator>(const modint &n)const{return x>n.x;}
	bool operator<=(const modint &n)const{return x<=n.x;}
	bool operator>=(const modint &n)const{return x>=n.x;}
	bool operator!=(const modint &n)const{return x!=n.x;}
	bool operator==(const modint &n)const{return x==n.x;}
	friend istream &operator>>(istream &is,modint &n){LL l;is>>l;n=modint<mod>(l);return is;}
	friend ostream &operator<<(ostream &os,const modint &n){return os<<n.x;}
	int getmod(){return mod;}
	modint inv()const{int a=x,b=mod,c=1,d=0,n;while(b){n=a/b;swap(a-=n*b,b);swap(c-=n*d,d);}return modint(c);}
	modint pow(LL n)const{modint ret(1),m(x);while(n){if(n&1)ret*=m;m*=m;n>>=1;}return ret;}
};

int main() {
	LL N,flag=0;
	MI m;
	cin>>N;
	LL D[N],E[N];
	for(LL i=0;i<N;i++){
		cin>>D[i]>>E[i];
	}
	for(LL i=0; i<N-2; i++){
		if(D[i]==E[i]&&D[i+1]==E[i+1]&&D[i+2]==E[i+2]){
			flag=1;
		}
	}
	if(flag==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;	
	}
}


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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut a: [usize; n + 1],
        b: [usize; n]
    }
    let mut ans = 0;
    for i in 0..n {
        if a[i] >= b[i] {
            ans += b[i];
        } else if a[i] + a[i + 1] >= b[i] {
            ans += b[i];
            a[i + 1] -= b[i] - a[i];
        } else {
            ans += a[i] + a[i + 1];
            a[i + 1] = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
S = input()
N = len(S)

maxc = 0
c = 0

for i in range(N):
    if S[i] in {'A', 'T', 'G', 'C'}:
        c += 1
    else:
        maxc = max(maxc, c)
        c = 0
maxc = max(maxc, c)

print(maxc)

Measured memory_bytes: 3060
#!/usr/bin/env python3
S = input()

a, b = S[:2], S[2:]
a = int(a)
b = int(b)
if 0 < a and a <= 12 and 0 < b and b <= 12:
    print('AMBIGUOUS')
elif 0 < b and b <= 12:
    print('YYMM')
elif 0 < a and a <= 12:
    print('MMYY')
else:
    print('NA')


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

int xx(vector<int64_t>& box,int64_t min,int n){
    int min2=min;
    int mode=0;
    int64_t b;

    for(int i=0;i<n;i++){
        b=box.at(i)%min;
        if(b!=0)
           box.at(i)=b;
        if(min>box.at(i)&&box.at(i)!=0){
            min2=box.at(i);
            mode=1;
        }
    }
    if(mode==0)
        return min;
        
    xx(box,min2,n);
    
}


int main(){
    int n;
    int ans =1;
    int64_t min;
    cin>>n;
    
    vector<int64_t> a(n);

    for(int i=0;i<n;i++){
        cin>>a.at(i);
        if(i==0)
           min=a.at(i);
        if(min>a.at(i))
           min=a.at(i);
    }
    
    ans=xx(a,min,n);
    cout<<ans<<endl;
    
}

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

using namespace std;

int main(){
	//freopen("C:\Users\changzheng\Desktop\in.txt","r",stdin);
	//freopen("C:\Users\changzheng\Desktop\out.txt","w",stdout);
	int n;
	cin>>n;
	cout<<(1000-n%1000)%1000;
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}

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

long long int A, B, C, K;

int main() {
    cin >> A >> B >> C >> K;
    while (K--) {
        if (A >= B) B *= 2;
        else if (B >= C) C *= 2;
    }
    if (C > B && B > A) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3544
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define fo(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll ceil(const ll &a, const ll &b)
{
    if(a%b == 0)
        return a/b;
    return a/b +1;
}
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
string s;
    cin>>s;
    ll n=s.size();
    if(s[n-1]=='s')
    {
        s+="es";
    }
    else
    {
        s+='s';
    }
    cout<<s;
    return 0;
}

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

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

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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

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

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

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


int main(){
  int N, L[SIZE];

  cin >> N;

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

  sort(L, L+N);

  ll ans = 0;

  for (int i=1; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      int b = L[i], c = L[j];

      int a = c - b + 1;

      ans += (L+i) - lower_bound(L, L+i, a);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef int LL;
typedef pair<LL, LL> II;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Silent_voice
#define endl "\n"

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 5e5;

LL n, a[MaxN], q, bloc, mark[MaxN], ans[MaxN], vt[MaxN];
vector<LL> query[MaxN], pos[MaxN];

class Tree{

    LL TNode[4 * MaxN], ri[4 * MaxN], le[4 * MaxN], leaf[MaxN], qi, qj;

    LL Find(LL node){
        if(le[node] > qj || ri[node] < qi) return 0;
        if(qi <= le[node] && ri[node] <= qj) return TNode[node];
        return (Find(node * 2) + Find(node * 2 + 1));  
    }

    public:
        void createTree(LL node, LL l, LL r){
            le[node] = l;
            ri[node] = r;
            if(l == r){
                leaf[l] = node;
                TNode[node] = 0;
                return;
            }
            createTree(node * 2, l, (l + r) / 2);
            createTree(node * 2 + 1, (l + r) / 2 + 1, r);
        }

        void update(LL node, LL val){
            LL h = leaf[node];
            TNode[h] = (TNode[h] + val);
            for(h /= 2 ; h ; h/= 2) TNode[h] = (TNode[h * 2] + TNode[h * 2 + 1]);
        }

        LL query(LL l, LL r){
            qi = l;
            qj = r;
            return Find(1);
        }
} tr;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    for(int i = 1 ; i <= n ; ++i) cin >> a[i];
    for(int i = 0 ; i < q ; ++i){
        LL x, y;
        cin >> x >> y;
        query[y].push_back(x);
        pos[y].push_back(i);
    }
    tr.createTree(1, 1, n);
    for(int i = 1 ; i <= n ; ++i){
        if(mark[a[i]]) tr.update(mark[a[i]], -1);
        tr.update(i, 1);
        mark[a[i]] = i;
        for(int j = 0 ; j < query[i].size() ; ++j){
            ans[pos[i][j]] = tr.query(query[i][j], i);
        }
    }
    for(int i = 0 ; i < q ; ++i) cout << ans[i] << endl;

    return 0;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    map<int,int> A;
    rep(i,N) {
        int a;
        cin >> a;
        A[a]++;
    }
    int od,ev;
    od = ev = 0;
    for (auto m:A) {
        if (m.second%2==0) ev++;
        else od++;
    }
    int ans = ev+od;
    if (ev%2!=0) ans--;
    cout << ans << endl;
}


Measured memory_bytes: 8204
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	bool flag=true;
	for (int i=0; i<s.size()-1; i++)
	{
		if (s[i]==s[i+1])
		{
			flag=false;
		}
	}
	if (flag)
	{
		cout<<"Good";
		return 0;
	}
	cout<<"Bad";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	using T = tuple<string,int,int>;
	vector<T> v;
	rep(i,N){
		string s;
		int a;
		cin >> s >> a;
		v.emplace_back(s,-a,i+1);
	}
	sort(all(v));
	rep(i,N) cout << get<2>(v[i]) << endl;
}


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

int main(){
    int n, m;
    string s[100], t[100];
    scanf("%d\n", &n);
    for(int i = 0;i < n;i++) cin >> s[i];
    scanf("%d\n", &m);
    for(int i = 0;i < m;i++) cin >> t[i];

    int maxa = -1;
    for(int i = 0;i < n;i++){
        int k = 0;
        for(int j = 0;j < n;j++){
            if(s[i] == s[j]) k++;
        }
        for(int j = 0;j < m;j++){
            if(s[i] == t[j]) k--;
        }
        maxa = max(maxa, k);
    }
    if(maxa >= 0) cout << maxa << "\n";
    else cout << "0" << "\n";
    return 0;
}


Measured memory_bytes: 256
/* ex3_5
   hangan2020*/ 

#include <stdio.h>
#include <string.h>

int main(void){
    char str[11],  *p; 
    int len, max;

    //文字列入力
    scanf("%s", &str[0]);
    //文字列先頭のアドレス
    p = str;
    len = 0;
    max = 0; 

    //null文字ではない間に
    while(*p){
        
        //長さリセット
        len = 0;

        //ACGT列を見つけたら長さをカウントする。
        //カウントが終わるとポインタは最後の文字の次の文字にある
        while(*p == 'A'||*p == 'C'||*p == 'G'||*p == 'T'){
            len++;
            p++;
        }
        
        //もしカウントしている文字列が前の文字列より長かったらmaxにする
        if(len > max){
            max = len;
        }

        //次の文字へ
        p++;

    }

    printf("%d", max);

    return 0;

}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   string a, b; cin >> a >> b;
   int ans = 0;
   for(int i = 0; i < a.size(); i++) {
      if(a[i] != b[i]) ans++;
   }
   cout << ans << '\n';
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;

using ld = long double;
using vd = vector<double>;
using vvd = vector<vd>;

using vb = vector<bool>;
using vvb = vector<vb>;

#define FOR(i,a,b) for(ll i=(a); i < (b); (i)++)

#define DBG 0
#define TR(X) ({if (DBG) cerr << "TR " << (#X) << " = " << (X) << endl; })
#define TRM(i,j,c) ({if (DBG) cerr << "TR (" << (i) << ", " << (j) << ") = " << (c)[i][j] << endl;})

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

    ll N, K;
    cin >> N >> K;

    vl a(N);
    FOR(i,0,N)
        cin >> a[i];

    vb dp(K+1, false);
    FOR(i,0,K+1) {
        TR(i);
        FOR(j,0,N) {
            if(a[j] <= i){
                TR(j);
                TR(i-a[j]);
                TR(dp[i-a[j]]);

                dp[i] = ! (dp[i - a[j]]);
                if(dp[i])
                    break;
            }
        }
        TR(dp[i]);
    }

    if(dp[K]){
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}


Measured memory_bytes: 256
//knasiri
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#define f first
#define s second
#define pb push_back
using namespace std;
pair<int,int>a[20000+10];
const long int INF=9990099999;
long long int dis[100000];
long long int w[100000];
long long int n,m,r;
bool neg_cycle=false;
void belman_ford(int x)
{
	for(int i=0;i<n;i++)
	{
		dis[i]=INF;
	}
	dis[x]=0;
	for(int i=0;i<=n+1;i++)
	{
		for(int j=0;j<m;j++)
		{
			long long int u=a[j].f;
			long long int v=a[j].s;
			if(i>=(n-1))
			{
				if(((dis[u]+w[j])<dis[v])&& dis[u]!=INF)
					neg_cycle=true;
			}
			else
			{
				if(dis[u]!=INF)
				{
					dis[v]=min((dis[u]+w[j]),dis[v]);
				}
			}
			
			//cout<<v<<" <------> "<<dis[v]<<endl;
		}

	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a[i].f>>a[i].s>>w[i];
	}
	for(int i=0;i<n;i++)
	{
		belman_ford(i);
		if(neg_cycle)
		{
			cout<<"NEGATIVE CYCLE"<<endl;
			return 0;
		}
		for(int j=0;j<n;j++)
		{
			if(dis[j]==INF)
			{
				cout<<"INF";
			}
			if(dis[j]!=INF)
			{
				cout<<dis[j];
			}
			if(j!=n-1)
				cout<<' ';
		}
		cout<<endl;
	}
	

///ddddddddd//dd//d//ddddd/dd//d
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int bin_exp(int b,int e)
{
	if(e==0)	
		return 1;
	int a=bin_exp(b,e/2);
	if(e&1)	
		return a*a*b;
	else 
		return a*a;
}

int powm(int x,int y,int m=MOD) 
{
	x=x%m;
	int res=1;
	while(y)
	{
		if(y&1)
			res=res*x;
		res%=m;
		y=y>>1;
		x=x*x;
		x%=m;
	}
	return res;
}

int modInverse(int a,int m=MOD)
{
	return powm(a,m-2,m);
}

int fact[1000000], mi[1000000]; 

int nCr(int n,int r)
{
	return (((fact[n] * mi[r]) % MOD * mi[n - r]) % MOD); 
}



int32_t main()
{
	fastIO
	inp_out();

	int n, m; 
	cin >> n >> m; 
	fact[0] = 1; 
	mi[0] = 1; 
	for(int i = 1; i < 1000000; ++ i)
	{
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD; 
		mi[i] = mi[i - 1] * modInverse(i); 
		mi[i] %= MOD; 
	}

	int ans  = nCr(m, n); 

	ans *= fact[n]; 
	ans %= MOD;  

	int cnt = 0; 
	for(int i = 0; i <= n;  ++ i)
	{
		if(i & 1)
		{
			cnt -= ((nCr(n, i) * fact[m - i]) % MOD * mi[m - n]) % MOD; 
			cnt  %= MOD; 
			cnt += MOD; 
			cnt %= MOD; 

		}

		else
		{
			cnt += ((nCr(n, i) * fact[m - i]) % MOD * mi[m - n]) % MOD; 
			cnt %= MOD; 
		}
	}

	ans *= cnt; 
	ans %= MOD; 

	cout << ans; 
	return 0;
}

Measured memory_bytes: 19188
#include<bits/stdc++.h>
using namespace std;
double x[100005],y[100005];
double dx[100005],dy[100005];
int n;
double check(double a){
	double mnx=1e18,mxx=-1e18,mny=1e18,mxy=-1e18;
	for(int i=0;i<n;i++){
		double xx=x[i]+a*dx[i];
		double yy=y[i]+a*dy[i];
		mnx=min(mnx,xx);
		mxx=max(mxx,xx);
		mny=min(mny,yy);
		mxy=max(mxy,yy);
	}
	return (mxx-mnx)*(mxy-mny);
}
int main(){
	
	cin>>n;
	char s;
	memset(dx,0,sizeof(dx));
	memset(dy,0,sizeof(dy));
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>s;
		if(s=='D')
			dy[i]=-1;
		if(s=='U')
			dy[i]=1;
		if(s=='R')
			dx[i]=1;
		if(s=='L')
			dx[i]=-1;
	}
	double l=0,r=1e9;
	double ans=1e18;
	for(int i=0;i<200;i++){
		double ll=(l*2+r)/3;
		double rr=(r*2+l)/3;
		double lll=check(ll),rrr=check(rr);
		ans=min(ans,lll);
		ans=min(ans,rrr);
		if(lll<rrr)
			r=rr;
		else l=ll;
	}
	printf("%lf\n",ans);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll n = (w + 1) / 2;
    ll nn = w % 2 == 0 ? n : n - 1;
    ll ans = (h / 2) * nn + (h - (h / 2)) * n;
    cout << ans << endl;
    return 0;
}


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

ll gcd(ll a,ll b){
    if(a<b)return gcd(b,a);
    if(a%b==0)return b;
    return gcd(b ,a%b);
}
int main(){
    int m,d;
    cin >> m >> d;
    int ans = 0;

    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            if(j%10 > 1 && j/10 > 1 && (j%10)*(j/10)==i) ans++;
        }    
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { d, r, u, l , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D array to 1D array. (Zero-indexed)
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) {
	int r = n / nCol, c = n % nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

void inter(string s) {
	cout << s << endl;
	fflush(stdout);
}


int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vi v(n);
	lop(i, n) cin >> v[i];
	sort(all(v));
	ll ans = 0;
	lop(i, k) ans += v[i];
	cout << ans << endl;



	return 0;
}


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

int main() {
    int64_t a, b, c, k; cin >> a >> b >> c >> k;

    int64_t sum = 0;

    sum += 1 * min(a, k);
    k -= a <= k ? a : k;
    k -= b <= k ? b : k;
    sum += -1 * min(c, k);

    cout << sum << endl;
}



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

int main(){
    int a,b;
    string s;
    cin >> a >> b >> s;
    bool ans=true;
    for(int i=0;i<a+b+1;i++){
        if(i==a&&s[i]!='-') ans=false;
        if(i!=a){
            if(!isdigit(s[i])) ans=false;
        }
    }
    
    if(ans) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=100010;
int n;
vector<pii>vec;

int Main()
{
	if(n==(n&-n))return puts("No"),0;
	fo(i,1,2)vec.emplace_back(i,i+1);
	vec.emplace_back(3,n+1);
	fo(i,1,2)vec.emplace_back(n+i,n+i+1);
	for(int i=4;i<n;i+=2){
		vec.emplace_back(1,i);
		vec.emplace_back(i,i+1);
		vec.emplace_back(1,n+i+1);
		vec.emplace_back(n+i+1,n+i);
	}
	if(~n&1){
		int x,y;
		fo(i,2,n-1)if((n^i^1)<n){x=i;y=n^i^1;break;}
		if(x&1)vec.emplace_back(n+x,n);
		else vec.emplace_back(x,n);
		swap(x,y);
		if(x&1)vec.emplace_back(n+x,n+n);
		else vec.emplace_back(x,n+n);
	}
	cout<<"Yes\n";
	for(auto x:vec)cout<<x.first<<' '<<x.second<<'\n';
	return 0;
}

int main()
{
	while(scanf("%d",&n)!=EOF)Main();
	return 0;
}


Measured memory_bytes: 3952