akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int n;
	cin >> n;
	int ans = Inf;
	for (int i = 1; i*i <= n; i++) {
		if (n % i == 0) {
			ans = min(ans, i - 1 + (n / i - 1));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(int i =(a);i<(n);i++)
#define urep(i,a,n) for(int i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

ll W, H, N,ans;
ll A[200000];
int main() {
	cin >> N;
	rep(i, 0, N) {
		cin >> A[i];
		A[i] -= (i + 1);
	}
	sort(A, A + N);
	ans = 0;
	ll mid;
	if (N % 2) {
		mid = A[N / 2];
	}
	else {
		mid = (A[N / 2] + A[N / 2 - 1]) / 2;
	}
	rep(i, 0, N) {
		ans += abs(A[i] - mid);
	}

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

Measured memory_bytes: 1792
using System;

namespace Range
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var a_b_c = input.Split(new Char[] { ' ' });
            var a = decimal.Parse(a_b_c[0]);
            var b = decimal.Parse(a_b_c[1]);
            var c = decimal.Parse(a_b_c[2]);

            if (a < b)
            {
                if (b < c)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 17968
import sys
counts = [0] * 26

s = sys.stdin.read()
	
for c in s:
	o = ord(c)
	if o >= 65 and o <= 90:
		counts[o - 65] += 1
	elif o >= 97 and o <= 122:
		counts[o - 97] += 1
	
for i in range(len(counts)):
	print(chr(i + 97) + ' : ' + str(counts[i]))



Measured memory_bytes: 5560
import random
D = int(input())
C = list(map(int, input().split()))

for i in range(D):
    input()

c = 0
j = 0
while(True):
    j += 1
    if j == 27:
        j = 1
    rng = random.randint(0, 100)
    if rng > C[j - 1]:
        continue
    c += 1
    print(j)
    if c == D:
        break


Measured memory_bytes: 9592
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 


const int M = 2e5;
const int MX=4*M;
const int MD=1e9+7;
int main() {
	ll a,b,c,tp;
	cin>>a>>b>>c;
	tp=c-a-b;
	if(tp<0){
		cout<<"No";
		return 0;
	}
	if(tp*tp>4*a*b)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int R,S,P;
int ans;
string t;
int main()
{
	int n,k;
	cin>>n>>k;
	cin>>R>>S>>P;
	cin>>t;
	for(int i=0;i<t.size();i++)
	{
		if(t[i]=='r')
		{
			if(i>=k&&t[i-k]=='r')
			{
				t[i]='#';
			}
			else 
			{
				ans+=P;
			}
		}
		if(t[i]=='s')
		{
			if(i>=k&&t[i-k]=='s')
			{
				t[i]='#';
			}
			else 
			{
				ans+=R;
			}
		}
		if(t[i]=='p')
		{
			if(i>=k&&t[i-k]=='p')
			{
				t[i]='#';
			}
			else
			{
				ans+=S;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
ll ceil(ll a, ll b){if((a%b) != 0) return a/b+1; return a/b;}
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

void solve(){
    ll m, n; cin >> n >> m;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }
    sort(a, a+n);
    ll s = 0 ;
    repr(i, n)
    {
        if(m == 0){
            s += a[i];
        }
        else m--;

    }
    cout << s;
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;   
    vector<pair<ll,ll> > t(n);
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        t[i] = make_pair(a,b);
    }
    sort(t.begin(),t.end());
    for(auto v : t){
        if(k-v.second<=0){
            cout<<v.first<<endl;
            return 0;
        }
        k-=v.second;
    }
}

Measured memory_bytes: 1792
#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;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 
 
 
#define pb push_back
 
// #define mp make_pair 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define itt iterator
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define isvowel(a) (a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_upda
#define MAX 1000001
 
#define maxn 1000005
#define eps 0.0000001




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

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

	
	int n,m;
	cin>>n>>m;

	int pen[n+1];
	bool ac[n+1];
	initialise(pen,0);
	initialise(ac,0);

	for(int i=0;i<m;i++)
	{
		int j;
		string s;
		cin>>j>>s;

		if(s=="AC")
		{
			ac[j]=1;
		}
		else
		{
			if(ac[j]) continue;
			pen[j]+=1;
		}
	}

	int ans=0,tp=0;

	for(int i=1;i<=n;i++)
	{
		if(ac[i]){
		ans+=ac[i];
		tp+=pen[i];}
	}

	cout<<ans<<" "<<tp<<'\n';

	
	
}

Measured memory_bytes: 768
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = float('inf')
for i in range(n-k+1):
    left = i
    right = i+k-1
    ans = min(ans, min(abs(x[left])+abs(x[right]-x[left]),abs(x[right])+abs(x[left]-x[right])))
print(ans)


Measured memory_bytes: 62576
n=int(input())
w=[input() for _ in range(n)]
flg=True
for i in range(1,n):
    if w[i-1][-1]!=w[i][0]:
        flg=False
ans=[]
for i in w:
    if i in ans:
        flg=False
    ans.append(i)
print("Yes" if flg else "No")    


Measured memory_bytes: 38384
<?php
 
$stdin = preg_split('/ /', trim(fgets(STDIN)));
$a = intval($stdin[0]);
$b = intval($stdin[1]);
 
if ($a > $b) {
    print("a > b\n");
} elseif ($a < $b) {
    print("a < b\n");
} else {
    print("a == b\n");
}

Measured memory_bytes: 15436
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n, k; cin >> n >> k;

  int cnt = n-1;
  k--;
  cout << (cnt+k-1)/k << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // みんなのプロコン2019C - When I hit my pocket...
  // 日本円との交換は2回の操作でB-A枚増加させることができる
  // 2回叩けば2枚増えるのでこれよりも少ない場合は交換しない
  // 交換可能な最低枚数を満たしていること
  // 最低枚数を満たすのに必要な回数が確保できない場合は交換しない（できない）
  // 2回必要なので残り1回なら叩くしかない
  ll K, A, B;
  cin >> K >> A >> B;
  if(B-A <= 2 || K <= A){ // 叩くだけで終わりのパターン
    cout << K + 1 << endl;
    return 0;
  }
  // 以下は交換を伴う処理の場合
  ll ans = 1;
  if(A > 1){ // 初期状態で最低枚数を満たしていない場合の前処理
    ans += A - 1;
    K -= A - 1;
  }
  if(K % 2 == 1){ // 奇数なら最後は叩く
    ans += (B - A) * (K / 2);
    ans++;
  }else{ // 偶数なら最後まで交換を続ける
    ans += (B - A) * (K / 2);  
  }
  cout << ans << endl;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left\n";
  else if (a + b < c + d) cout << "Right\n";
  else cout << "Balanced\n";
  return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> dp(n + 2, 1500000000);
    for(int i = 0; i < n; i++)cin >> a[i];
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        dp[i + 1] = min(dp[i] + abs(a[i] - a[i + 1]), dp[i + 1]);
        dp[i + 2] = min(dp[i] + abs(a[i] - a[i + 2]), dp[i + 2]);
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e6+9;
const ll mod = 1e9+7;

bool vis[1000];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	if (s.length() < 26) {
		cout << s;
		for (char c = 'a'; c <= 'z'; c++) {
			bool f = true;
			for (int i = 0; i < s.length(); i++)
				if (s[i] == c)
					f = false;
			if (f) {
				cout << c << "\n";
				return 0;
			}
		}
	}
	for (int i = s.length() - 1; i >= 0; i--) {
		bool f = false;
		char cur;
		for (char c = s[i] + 1; c <= 'z'; c++)
			if (vis[c]) {
				cur = c;
				f = true;
				break;
			}
		if (f) {
			for (int  t = 0; t < i; t++)
				cout << s[t];
			cout << cur << "\n";
			return 0;
		}
		vis[s[i]] = true;
	}
	cout << "-1\n";
}

Measured memory_bytes: 256
from collections import defaultdict
S = input()
dict = defaultdict(int)

for s in S:
    dict[s] += 1

ans = 10 ** 3
for c in dict.keys():
    max_seq = 0
    tmp = -1
    for i, s in enumerate(S):
        if s == c:
            max_seq = max(max_seq, i - tmp - 1)
            tmp = i
    max_seq = max(max_seq, len(S)-tmp-1)
    ans = min(max_seq, ans)
print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int X,Y;
    cin >> X >> Y;
    for(int i = 0; i <= X; i++){
        int x = i;
        int y = X - x;
        if(2*x + 4*y == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		System.out.println(solve(1, N));
	}

	private static long solve(long a, long b) {
		if (a >= b) return 0;
		if (b == 2) return 1;

		long p = 1;
		for (long i = 2; i * i <= b + 1; i++) {
			if ((b + 1) % i == 0) {
				p = (b + 1) / i;
				break;
			}
		}

		long v = b * (b - 1) / 2 - (p - 1) * (p - 2) / 2;
		return solve(a, p - 1) + v;
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    String[] b = String.valueOf(a).split("");
    
    String a1 = b[0];
    String a2 = b[1];
    String a3 = b[2];
    String a4 = b[3];
    
    if (a1.equals(a2) && a2.equals(a3)) {
      System.out.println("Yes");
    } else if (a2.equals(a3) && a3.equals(a4)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

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

using namespace std;

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    vt<int> a(9);
    for (int &x : a) cin >> x;

    vt<int> b(3);
    for (int i = 0; i < 3; i++) {
        int mn = *min_element(a.begin() + i * 3, a.begin() + i * 3 + 3);
        for (int j = 0; j < 3; j++) {
            if (!i) b[j] = a[j] - mn;
            else if (b[j] != a[i * 3 + j] - mn)
                return void(cout << "No");
        }
    }

    cout << "Yes";
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}



Measured memory_bytes: 3648
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        double k = (double)(l / 3.0);
        double tai = k * k * k;
        System.out.println(tai);
        sc.close();
    }
}

Measured memory_bytes: 36020
#include "bits/stdc++.h"
using namespace std;

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e3;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};



void solve(){
  int n,wt;
  cin>>n>>wt;

  vi v(n+1,0),w(n+1,0);

  rep(i,1,n+1)
	   cin>>w[i]>>v[i];

  vi a(1e5+2,1e18);
  a[0]=0;

  rep(i,1,n+1){

   for(int j=1e5-v[i];j>=0;j--)
	    a[j+v[i]]=min(a[j+v[i]],a[j]+w[i]);
  }

  
  for(int j=1e5;j>=0;j--){
    if(a[j]<=wt){
		cout<<j<<endl;
		return;
	}
  }
  
}



int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	   
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int N;
  cin >> N;
  map<string, int> m;
  REP(i, N) {
    string S;
    cin >> S;
    m[S]++;
  }
  int maxc = 0;
  vector<string> maxby;
  for(auto x : m) {
    if(x.second > maxc) {
      maxc = x.second;
      maxby.clear();
    }
    if(x.second >= maxc) {
      maxby.push_back(x.first);
    }
  }
  sort(maxby.begin(), maxby.end());
  for(auto x : maxby) {
    cout << x << endl;
  }
}

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

int main(){
  int a,b,c,d,x;
  cin >> a;
  b=a-a%100;//100の位
  c=(a-b)-(a-b)%10;//10の位
  d=a-b-c;//1の位
  x=b/100+c/10+d;
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
char s[12];
cin>>s;

ll res=0;
int n = strlen(s);
for(int i=0;i<(1<<(n-1));i++){
    ll cur=0;
    for(int j=0;j<n;j++){
        cur=cur*10+s[j]-'0';
        if(i & (1<<j)){
            res+=cur;
            cur=0;
        }
    }
    res+=cur;
}
cout<<res<<endl;
return 0;
}

Measured memory_bytes: 256
/*" بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ -In the name of Allah."
   Never stop chasing!-MD.SOURAV.

   ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
   ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
   ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
   [███████████████████].░░░░░░░░░░░░░░
   ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░
*/

#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li              ong int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define MOD 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
#define ignore         cin.ignore (std::numeric_limits<std::streamsize>::max(),'\n');
#define MAX 32000

using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpllll;
typedef vector<pair<int,int>> vpiiii;
typedef map<ll,ll> mllll;
typedef map<char,ll> mchll;
typedef map<string,ll>msll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

      int n;
      cin>>n;
      vector<ll>v;
      enter(v,n);
      int cnt=0;
      //srt(v);
      for(int i=0;i<n-2;i++)
	  {
	  	  for(int j=i+1;j<n-1;j++)
		  {
		  	 if(v[j]!=v[i])
			 {

			 	for(int k=j+1;k<n;k++)
				{
					if(v[k]!=v[j] && v[k]!=v[i])
					{
						if((v[i]+v[j]>v[k]) )
								{
									if(v[j]+v[k]>v[i])
									{
										if(v[i]+v[k]>v[j])
										{
											cnt++;
										}
									}
								}
					}
				}
			 }
		  }
	  }
	  cout << cnt << endl;



}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

double solve(double r, int N) {
    double EPS = 1e-9;
    vector<int> L(N);
    vector<int> R(N);
    vector<int> H(N);
    vector<int> h(45);
    for (int i = 0; i < N; i++) {
        cin >> L[i] >> R[i] >> H[i];
    }
    for (int i = 0; i < N; i++) {
        for (int j = L[i] +20; j < R[i] +20 ; j++) {
            h[j] = max(h[j], H[i]);
        }
    }
    vector<int> tmp(45);
    for (int i = 1; i < 45; i++) {
        tmp[i] = min(h[i], h[i-1]);
    }
    h = tmp;

    bool flag = true;
    int center = -r;
    while (flag) {
        for (int i = 0; i < 45; i++) {
            if ((double)r - sqrt((double)((20-i)*(20-i) + (h[i]-center)*(h[i]-center))) > EPS) {
                flag = false;
                break;
            }
            if (i == 44) center++;
        }
    }
    
    double ng, mid, ok;
    ng = center, ok = center-1;
    for (int i = 0; i < 100; i++) {
        mid = (ok + ng) / 2.0;
        bool flag = true;
        for (int i = 0; i < 45; i++) {
            if ((double)r - sqrt((double)((20-i)*(20-i) + (h[i]-mid)*(h[i]-mid))) > EPS) {
                flag = false;
                break;
            }
            if (i == 44) center++;
        }
        if (flag){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok + r;
}

int main(void) {
    double R;
    int N;
    vector<double> ans;
    while (1) {
        cin >> R >> N;
        if (R == 0 && N == 0) break;
        ans.push_back(solve(R, N));
    }
    for (auto &i: ans) {
        printf("%f\n", i);
    }
}




Measured memory_bytes: 3256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
vector<vector<int>> G;
int dfs(int i ,int& count) {
	count++;
	if (i == 0){
		return count;
	}
	for (auto j : G[i]) {
		if (j == i) {
			continue;
		}
		dfs(j,count);
	}
}
int main() {
	int N, M;
	cin >> N >> M;
	G.resize(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> rec(N,0);
		vector<int> dist(N, -1);
		queue<int> que;
		dist[0] = 0;
		que.push(0);
		while (!que.empty()) {
			int v = que.front();
			que.pop();
			for (int nv : G[v]) {
				if (dist[nv] != -1) continue;
				dist[nv] = dist[v] + 1;
				que.push(nv);
				rec[nv] = v + 1;
			}
		}
	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (rec[i] == 0) {
			ans++;
		}
	}
		cout << "Yes" << endl;
		for (int i = 1; i < N; i++) {
			cout << rec[i] << endl;
		}
}

Measured memory_bytes: 10568
H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A+=[a]
  B+=[b]
dp=[[float('inf') for i in range(H+1)]for i in range(N+1)]#i番めの魔法までを使って体力j減らすのに必要な魔力の最小値
dp[0][0]=0
for i in range(1,N+1):
  for j in range(H+1):
    if j>=A[i-1]:
      Ai=A[i-1]
      Bi=B[i-1]
      dp[i][j]=min(dp[i][j-Ai]+Bi,dp[i-1][j])
    else:
      dp[i][j]=min(dp[i-1][j],B[i-1])
ans=dp[N][H]
print(ans)

Measured memory_bytes: 305544
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    map<ll,ll> h;
    rep(i,n){
        ll a;
        cin >> a;
        h[a]++;
    }
    vector<pll> ans;
    for(auto x:h){
        ans.push_back(x);
    }
    sort(ans.rbegin(),ans.rend());
    ll m=ans.size();
    ll cnt=0;
    ll s=1;
    vector<ll> b(2);
    rep(i,m){
        if(ans[i].se>=2){
            b[cnt]=ans[i].fi;
            ans[i].se-=2;
            cnt++;
            i--;
        }
        if(cnt==2) break;
    }
    rep(i,2){
        s*=b[i];
    }
    cout << s << endl;
    return 0;
} 

Measured memory_bytes: 11512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n;
    string s;
    cin >> n >> s;
    
    vector<int> a(n);
    auto construct = [&](){
        for(int i = 1; i + 1 < n; ++i){
            int val = a[i];
            if(s[i] == 'x') val ^= 1;
            a[i + 1] = a[i - 1] ^ val;
        }
        return;
    };
    auto judge = [&](){
        bool res = true;
        if(s[n - 1] == 'o'){
            if(a[n - 1])    res &= (a[0] != a[n - 2]);
            else    res &= (a[0] == a[n - 2]);
        } else {
            if(a[n - 1])    res &= (a[0] == a[n - 2]);
            else    res &= (a[0] != a[n - 2]);
        }
        if(s[0] == 'o'){
            if(a[0])    res &= (a[1] != a[n - 1]);
            else    res &= (a[1] == a[n - 1]);
        } else {
            if(a[0])    res &= (a[1] == a[n - 1]);
            else    res &= (a[1] != a[n - 1]);
        }
        return res;
    };
    auto output = [&](){
        for(int i = 0; i < n; ++i){
            if(a[i])    cout << 'W';
            else    cout << 'S';
        }
        cout << endl;
        return;
    };

    for(int i = 0; i <= 1; ++i){
        a[0] = i;
        for(int j = 0; j <= 1; ++j){
            a[1] = j;
            construct();
            if(judge()){
                output();
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int l=k,r=n+1;
    long double ans=0;
    rep(i,20){
        if(l<r)ans+=(long double)1.0*(r-l)/n*pow(.5,i);
        r=min(l,n+1);
        l=(l+1)/2;
    }
    cout<<setprecision(12)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int n,i;
  scanf("%d", &n);
  int m[n];
  int boss[n];
  for (i = 0; i <= n; i++)
    boss[i] = 0;
  for (i = 2; i <= n; i++)
  {
    scanf("%d", &m[i]);
    boss[m[i]]++;
  }
  for(i = 1; i <= n; i++)
    printf("%d\n", boss[i]);
  return (0);
}

Measured memory_bytes: 3284
n = int(input())
a = [int(i) for i in input().split()]

max_n = max(a)
min_n = min(a)

if abs(max_n - min_n) > abs(min_n - max_n):
    print(abs(max_n - min_n))
else:
    print(abs(min_n - max_n))


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N; cin >> N;
  vector<ll> a(N); rep(i,N) cin >> a[i];

  ll t = 0;
  rep(i,N){
    t = t ^ a[i];
  }

  vector<ll> ans(N);
  rep(i,N){
    ans[i] = t ^ a[i];
    cout << ans[i] << " ";
  }
  cout << endl;
}


Measured memory_bytes: 6232
fun main() {
    val k = readLine()!!.toInt()
    val input = readLine()!!.split(" ")
    val a = input[0].toInt()
    val b = input[1].toInt()
    var result = "NG"
    var i = k

    run loop@{
        while (i <= b) {
            if (i in a..b) {
                result = "OK"
                return@loop
            }
            i += k
        }
    }
    println(result)
}

Measured memory_bytes: 35620
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

char d(char a){
    if(a=='T')return 'a';
    if(a=='L')return 'i';
    if(a=='U')return 'u';
    if(a=='R')return 'e';
    if(a=='D')return 'o';
    return '\0';
}


string first(char s1,char s2){
    char data[]={'w','-','k','s','t','n','h','m','y','r'};
    
    if(s1=='0' && s2=='U')return "nn";
    if(s1=='1'){
        string a="";
        a+=d(s2);
        return a;
    }
    string a;
    a+=data[s1-'0'];
    a+=d(s2);
    return a;
}

int main(){
    string ans="";
    string s;
    cin>>s;
    for(int i=0;i<s.sz;i+=2){
        ans+=first( s[i],s[i+1] );
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x,t;

int main(){
	cin>>x>>t;
	cout<<max(0,x-t)<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int[] inputs = Stream.of(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		int ans = 0;
		for(int i = 0; i <= inputs[0];i++) {
			int sum = Stream.of(String.valueOf(i).split("")).mapToInt(Integer::parseInt).sum();
			if(inputs[1] <= sum && sum <= inputs[2]) ans += i; 
		}
		System.out.println(ans);
	}
}

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

int main(){
    int n;
    int wh[128]={0};
    int k=0;
    while(scanf("%d",&n),n){
        int c[150000]={0};
        for(int i=1;i<=n;i++){
            scanf("%d",&c[i]);
            c[0]=c[i];
            if(i%2==0){
                int j=i-1;
                if(c[i]!=c[i-1] && c[i]==1){
                    for(;;){
                        if(c[i]==c[j])break;
                        c[j]=1;
                        j--;
                    }
                }else if(c[i]!=c[i-1] && c[i]==0){
                    for(;;){
                        if(c[i]==c[j])break;
                        c[j]=0;
                        j--;
                    }
                }
            }
        }
        int cnt[128]={0};

        for(int i=1;i<=n;i++){
            if(c[i]==0)cnt[k]++;
            wh[k]=cnt[k];
        }
        wh[k]=cnt[k];
        k++;
    }
    for(int i=0;i<k;i++){
        printf("%d\n",wh[i]);
    }
    return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
using namespace std;


int main()
{
	int w, h, n,maxX=0,minX=10000,maxY=0,minY=100000;
	cin >> w >> h >> n;
	vector<int>x(n),y(n),a(n);
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> a[i];
	x.push_back(w);
	y.push_back(0);
	a.push_back(2);
	x.push_back(0);
	y.push_back(h);
	a.push_back(4);
	for (int i = 0; i < a.size(); i++) {
		switch (a[i]) {
			case 1:maxX = max(maxX, x[i]); break;
			case 2:minX = min(minX, x[i]); break;
			case 3:maxY = max(maxY, y[i]); break;
			case 4:minY = min(minY, y[i]); break;
		}
	}
	cout << (minX-maxX)*(minY-maxY)*(minX>maxX && minY>maxY) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include<unordered_map>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
ll floorRoot5(ll n) 
{ 
    // Base cases 
    if (n == 0 || n == 1) 
       return n; 
  
    // Do Binary Search for floor of 5th square root 
    ll low = 1, high = n, ans = 0; 
    while (low <= high) 
    { 
        // Find the middle point and its power 5 
        ll mid = (low + high) / 2; 
        ll mid5 = mid*mid*mid*mid*mid; 
  
        // If mid is the required root 
        if (mid5 == n) 
            return mid; 
  
        // Since we need floor, we update answer when 
        // mid5 is smaller than n, and move closer to 
        // 5'th root 
        if (mid5 < n) 
        { 
            low = mid + 1; 
            ans = mid; 
        } 
        else // If mid^5 is greater than n 
            high = mid - 1; 
    } 
    return ans; 
}
bool check(ll x){
    if(power1(floorRoot5(x), 5) == x){return 1;}
    return 0;
}
int main(){
    fast;
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        ll n;
        cin >> n;
        ll a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        map<ll, ll> m;
        for(int j = 1; j <= n; j++){
            if(j > a[j - 1]){
                m[(j - a[j - 1])]++;
            }
        }
        ll o = 0;
        for(int i = 1; i <= n; i++){
            ll cur = i + a[i - 1];
            o += m[cur];
            if(m.count(i - a[i - 1])){
                m[(i - a[i])]--;
            }
        }
        cout << o << endl;
    }
}

Measured memory_bytes: 21580
n=int(input())
p=list(map(int,input().split()))
ind=[0]*n
for i in range(n):ind[p[i]-1]=i+1
l=[0]+[i for i in range(n+1)]
r=[i+1 for i in range(n+1)]+[n+1]
ans=0
for i in range(n):
  ans+=(r[r[ind[i]]]-r[ind[i]])*(ind[i]-l[ind[i]])*(i+1)
  ans+=(l[ind[i]]-l[l[ind[i]]])*(r[ind[i]]-ind[i])*(i+1)
  l[r[ind[i]]],r[l[ind[i]]]=l[ind[i]],r[ind[i]]
print(ans)

Measured memory_bytes: 20168
import sys
H,W = map(int,input().split())
h,w = map(int,input().split())
array = [[0]*W for I in range(H)]
# fill Horizone 1
for I in range(h):
    array[I] = [1]*W
# replace Horizone and Vertical
array = [list(x) for x in zip(*array)]
# fill Horizone 1
for I in range(w):
    array[I] = [1]*H
# replace Horizone and Vertical
array = [list(x) for x in zip(*array)]

count = 0
for I in range(H):
    count += array[I].count(0)
print(count)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define ui64 uint64_ti
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define kpair pair<int, pair<int,int>
#define lwb lower_bound
#define upb upper_bound
const int mod = 1e9+7;
const int maxn = 1e5;

using namespace std;
ifstream fi("");
ofstream fo("");
ll maxv[100001];
ll n,wmax,w,v,res=0;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>wmax;
    for(int i=0;i<n;i++){
        cin>>w>>v;
        for(int j = wmax;j>=w;j--) maxv[j]= max(maxv[j-w]+v,maxv[j]);
    }
    for(int i=0;i<=wmax;i++){
        res = max(res,maxv[i]);
    }
    //cout<<endl;
    cout<<res;
}





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

using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> v(s.size());
	v[0] = 0;
	for (int i = 1; i < v.size(); i++) v[i] = v[i - 1] + (s[i - 1] != s[i]);
	cout << v.back() << endl;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,ans;
double x[101],y[101],a[101][101];
int main(){
  while(cin>>n,n){
    ans=0;
    r(i,n)scanf("%lf,%lf",&x[i],&y[i]);
    r(i,1000)r(j,1000){
      int a=0;
      r(k,n)if((x[k]-(double)i/100)*(x[k]-(double)i/100)+(y[k]-(double)j/100)*(y[k]-(double)j/100)<=1)a++;
      ans=max(a,ans);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3080
// a template for main.cpp
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x : a) cin >> x;
    map<int, int> m;
	ll ans = 0;
    for (int i = 0; i < n; i++) {
    	int in = i + 1;
    	int now = -a[i] - in;
    	ans += m[a[i] - in];
    	m[now]++;
    }
    cout << ans << endl;
}


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

const int N = 2e5 + 10;
int a[N];
bool mark[N];

int main() {
	int n, x;
  	cin >> n >> x;
  	cout << (x != 1 && x != 2 * n - 1? "Yes": "No") << endl;
	if(x != 1 && x != 2 * n - 1) {
    	a[n] = x;
      	a[n + 1] = x + 1;
      	a[n - 1] = x - 1;
      	mark[x] = true;
      	mark[x + 1] = true;
      	mark[x - 1] = true;
      	if(n >= 2) {
        	if(x > 2) {
            	mark[x - 2] = true;
            	a[n + 2] = x - 2;
            }
            else {
            	mark[x + 2] = true;
            	a[n - 2] = x + 2;
            }
        }
     	int cnt = 1;
      	for (int i = 1; i <= 2 * n - 1; i++) {
          	while(mark[cnt])
          		cnt++;
      		if(!a[i]) {
            	a[i] = cnt;
            	mark[cnt] = true;
            }
        }
    }
	if(x != 1 && x != 2 * n - 1)
    	for (int i = 1; i <= 2 * n - 1; i++)
        	cout << a[i] << endl;
 	return 0;
} 

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

int main(){
    int N;
    cin >> N;
    vector<pair<double,string> > vec(N);
    for (int i = 0; i < N; i++){
        cin >> vec.at(i).first >> vec.at(i).second;
    }
    double money = 0;
    for (int i = 0; i < N; i++){
        if (vec.at(i).second == "JPY"){
            money += vec.at(i).first;
        }
        else if (vec.at(i).second == "BTC"){
            money += vec.at(i).first * 380000.0;
        }
    }
    cout << money << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
struct node 
{
	int v,rk1,rk2; 
}a[2001];
const long long mod=1e9+7;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i].v);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i].v>a[j].v)
			{
				a[i].rk1++;
				if(j>i)
				  a[i].rk2++;
			}
		}
	}
	/*for(int i=1;i<=n;i++)
	  cout<<a[i].rk1<<" "<<a[i].rk2<<endl;*/
	long long ans=0; 
	for(int i=1;i<=n;i++)
	{
		ans=((long long)(ans+(long long)a[i].rk2*k))%mod;
		ans=((long long)(ans+((long long)((k-1))*k)/2%mod*a[i].rk1))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
const main = async () => {
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()
  
  let setting = input.split('\n')

const process = setting[0]

setting.shift()

let answer = {
  'AC': 0,
  'WA': 0,
  'TLE': 0,
  'RE': 0
}

setting.map((key) => {
  answer[key]++
})


Object.keys(answer).map((key) => {
  console.log(key + ' x ' + answer[key])
})
}

main()

Measured memory_bytes: 37140
num = input()

for bit in range(2**3):
    op = ["+", "+", "+"]
    for i in range(3):
        if (bit >> i) & 1:
            op[i] = "-"
    if eval(num[0]+op[0]+num[1]+op[1]+num[2]+op[2]+num[3]) == 7:
        print("{}=7".format(num[0]+op[0]+num[1]+op[1]+num[2]+op[2]+num[3]))
        break


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

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
#define MOD 1e9+7
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;
int n;
vl H, S;

struct UnionFind {

    vector<int> par;
    vector<int> rank;
    vector<int> size;

    UnionFind(int N) : par(N), rank(N), size(N) {
        REP(i, N) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    
    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (rank[x] > rank[y]) {
            par[y] = x;
            size[x] += size[y];
        } else {
            par[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

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

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

int main() {
    ll N, M;
    cin >> N >> M;

    vi A, B;
    A.resize(M);
    B.resize(M);

    UnionFind uf(N);

    REP(i, M) {
        cin >> A[i] >> B[i];
        --A[i]; --B[i];
    }

    vl ans;
    ans.resize(M);
    ans[M-1] = N*(N-1)/2;
    REPD(i, M-1) {
        if (!uf.same(A[i+1], B[i+1])) {
            ans[i] = ans[i+1]-uf.ret_size(uf.find(A[i+1]))*uf.ret_size(B[i+1]);
            uf.unite(A[i+1], B[i+1]);
        } else {
            ans[i] = ans[i+1];
        }
    }

    REP(i, M) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
		cin >> H >> W;
		if(H==0 && W==0)	break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j)%2==0)	cout<<"#";
				else			cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152