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

int lcs[3009][3009];

int main()
{
    string a, b;
    int i, j, n, m;
    cin >> a >> b;

    n = a.size();
    m = b.size();

    for(i = 0; i <= n; i++)
        lcs[i][0] = 0;
    for(i = 0; i <= m; i++)
        lcs[0][i] = 0;

    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= m; j++)
        {
            if(a[i-1] == b[j-1])
                lcs[i][j] = lcs[i-1][j-1] + 1;
            else
                lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
        }
    }

    i = n, j = m;
    string ans;
    while(i > 0 && j > 0)
    {
        if(a[i-1] == b[j-1])
        {
            ans = a[i-1] + ans;
            i--;
            j--;
        }
        else if(lcs[i-1][j] >= lcs[i][j-1])
            i--;
        else
            j--;
    }

    cout << ans;
}



Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <bitset>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    int C[N];
    int A[N][M];
    for(int i=0; i<N; i++){
        cin >> C[i];
        for(int j=0; j<M; j++){
            cin >> A[i][j];
        }
    }

    const int INF = 1000000005;
    int ans = INF;
    for(int s=0; s<(2<<N); s++){
        int sum[M];
        fill(sum, sum+M, 0);
        int cost = 0;
        for(int i=0; i<N; i++){
            if(((s >> i)&1) == 0) continue;
            cost += C[i];
            for(int j=0; j<M; j++){
                sum[j] += A[i][j];
            }
        }

        bool fl = true;
        for(int i=0; i<M; i++){
            if(sum[i] < X) fl = false;
        }
        if(fl) ans = min(ans, cost);
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
/// Coded by Dhiman Sarker Bappi (Dhimanda) - RMSTU

#include<bits/stdc++.h>
using namespace std;
#define    in_file     freopen("input.txt", "r", stdin)
#define    out_file    freopen("output.txt", "w", stdout)
#define    fast        ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define    F           first
#define    S           second
#define    pb          push_back
#define    popb        pop_back
#define    pf          push_front
#define    popf        pop_front
#define    lcm(a,b)    (a*b)/gcd(a,b)
#define    gcd(a,b)    __gcd(a,b)
#define    pi          2*acos(0)
#define    elif        else if
#define    ll          long long
#define    sp          fixed<<setprecision
#define    nl          '\n'
#define    endl        '\n'
#define    forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define    fora(i,n)   for(int (i)=0; (i) < (n); (i)++)


int Int(){int x;scanf("%d", &x);return x;}
#define    Int         Int()
#define    mx          100010
void dhimanda();
int main()
{
    //fast;
   // in_file;
    //out_file;
    int t=1;
    //t=Int;
    forr(i,1,t){
        //printf("Case %d: ", i);
        dhimanda();
    }
    return 0;
}
void dhimanda(){
    ll n;
    cin >> n;
    ll ans = 0 ;
    for(int i=1; i<= n ; i++) {
        for(int j=1; j <= n ; j++) {
            for(int k=1; k<=n ; k++) {
                ans += gcd(i,gcd(j,k));
            }
        }
    }
    cout << ans <<endl;
}

// Contact : chessdhiman@gmail.com



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

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

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

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,tmp=0;
	string s;
	cin >> n >> s;
	string t=s;
	rep(i,n){
		if(s[i]==')') tmp--;
		else tmp++;
		if(tmp<0){
			tmp++;
			t="("+t;
		}
	}
	rep(i,tmp) t+=')';
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, maxs;
	cin >> nn;
	string tmp;
	map<string, int64> ss;
	set<string> memo;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> tmp;
		ss[tmp]++;
		memo.insert(tmp);
	}
	for(set<string>::iterator ite = memo.begin();ite != memo.end();ite++)
	{
		int64 vv = ss.at(*ite);
		maxs = max(maxs, vv);
	}
	for(set<string>::iterator ite = memo.begin();ite != memo.end();ite++)
	{
		int64 vv = ss.at(*ite);
		if(vv == maxs)
		{
			cout << *ite << endl;
		}
	}
	cout << endl;
	return 0;
}


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

int main(void){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for(int i=1; i<N; i++){
    string left = S.substr(0, i);
    string right = S.substr(i);

    map<char, int> mpL, mpR;
    for(int j=0; j<i; j++){
      mpL[left[j]]++;
    }
    /*
    for(int j=0; j<N-i; j++){
      mpR[right[j]]++;
    }
    */
    int tmp = 0;
    auto tmpmpL = mpL;
    for(int j=0; j<N-i; j++){
//      cout << right[j] << ", ";
      if(tmpmpL[right[j]] > 0) {
        tmp++;
        tmpmpL[right[j]] = 0;
      }
    }
    ans = max(ans, tmp);     
//    cout << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int numofbits(unsigned long long bits) {
    bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555);
    bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333);
    bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f);
    bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff);
    bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff);
    return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n;
    int N = pow(2, n);
    int k, mask = 0, b;
    cin >> k;
    rep(i, k) {
        cin >> b;
        mask |= 1 << b;
    }
    rep(i, N) {
        if((i & mask) == mask) {
            cout << i << ":";
            m = i;
            for(int j = 0; m > 0; j++) {
                if(m & 1) cout << " " << j;
                m /= 2;
            }
            cout << "\n";
        }
    }
}



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

int main()
{
	long long n,k;
	cin>>n>>k;
	long long a=(n/k);


	long long b1=abs(n-a*k);
	long long b2=abs(n-(a+1)*k);
	

	long long ans=min(b1,b2);
	cout<<ans;

	return 0;
}

Measured memory_bytes: 384
n=int(input())
c=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
for i in range(n):
    if b[i]>c[i]:
        
        rem=b[i]-c[i]
        
        ans+=c[i]+min(rem,c[i+1])
        c[i+1]=max(c[i+1]-rem,0)
    else:
        ans+=b[i]
print(ans)


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
	int d, l;
	cin >> d >> l;
	cout << d / l + (d - d / l * l) << endl;
	return 0;
}



Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

	return 0;
}


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

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

  ll H, N;
  cin >> H >> N;

  ll *A = new ll[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  bool ans = true;
  for (int i = 0; H > 0; i++) {
    if (i == N) {
      ans = false;
      break;
    }
    H -= A[i];
  }

  cout << (ans? "Yes": "No") << endl;

  return 0;
}


Measured memory_bytes: 1024
from collections import deque

K = int(input())

q = deque(list(range(1,10)))

for _ in range(K-1):
    p = q.popleft()

    if p%10 > 0:
        q.append(p*10 + p%10 - 1)
    
    q.append(p*10 + p%10)

    if p%10 < 9:
        q.append(p*10 + p%10 + 1)

print(q.popleft())

Measured memory_bytes: 11912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  
  ll ans = 0, MA = a[0];

  rep(i,n) {
    if (MA < a[i]) MA = a[i];
    else {
      ans += (MA-a[i]);
      a[i] = MA;
    }
    
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3992
import math

n,d = list(map(int, input("").split()))
xy = [list(map(int,input().split())) for i in range(n)]

kosu = 0

for i in range(n):
    a = math.sqrt(xy[i][0] ** 2  + xy[i][1] ** 2)
    if a <= d:
        kosu += 1

print(kosu)

Measured memory_bytes: 45440
#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;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    for(int i = 0; i < n-1; ++i)    cin >> c[i] >> s[i] >> f[i];
    for(int i = 0; i < n-1; ++i){
        ll res = s[i] + c[i];
        for(int j = i+1; j < n-1; ++j){
            if(res <= s[j]){
                res = s[j] + c[j];
                continue;
            }
            ll time = f[j] * ceil((double)(res - s[j]) / f[j]);
            res = s[j] + time + c[j];
        }
        cout << res << "\n";
    }
    cout << 0 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
string s;
vector<char> v;

void input(void){
char c;
cin>>s;
n=s.length();
}
void solve(void){
    ll a,x=0,y=0;
    vl ans(n,0);
    rep(i,n){
        if(y==0){
            if(s[i]=='R'){
                x++;
            }
            else{
                a=i-1;
                y++;
            }
        }
        else{
             if(s[i]=='L'){
                y++;
            }
            else{
                ans[a]=(x+1)/2+y/2;
                ans[a+1]=(y+1)/2+x/2;
              x=1;
              y=0;
            }
        }
      //cout<<a<<" "<<x<<" "<<y<<endl;
    }
  
     ans[a]=(x+1)/2+y/2;
     ans[a+1]=(y+1)/2+x/2;
    
    rep(i,n){
        cout<<ans[i];
        if(i!=n-1)cout<<" ";
    }
    return;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 1488
#include<stdio.h>

int fib(int n){
	int fi[45],i;
	
	fi[0]=1;
	fi[1]=1;
		
	
	for(i=2;i<=n;i++){
		fi[i] = fi[i-1]+fi[i-2];
		}
		
	return fi[n];
	}

int main(){
	int n;
	scanf("%d",&n);
	if(n<0 || n >44) return 1;
	
	printf("%d\n",fib(n));
	return 0;
	}

Measured memory_bytes: 596
#include <iostream>

int main(int argc, char *argv[]) {
	int a, b, c, t;
	std::cin >> a >> b >> c;

	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	if (b > c) {
		t = b;
		b = c;
		c = t;
	}
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	std::cout << a << " " << b << " " << c << std::endl;

	return 0;
}

Measured memory_bytes: 1164
import std.stdio;

void main() {
	int m1, m2, d1, d2;
	scanf("%d %d\n%d %d\n", &m1, &d1, &m2, &d2);
	if (m1 == m2) {
		0.write;
	}
	else {
		1.write;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct d{
    string s;
    int w;
    int idx;
}cont[105];
bool cmp(d x ,d y){
    if(x.s==y.s){
        return x.w>y.w;
    }
    else{
        return x.s<y.s;
    }
}
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> cont[i].s>>cont[i].w;
        cont[i].idx=i+1;
    }
    sort(cont,cont+n,cmp);
    for(int i=0;i<n;i++){
        cout<<cont[i].idx<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int x[100100],y[50010],z[150110];
int main()
{
    int n,m;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&x[i]);
    int a=unique(x,x+n)-x;
    scanf("%d",&m);
    for(int i=0;i<m;i++)
        scanf("%d",&y[i]);
        sort(y,y+m);
    int b=unique(y,y+m)-y;
    for(int i=0;i<a;i++)
        z[i]=x[i];
    for(int i=a;i<a+b;i++)
        z[i]=y[i-a];
    sort(z,z+a+b);
    int t=unique(z,z+a+b)-z;
    printf("%d\n",a+b-t);
}

Measured memory_bytes: 3716
h, w = gets.chomp.split(" ").map(&:to_i)
rows = []
h.times do
  rows.push(gets.chomp.chars)
end
outputs = rows
count = 0
rows.each_with_index do |ary, aryIndex|
  ary.each_with_index do |elm, elmIndex|
    if elm != "#"
      searchAry = [[aryIndex - 1, elmIndex - 1], [aryIndex - 1, elmIndex], [aryIndex - 1, elmIndex + 1], [aryIndex, elmIndex - 1], [aryIndex, elmIndex + 1], [aryIndex + 1, elmIndex - 1], [aryIndex + 1, elmIndex], [aryIndex + 1, elmIndex + 1]]
      searchAry.each do |search|
        if search[0] >= 0 && search[0] <= h - 1 && search[1] >= 0 && search [1] <= w - 1
          if rows[search[0]][search[1]] == "#"
            count += 1
          end
        end
      end
      outputs[aryIndex][elmIndex] = count
    end
    count = 0
  end
end
outputs.each do |output|
  puts "#{output.join}\r"
end

Measured memory_bytes: 2172
#include <iostream>
#include <cstdlib>
#include <climits>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, int> P;

int main(){
  int h,w;
  while(cin>>h>>w,h){
    int diagonal = h*h + w*w;
    pair<P,int> p(make_pair(diagonal, h), w);
    vector<pair<P, int>> v;
    for(int i=1;i<=150;++i){
      for(int j=i+1;j<=150;++j){
        if(i>=j) break;
        if(i==h&&j==w) continue;
        if(diagonal <= i*i + j*j){
          v.emplace_back(make_pair( make_pair(i*i+j*j,i), j));
        }
      } 
    }

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

    for(int i=0;i<v.size();++i){
      if(p < v[i]){
        cout << v[i].first.second << " " << v[i].second << endl;
        break;
      }
    }

  }

  return EXIT_SUCCESS;
}

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

int main(){
    string S;
    cin >> S;
    
    int d;
    if ( S == "SUN" ){
        d = 7;
    } else if ( S == "MON" ) {
        d = 6;
    } else if ( S == "TUE" ) {
        d = 5;
    }else if ( S == "WED" ) {
        d = 4;
    } else if ( S == "THU" ) {
        d = 3;
    } else if ( S == "FRI" ) {
        d = 2;
    } else {
        d = 1;
    }

    cout << d << endl;
    
    return 0;
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())

n_minus_route = [0] * N
n_plus_route = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        tmp = abs(X-i) + 1 + abs(Y-j)
        if j-i > tmp:
            n_minus_route[j-i] += 1
            n_plus_route[tmp] += 1

for k in range(1, N):
    ans = N - k - n_minus_route[k] + n_plus_route[k]
    print(ans)

Measured memory_bytes: 3444
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n,m;
int cost[MAXN];
vector<int> adj[MAXN];

int comp[MAXN],ncomp;
pair<int,int> mncomp[MAXN];

bool used[MAXN];
int rem[MAXN],nrem;

void setcomp(int at,int c) {
	if(comp[at]!=-1) return; comp[at]=c;
	REPSZ(i,adj[at]) setcomp(adj[at][i],c);
}

void run() {
	scanf("%d%d",&n,&m); REP(i,n) scanf("%d",&cost[i]); REP(i,m) { int a,b; scanf("%d%d",&a,&b); adj[a].PB(b); adj[b].PB(a); }
	
	REP(i,n) comp[i]=-1; ncomp=0;
	REP(i,n) if(comp[i]==-1) setcomp(i,ncomp++);
	if(ncomp==1) { printf("0\n"); return; }

	REP(i,ncomp) mncomp[i]=MP(INT_MAX,-1); REP(i,n) mncomp[comp[i]]=min(mncomp[comp[i]],MP(cost[i],i));

	ll ret=0; REP(i,n) used[i]=false; REP(i,ncomp) ret+=mncomp[i].first,used[mncomp[i].second]=true;
	nrem=0; REP(i,n) if(!used[i]) rem[nrem++]=cost[i];
	int need=2*(ncomp-1)-ncomp; if(nrem<need) { printf("Impossible\n"); return; }
	sort(rem,rem+nrem); REP(i,need) ret+=rem[i]; printf("%lld\n",ret);
}

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


Measured memory_bytes: 7040
from operator import itemgetter

N, M = map(int, input().split())
AB = sorted([tuple(map(int, input().split())) for _ in range(M)], key=itemgetter(1))

removes = -1
answer = 0
#print(AB)
for a, b in AB:
    if a > removes:
        removes = b - 1
        answer += 1
print(answer)
    

Measured memory_bytes: 19024
#include <iostream>
using namespace std;
int main(void) {
	long long a, b, c;
	cin >> a >> b >> c;
	if (b < c) swap(b, c);
	if (a < b) swap(a, b);
	long long ans = 0;
	if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {
		long long num = a / 2;
		long long num2 = num + 1;
		num = b * c * num;
		num2 = b * c * num2;
		ans = num2 - num;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n,i,j;
	cin >> n;
	for(i=1;i<=9;i++){
		for(j=0;j<=9;j++){
			if(i*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math


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

A.append(X)
A = sorted(A)

anslis = [0]*N
for i in range(N):
    anslis[i] = A[i+1] - A[i]

g = anslis.pop(0)
for c in anslis:
    g = math.gcd(g,c)

print(g)

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

int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    if (a % 2 != 0) {
      continue;
    }
    if (a % 3 != 0 && a % 5 != 0) {
      cout<<"DENIED"<<endl;
      return 0;
    }
  }
  cout<<"APPROVED"<<endl;
}

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

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)
#define FOREACH(i,x) for (__typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

int cnt[256], cnt2[256];
char buf[10000];



int main() {
  // ios_base::sync_with_stdio(0);

  int H, W;
  scanf("%d%d", &H, &W);
  REP(i,H) {
    scanf("%s", buf);
    REP(j,W) {
      ++cnt[buf[j] - 'a'];
    }
  }

  int even = 0, odd = 0;
  REP(i,256) {
    if (cnt[i]%4 == 0) continue;
    if (cnt[i]%2 == 0) ++even;
    else ++odd;
  }

  int allowed_odd = (H&1)&W;
  int allowed_even = ((H%2) ? W / 2 : 0) + ((W%2) ? H/2 : 0);

  bool ok = (odd <= allowed_odd && even <= allowed_even);
  printf(ok ? "Yes\n" : "No\n");
}


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

#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define eb emplace_back
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;

void run() {
  	int a, b, c;
  	cin >> a >> b >> c;
  	swap(a, b);
  	swap(a, c);
  	cout << a << " " << b << " " << c << endl;
}

int main() 
{
    IO;
    double st = clock();
    run();
    cerr << "\n" << "time = " << (clock() - st) / CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 3784
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	int ans = MOD;
	for (int i = 0; i + K - 1 < N; i++) {
		ans = min(v[i + K - 1] - v[i],ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


 
int main() {
        string s;
        cin >> s;
        int n = s.size();
        bool ok = true;
        rep(i,n/2){
                if(s[i] != s[n-i-1]) ok = false;
        }
        if(!ok){
                cout << "No" << endl;
                return 0;
        }
        int k = (n-1)/2;
        rep(i,k/2){
                if(s[i] != s[k-i-1]) ok = false;
                if(s[i+k+1] != s[n-1-i]) ok = false;
        }
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int N; cin >> N;
    string s; cin >> s;

    int ans = 0;

    rep(i, 10) rep(j, 10) rep(k, 10){
        int cur = 0;
        rep(l, N){
            if(cur==0 && s[l]-'0'==i) ++cur;
            else if(cur==1 && s[l]-'0'==j) ++cur;
            else if(cur==2 && s[l]-'0'==k) ++cur;
        }
        if(cur==3) ++ans;
    }
    cout << ans << endl;

    return 0;
}


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

int main(void) {

	string s;
	int N;

	cin >> N >> s;

	int num = 0, j = 0;

	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') { num++; }
		else { j++; }
	}
	if (num > j) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
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(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a,b;
cin>>a>>b;
if(a>9||b>9)cout<<-1<<endl;
else cout<<a*b<<endl;
}



Measured memory_bytes: 892
A,B,K = map(int,input().split())
c = 0
if K%2 == 0:
  while c < K:
    B = B+A//2
    A = A//2
    c += 1
    A = A+B//2
    B = B//2
    c += 1
else:
  while c < K-1:
    B = B+A//2
    A = A//2
    c += 1
    A = A+B//2
    B = B//2
    c += 1
  B = B+A//2
  A = A//2
print(A,B)

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


// chmax, chmin
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; }


// debug stream of pair, vector 
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1, T2> P)
{
	return s << '<' << P.first << ", " << P.second << '>';
}
template<class T> ostream& operator << (ostream &s, vector<T> P)
{
	for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s;
}



int N, K;
vector<int> P, Q;

void mergesort(vector<int> &a, int left, int right) {
	if (right - left <= 1) return;
	int mid = (left + right) / 2;
	mergesort(a, left, mid);
	mergesort(a, mid, right);

	/*
	cout << "---------------------" << endl;
	COUT(left);
	COUT(right);
	for (int i = left; i < right; ++i) cout << a[i] << ", ";
	cout << endl;
	*/
	vector<pair<int, int> > rs;
	for (int i = mid; i < right; ++i) rs.push_back({ a[i], i - mid });
	sort(rs.begin(), rs.end(), greater<pair<int,int> >());

	vector<int> pl(right - mid);
	int pointer = mid;
	for (auto pa : rs) {
		int val = pa.first;
		int id = pa.second;
		while (pointer > left && a[pointer - 1] >= val + K) --pointer;
		pl[id] = pointer;
	}
	vector<int> res;
	int last = left;
	for (int i = 0; i < pl.size(); ++i) {
		for (int j = last; j < pl[i]; ++j) {
			res.push_back(a[j]);
		}
		last = max(last, pl[i]);
		res.push_back(a[i + mid]);
	}
	for (int i = last; i < mid; ++i) res.push_back(a[i]);
	for (int i = 0; i < res.size(); ++i) a[i + left] = res[i];

	//COUT(pl); COUT(res);
}

int main() {
	cin >> N >> K;
	P.resize(N); Q.resize(N);
	for (int i = 0; i < N; ++i) cin >> P[i], --P[i];
	for (int i = 0; i < N; ++i) Q[P[i]] = i;
	mergesort(Q, 0, N);
	vector<int> res(N);
	for (int i = 0; i < N; ++i) res[Q[i]] = i;
	for (int i = 0; i < N; ++i) cout << res[i]+1 << endl;
}

Measured memory_bytes: 10216
#include <stdio.h>

int main(void)
{
	int i;
	int paper;
	int coin;
	int change;
	
	do{
		scanf("%d", &coin);
		
		paper = 1000 - coin;
		change = 0;
		
		if (coin == 0){
			break;
		}
		
		while (paper != 0){
			if (paper >= 500){
				paper -= 500;
				change++;
			}
			else if (paper >= 100){
				paper -= 100;
				change++;
			}
			else if (paper >= 50){
				paper -= 50;
				change++;
			}
			else if (paper >= 10){
				paper -= 10;
				change++;
			}
			else if (paper >= 5){
				paper -= 5;
				change++;
			}
			else if (paper >= 1){
				paper -= 1;
				change++;
			}
		}
		printf("%d\n", change);
	}while (1);
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
const double pi=acos(-1);
 
int main(){
    double a,b,x;
    cin>>a>>b>>x;

    x/=a;
    
    if(x>a*b/2){
        cout<<setprecision(10)<<atan(-2*(x-a*b)/pow(a,2))*180/pi<<endl;
    }else{
        cout<<setprecision(10)<<atan(b*b/(2*x))*180/pi<<endl;
    }
}

Measured memory_bytes: 384
/*
 * 0158.cpp
 *
 *  Created on: 2011/07/27
 *      Author: isa
 */

#include <iostream>
#include <cstring>

using namespace std;

int m[1000001];

void func(long long num, int times){
	if(num > 1000000 || m[num] != -1) return;
	m[num] = times;
	func(num*2,times+1);
	if((num-1)%3 == 0 && ((num-1)/3)%2 == 1){
		func((num-1)/3, times+1);
	}
}

int main(void){
	int n;
	memset(m,-1,sizeof(m));
	m[1] = 0;
	func(2,1);
	while(cin >> n && n) cout << m[n] << endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(void){
    int R[MAX];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> R[i];
    }
    int ans[MAX], minv[MAX];
    //ans[i]はR[0]~R[i-1]におけるR[j]-R[i](j>i)の最大値。
    ans[0] = -2000000000;
    minv[0] = R[0];

    for (int i = 1; i < n; i++){
        ans[i] = max(ans[i-1], R[i] - minv[i-1]);
        minv[i] = min(R[i], minv[i-1]);
    }
    cout << ans[n-1] << endl;
    return 0;
}


Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 4001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;

// MOD確認


int main(){
    /*ll K,A,B;
    cin >> K >> A >> B;
    FOR(i,A,B+1){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;*/
    ll X;
    cin >> X;
    ll ans = 0;
    ll A = 100;
    while(A < X){
        A += A * 0.01;
        ans++;
    }
    cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  int out;
  int a[1];//それぞれの桁の数
  a[0]=n/100;
  out = a[0] *111;
  if(n <= out){
    n = out;
  }else if(n > out){
    n = out + 111;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Kagisys
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<String> s = new HashSet<String>();
		while(n--!=0)s.add(sc.next());
		boolean locked = true;
		int m = sc.nextInt();
		while(m--!=0){
			String t = sc.next();
			if(!s.contains(t)){
				System.out.println("Unknown "+t);
			}
			else if(locked){
				System.out.println("Opened by "+t);
				locked = false;
			}
			else{
				locked = true;
				System.out.println("Closed by "+t);
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<math.h>

using namespace std;

int main(void)

{
    long double d, a, b;
    int n, i, counter = 0;
    cin>>n>>d;
    for(i = 0; i < n; i++){
        cin>>a>>b;
        a *= a;
        b *= b;
        a += b;
        b = sqrt(a);
        if(b <= d)
            counter++;
    }
    cout<<counter<<endl;
    return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<long long> anss(4);
  anss[0] = a*c;
  anss[1] = a*d;
  anss[2] = b*c;
  anss[3] = b*d;
  long long ans = anss[0];
  for(int i=1;i<4;i++) {
    ans = max(ans,anss[i]);
  }
  if(a<=0 && b>=0 || c<=0 && d>=0) {
    ans = max(ans,(long long)0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define MOD 1000000007
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define FOR(a,n) for(int i=a;i<n;++i)
#define arrin(n) for(int i=0; i < n; ++i) cin>>arr[i];
#define arrout(n) for(int i=0; i < n; ++i) cout<<arr[i]<<" ";cout<<nl;
#define nl "\n"
#define mp make_pair
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;


int main(){    	
	fastio();
	int n;
	cin>>n;
	int a[n];
	for(int j=0;j<n;j++) cin>>a[j];
   	vector <int> v;
   	int i=n-1;
   	if(!(n&1)) i--;
   	for(;i>=0;i-=2) v.pb(a[i]);
   	for(i=1;i<n;i+=2) v.pb(a[i]);
   	if(n&1) for(i=0;i<n;i++) cout<<v[i]<<" ";
   	else 	 for(i=n-1;i>=0;i--) cout<<v[i]<<" ";
   	

   	return 0;
}	





Measured memory_bytes: 3828
#include <stdio.h>

int main(void){
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  if(a < b){
    if(b < c){
     printf("%d %d %d\n", a, b, c); 
    }else if(c < b){
	if(a < c){
      printf("%d %d %d\n", a, c, b);
	}
	else{
	   printf("%d %d %d\n", c, a, b);
	}
    }
  }

  else if(b < c){
    if(c < a){
      printf("%d %d %d\n", b, c, a);
    }else if(a < c){
      printf("%d %d %d\n", b, a, c);
    }
  }
    
  else if(c < a){
    if(a < b){
      printf("%d %d %d\n", c, a, b);
    }else if(b < a){
      printf("%d %d %d\n", c, b, a);
    }
  }
  return 0;
  }
  


Measured memory_bytes: 1968
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iomanip>
#define ll long long int
#define add push_back

using namespace std; 


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

    int T;  
    //cin >> T;
    T = 1;
    while(T--){
        int d,t,s; cin >> d >> t >> s;
        if(d <= t*s)
            cout << "Yes" << endl;
        else 
            cout << "No" << endl;
        
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N; cin >> N;
  ll result = N*(N-1)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef priority_queue <ll> pqb;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqs;
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}
 
bool cmp(pll a,pll b)
{
  ll as=abs(a.ff-a.ss);
  ll bs=abs(b.ff-b.ss);
    return (as>bs);
}
 
ll dx[]={-1,0,1,0};
ll dy[]={0,1,0,-1};
 
//vl v[100005];

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll t;
    //cin>>t;
    t=1;
    while(t--){
    	ll n;
    	cin>>n;
    	ll a[n];
    	for(ll i=0;i<n;i++){
    		cin>>a[i];
    	}
    	sort(a,a+n);
    	ll cnt=0;
    	for(ll i=0;i<n;i++){
    		for(ll j=i+1;j<n;j++){
    			for(ll k=j+1;k<n;k++){
    				if(a[k]<a[i]+a[j] && a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k])cnt++;
    			}
    		}
    	}
    	cout<<cnt<<endl;
    }
    return 0; 
}

Measured memory_bytes: 3604
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
  S = input()
  if S == "AC":
    AC += 1
  elif S == "WA":
    WA += 1
  elif S == "TLE":
    TLE += 1
  else:
    RE += 1
print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    string S, T;
    cin >> S >> T;
    int cnt=0;
    for(int i=0; i<S.size(); i++){
        if(S[i]==T[i]){
            cnt++;
        }
    }
    cout << cnt;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    MyLinkedList list = new MyLinkedList();
    for (int i = 0; i < n; i++) {
      String command = sc.next();
      switch (command) {
      case "insert":
        list.insert(Integer.parseInt(sc.next()));
        break;
      case "delete":
        list.delete(Integer.parseInt(sc.next()));
        break;
      case "deleteFirst":
        list.deleteFirst();
        break;
      case "deleteLast":
        list.deleteLast();
        break;
      }
    }
    list.print();
  }
}

class Element {
  Element prev, next;
  int value;

  Element(int value) {
    this.value = value;
  }
}

class MyLinkedList {

  Element nil;

  MyLinkedList() {
    nil = new Element(-1);
    nil.next = nil;
    nil.prev = nil;
  }

  void insert(int value) {
    Element element = new Element(value);
    element.next = nil.next;
    nil.next.prev = element;
    nil.next = element;
    element.prev = nil;
  }

  void delete(int value) {
    for (Element e = nil.next; e.value != -1; e = e.next) {
      if (e.value == value) {
        e.prev.next = e.next;
        e.next.prev = e.prev;
        return;
      }
    }
  }

  void deleteFirst() {
    Element element = nil.next;
    nil.next = element.next;
    element.next.prev = nil;
  }

  void deleteLast() {
    Element element = nil.prev;
    nil.prev = element.prev;
    element.prev.next = nil;
  }

  void print() {
    PrintWriter writer = new PrintWriter(System.out);
    for (Element e = nil.next; e.next.value != -1; e = e.next) {
      writer.print(e.value + " ");
    }
    writer.println(nil.prev.value);
    writer.flush();
  }
}


Measured memory_bytes: 323956
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    set<int> data;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++)data.insert(i*j);
    }
    if(data.count(n))cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
if n % 2 == 0:
    a_ = [[a[i],a[i+1]] for i in range(0,n,2)]
    for i,j in enumerate(a_):
        j_ = j[0]
        k_ = j[1]
        if  (i*2+1) != j_ or (i*2+1) != k_:
            print(0)
            break
    else:
        r = (2 ** (n//2))%((10**9)+7)
        print(int(r))
else:
    if a[0] == 0:
        a_ = [[a[i],a[i+1]] for i in range(1,n,2)]
        for i,j in enumerate(a_,start=1):
            j_ = j[0]
            k_ = j[1]
            if i*2 != j_ or i*2 != k_:
                print(0)
                break
        else:
            r = (2**((n-1)//2))%((10**9)+7)
            print(int(r))
    else:
        print(0)

Measured memory_bytes: 14008
#include<cstdio>
#define N 1<<20
#define int long long
int n,a[N],h[N];
struct segt{
	int mx[N],sz;
	void init(){
		for(sz=1;sz<=n+1;sz<<=1);
		for(int i=1;i<(sz<<1);++i)mx[i]=-1e18;
	}
	void upd(int x,int v){
		mx[x+=sz]=v;
		while(x>>=1)mx[x]=(mx[x<<1]>mx[x<<1|1]?mx[x<<1]:mx[x<<1|1]);
	}
	int qry(int l,int r){
		int ans=-1e18;
		for(l+=sz,r+=sz;l^r;l>>=1,r>>=1){
			if(l&1){ans=(ans<mx[l]?mx[l]:ans);l++;}
			if(r&1){r--;ans=(ans<mx[r]?mx[r]:ans);}
		}
		return ans;
	}
};
segt dp;
signed main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%d",&h[i]);
	for(int i=0;i<n;++i)scanf("%d",&a[i]);
	dp.init();
	dp.upd(0,0);
	for(int i=0;i<n;++i)dp.upd(h[i],dp.qry(0,h[i])+a[i]);
	printf("%lld\n",dp.qry(1,n+1));
	return 0;
}


Measured memory_bytes: 10368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    string T;
    cin >> T;

    REP(i, 0, T.size()){
        if (T[i] == '?'){
            T[i] = 'D';
            // if (i==0){
            //     if (T[i+1] == 'D'){
            //         T[i] = 'P';
            //     } else{
            //         T[i] = 'D';
            //     }
            // } else if (i==T.size()-1){
            //     T[i] = 'D';
            // } else{
            //     if (T[i-1] == 'P'){
            //         T[i] = 'D';
            //     } else{
            //         if (T[i+1] == 'D'){
            //             T[i] = 'P';
            //         } else{
            //             T[i] = 'D';
            //         }
            //     }
            // }
        }
    }
    cout << T << endl;

    return 0;
}


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

int main(){

  int N,K;
  cin >> N >> K;
  int ans = 0;
  for(int i = 0;i < N;i++){
    ans += 500;
  }
  if(ans >= K)
    cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    int64_t N, A, B;
    cin >> N >> A >> B;
    int64_t X = N / (A + B);
    int64_t Y = N % (A + B);
    cout << X * A + min(Y, A) << endl;
}

Measured memory_bytes: 256