akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<map>
using namespace std;

int main(){

int a,b,c,count;
std::vector<int> v;



std::cin >> a>>b>>c;


  v.push_back(a);
  v.push_back(b);
  v.push_back(c);



while(!(v[0]==v[1]&&v[1]==v[2])){

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


  if(v[0]+2<=v[2]){
    v[0]=v[0]+2;
    count++;
  }
  else{
    v[0]++;
    v[1]++;
    count++;
  }
}



std::cout << count << '\n';


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	vector<int> is(26);
	int n = s.size();
	rep(i, n) {
		is[s[i] - 'a']++;
	}
	bool ok = true;
	for (int i : is) {
		if (i % 2 == 1) ok = false;
	}
	if (ok) printf("%s\n", "Yes");
	else printf("%s\n", "No");
	return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, K = map(int, input().split())
P = list(map(int, input().split()))

P.sort()
ans = sum(P[:K])
print(ans)

Measured memory_bytes: 9244
//Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#define ll long long
#define inf 20021225
#define N 100010
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int a[N<<1],tmp[N<<1],n;
bool check(int x)
{
	for(int i=1;i<(n<<1);i++)	tmp[i]=a[i]>=x;
	int mid=n;
	for(int d=0;d<n-1;d++)
	{
		if(tmp[mid-d-1]==tmp[mid-d])	return tmp[mid-d];
		if(tmp[mid+d+1]==tmp[mid+d])	return tmp[mid+d];
	}
	return tmp[1];
}
int main()
{
	n=read(); int mx=1;
	for(int i=1;i<(n<<1);i++)	a[i]=read(),mx=max(mx,a[i]);
	int l=1,r=mx,ans=1;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(check(mid))	l=mid+1,ans=mid;
		else	r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))

MOD = 10**9+7
w_sum = 0
for i in range(N//2):
    times = N-1 - i*2
    w = X[-1-i] - X[i]
    w_sum += (w*times)%MOD
    w_sum %= MOD

h_sum = 0
for i in range(M//2):
    times = M-1 - i*2
    h = Y[-1-i] - Y[i]
    h_sum += (h*times)%MOD
    h_sum %= MOD

print((w_sum * h_sum) % MOD)

Measured memory_bytes: 18624
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)

typedef struct {
	int a;
	int b;
}line; //ax+b

typedef struct LCST_node_sub{
	line l;
	struct LCST_node_sub *left;
	struct LCST_node_sub *right;
}LCST_node;

typedef struct {
	int domain_min; //xの取る最小値
	int domain_max; //xの取る最大値
	LCST_node *root;
}LCST;

int min(int a, int b){
	return a <= b ? a : b;
}

int calc(int x, line l){
	return l.a * x + l.b;
}

//定義域が[domain_min, domain_max)のLi Chao Segment Treeを作る
LCST *make_LCST(int domain_min, int domain_max){
	LCST *lcst = (LCST *)malloc(sizeof(LCST));
	lcst->domain_min = domain_min;
	lcst->domain_max = domain_max;
	lcst->root = NULL;
	return lcst;
}

LCST_node *add_line_LCST_sub(line l, int dmin, int dmax, LCST_node *r){
//	printf("(l ,dmin, dmax) = ((%d, %d), %d, %d)\n", l.a, l.b, dmin, dmax);
	if(r == NULL){
		LCST_node *newr;
		newr = (LCST_node *)malloc(sizeof(LCST_node));
		newr->l = l;
		newr->left = NULL;
		newr->right = NULL;
		return newr;
	}
	else{
		int dmid = (dmin + dmax) / 2;
		int sub_left = calc(dmin, l) - calc(dmin, r->l);
		int sub_right = calc(dmax, l) - calc(dmax, r->l);
		int sub_half = calc(dmid, l) - calc(dmid, r->l);
		if(sub_half < 0){
			line tmp = l;
			l = r->l;
			r->l = tmp;
			sub_left = -sub_left;
			sub_right = -sub_right;
			sub_half = -sub_half;
		}
		if((sub_left >= 0 && sub_right >= 0) || dmax - dmin == 1){
			return r;
		}
		else if(sub_left >= 0){
			r->right = add_line_LCST_sub(l, dmid, dmax, r->right);
			return r;
		}
		else{
			r->left = add_line_LCST_sub(l, dmin, dmid, r->left);
			return r;
		}
	}
}

//lcstに直線lを追加する
void add_line_LCST(line l, LCST *lcst){
	lcst->root = add_line_LCST_sub(l, lcst->domain_min, lcst->domain_max, lcst->root);
}

int query_LCST_sub(int x, int dmin, int dmax, LCST_node *r){
	if(r == NULL){
		return inf;
	}
	else{
		int dmid = (dmin + dmax) / 2;
		if(x < dmid){
			return min(calc(x, r->l), query_LCST_sub(x, dmin, dmid, r->left));
		}
		else{
			return min(calc(x, r->l), query_LCST_sub(x, dmid, dmax, r->right));
		}
	}
}

//min{l(x) | l∊lcst} を求める
int query_LCST(int x, LCST *lcst){
	return query_LCST_sub(x, lcst->domain_min, lcst->domain_max, lcst->root);
}

signed main(){
	int N, C, i;
	scanf("%lld%lld", &N, &C);
	int *h = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &h[i]);
	}
	LCST *lcst = make_LCST(0, 1000001);
	int val = 0;
	for(i = 1; i < N; i++){
		add_line_LCST((line){-2 * h[i - 1], val + h[i - 1] * h[i - 1]}, lcst);
		val = h[i] * h[i] + C + query_LCST(h[i], lcst);
	}
	printf("%lld\n", val);
	return 0;
}

Measured memory_bytes: 11136
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int n = s.size(), m = t.size();

	vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	string res = "";
	
	int i = n, j = m;

	while (i > 0 && j > 0) {
		if (s[i - 1] == t[j - 1]) {
			res += s[i - 1];
			i--;
			j--;
		}
		else if (dp[i - 1][j] > dp[i][j - 1]) {
			i--;
		}
		else j--;
	}

	reverse(res.begin(), res.end());

	cout << res << endl;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,m,c;
  while(cin>>n>>m>>c,n){
    using P = pair<int, int>;
    vector< vector<P> > G(n);
    for(int i=0;i<m;i++){
      int u,v,w;
      cin>>u>>v>>w;
      u--;v--;
      G[u].emplace_back(v,w);
    }

    using PP = pair<int, P>;
    priority_queue<PP, vector<PP>, greater<PP> > pq;
    const int INF = 1e9;
    vector< vector<int> > dist(n+1,vector<int>(n,INF));
    dist[0][0]=0;
    pq.emplace(dist[0][0],P(0,0));

    while(!pq.empty()){
      int d=pq.top().first;
      int x,v;
      tie(x,v)=pq.top().second;
      pq.pop();
      if(dist[x][v]<d) continue;

      for(auto e:G[v]){
        int y=x,u=e.first,w=e.second;
        if(dist[y][u]<=dist[x][v]+w) continue;
        dist[y][u]=dist[x][v]+w;
        pq.emplace(dist[y][u],P(y,u));
      }

      if(x==n) continue;
      for(auto e:G[v]){
        int y=x+1,u=e.first,w=0;
        if(dist[y][u]<=dist[x][v]+w) continue;
        dist[y][u]=dist[x][v]+w;
        pq.emplace(dist[y][u],P(y,u));
      }
    }

    for(int i=0;i<=n;i++){
      if(dist[i][n-1]<=c){
        cout<<i<<endl;
        break;
      }
    }
  }
  return 0;
}



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

using namespace std;

int main(){
  int n,m;
  int l,r;
  cin>>n>>m;
  vector<int> gate(n);
  for(int kk=0;kk<n;kk++){
    gate[kk]=0;
  }
  //vector<int> R(n);
  int tmpl=0;
  int tmpr=100000;
  for(int i=0;i<m;i++){
    cin>>l>>r;
    if(tmpl<l){
      tmpl=l;
    }
    if(tmpr>r){
      tmpr=r;
    }
  }
  int ans=0;
  for(int k=l-1;k<r;k++){
    if(gate[k]==m){
      ans++;
    }
    //cout<<gate[k]<<endl;
  }
  ans=tmpr-tmpl+1;
  if(ans<0){
    ans=0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

VL people;
vector<vector<PLL>> arr;
ll gflag=1;

void setp(ll k,ll t)
{
	if(people[k]!=t&&people[k]!=-1)
	{
		gflag=0;
		return;
	}

	if(t==0)
	{
		people[k]=0;
		return;
	}
	people[k]=1;
	fr(i,0,SZ(arr[k]))
	{
		//if(arr[k][i].S==1&&people[arr[k][i].F]==-1)
		//setp(arr[k][i].F,arr[k][i].S);
		if(people[arr[k][i].F]==-1)
		{
			setp(arr[k][i].F,arr[k][i].S);
		}
		else
		{
			if(people[arr[k][i].F]!=arr[k][i].S)
				gflag=0;
		}
	}
	return ;
}
void solve()
{
	ll n;
	rl(n);
	arr.clear();
	arr.assign(n,vector<PLL>());
	fr(i,0,n)
	{
		ll a;
		rl(a);
		fr(j,0,a)
		{
			ll x,y;
			rl2(x,y);
			x--;
			arr[i].PB(MP(x,y));
		}
	}
	unsigned int pset=pow(2,n);
	ll ans=0;
	fr(i,0,pset)
	{
		//VL(n,-1);
		people.clear();
		people.assign(n,-1);
		gflag=1;
		fr(j,0,n)
		{
			int flag=1;
			//gflag=1;
			if(i&(1<<j))
			{
				setp(j,1);
			}
		}
		ll ct=0;
		if(gflag)
		{
			fr(i,0,n)
			{
				if(people[i]==1)
					ct++;
			}
		}
		ans=max(ans,ct);

	}
	wl(ans);
		NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int h, w;
	int i, j;
	
	while (scanf("%d %d", &h, &w), h || w){
		if (h == 0 && w == 0) break;
		
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				printf("#");
			}
			
			printf("\n");
		}
		
		printf("\n");
	}
		
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
int a[200005], b[200005], n;
bool check(int k){
	int i, j;
	for(i = 1 ; i <= n * 2 - 1 ; ++i)
		b[i] = a[i] >= k;
	if(b[n - 1] == b[n] || b[n] == b[n + 1])
		return b[n];
	i = n - 1, j = n + 1;
	while(i){
		if(b[i] == b[i + 1]) return b[i];
		if(b[j] == b[j - 1]) return b[j];
		--i, ++j;
	}
	return !((n & 1) ^ b[n]);
}
int main(){
	int i, l, r, mid, ans = 0;
	scanf("%d", &n);
	for(i = 1 ; i <= n * 2 - 1 ; ++i)
		scanf("%d", &a[i]);
	l = 1, r = 2 * n - 1;
	while(l <= r){
		mid = (l + r) >> 1;
		if(check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    SGET(S);
    int a = 0;
    for(int i = 0;i < S.size()/2;i++){
        if(S[i] != S[S.size()-i-1]){
            a++;
        }
    }
    cout << a << endl;
}


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

using ll = long long;

const int K = 100005;

int n, w;
ll d[K];

int main(){
    scanf("%d%d", &n, &w);
    for(int x, y; n--; ){
        scanf("%d%d", &x, &y);
        for(int i = w; i >= x; i--) d[i] = max(d[i], d[i - x] + y);
    }
    printf("%lld\n", d[w]);
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {
        int A = int.Parse(Console.ReadLine());
        int B = int.Parse(Console.ReadLine());

        for(int a = 1; a <= 3; a++) {
            if (a != A && a != B) {
                Console.WriteLine(a);
            }
        }

    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cmath>

using namespace std;

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

	int left = 0;
	for (int i = 0; i < M; i++) {
		int tmp;
		cin >> tmp;
		if (tmp < X)left++;
	}

	int ans = min(M - left, left);

	cout << ans << endl;

	return 0;
}

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

const int M = 1e9+7;

int main(){
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int i=0;i<n;i++) cin>>arr[i];

	vector<int> pos(n);
	for(int i=0;i<n;i++) pos[arr[i]]++;

	if(pos[0]>1){
		cout<<0;
		return 0;
	}
	for(int p : arr){
		if(pos[p]>2){
			cout<<0;
			return 0;
		}
	}
	long long int res = 1;
	for(int i=1;i<=n/2;i++){
		res*=2;
		if(res>M) res-=M;
	}
	cout<<res;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 1e5;
int n, m;
LL all;
int pre[2*MaxN + 5], last[2*MaxN + 5], other[2*MaxN + 5];
LL cost[2*MaxN + 5];
LL	dis[MaxN + 5];
int seq[MaxN + 5];
bool Inque[MaxN + 5];


void Build(int x, int y, LL w)
{
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = w;
}

void Bfs(int s)
{
	LL head = 1, tail = 1, now, ed, dr;
	seq[tail] = s;
	for(int i = 1; i <= n; i++)
	{
		if(i == s) dis[i] = 0;
		else dis[i] = 1ll << 60;
	}
	Inque[s] = 1;
	while(head <= tail)
	{
		now = seq[head];
		ed = last[now];
		while(ed != -1)
		{
			dr = other[ed];
			if(dis[now] + cost[ed] < dis[dr])
			{
				dis[dr] = dis[now] + cost[ed];
				if(!Inque[dr])
				{
					Inque[dr] = 1;
					seq[++tail] = dr;
				}
			}
			ed = pre[ed];
		}
		Inque[now] = 0;
		head++;
	}
}

int main()
{
	all = -1;
	memset(last, -1, sizeof(last));
	scanf("%d", &n);
	for(int i = 1; i < n; i++)
	{
		int a,b;
		LL w;
		scanf("%d %d %lld", &a, &b, &w);
		Build(a, b, w); Build(b, a, w);
	}
	int q,k,u,v;
	scanf("%d %d",&q,&k);
	memset(seq, 0, sizeof(seq));
	memset(Inque, 0, sizeof(Inque));
	Bfs(k);
	while(q--){
			scanf("%d %d",&u,&v);
		printf("%lld\n", dis[u]+dis[v]);
	}
	return 0;
}

Measured memory_bytes: 6912
def resolve():
    N, M, Q = map(int, input().split())
    cum_A = [[0]*(N+1) for _ in range(N+1)]
    for _ in range(M):
        l, r = map(int, input().split())
        cum_A[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            cum_A[i][j] += cum_A[i-1][j] + cum_A[i][j-1] - cum_A[i-1][j-1]

    for _ in range(Q):
        ans = 0
        l, r = map(int, input().split())
        ans = cum_A[r][r] - cum_A[r][l-1] - cum_A[l-1][r] + cum_A[l-1][l-1]

        print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13288
#include<bits/stdc++.h>
#include<map>
#include <cstring>
#include<string.h>
#include<stdio.h>

using namespace std;
#define ll long long int


int main()
{
 ll n,m;
 cin>>n>>m;
 if(n!=m)
 	cout<<"No"<<endl;
 else
 	cout<<"Yes"<<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>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    Int H, W;
    Int ans = INFl;

    void tate() {
        for (int i = 1; i < H; ++i) {
            vector<Int> men;
            men.push_back(i * W);
            men.push_back((H - i) * (W / 2));
            men.push_back((H - i) * (W - W / 2));
            sort(all(men));
            Int tmp = men.back() - men.front();
            chmin(ans, tmp);
        }
    }

    void yoko() {
        swap(H, W);
        tate();
        swap(H, W);

    }

    void solve() {
        cin >> H >> W;
        ans = min(H, W);
        if (H % 3 == 0 || W % 3 == 0) {
            cout << 0 << endl;
            return;
        }

        tate();
        yoko();
        cout << ans << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	k--;
	cout <<  a[k];
}


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

class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);	
	    int t = sc.nextInt();
      	int x = sc.nextInt();
      	BigDecimal res = new BigDecimal((double)t/x);
      	System.out.println(res.setScale(10,BigDecimal.ROUND_HALF_DOWN));
    }
}


Measured memory_bytes: 23764
#include <stdio.h>

using namespace std;

int main(){
     int H,W;
    
       for(;;){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)
        {
            break;
        }
        for(int i=0; i<H; i++)
        {
            for(int j=0; j<W; j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    
       }


}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b,c,d,cmp=0,cmpp,m,h,w,x,y,sum=0,pos=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n;
       map<int,int> mp;
       rep(i,n){
           cin>>a[i];
           mp[a[i]]++;
           //cmp=max(cmp,a[i]);
       }
      // sort(a,a+n);
     // ans=n;
       rep(i,n){
         //  Cout(mp[a[i]]);
           if(mp[a[i]]!=1 && mp[a[i]]!=0){
               pos+=mp[a[i]]-1;
              // cnt++;
               ans++;
               mp[a[i]]=0;
              // Cout(pos);
           }
           else{
               if(mp[a[i]]!=0){
               ans++;
               mp[a[i]]=0;
               }
           }
       }
      // Cout(pos);
       if(pos%2==0){
           Cout(ans);
       }
       else{
           Cout(ans-1);
       }
       
return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define N 3050
int memo[N][N];
string a,b;

int dp(int curr1 , int curr2) {
    if (curr1 >= a.length() || curr2 >= b.length()) return 0;
    int &sol = memo[curr1][curr2];
    if (sol != -1) return sol;
    sol = max(dp(curr1 + 1 , curr2) , dp(curr1 , curr2 + 1));
    if (a[curr1] == b[curr2]) {
        sol = max(
            dp(curr1 + 1 , curr2 + 1) + 1 ,
            sol
        );
    }
    return sol;
}

void dp2(int curr1 , int curr2) {
    if (curr1 >= a.length() || curr2 >= b.length()) return;
    int inc1 = dp(curr1 + 1 , curr2), inc2 = dp(curr1 , curr2 + 1),take;
    if (a[curr1] == b[curr2]) take = dp(curr1 + 1 , curr2 + 1) + 1;
    else take = INT_MIN;
    if (inc1 >= take && inc1 >= inc2) {
        dp2(curr1 + 1 , curr2);
    } else if (inc2 >= take && inc2 >= inc1) {
        dp2(curr1 , curr2 + 1);
    } else if (take >= inc1 && take >= inc2) {
        printf("%c" , a[curr1]);
        dp2(curr1 + 1 , curr2 + 1);
    }
}

int main() {
    char x[N],y[N]; scanf("%s %s" , x , y);
    a = x, b = y;
    memset (memo , -1 , sizeof memo);
    dp(0 , 0);
    dp2(0 , 0);
    printf("\n");
}


Measured memory_bytes: 40372
# -*-coding: utf-8 -*-
N, M = map(int, input().split())
lr = []
for i in range(M):
    lr.append(list(map(int, input().split())))
l = lr[0][0]
r = lr[0][1]
for i in range(1, M):
    if lr[i][0] > l:
        l = lr[i][0]
    if lr[i][1] < r:
        r = lr[i][1]
    
if r >= l:
    print(r - l + 1)
else:
    print(0)

Measured memory_bytes: 27344
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
int qu[10000];
int main() {
	int n, d;
	while (cin >> n >> d, n) {
		queue<int> q[100];
		priority_queue<P, vector<P>> que;
		int mi = (int)MOD;
		rep(i, n) {
			int m; cin >> m; int sum = 0;
			rep(j, m) {
				cin >> qu[j];
				sum += qu[j];
			}
			per(j, m) {
				q[i].push(qu[j]);
			}
			que.push({ sum,i });
			mi = min(mi, sum);
		}
		while (true) {
			P now = que.top(); que.pop();
			if (now.first == 0) {
				cout << "Yes" << endl; break;
			}
			if (now.first - mi > d) {
				cout << "No" << endl; break;
			}
			rep(i, n-1) {
				P oth = que.top(); que.pop();
				int num = oth.second;
				while (!q[num].empty()) {
					int r = q[num].front();
					if (now.first - (oth.first - r) <= d) {
						oth.first -= r; q[num].pop();
					}
					else {
						break;
					}
				}
				que.push(oth);
				mi = min(mi, oth.first);
			}
			int nex = now.second;
			int z = q[nex].front(); q[nex].pop();
			now.first -= z;
			mi = min(mi, now.first);
			que.push(now);
		}
	}
	return 0;
}


Measured memory_bytes: 3136
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    #ind=a[i]
    ans+=c[a[i]-1]
print(ans)


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll A;
  scanf("%lld",&A);
  ll B;
  scanf("%lld",&B);
  ll C;
  scanf("%lld",&C);
  ll D;
  scanf("%lld",&D);
  if (A+B>C+D) cout << "Left" << endl;
  else if (A+B<C+D) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

int main()
{
  solve();
  return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main(){
 int n,sum=0,a[100000];
 map<int,bool> m={};
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>a[i];
  if(!m[a[i]]){
    m[a[i]]=true;
    sum++;
  }
}
 cout<<(sum%2==1?sum:sum-1);
}

Measured memory_bytes: 5376
S=input()
S1=int(S[:2])
S2=int(S[2:4])
YYMM=(0<S2)and(S2<13)
MMYY=(0<S1) and (S1<13)
if YYMM:
  if MMYY:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if MMYY:
    print('MMYY')
  else:
    print('NA')



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(string s) {
  ll N = s.length();

  set<char> cand;
  REP(i, N)
    cand.emplace(s[i]);

  if (cand.size() == 1) {
    // printf("string with one char\n");
    cout << 0 << endl;
    return;
  }

  ll ans(N);
  for (const char c : cand) {
    string t(s);
    // printf("start c=%c\n", c);
    REP(i, N) {
      bool finish(true);
      REP(j, N - i - 1) {
	if (t[j] == c)
	  continue;
	else if (t[j + 1] == c)
	  t[j] = c;
	else
	  finish = false;
      }
      // printf("%s\n",t.substr(0, N - i - 1).c_str());
      if (finish) {
	// printf("ans = %lld\n", i);
	ans = min(ans, i + 1);
	break;
      }
    }
  }
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  solve(s);

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define vec(j,n) vector<int>(j(n))
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main(){
    int s;
    cin >> s;
    vector<int>aa(1000009);
    aa.at(0)=s;
    for(int i=0;i<1000009;i++){
        if(aa.at(i)%2 == 0){
        aa.at(i+1) = aa.at(i) / 2;
        }else{
        aa.at(i+1) = 3 * aa.at(i) + 1;
        }
        for(int j=0;j < i + 1 ;j++){
            if(aa.at(i+1)==aa.at(j)){
                cout << i + 2 << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define mod          1000000007

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;
double x=0.0, y=0.0, z;
int main()
{

    //scan(n);
    cin>>n;
    f0(i,n)
    {
        cin>>m;
        x = x+(1.0/m);
    }
    y=(1.0/x);
    printf("%.5f\n",y);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

static const ll MOD = 1000000007LL;

int main(){
  string S;
  cin >> S;
  int N = S.size();
  ll dp[N+1][13];
  for(int i = 0; i < N+1; ++i){
    for(int j = 0; j < 13; ++j){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1LL;
  
  for(int i = 0; i < N; ++i){
    int c;
    if(S[i] == '?') c = -1;
    else c = S[i] - '0';
    for(int j = 0; j < 10; ++j){
      if(c != -1 && c != j) continue;
      for(int ki = 0; ki < 13; ++ki){
	dp[i+1][(10*ki + j) % 13] += dp[i][ki];
      }
    }
    for(int j = 0; j < 13; ++j) dp[i+1][j] %= MOD;
  }

  ll res = dp[N][5];
  cout << res << endl;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  VV<> c; assign(c, h, w);
  for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) cin >> c[i][j];
  VV<> cum; assign(cum, h + 1, w + 1);
  for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) cum[i + 1][j + 1] = cum[i + 1][j] + cum[i][j + 1] - cum[i][j] + c[i][j];
  auto chk = [&](int x) -> bool {
    for (int i = 0; i + x < h + 1; ++i) for (int j = 0; j + x < w + 1; ++j) if (cum[i + x][j + x] - cum[i + x][j] - cum[i][j + x] + cum[i][j] == 0) return true;
    return false;
  };
  int ok = 0, ng = min(h, w) + 1;
  while (ng - ok > 1) {
    int med = ok + ng >> 1;
    if (chk(med)) ok = med;
    else ng = med;
  }
  cout << ok * ok << '\n';
}


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

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

int main(){
string S;
cin>>S;
map<char,int> m;
rep(i,3)
m[S[i]]++;

if(m['a']==1&&m['b']==1&&m['c']==1)
cout<<"Yes"<<endl;
else
{
  cout<<"No"<<endl;
}



  return 0;
}


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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  string ans = "No";
  string N;
  cin >> N;

  if (N[0] == N[1] && N[1] == N[2]) {
    ans = "Yes";
  }
  if (N[1] == N[2] && N[2] == N[3]) {
    ans = "Yes";
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int s, w;
cin >> s >> w;
if(s<=w){
    cout<<"unsafe"<<endl;
}
else{
    cout<<"safe"<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 3648
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int size = s.size();
  for (int i = 0; i < size - 1; i++)
  {
    if (s[i] != s[i + 1])
    {
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 512
import collections
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
Q = int(input())
tot = sum(A)
for _ in range(Q):
    B, C = list(map(int, input().split()))
    if B in cnt:
        tot += (C - B) * cnt[B]
        cnt[C] += cnt[B]
        cnt[B] = 0
    print(tot)

Measured memory_bytes: 94220
N, K = map(int, input().split())
m = 0
if K == 0:
    print(N**2)
    exit()

for b in range(K+1,N+1):
    m += (b-K)*(N//b)
    if N%b-K >= 0:
        m += N%b-K+1
print(m)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  ll ans = 0;

  rep(i, n) {
    repI(j, i+1, n) {
      repI(k, j+1, n) {
        ll maxl = max(l[i], max(l[j], l[k]));
        if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
        if (l[i]+l[j]+l[k] - maxl > maxl) {
          ans++;
          // cout << i << j << k << " " << l[i] << " " << l[j] << " " <<l[k] << endl;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){

    string s;
    string t;

    cin >> s >> t;

    char m;
    int num;
    for (int i = 0; i < s.size(); i++){
        m = s[i];
        num = i;
        for (int k = i+1; k < s.size(); k++){
            if (m > s[k]){
                m = s[k];
                num = k;
            }
        }
        int tmp = s[i];
        s[i] = m;
        s[num] = tmp;
    }


    for (int i = 0; i < t.size(); i++){
        m = t[i];
        num = i;
        for (int k = i+1; k < t.size(); k++){
            if (m < t[k]){
                m = t[k];
                num = k;
            }
        }
        int tmp = t[i];
        t[i] = m;
        t[num] = tmp;
    }

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using System;
class Atcoder_Templete
{
    static void Main(string[] args)
    {
        string input_string = Console.ReadLine();
        int input_int = int.Parse(input_string);
        string result = Judge(input_int);

        

        //出力
        Console.WriteLine(result);
    }

    public static string Judge(int X)
    {
        for (int i = 9; i >= 1; i--)
        {
            if(X % i == 0)
            {
                int newX = X / i;
                for(int j = 9; j >= 1; j--)
                {
                    if(newX % j == 0 && newX / j == 1)
                    {
                        return "Yes";
                    }
                }
            }
        }
        return "No";
    }

}

Measured memory_bytes: 11092
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vector<T>vec;
  rep(i,n){
    ll a,b;cin>>a>>b;
    vec.push_back(make_tuple(a+b,a,b));
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  ll Takahashi=0;
  ll Aoki=0;
  rep(i,n){
    if(i%2==0)Takahashi+=get<1>(vec[i]);
    else Aoki+=get<2>(vec[i]);
  }
  cout<<Takahashi-Aoki<<endl;
}


Measured memory_bytes: 4852
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128
int r, s, p;
inline int run(char ch) {
  if(ch == 's') return r;
    if(ch == 'r') return p;
    return s;
}
signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  int n, k;
  string str;
  
  cin >> n >> k >> r >> s >> p >> str;
  vi f(k, 1);
  long long res = 0;
  for(int i = 0; i < k; ++i) {
    res += run(str[i]);
  }
  for(int i = k; i < n; ++i) {
    if(str[i] == str[i - k]) {
      if(f[i % k]) f[i % k] = 0;
      else {
        f[i % k] = 1;
        res += run(str[i]);
      }
    }
    else {
      res += run(str[i]);
      f[i % k] = 1;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 848
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])

    def search(self, s, g):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]


def solve():
    n = getN()
    nums = getList()
    c = Counter(nums)
    ans = 0
    for k, v in c.items():
        if v < k:
            ans += v
        elif v > k:
            ans += v - k
    print(ans)
    return
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 99520
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> ans;
    int cur = n;
    while(cur>0){
        bool impossible = true;
        for(int i=0;i<m;i++){
            if(cur-(m-i)<0)continue;
            if(cur-(m-i) == 0 || s[cur-(m-i)]=='0'){
                impossible = false;
                ans.push_back(m-i);
                cur -= (m-i);
                break;
            }
        }
        if(impossible){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout << ans[i] << (i==0?'\n': ' ');
    }
}

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

int main(){
  string a;
  cin >> a;
  
  int i,count;
  count = 0;
  for(i=0;i<3;i++){
    if(a.at(i) == '1') {
      count++;
    }
    else continue;
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    c*=2;
    int z=max(x,y);
    ll ans=inf;
    for(int i=0;i<=z;i++){
        int abpiz=c*i;
        int apiz=a*max(0,x-i);
        int bpiz=b*max(0,y-i);
        ll sum=abpiz+apiz+bpiz;
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		long N = Long.parseLong(sc.next());
		long K = Long.parseLong(sc.next());
		if (N == 0) {
			System.out.println(N);
			return;
		}

		System.out.println(Math.min(N % K, Math.abs(K - (N % K))));
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 22996