akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(15) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll a=ii(), b=ii(), h=ii(), m=ii();
    ld r=(((ld)h/12.0+(ld)m/720.0)-(ld)m/60.0)*2.0*M_PI;
    ode(sqrt((ld)a*(ld)a + (ld)b*(ld)b - 2.0*(ld)a*(ld)b * cos(r)));
    return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    lint res = 0;
    res += min(a, k);
    k -= a;
    k -= b;
    if (k > 0) res -= min(c, k);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <tuple>

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

class UF{
	private:
		std::vector<int> group;
		// int < 0 �Ȃ玩���̃O���[�v�̃T�C�Y
		// int >= 0 �Ȃ玩���̃O���[�v�̐e�ԍ�
	public:
		UF(int n){
			std::vector<int> temp(n,-1);
			group = temp;
		}
		int find(int a){
			if( group[a]<0 ) return a;
			group[a] = find(group[a]);
			return group[a];
		}
		int size(int a){
			return -group[find(a)];
		}
		bool same(int a,int b){
			if( find(a)==find(b) ) return true;
			return false;
		}
		void unit(int a,int b){
			a = find(a);
			b = find(b);
			if( a==b ) return;
			group[a] += group[b];
			group[b] = a;
			return;
		}
};

int main(){
	int N,M;
	cin >> N >> M;
	UF city(N);
	rep(i,0,M){
		int a,b;
		cin >> a >> b;
		city.unit(a-1,b-1);
	}
	bool flag[N];
	rep(i,0,N) flag[i]=true;
	int ans=0;
	rep(i,0,N){
		int k=city.find(i);
		if( flag[k] ) ans++;
		flag[k]=false;
	}
	cout << _max(ans-1,0);
	return 0;
}

Measured memory_bytes: 4052
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size()) 
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int r[10050];
int root(int x) {
	return (x == r[x]) ? x : (r[x] = root(r[x]));
}

char in[105];
int cnt[26];
int C[10050];

int X[10050];
int main() {
	int N, M, i, j, k;
	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) {
		scanf("%s", in);
		for (j = 0; j < M; j++) cnt[in[j] - 'a']++;
	}

	for (i = 0; i < N*M; i++) r[i] = i;
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			int x = i * M + j;
			int y = (N - 1 - i) * M + j;
			r[root(x)] = root(y);

			y = i * M + (M - 1 - j);
			r[root(x)] = root(y);
		}
	}

	for (i = 0; i < N*M; i++) C[root(i)]++;

	for (i = 0; i < N*M; i++) X[C[i]]++;
	for (i = 50; i >= 1; i--) {
		for (j = 0; j < X[i]; j++) {
			for (k = 0; k < 26; k++) {
				if (cnt[k] >= i) {
					cnt[k] -= i;
					break;
				}
			}
			if (k >= 26) return !printf("No\n");
		}
	}
	return !printf("Yes\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>VI;
const int N=1e5+5;
int a[N],b[N],n,i,ans,z;
inline VI F(int*be,int*en){VI a(be,en);sort(a.begin(),a.end());return a;}
map<int,VI>e;
set<int>s;
void dfs(int x){s.insert(x);z|=x==a[n+1];for(int y:e[x])if(!s.count(y))dfs(y);}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n;for(i=1;i<=n;++i)cin>>a[i],a[n+1]^=a[i];for(i=1;i<=n;++i)cin>>b[i],b[n+1]^=b[i];
	if(F(a+1,a+n+2)!=F(b+1,b+n+2))return puts("-1"),0;
	for(i=1;i<=n;++i)if(a[i]!=b[i])e[a[i]].push_back(b[i]),e[b[i]].push_back(a[i]),++ans;
	for(i=1;i<=n;++i)if(a[i]!=b[i] && !s.count(a[i]))z=0,dfs(a[i]),ans+=!z;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 24432
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		int[] c = new int[n + 1];
		for (int i = 0; i < n; i++)
			c[a[i]]++;
		long r = 0;
		for (int i = 0; i <= n; i++)
			if (c[i] > 1)
				r += (long) c[i] * ((long) c[i] - 1) / 2;
		for (int i = 0; i < n; i++) {
			long ans = solve(n, a[i], c, r);
			System.out.println(ans);
		}
	}

	private static long solve(int n, int a, int[] c, long r) {
		if (c[a] > 1)
			return r - c[a] + 1;
		else
			return r;
	}
}

Measured memory_bytes: 94240
#include <stdio.h>

int main() {
    
    int l, m, n, i, j;
    
    int big, a, b;
    
    scanf("%d", &i);
    for (j = 0; j < i; j++) {
        
        scanf("%d %d %d", &l, &m, &n);
        
        big = l;
        if (big < m) { a = big; big = m; } else { a = m; }
        if (big < n) { b = big; big = n; }  else { b = n; }
        
        
        if (big * big == a * a + b * b) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
        
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 201;
ll k,i;
string a;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>k;
    for(i = 0;i < min((ll)a.length(),k);i++){
        if(a[i] - '0' > 1){
            cout<<a[i];
            return 0;
        }
    }
    cout<<a[k - 1];
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t,a, ...) t a,##__VA_ARGS__;auto a##_in = [&]() { return in, a, ##__VA_ARGS__, 0; }();
#define In(a, ...) auto k##a##_in = [&]() { __VA_ARGS__; return 0; }();

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

struct Data {
  int a, b;
};
vector<Data> d;
ll solve1(int keta) {
  keta--;
  ll ans = 0;
  for (auto& i : d) {
    if ((i.a >> keta) == 0) {
      ans += i.b;
    }
  }
  return ans;
}

ll solve2(int k, int keta) {
  int mask = ~k & ((1 << keta) - 1);
  err(mask);
  ll ans = 0;
  for (auto& i : d) {
    if ((i.a & mask) == 0) {
      ans += i.b;
    }
  }
  return ans;
}
bitset<10> Bit(int i) {
  return bitset<10>(i);
}
ll solve3(int k, int keta) {
  vector<int> a(keta);
  int tmp = k;
  for (auto& i : a) {
    i = tmp & 1;
    tmp /= 2;
  }
  reverse(all(a));
  ll ans = 0;

  ll now = 0;
  err(a);
  rep(i, keta) {
    if (a[i] == 1 && i >= 1) {
      int am = keta - i;
      err(i, am, now, Bit(now << am), Bit(((1 << (am - 1)) - 1)));
      amax(ans, solve2((now << am) | ((1 << (am - 1)) - 1), keta));
    }
    now = now << 1 | a[i];
  }
  return ans;
}
void Calc() {
  var(int, n, k);

  d.resize(n);
  for (auto& i : d) {
    in, i.a, i.b;
  }

  d.erase(std::remove_if(all(d), [=](Data d) {
    return d.a > k;
  }), d.end());

  int tmp = k;
  int keta = 0;
  while (tmp) {
    tmp /= 2;
    keta++;
  }
  cout << (max({ solve1(keta), solve2(k, keta),solve3(k,keta) })) << endl;
}


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

int n;
int a[1000100];
int ans[100100];

signed main(){
	cin >> n;
	rep(i, n) cin >> a[i];
	ans[0] = 0;
	for(int i = 1; i < n; i++){
		ans[i] = a[i-1] - ans[i-1];
	}
	ans[0] += (a[n-1] - ans[n-1] + ans[0]) / 2;
	cout << (ans[0] * 2) << " ";
	for(int i = 1; i < n; i++){
		ans[i] = a[i-1] - ans[i-1];
		cout << ans[i]*2 << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2816
#n,じゃんけん回数  k，ちょうど出せないk回前までの手
n,k = map(int,input().split())
#r,s,p：グー，ちょき，パーで勝ったときの点数
r,s,p = map(int,input().split())
#相手の手
arr = list(input())
point = 0
for x,y in enumerate(arr):
    if x+k < n:
        if arr[x+k] == arr[x]:
            arr[x+k]=None

for i in arr:
    if i == "r":
        point+=p
    elif i =="s":
        point+=r
    elif i =="p":
        point+=s

print(point)

Measured memory_bytes: 54128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 200005
#define ll long long
#define pi pair<int , int>
#define pip pair<pi ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 1000000007
#define int ll
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
// this is triplet class , which will help us .
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
// this is for finding inversing multiplicative module of a number.
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
    lps[i] = j+1;
   i++;
   j++;
  }
  else{
    if(j != 0){
     j = lps[j-1];
    }
    else{
     lps[i] = 0;
     i++;
    }
  }
 }
 return lps[len-1];
}




vector<int> edges[N];
set<pi> st;
bool visited[N];
void dfs(vector<int>&comp , int S , int p){
       comp.pb(S);
       visited[S] = true;
      for(auto it:edges[S]){
           if(!visited[it]){
              dfs(comp , it , S);
           }
      }
}
int32_t main(){
   ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    cout.tie(NULL);
     int n;
     cin>>n; 
    int arr[n];
    int sum = 0;
    for(int i = 0 ; i <  n; i++){
       cin>>arr[i];
        sum += arr[i];
    }
    int ans = 0;
    for(int i = 0 ; i < n ; i++){
             ans = (ans%mod + ((arr[i]%mod)*((sum - arr[i])%mod) + mod)%mod + mod)%mod;
    }
    cout<<(ans*mmInverse(2 , mod)+mod)%mod<<endl;

}

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

using namespace std;
using ll = long long;

int main() {
	const ll INF = 1e18;
	ll A, B, Q;
	cin >> A >> B >> Q;
	vector<ll> s(A);
	vector<ll> t(B);
	vector<ll> x(Q);
	for (int i = 0; i < A; ++i) { cin >> s[i]; }
	for (int i = 0; i < B; ++i) { cin >> t[i]; }
	for (int i = 0; i < Q; ++i) { cin >> x[i]; }

	vector<ll> res(Q, INF);
	for (int i = 0; i < Q; ++i) {
		int its = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
		int itt = lower_bound(t.begin(), t.end(), x[i]) - t.begin();

		ll sl = -1;
		ll sr = -1;
		ll tl = -1;
		ll tr = -1;
		if (its > 0) { sl = s[its - 1]; }
		if (its < A) { sr = s[its]; }
		if (itt > 0) { tl = t[itt - 1]; }
		if (itt < B) { tr = t[itt]; }

		if (sl > 0 && tl > 0) {
			res[i] = min(res[i], x[i] - min(sl, tl));
		}
		if (sr > 0 && tr > 0) {
			res[i] = min(res[i], max(sr, tr) - x[i]);
		}
		if (sl > 0 && tr > 0) {
			ll tmp = 2*min(x[i] - sl, tr - x[i]) + max(x[i] - sl, tr - x[i]);
			res[i] = min(res[i], tmp);
		}
		if (tl > 0 && sr > 0) {
			ll tmp = 2*min(x[i] - tl, sr - x[i]) + max(x[i] - tl, sr - x[i]);
			res[i] = min(res[i], tmp);
		}
	}

	for (int i = 0; i < Q; ++i) {
		cout << res[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 4480
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979
 
void mul_mod(ll& a, ll b){
    a *= b;
    a %= MOD;
}

void add_mod(ll& a, ll b){
    a += b;
    a %= MOD;
}

int main(void){
	int h,w,i,j,mp[55][55];
	string s[55];
	bool flag = true;
	fill(mp[0],mp[55],0);
	cin >> h >> w;
	for(i=0; i<h; ++i){
		cin >> s[i];
		for(j=0; j<w; ++j){
			mp[i+1][j+1] = ((s[i][j] == '#')?1:0);
		}
	}
	for(i=1; i<=h; ++i){
		for(j=1; j<=w; ++j){
			if(!mp[i][j]){
				continue;
			}
			if(!(mp[i-1][j] || mp[i+1][j] || mp[i][j-1] || mp[i][j+1])){
				flag = false;
				break;
			}
		}
		if(!flag){
			break;
		}
	}
	cout << ((flag)?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

#### START
x = int(input())

point = 0
cnt = 0
cnt += (x//11)*2
if x%11>6:
    cnt+=2
elif x%11>0:
    cnt+=1

print(cnt)

Measured memory_bytes: 12236
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ");

  let kari2 = kari.map(i => parseInt(i));

  let h = kari2[0];
  let a = kari2[1];

  console.log(Math.ceil(h / a));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;
#define ALL(v) (v).begin(), (v).end()

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}
bool compare_by_b(pair<int,int> a,pair<int,int> b){
    if(a.second!=b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main()
{
 int N,M;cin>>N>>M;
 vector<int> H(N);
 int res=0;
 vector<vector<int>> ans(N,vector<int>(0));
 for(int i=0;i<N;i++){
     int h;cin>>h;
     H[i]=h;
     ans.at(i).push_back(h);
 }
 for(int i=0;i<M;i++){
     int A,B;cin>>A>>B;A--;B--;

    ans.at(A).push_back(H[B]);
    ans.at(B).push_back(H[A]);
 }
 for(int i=0;i<N;i++){
     sort(ans.at(i).begin(),ans.at(i).end());
    
     if(ans.at(i).at(ans.at(i).size()-1)==H[i]){
         if(ans.at(i).size()!=1){
             if(ans.at(i).at(ans.at(i).size()-1)!=ans.at(i).at(ans.at(i).size()-2))res++;
         }else{
             res++;
         }
 }
 }
 cout<<res<<endl;
 }


 
    
        






Measured memory_bytes: 9784
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    int res=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n-1;j++){
            if(s[i]!=s[j])continue;
            if(i>=1&&(s[i-1]==s[j-1]))continue;
            for(int p=0;p<n;p++){
                int px=p+i;
                int py=p+j;
                if(px>=j||py>=n)break;
                if(s[px]!=s[py])break;
                res=max(res,p+1);
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<cmath>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21)
		cout << "bust";
	else
		cout << "win";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    ll C;
    cin >> C;
    string S;
    cin >> S;
    vector<ll> L(K+1,0);
    vector<ll> R(K+1,0);
    ll memo=1;
    for(ll i=1;i<=K;i++){
        while(1){
            if(S[memo-1]=='o'){
                L[i]=memo;memo+=C+1;break;
            }
            else memo++;
        }
    ;}
    memo=N;
    for(ll i=K;i>=1;i--){
        while(1){
            if(S[memo-1]=='o'){
                R[i]=memo;memo-=C+1;break;
            }
            else memo--;
        }
    ;}
    ll counter=0;
    for(ll i=1;i<=K;i++){
        if(L[i]==R[i]){cout<<L[i]<<endl;}
    ;}

return 0;
}


Measured memory_bytes: 4996
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vector<vi> black(2010), white(2010), pre(2010), dp(2010);
//int black[2010][2010] = {0};
//int white[2010][2010] = {0};
//int pre[2010][2010] = {0};
//int dp[2010][2010] = {0};
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    vector<pair<int, char>> in(2*n);
    int ans = 0;

    FOR(i, n+1){
        black[i] = vi(n+1);
        white[i] = vi(n+1);
        pre[i] = vi(n+1);
        dp[i] = vi(n+1);
    }
    FOR(i, n*2){
        cin >> in[i].second>> in[i].first;
    }
    FOR(i, n*2){
        auto& val = in[i];
        if(val.second == 'B')swap(pre, black);
        else swap(pre, white);
        for(int j = i-1; j >= 0; j--){
            if(val.second == in[j].second && in[j].first > in[i].first)ans++;
            else if(val.second == in[j].second)continue;
            else{ 
               pre[in[i].first][in[j].first - 1]++; 
            }
        }
        for(int j = n-1; j >= 0; j--){
            pre[in[i].first][j] += pre[in[i].first][j+1];
        }
        if(val.second == 'B')swap(pre, black);
        else swap(pre, white);
    }
    FOR(i, n +1){// white squares
        FOR(j, n +1){ // black squres
            if(i == 0 && j == 0)continue;
            if(i == 0){
                dp[0][j] = dp[i][j-1] + black[j][0]; 
            }else if(j == 0){
                dp[i][j] = dp[i-1][j] + white[i][0];
            }else{
                dp[i][j] = min(dp[i][j-1] + black[j][i], dp[i-1][j] + white[i][j]);
            }
        }
    }

    cout << ans + dp[n][n];

}




Measured memory_bytes: 125696
#include <iostream>
#include <string>

using namespace std;

int main() {
    string need;
    cin >> need;
    int N;
    cin >> N;
    int ans = 0;
    while(N--) {
        string str;
        cin >> str;
        str += str;
        if(str.find(need) != string::npos) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func gcd(a, b int) int {
	if b > a {
		a, b = b, a
	}
	for {
		r := a % b
		if r == 0 {
			return b
		}
		a = b
		b = r
	}
}

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	r := gcd(a, b)
	for i := r; i > 0; i-- {
		if r%i == 0 {
			k--
		}
		if k == 0 {
			fmt.Println(i)
			break
		}
	}
}


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

typedef long long ll;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        sum += a.at(i);
    }
    ll sum_2 = sum/2;
    ll tmp = 0;
    for(i = 0;i < n;i += 2){
        tmp += a.at(i);
    }
    vector<ll> ans(n);
    ans.at(0) = (tmp-sum_2)*2;
    for(i = 1;i < n;++i){
        ans.at(i) = 2*(a.at(i-1) - ans.at(i-1)/2);
    }
    for(i = 0;i < n;++i){
        cout << ans.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::collections::HashMap;

fn main() {
    input! {
        _n: usize,
        s: chars
    }
    let mut map = HashMap::new();
    for ch in s {
        let counter = map.entry(ch).or_insert(0);
        *counter += 1;
    }
    let ans = map.values().into_iter().fold(0 as u64, |acc, c| {
        (acc + acc * c + c) % 1_000_000_007
    });
    println!("{}", ans);
}


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

const int MOD = 998244353;

int Mul(int x, int y) { return 1LL * x * y % MOD; }
int Add(int x, int y) { return (x += y) >= MOD ? x - MOD : x; }

int K, n, g[4020][4020], s[4020][4020], f[4020][4020];

int main(void) {
  scanf("%d%d", &K, &n);

  g[0][0] = 1;
  for(int j = 0; j <= n; j++)
    s[0][j] = 1;
  for(int i = 1; i <= K; i++) {
    for(int j = 0; j <= n; j++)
      g[i][j] = s[i - 1][j];

    s[i][0] = g[i][0];
    for(int j = 1; j <= n; j++)
      s[i][j] = Add(s[i][j - 1], g[i][j]);

  }

  f[0][0] = 1;
  for(int j = 0; j <= n; j++)
    s[0][j] = 1;
  for(int i = 1; i <= K; i++) {
    f[i][0] = 1;
    for(int j = 1; j <= n; j++)
      f[i][j] = Add(f[i - 1][j], Mul(2, s[i - 1][j - 1]));

    s[i][0] = f[i][0];
    for(int j = 1; j <= n; j++)
      s[i][j] = Add(s[i][j - 1], f[i][j]);
  }

  //cerr << f[1][0] * g[1][3] << endl;
  for(int i = 2; i <= K; i++) {
    int cnt = K - i + 1, pp = 0;
    if(i % 2 == 0) pp = 1;
    
    int Ans = 0;
    for(int j = 0; j <= n; j++) {
      Ans = Add(Ans, Mul(f[(K - cnt - pp) / 2][j], g[cnt][n - j]));
      if(i % 2 == 0 && n > j)
	Ans = Add(Ans, Mul(f[(K - cnt - pp) / 2][j], g[cnt][n - j - 1]));
    }
    cout << Ans << endl;
  }

  for(int i = K + 1; i <= 2 * K; i++) {
    int cnt = 0, pp = 0;
    for(int j = 1; j <= K; j++)
      if(j + j == i) pp = 1;
      else if(i - j <= K);
      else cnt++;

    int Ans = 0;
    for(int j = 0; j <= n; j++) {
      
      Ans = Add(Ans, Mul(f[(K - cnt - pp) / 2][j], g[cnt][n - j]));
      if(i % 2 == 0 && n > j)
	Ans = Add(Ans, Mul(f[(K - cnt - pp) / 2][j], g[cnt][n - j - 1]));
    }
    cout << Ans << endl;
  }
  return 0;
}


Measured memory_bytes: 100096
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll M =1e9+7;
const int N = 1e5+7;



void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{
    ll n,d,c=0;
    lscf(n),lscf(d);
    
    rep(i,0,n)
    {
        ll x,y;
        lscf(x),lscf(y);
        
        if(x*x+y*y<=d*d)
        c++;
     
    }
    
    lprin(c);
    
    
    
        
}


Measured memory_bytes: 3812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = d[0], b = d[1];
            while (true)
            {
                if (a == 0)
                {
                    Console.WriteLine(b);
                    break;
                }
                if (b == 0) { Console.WriteLine(a); break; }
                if (a > b) { a = a - b; }
                else { b = b - a; }
            }
        }
    }
}

Measured memory_bytes: 9624
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(int i=0;i<3;i+=1){
			int sah,sam,sas,fah,fam,fas,h,m,s;
			sah=cin.nextInt();
			sam=cin.nextInt();
			sas=cin.nextInt();
			fah=cin.nextInt();
			fam=cin.nextInt();
			fas=cin.nextInt();
			h=fah-sah;
			m=fam-sam;
			s=fas-sas;
			if(s<0){
				s=s+60;
				m=m-1;
			}
			if(m<0){
				m=m+60;
				h=h-1;
			}
			System.out.println(h+" "+m+" "+s);
		}
	}
}

Measured memory_bytes: 17152
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MOD = 1e9 + 7;

int main() {
  ll N, M;
  cin >> N >> M;
  set<ll> broken;
  ll a;
  for (int i = 0; i < M; i++) {
    cin >> a;
    broken.insert(a);
  }
  vector<ll> dp(N + 1, 0);
  dp[0] = 1;
  for (int i = 1; i <= N; i++) {
    if (broken.find(i) != broken.end()) continue;
    if (broken.find(i - 1) == broken.end()) {
      dp[i] = (dp[i] + dp[i - 1]) % MOD;
    }
    if (0 <= i - 2 && broken.find(i - 2) == broken.end()) {
      dp[i] = (dp[i] + dp[i - 2]) % MOD;
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 8628
#include<stdio.h>
int main(void) {
	int n, p[20], i, cnt=0;
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		scanf("%d", &p[i]); 
	}
	for (i = 1;i <= n-2;i++) {
		if ((p[i - 1]<p[i] && p[i + 1]>p[i]) || (p[i - 1]>p[i] && p[i + 1]<p[i]))
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside.
//AVX is better slightly
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

int n, m;
unordered_map <int, bool> mp;

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //ifstream cin ("test.in");
    cin >> n >> m;
    bool flag = 1;
    for (int i=1; i<=m; i++){
        int oth = n - i + flag;
        if (mp[oth - i] || mp[n + i - oth] || oth - i == n + i - oth){
            oth--;
            flag = 0;
        }
        cout << i << ' ' << oth << '\n';
        mp[oth - i] = 1;
        mp[n + i - oth] = 1;
    }

    return 0;
}


Measured memory_bytes: 10668
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val Mod = 1000000007L
  val A = 0
  val C = 1
  val G = 2
  val T = 3
  val dp = Array.ofDim[Long](n + 1, 4, 4, 4)
  dp(0)(T)(T)(T) = 1

  def valid(p3: Int, p2: Int, p1: Int, cur: Int): Boolean = (p3, p2, p1, cur) match {
    case (_, A, G, C) |
         (_, G, A, C) |
         (_, A, C, G) |
         (A, _, G, C) |
         (A, G, _, C) => false
    case _ => true
  }

  for {
    i <- (1 to n)
    p3 <- (A to T)
    p2 <- (A to T)
    p1 <- (A to T)
    cur <- (A to T)
    if (valid(p3, p2, p1, cur))
  } {
    dp(i)(p2)(p1)(cur) = (dp(i)(p2)(p1)(cur) + dp(i - 1)(p3)(p2)(p1)) % Mod
  }
  println(dp(n).flatten.flatten.sum % Mod)
}

Measured memory_bytes: 30692
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define re(i,a,n) for(i=a;i<=n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second


ll binpow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return binpow(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll m,n,i,f=0,j,ans=0,k,x,r,l,t;
    cin >> n >> m >> k  ;
    if(k*m<n) cout << "No" ;
    else cout << "Yes" ;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int d = max(a, max(b, c));
  int e = min(a, min(b, c));
  int f = a + b + c - d - e;
  e = d - e;
  f = d - f;
  if((f - e)%2 == 0){
    if(f %2 == 0){
      // all even
      cout << f/2 + e/2 << endl;
    }else{
      cout << f/2 + e/2 + 1<< endl;      
    }
  }else{
    cout << f/2 + e/2 + 2 << endl;
  }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}


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

int main () {
  int n,m,c;
  cin >> n >> m >> c;
  vector<int>b(m);
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  vector<vector<int>>a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    sum+=c;
    if(sum>0){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	n, k := oneInt(), oneInt()

	sss := oneStr()

	ans := calc(sss, n, k)
	fmt.Println(ans)

}

type runLength struct {
	cnt int
	s   string
}

func calc(sss string, n, k int) int {
	nums := []runLength{{0, "1"}}

	tmp := ""
	for _, s := range sss {
		if tmp == "" {
			tmp = string(s)
			nums = append(nums, runLength{1, tmp})
		} else {
			if tmp == string(s) {
				nums[len(nums)-1].cnt++
			} else {
				tmp = string(s)
				nums = append(nums, runLength{1, tmp})
			}
		}
	}

	nums = append(nums, runLength{0, "1"})

	sums := []int{0}

	for i, n := range nums {
		sums = append(sums, sums[i]+n.cnt)
	}

	ans := -1
	right := 0

	for left := 0; left < len(sums)-1-right; left++ {
		right = min(len(sums)-1, 2*k+1)
		if nums[left].s == "0" {
			right = min(len(sums)-1, 2*k)
		}

		ans = max(ans, sums[right+left]-sums[left])
	}

	//fmt.Println(nums)
	//fmt.Println(sums)

	return ans
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define INF 2e9
#define x first
#define y second
using namespace std;
typedef pair<int,int> P;
P in[5002];
int n,m;
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>in[i].x>>in[i].y;
  sort(in,in+n);

  int a,b,c,d;  
  while(m--){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int cnt=0;
    for(int i=0;i<n;i++){
      if(in[i].x>c) break;
      if((a<=in[i].x&&b<=in[i].y&&in[i].y<=d))cnt++;
    }
    cout <<cnt<<endl;
  }
  return 0;
}

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

using namespace std;
using ll=long long;

int main()
{
   int n;cin >>n;
   int l[n+1];
   for(int i=0;i<n;i++){
    cin >> l[i];
   }
   l[n]=100100;
   sort(l,l+n);
   int ans=0;
   for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        int s=l[i]+l[j];
        int t=lower_bound(l,l+n,s)-l;
        t--;
        if(t==j||t==i)continue;
        if(l[t]>=s)continue;
        ans+=(t-j);
    }
   }
   cout << ans << endl;
    return 0;
}


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

void solve(string &s, ll &sum, int index, ll current, ll result){
  if (index == s.size()-1)
  {
    result += current;
    sum += result;
    return;
  }
  int digit = s.at(index+1) - '0';
  solve(s, sum, index+1, current*10 + digit, result);
  solve(s, sum, index+1, digit, result + current);
}

int main(){
  string s;
  cin >> s;
  ll sum = 0;
  solve(s, sum, 0, s.at(0) - '0', 0);
  cout << sum << endl;
}


Measured memory_bytes: 256
import math
a, b, c = map(int, input().split())
for k in range(60):
  t = math.ceil((k * (a + b) - c) / 60)
  if t <= (k * (a + b) + a - c) / 60:
    print(t * 60 + c)
    break
else:
  print(-1)



Measured memory_bytes: 5668
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc097_a.cpp
 * time   : Thu Apr 30 18:44:27 2020
 * quest  : A - Colorful Transceivers
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (abs(c - a) <= d ? "Yes" : (abs(b - a) <= d && abs(c - b) <= d) ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  uint64_t n;
  cin>>n;
  vector<int> hurui(n,-1);
  hurui[1]=1;
  uint64_t j;
  for(int i=2;i<n;i++){
    if(hurui[i]==-1){
      j=i;
      while(j<n){
        hurui[j]=i;
        j+=i;
      }
    }
  }
  int sum=0;
  int curr;
  int pow;
  uint64_t div;
  uint64_t rest;
  for(int i=1;i<n;i++){
    if(i==1){
      sum++;
    }else{
      curr=1;
      div=i;
      rest=i;
      while(div>1){
        pow=1;
        while(rest%hurui[div]==0){
          pow++;
          rest/=hurui[div];
        }
        curr*=pow;
        div=rest;
      }
      sum+=curr;
    }
  }
  cout<<sum<<endl;
}
    

Measured memory_bytes: 7144
import sys
fl=sys.stdout.flush
res=['Vacant','Male','Female']

def main():
    n=int(input())
    r=['' for _ in range(n)]
    print(0)
    fl()
    r[0]=input()
    if r[0]==res[0]:
        return
    
    print(n-1) # even
    r[n-1]=input()
    fl()
    if r[n-1]==res[0]:
        return
    ll,rr=0,n-1
    while rr-ll>1:
        mid=(rr+ll)//2
        print(mid)
        fl()
        r[mid]=input()
        if r[mid]==res[0]:
            return
        if (r[mid]==r[rr])^((rr-mid)%2==0):
            ll=mid
        else:
            rr=mid
    
main()


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

bool solve(vi os, vi es) {
	bool one = 0;
	for (int x : os) {
		if (x == 1) one = 1;
	}

	if (one) {
		int s = 0;
		for (int x : es) {
			s ^= 1;
		}
		return s;
	}

	if (es.size() % 2 == 1) {
		return 1;
	}

	if (os.size() >= 2) {
		return 0;
	}

	es.pb(os[0] - 1);
	int d = -1;
	for (int x : es) {
		if (d == -1) {
			d = x;
		} else {
			d = __gcd(d, x);
		}
	}

	vi _os, _es;
	for (int x : es) {
		int nx = x / d;
		if (nx & 1) {
			_os.pb(nx);
		} else {
			_es.pb(nx);
		}
	}
	return !solve(_os, _es);
}

int main() {
	int N;
	vi os, es;
	cin >> N;

	rep(i, N) {
		int x;
		cin >> x;
		if (x & 1) {
			os.pb(x);
		} else {
			es.pb(x);
		}
	}

	puts(solve(os, es) ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 19440
#include<stdio.h>
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=1;
	int i;
	for(i=0;i<n;i++)
	{
		if(ans*2<ans+k)
		  ans*=2;
		else
		  ans+=k;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int c[3][3];
	bool ok = false;
	rep(i, 0, 9) scanf("%d", &c[i/3][i%3]);
	rep(i, 0, 101) rep(j, 0, 101) rep(k, 0, 101){
		bool flag = true;
		rep(x, 0, 3){
			if(c[0][x]-i!=c[1][x]-j or c[1][x]-j!=c[2][x]-k) flag = false;
		}
		ok |= flag;
	}
	if(ok) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Long.parseLong;
import static java.lang.Integer.parseInt;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = parseInt(in.readLine());
      long[] seq = new long[n];

      for(int i=0; i<n; i++)
        seq[i] = parseLong(in.readLine());

      Arrays.parallelSort(seq);

      byte[] resU = new byte[n];  // /\/\Pattern
      byte[] resD = new byte[n];  // \/\/Pattern

      for(int i=0; i<n; i++) {
        if( i==0 ) {
          resU[i] = -1;
          resD[i] =  1;
        }
        else if( i==n-1 ) {
          resU[i] = (n&1) == 0 ? (byte)  1 : -1;
          resD[i] = (n&1) == 0 ? (byte) -1 :  1;
        }
        else {
          resU[i] = (i&1) == 1 ? (byte)  2 : -2;
          resD[i] = (i&1) == 1 ? (byte) -2 :  2; 
        }
      }
      Arrays.parallelSort(resU);
      Arrays.parallelSort(resD);

      long sumU=0,sumD=0;
      for(int i=0; i<n; i++) {
        sumU += seq[i] * resU[i];
        sumD += seq[i] * resD[i];
      }

      System.out.println(Math.max(sumU, sumD));
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

int main() {
    int N; cin >> N;
    string s; cin >> s;
    vector<string> pos{
        "SS", "SW", "WS", "WW"
    };
    rep(k, 4) {
        string t = pos[k];
        rep(i, N) {
            if (i == N-1) s += s[0];
            if (t[i+1] == 'S') {
                if (t[i] == 'S' && s[i+1] == 'o') t += 'S';
                if (t[i] == 'S' && s[i+1] == 'x') t += 'W';
                if (t[i] == 'W' && s[i+1] == 'o') t += 'W';
                if (t[i] == 'W' && s[i+1] == 'x') t += 'S';
            }
            else if (t[i+1] == 'W') {
                if (t[i] == 'S' && s[i+1] == 'o') t += 'W';
                if (t[i] == 'S' && s[i+1] == 'x') t += 'S';
                if (t[i] == 'W' && s[i+1] == 'o') t += 'S';
                if (t[i] == 'W' && s[i+1] == 'x') t += 'W';
            }
        }
        if (t[N] == t[0] && t[N+1] == t[1]) {
            cout << t.substr(0, N) << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 776
'use strict';

var hasN = false; // has N *only* line
var type = "b";
// a: 2D split
// b: space split
// c: line split
// z: other (only source)
function main(N, p, s) {
  // N, processed data, source
  var big = p[0] > p[1] ? 0 : 1;
  var a = 0;
  a += p[big];
  p[big]--;
  big = p[0] > p[1] ? 0 : 1;
  a += p[big];
  console.log(a);
}
function common(a) {
  var line = a.split('\n').slice(0, a.split('\n').length - 1);
  if (hasN) var N = Number(line.shift());
  switch (type) {
    case "a":
      main(N, line.map(function (e) {
        return e.split(' ').map(function (ee) {
          return Number(ee);
        });
      }), a);
      break;
    case "b":
      main(N, line[0].split(' ').map(function (e) {
        return Number(e);
      }), a);
      break;
    case "c":
      main(N, line, a);
      break;
    case "z":
      main(N, null, a);
  }
}
common(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22964
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
A = list(map(int, input().split()))

th = 1.0 * sum(A) / (4 * M)

sorted_A = sorted(A, key=lambda x: -x)
if sorted_A[M - 1] < th:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 2940