akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int h,w,a;
    int i;
    double j;
    while(scanf("%d %d",&h,&w)){
        int mh=0,mw=0;
        if(h==0 && w==0)break;
        a = h*h + w*w;
        for(i=h+1;i<sqrt(a);i++){  //????§??????????????????????????????§??????????????¢?????¢???
            j=sqrt(a - i*i);
            if(i<j&&ceil(j) == floor(j)){  //?¨??????????????§?????????????????????´??°?????§????????¨???
            //???????????°??¨printf("pass equal");
                mh = i;
                mw = j;
                break;
            }
        }//end of for(i=h+1...)
        
        if(!mh&&!mw){  //????§????????????????????????¶??§????????????????????£?????¨???
            while(!mh){
                a++; //????§??????????1??§????????????
                for(i=1;i<sqrt(a);i++){  //????°??????´??°????????¢???
                    j=sqrt(a - i*i);
                    
                    if(i>=j)continue; //???????????????????????£????????????
                    
                    if(ceil(j) == floor(j)){  //??´??°?????§????????¨???
                    //???????????°??¨printf("pass alter");
                        mh = i;
                        mw = j;
                        break;
                    }
                }
            }
        }//end_of_if(!mh&&!mw)
        
        printf("%d %d\n",mh,mw);
    }
    return 0;
}

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

const int MAX_N  = 2e5+10;
int N, K;
int A[MAX_N];

bool ok(double x)
{
	int cnt = 0;
	for(int i=0;i<N;++i){
		if(A[i] > x) cnt += (int)ceil(A[i]/x)-1;
	}
	return cnt <= K;
}

void solve()
{
	double lo = 0, hi = 1e9;
	for(int i=0;i<100;++i){
		double mid = (lo+hi)/2.0;
		if(ok(mid)) hi=mid;
		else lo=mid;
	}
	cout << (long long)(ceil(hi)) << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N;++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 4440
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((b*10+c)%4==0) cout<<"YES"<<endl;else cout<<"NO"<<endl;
}


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

int main(){
   int n;
   string s1, s2;
   int a = 0, b = 0;
   cin >> n;
  
   for (  int i = 0; i < n; i++ ){
    cin >> s1 >> s2;
    if ( s1 > s2 ) a+=3;
    else if ( s1 < s2 ) b+=3;
    else {
     a++; b++;
    }
   }

 cout << a << " " << b << endl;

 return 0;
}


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int f[] = new int[n];
        int p[][] = new int[n][11];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 10; j++) {
                int fb = sc.nextInt();
                f[i] *= 2;
                f[i] += fb;
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= 10; j++) {
                p[i][j] = sc.nextInt();
            }
        }

        int max = Integer.MIN_VALUE;
        for (int num = 1; num < 1024; num++) {
            int sum = 0;
            for (int i = 0; i < n; i++) {
                int c = countBit(num & f[i]);
                sum += p[i][c];
            }
            max = Math.max(max, sum);
        }

        System.out.println(max);
    }

    private int countBit(int n) {
        n = ((n & 0xAAAAAAAA) >> 1) + (n & 0x55555555);
        n = ((n & 0xCCCCCCCC) >> 2) + (n & 0x33333333);
        n = ((n & 0xF0F0F0F0) >> 4) + (n & 0x0F0F0F0F);
        n = ((n & 0xFF00FF00) >> 8) + (n & 0x00FF00FF);
        n = ((n & 0xFFFF0000) >> 16) + (n & 0x0000FFFF);

        return n;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 25940
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		long N;
		cin >> N;

		auto pf = primefactor( N );
		int cnt = 0;

		for( auto& kv: pf ) {
			int x = kv.second;
			for( int i = 1; x >= i; ++i ) {
				cnt += 1;
				x -= i;
			}
		}

		cout << cnt << endl;
	}

	map<long, int> primefactor( long n ) {
		map<long, int> r;

		if( n > 1 ) {
			long x = n;
			for( ; x%2 == 0; x /= 2 ) { r[2] += 1; }
			for( long i = 3; i*i <= n; i += 2 ) {
				for( ; x%i == 0; x /= i ) { r[i] += 1; }
			}
			if( x > 1 ) { r[x] += 1; }
		}

		return r;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

using namespace std;

using ll = long long;

int main(void) {
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            cout << i << "x" << j << "=" << i * j << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
double a,b,c,d,e,f;
double x,y;
while(cin >> a >> b >> c >> d >> e >> f){
  x = (double)((e*c-b*f) / (a*e-b*d));
  y = (double)((-(d*c)+a*f) / (a*e-b*d));
  if(x == 0)
	x = 0;
  if(y == 0)
	y = 0;
  printf("%.3f %.3f\n",x,y);
 }
}

Measured memory_bytes: 1236
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll N = 3005, mod = 1e9 + 7, MOD = 5 * mod;
ll n, ans, dp[N][2];
string s;
int main(){
    cin >> n >> s;s = '#' + s;
    dp[1][1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= i; j++)dp[j][0] = dp[j][1], dp[j][1] = 0;
        for(int j = 1; j <= i; j++){
            if(s[i - 1] == '<')dp[j][1] = dp[j - 1][1] + dp[j - 1][0] - dp[0][0];
            if(s[i - 1] == '>')dp[j][1] = dp[j - 1][1] + dp[i - 1][0] - dp[j - 1][0];
            (dp[j][1] += MOD) %= mod;
        }
    }
    cout << dp[n][1] << endl;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {

	public static void main(String[] args)throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br =new  BufferedReader(is);
		while(true){
			String str = br.readLine();
			if(str == null)
				break;
			String str1 = str.substring(0, str.indexOf(" "));
			String str2 = str.substring(str.indexOf(" ")+1);
			int n1 = Integer.parseInt(str1);
			int n2 = Integer.parseInt(str2);
			int count1=0;
			n1 = n1 + n2;
			while(n1 > 0){
				n1 = n1/10;
				count1++;
			}
			System.out.println(count1);
		}
	}

}

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

template <typename T>
class BIT
{
public:
  int N;
  vector<T> bit;

  BIT(int n, T m = 0)
  {
    init(n, m);
  }

  void init(int n, int m)
  {
    N = n;
    bit.resize(n + 1);
    for (int i = 0; i < bit.size(); i++)
    {
      bit[i] = m;
    }
  }

  int64_t sum(int i)
  {
    T s = 0;
    while (i > 0)
    {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, T x)
  {
    while (i <= N)
    {
      bit[i] += x;
      i += i & -i;
    }
  }
};

int main()
{
  int N, Q, c, x, y;
  cin >> N >> Q;
  BIT<int64_t> B(N + 1);
  queue<int64_t> ans;
  for (int i = 0; i < Q; i++)
  {
    cin >> c >> x >> y;
    if (c)
    {
      ans.push(B.sum(y) - B.sum(x - 1));
    }
    else
    {
      B.add(x, y);
    }
  }
  while (ans.size())
  {
    cout << ans.front() << endl;
    ans.pop();
  }
}


Measured memory_bytes: 4212
N,K = map(int,input().split())

n = 0
m = 1
res = []
while m<=N :
	n = 0
	while True :
		if m*pow(2,n) >= K :
			res.append(n)
			m+=1
			break
		n+=1
pr = 0
for n in res :
	pr += (1/N)*pow(1/2,n)
print(pr)

Measured memory_bytes: 3864
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> data(h, vector<char>(w));
    vector<bool> x(h,false),y(w,false);

    rep(i,h){
        rep(j,w){
            cin >> data[i][j];
            if(data[i][j]=='#'){
                x[i]=true;
                y[j]=true;
            }
        }
    }

    rep(i,h){
        if(x[i]){
            rep(j,w){
                if(y[j]){
                    cout << data[i][j];
                }
            }
        cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
  int b,c;
  cin >> b >> c;

  int b_ans = 0,c_ans = 0;

  for(int i=0; i<b; i++){
      int z = std::pow(10, i);
      b_ans = b_ans + c * z;
  }

    for(int i=0; i<c; i++){
      int z = std::pow(10, i);
      c_ans = c_ans + b * z;
  }
  
if(b < c){
cout  << c_ans << endl;
}else{
cout  << b_ans << endl;
}
      

      

    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n;
	cin >> n;
	cout << n*800 - (n/15)*200;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#define ll long long
#define N 5003
#define M 202
#define pi pair < int , int >
#define mkp(a,b) make_pair(a, b)

using namespace std;

ll g[N][N], dis[N];
int a[N], b[N][M], l[N][M], r[N][M];
int n, m;

stack < pi > st;

int read();

int main(){
	n = read();m = read();
	for(int i = 1; i < n; ++i) a[i] = read(), dis[i] = dis[i - 1] + a[i];
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			b[i][j] = read();
	for(int i = 1; i <= m; ++i){
		for(int j = 1; j <= n; ++j){
			int x = b[j][i];
			while(!st.empty() && st.top().first <= x){
				int p = st.top().second;st.pop();
				r[p][i] = j - 1;
			}
			st.push(mkp(x, j));
		}
		while(!st.empty()){
			int p = st.top().second;
			r[p][i] = n;st.pop();
		}
		for(int j = n; j; --j){
			int x = b[j][i];
			while(!st.empty() && st.top().first < x){
				int p = st.top().second;st.pop();
				l[p][i] = j + 1;
			}
			st.push(mkp(x, j));
		}
		while(!st.empty()){
			int p = st.top().second;
			l[p][i] = 1;st.pop();
		}
	}
	for(int i = 1; i <= m; ++i)
		for(int j = 1; j <= n; ++j){
			int xl = l[j][i], xr = r[j][i], x = b[j][i];
			g[xl][j] += x;g[xl][xr + 1] -= x;
			g[j + 1][j] -= x;g[j + 1][xr + 1] += x;
		}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			g[i][j] += g[i][j - 1];
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			g[j][i] += g[j - 1][i];
	ll ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = i; j <= n; ++j)
			ans = max(ans, g[i][j] - dis[j - 1] + dis[i - 1]);
	cout << ans << endl;
	return 0;
}

int read(){
	int x = 0;char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return x;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

  ll ans = 0;
  rep(b, K + 1, N + 1) {
    ll q = N / b;
    ll r = N - q * b;
    ans += q * (b - K) + max(r - (K - 1), 0LL);
  }
  if (K == 0) ans = N * N;

  cout << ans << BR;
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  int alice = 0, bob = 0;
  rep(i, n) {
    if(i&1) bob += a[i];
    else alice += a[i];
  }
  cout << alice-bob << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
v=[]; ans=[]
for i in range(n):
    c=input()
    v.append(int(c))

v= sorted(v)[:min(len(v), 5)]
for i,d in enumerate(v):
    for i2,d2 in enumerate(v):
        if i==i2: continue;
        w=int(str(d) + str(d2))
        ans.append(w)
ans.sort()
print(ans[2])



Measured memory_bytes: 5952
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323

ll n, c;
const int N = 1e5+5;
ll a[N], b[N], v[N], type1[N], type2[N];

void solve()
{
       cin>>n>>c;
       rep(i, 1, n+1)
       {
              cin>>a[i]>>v[i];
              b[i] = c - a[i];
       }
       // a[i] - distance in clockwise from O, b[i] - dis in anti clock from O
       // type 1: 2*OA + OB
       // fix one x_a, then search for best x_b => can only be x_b + 1, x_b + 2, ...., x_b + n, O
       // in anti clock best up to all x_i calculate
       ll sum = 0;
       for(ll i = n; i > 0; i--)
       {
              type1[i] = type1[i+1];
              sum += v[i];
              if(sum - b[i] > type1[i]) type1[i] = sum - b[i];
       }
       // type1: for anticlockwise move
       //for(ll i=1; i<=n; i++) cout<<"type1["<<i<<"] : "<<type1[i]<<" \n";
       //cout<<endl;
       ll mx = 0;
       sum = 0;
       for(ll i=1; i < n; i++)
       {
              sum += v[i];
              ll x = sum - 2*a[i] + type1[i+1];
              ll y = sum - a[i];
              x = max(x, y);
              mx = max(mx, x);
       }
       mx = max(mx, sum + v[n] - a[n]);
       sum=0;
       type2[0] = 0;
       for(ll i = 1; i <= n; i++)
       {
              type2[i] = type2[i-1];
              sum += v[i];
              if(sum - a[i] > type2[i]) type2[i] = sum - a[i];
       }
       sum = 0;
       for(ll i = n; i > 1; i--)
       {
              sum += v[i];
              ll x = sum - 2*b[i] + type2[i-1];
              ll y = sum - b[i];
              x = max(x, y);
              mx = max(mx, x);
       }
       mx = max(mx, sum + v[1] - b[1]);
       cout<<mx<<endl;
}


int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 4224
N=int(input())
L=list(map(int,input().split()))

ans=0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in  range(j+1,N):
            if L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
                if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
                    ans+=1

print(ans)

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cout << (s.find('7') != string::npos ? "Yes\n" : "No\n");
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication26
{
    class Program
    {
        static void Main(string[] args)
        {
			string s,t;
			while(true)
			{
				s=Console.ReadLine();
				if (string.IsNullOrEmpty(s)) break;
				t=Console.ReadLine();
				string[] a = s.Split(' ');
				string[] b = t.Split(' ');
				int d,e;
				d=0;e=0;
				for(int c =0;c<4;c++)
				{
					if(a[c]==b[c])d++;
					else{
						bool flag=false;
						for(int h =0;h<4;h++)
						{
							if(a[c]==b[h])flag=true;
						}
						if(flag==true)e++;
					}
				}
				Console.WriteLine("{0} {1}",d,e);
			}
		}
    }
}
 
 

Measured memory_bytes: 9144
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int result = X / 500 * 1000;
		X = X % 500;
		result += X / 5 * 5;
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 23508
n, w = map(int, input().split())

value = []
weight = []

for _ in range(n):
  vi, wi = map(int, input().split())
  value.append(vi)
  weight.append(wi)

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

for i in range(n):
  for j in range(w, weight[i] - 1, -1):
    dp[j] = max(dp[j], dp[j - weight[i]] + value[i])

print(dp[w])


Measured memory_bytes: 5924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,m;
  while(cin>>n>>d,n||d){
    int i,j,k;
    vector<int> v[n];
    int sum[n];
    int ma=0,mi=1000000000;
    for(i=0;i<n;i++){
      cin >> m;
      sum[i]=0;
      for(j=0;j<m;j++){
	cin >> k;
	sum[i]+=k;
	v[i].push_back(k);
      }
      ma=max(ma,sum[i]);
      mi=min(mi,sum[i]);
    }
    bool f=true,ff=false;
    while(f){
      f=false;
      ff=true;
      for(i=0;i<n;i++){
	if(v[i].size()==0) continue;
	ff=false;
	k=v[i][v[i].size()-1];
	ma=0;mi=1000000000;
	for(j=0;j<n;j++){
	  if(i==j) continue;
	  ma=max(ma,sum[j]);
	  mi=min(mi,sum[j]);
	}
	if(abs(ma-(sum[i]-k))<=d&&abs(mi-(sum[i]-k))<=d){
	  sum[i]-=k;
	  v[i].pop_back();
	  f=true;
	  break;
	}
      } 
    }
    if(ff) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
print(n-k+1)

Measured memory_bytes: 23432
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n >> x >> y;
  map<int, int> ans;
  REP2(int, i, 1, n) REP2(int, j, i+1, n+1) ++ans[min(min(abs(j-i), abs(x-i)+1+abs(y-j)), abs(y-i)+1+abs(x-j))];
  REP2(int, k, 1, n) cout << ans[k] << endl;

  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
vector<vector<int>> v;
vector<int> dp;
int dfs(int x) {
    if(dp[x]) return dp[x];
    for(auto i:v[x]) dp[x]=max(dp[x],dfs(i)+1);
    return dp[x];
}
int main() {
    cs
    int n,m,x,y;cin>>n>>m;
    v.resize(n+1);
    dp.resize(n+1);
    rep(i,m) {
        cin>>x>>y;
        v[x].push_back(y);
    }
    repp(i,1,n) {
        x=dfs(i);
    }
    cout<<*max_element(dp.begin(),dp.end());
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
using namespace std;



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

    vector<int> vec(n);

    for(int i = 0; i < n; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    if(n <= k)
    {
        cout << 0 << endl;
        return 0;
    }

    long long sum = 0;
    for(int i = k; i < n; i++) sum += vec.at(i);

    cout << sum << endl;

    
    
    
    return 0;
}

Measured memory_bytes: 1024
N, C = map(int, input().split())
d = []
for i in range(C):
    d.append(list(map(int, input().split())))
c = []
for i in range(N):
    c.append(list(map(int, input().split())))

diff0 = []
diff1 = []
diff2 = []

for color in range(1, C+1):
    d0 = 0
    d1 = 0
    d2 = 0
    for i in range(N):
        for j in range(N):
            diff = d[c[i][j]-1][color-1]
            if (i+j) % 3 == 0:
                d0 += diff
            elif (i+j) % 3 == 1:
                d1 += diff
            else:
                d2 += diff
    diff0.append(d0)
    diff1.append(d1)
    diff2.append(d2)

ans = 10**10
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i != j and j != k and k != i:
                ans = min(ans, diff0[i] + diff1[j] + diff2[k])
print(ans)

Measured memory_bytes: 45660
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = readline() |> chomp
	n = length(s)
	f = 0
	for i in 1:n>>1
		if s[i]!=s[n+1-i]
			f = 1
		end
	end
	m = n>>1
	for i in 1:m>>1
		if s[i]!=s[m+1-i]
			f = 1
		end
	end
	for i in div(n+3,2):n
		if s[i]!=s[n+div(n+3,2)-i]
			f = 1
		end
	end
	println(f==0?"Yes":"No")
end

main()

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll l, r;
  cin >> l >> r;
  const int B = 62;
  const int MOD = 1e9 + 7;
  int dp[B][2][2][2];
  memset(dp, -1, sizeof dp);
  function <int(int,int,int,int)> rec = [&] (int pos, int gt_x, int lt_y, int msb) {
    if (pos == -1) return 1;
    int& ret = dp[pos][gt_x][lt_y][msb];
    if (ret != -1) return ret;
    ret = 0;
    int bit_l = (l >> pos) & 1;
    int bit_r = (r >> pos) & 1;
    // x = 0, y = 0
    if (gt_x or (bit_l == 0)) {
      ret += rec(pos - 1, gt_x, lt_y or (bit_r == 1), msb);
      if (ret > MOD) ret -= MOD;
    }
    // x = 0, y = 1
    if ((gt_x or (bit_l == 0)) and (lt_y or (bit_r == 1)) and msb) {
      ret += rec(pos - 1, gt_x, lt_y, msb);
      if (ret > MOD) ret -= MOD;
    }
    // x = 1, y = 1
    if (lt_y or (bit_r == 1)) {
      ret += rec(pos - 1, gt_x or (bit_l == 0), lt_y, 1);
      if (ret > MOD) ret -= MOD;
    }
    return ret;
  };
  cout << rec(B - 1, 0, 0, 0) << '\n';
  return (0);
}


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
/*vector<int> d(N+1,-1);

//頂点xとの各点との最短距離を求める
void bfs(int x,Graph &G){
  d[x] = 0;
  queue<<int> que;
  que.push(x);

  // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}*/

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> s(M),c(M);
  rep(i,M){
    cin >> s[i];
    cin >> c[i];
  }
  string ans = "-1";
  int i = 0;
  if(N == 2) i = 10;
  if(N == 3) i = 100;
  
  for(;i<=999;i++){
    string S = to_string(i);
    bool flag = true;//iが条件を満たす整数かどうか
    for(int j = 0;j<M;j++){
      if(S[s[j]-1] != (char)(c[j] + 48)){
        flag = false;
        break;
      }
    }
    if(flag){
      ans = S;
      break;
    }
  }
  if(N >= 2 && ans[0] == '0') cout << -1 << endl;
  else cout << ans << endl;
 }


Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
ls = [0]
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        ls.append(ls[i]+1)
    else:
        ls.append(ls[i])

for i in range(q):
    l,r = map(int,input().split())
    print(ls[r-1]-ls[l-1])

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[123], t[123];

int main(){
	int n; scanf("%d%s%s", &n, s, t);
	REP(i, n) printf("%c%c", s[i], t[i]);
}


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

int main(){

  int N,a,b,c;

  std::cin >> N;

  for(int i=0;i<N;i++){
    std::cin >> a >> b >> c;
    a = pow(a,2);
    b = pow(b,2);
    c = pow(c,2);

    if(a+b==c||a+c==b||b+c==a){
      std::cout << "YES" << std::endl;
    }else{
      std::cout << "NO" << std::endl;
    }
  }
}

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

int main() {
  int n, m, ans = -1;
  cin >> n >> m;
  vector<int> s(n);
  vector<char> c(n);
  for (int i = 0; i < m; ++i) cin >> s[i] >> c[i];
  for (int i = pow(10, n-1)-1, ma = pow(10, n); i < ma; ++i) {
    string str = to_string(i);
    if ((int)str.size() != n) continue;
    
    bool flag = 1;
    for (int j = 0; j < m; ++j) {
      if (str[s[j]-1] != c[j]) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
s = str(input())
q = int(input())
ls = [list(map(str,input().split())) for _ in range(q)]
a = -1
f = []
b = []
for i in range(q):
    if ls[i] == ["1"]:
        if a == -1:
            a = -2
        else:
            a = -1
    else:
        if a+int(ls[i][1]) == 0:
            f.append(ls[i][2])
        else:
            b.append(ls[i][2])
if a == -1:
    f = f[::-1]
    print("".join(f)+s+"".join(b))
else:
    b = b[::-1]
    print("".join(b)+s[::-1]+"".join(f))

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

int main(){
  int N; cin>>N;
  
  int p,s=0,x=0;
  for(int i=0;i<N;i++){
    cin>>p; s+=p;
    x=max(x,p);
  }
  cout<<s-x/2<<endl;
}

Measured memory_bytes: 256
/*
 * atcoder/abc170/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;
  cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  sort(A.begin(), A.end());
  int max_ = A[n-1];
  vector<int> C(max_+1, 0);
  vector<bool> ok(max_+1, true);
  loop(i,0,n) {
    C[A[i]]++;
  }

  for (int i=0; i<n; i++) {
    int a = A[i];
    // cout << a << " : ";
    if (ok[a]) {
      for (int j=a*2; j<=max_; j += a) {
        ok[j] = false;
        // cout << " " << j;
      }
    }
    // cout << endl;
  }

  int count = 0;
  // vector<int> D;
  for (auto&&a: A) {
    if (C[a]>1) continue;
    count += ok[a];
    // if (ok[a]) D.push_back(a);
  }
  cout << count << endl;
  // dump(D);
}


Measured memory_bytes: 7980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		while(true){
		//Scanner scan = new Scanner(System.in);


		int H = scan.nextInt();
	    int W = scan.nextInt();


	    if(H == 0 && W == 0)break;
	    for(int i = 1;i <= H ;i++){
	    	for(int j = 1;j <= W; j++){
	    		if((i == 1 || j == 1) || i == H || j == W){
	    			//sb.append("#");
	    			System.out.print("#");
	    		}else{
	    			//sb.append(".");
	    			System.out.print(".");
	    		}

	    	}
	    	System.out.println();
	    	//sb.append("\n");
	    }
	    //sb.append("\n");
	    System.out.println();
	   }
		//System.out.print(sb);

	}

}

Measured memory_bytes: 37376
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
long long int arr[n];
for(int i = 0 ; i < n ; i++)
    cin >> arr[i];
int ans = 1,ma = 1;
for(int i = 1 ; i < n ; i++){
    if(arr[i] <= arr[i-1])
        ans++;
    else{
        if( ma < ans)
            ma = ans;
        ans = 1;
    }
}
if(ma < ans)
    ma = ans;
cout << ma-1 << endl;
return 0;
}


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

int main() {
    int n;
    float res;
    cin >> n;
    if (n==1)
        res = 1.0;
    else 
        if (n%2==0)
            res = 0.5;
        else
        {
            int x = (n-1)/2+1;
            res = (float)x / (float)n;
        }
    printf("%.6f", res); 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int c[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  int a,b;
  cin>>a>>b;
  if(c[a]==c[b])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  
  int h , w;
  scanf("%d %d",&h ,&w);
  
  char s[h][w];
  for(int i = 0;i < h;i ++){
      scanf("%s",s[i]);
  }
  
  int ans = 0 , flag = 0;

  for(int i = 0;i < h;i ++){
    for(int j = 0;j < w;j ++){
      if(s[i][j] == '#'){
        if(s[i-1][j] == '#' && i - 1 >= 0){
          ans ++;
        }
        if(s[i][j - 1] == '#' && j -1 >= 0){
          ans ++;
        }
        if(s[i][j + 1] == '#' && j + 1 < w){
          ans ++;
        }
        if(s[i + 1][j] == '#' && i + 1 < h){
          ans ++;
        }
        if(ans == 0){
          flag ++;
        }
        ans = 0;
      }
    }
  }
  
  if(flag == 0){
   printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FF 99999
#define P pair<int,int>
int main(){
        int h,w;
        cin>>h>>w;
        vector<string> m(h);
        int sum=0;
        for(int i=0; i<h; i++){
                cin>>m[i];
                for(int j=0; j<w; j++){
                        if(m[i][j]=='.')
                                sum++;
                }
        }
        sum-=1;
        vector<vector<int>> route(h,vector<int>(w,FF));
        route[0][0]=0;
        queue<pair<int,int>> now;
        now.push(P(0,0));

        while(!now.empty()){
          		P ax;
                ax=now.front(),now.pop();
                int tx=ax.first,ty=ax.second;
                if(tx==w-1&&ty==h-1){
                        cout<<sum-route[h-1][w-1];
                        return 0;
                }
                int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
                for(int i=0; i<4; i++){
                        int ttx=tx+dx[i],tty=ty+dy[i];
                        if(ttx<0||ttx>=w||tty<0||tty>=h)
                                continue;
                        if(m[tty][ttx]=='.'&&route[tty][ttx]==FF){
                                route[tty][ttx]=route[ty][tx]+1;
                                now.push(P(ttx,tty));
                        }
                }
        }
        cout<<-1;
}

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

int main() {
    int n;
    cin >> n;
    vector<int64_t> march(5);
    rep(i, n){
        string str;
        cin >> str;
        if(str[0] == 'M')march[0]++;
        if(str[0] == 'A')march[1]++;
        if(str[0] == 'R')march[2]++;
        if(str[0] == 'C')march[3]++;
        if(str[0] == 'H')march[4]++;
    }
    int64_t ans = 0;
    ans += march[0] * march[1] * march[2];
    ans += march[0] * march[1] * march[3];
    ans += march[0] * march[1] * march[4];
    ans += march[0] * march[2] * march[3];
    ans += march[0] * march[2] * march[4];
    ans += march[0] * march[3] * march[4];
    ans += march[1] * march[2] * march[3];
    ans += march[1] * march[2] * march[4];
    ans += march[1] * march[3] * march[4];
    ans += march[2] * march[3] * march[4];

    cout << ans << endl;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a * b) > (c * d)) {
            cout << a * b << endl;
    }
    else if ((a * b) < (c * d)){
            cout << c*d << endl;
    }
    else{
        cout << a * b << endl;
    }
}

Measured memory_bytes: 256
n,d = gets.chomp.split(" ").map(&:to_i)
x = []

for i in 1..n do
    x.push(gets.chomp.split(" ").map(&:to_i))
end

cnt = 0

for i in 1..n-1 do
    for j in i+1..n do
        dis = 0.0
        for k in 1..d do
            dis += (x[i-1][k-1] - x[j-1][k-1]) ** 2
        end
        if Math.sqrt(dis) % 1.0 == 0.0
            cnt += 1
        end
    end
end


puts cnt

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

using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    for (int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;
        s--;
        if (a[s] >= 0 && a[s] != c) {
            puts("-1");
            return 0;
        }
        a[s] = c;
    }
    if (a[0] == 0 && n > 1) {
        puts("-1");
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] == -1) {
            if (i == 0 && n > 1) a[i] = 1;
            else a[i] = 0;
        }
        cout << a[i];
    }
    cout << "\n";
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  cout << R + (100 * max(0LL, 10 - N)) << endl;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $N);

$ls = array_map(function ($e) {
    return intval($e);
}, explode(' ', trim(fgets(STDIN))));

$ans = 0;

for ($i=0; $i < $N; $i++) {
    for ($j=$i+1; $j < $N; $j++) {
        for ($k=$j+1; $k < $N; $k++) {
            if ($ls[$i] !== $ls[$j] && $ls[$i] !== $ls[$k] && $ls[$j] !== $ls[$k]) {
                if ($ls[$i]+$ls[$j] > $ls[$k] && $ls[$j]+$ls[$k] > $ls[$i] && $ls[$i]+$ls[$k] > $ls[$j]) {
                    $ans++;
                }
            }
        }
    }
}

echo $ans;

echo PHP_EOL;


Measured memory_bytes: 16244
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
Y = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7

X_SUM, Y_SUM = 0, 0
for i, x in enumerate(X):
    X_SUM = (X_SUM + x * (i - (N - i - 1))) % mod

for i, y in enumerate(Y):
    Y_SUM = (Y_SUM + y * (i - (M - i - 1))) % mod

print((X_SUM * Y_SUM) % mod)


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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 

#define ll                      long long
#define read1(x)                 cin>>x
#define read2(x,y)               cin>>x>>y
#define print(x)				cout<<x<<endl
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define uset                    unordered_set
#define clr(a,b)                memset(a,b,sizeof a)
#define all(ds)                 ds.begin(), ds.end()
#define rev(ds)                 ds.rbegin(), ds.rend()
#define asc(A)                  sort(A.begin(), A.end())
#define dsc(A)                  sort(A.begin(), A.end(), greater<int>())
#define gcd(x,y)                __gcd(x,y)
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)               for(int i=n-1; i>=0; --i)
#define printVector(v)          for(int i= 0;i<v.size();i++) {cout<<v[i]<<" ";} cout<<endl;
#define precise(x)              cout<<fixed<<setprecision(x)
#define inf                     10000000000000

 

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll power(ll x, ll y, ll m) { if(!y) return 1; ll p=power(x, y>>1, m)%m; p=p*p%m; return (y&1)?(x*p)%m:p;}
ll modInverse(ll a, ll m){ return power(a, m-2, m); }
bool isPrime(ll num){bool flag=true;for(ll i =2;i<=num/2;i++){if(num%i==0) {flag=false; break;} }return flag;}
ll sumofdigits(ll n){ll c=0;while(n>0){c++;n/=10;}return c;}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) {return a.first > b.first; }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {return a.second < b.second; }

//const double PI= 2*acos(0.0);
const long long MOD= 1000000007;


void solve(){
    
    int n; cin>>n;
    if(n%1000 == 0)print(0);
    else print(1000-n%1000);
}

int main()
{
#ifndef ONLINE_JUDGE  
    input_output  
#else   
    fastio
#endif

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

    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main(){
int  n;
cin >> n;
vector <int>a(n);
int sum =0;
for(int i=0;i<n;i++){
cin >> a.at(i);
sum += a.at(i);
}
int ave = sum / n;
int mx=0;
for(int i=0;i<n;i++){
mx += pow(a.at(i)-ave,2);
}
int mx2=0;
for(int i=0;i<n;i++){
mx2 += pow(a.at(i)-ave-1,2);
}
  
  
cout<< min(mx,mx2) <<endl;
}

Measured memory_bytes: 3592
#include <cstdio>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

char buf[110][110];

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  int nRow = 100;
  int nCol = 100;

  REP(i, nRow) {
    REP(j, nCol) {
      buf[i][j] = i < nRow/2 ? '.' : '#';
    }
  }

  {
    int curA = 1;
    REP(i, nRow) {
      REP(j, nCol/ 2) {
        if(curA == a) {
          break;
        }
        buf[nRow-1-2*i][2*j] = '.';
        curA++;
      }
    }
  }
  {
    int curB = 1;
    REP(i, nRow) {
      REP(j, nCol/ 2) {
        if(curB == b) {
          break;
        }
        buf[2*i][2*j] = '#';
        curB++;
      }
    }
  }

  printf("%d %d\n", nRow, nCol);
  REP(i, nRow) {
    puts(buf[i]);
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int x = scanner.nextInt();
			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			long sum = 0L;
			for (int i = 0; i < n - 1; i++) {
				if (a[i] + a[i + 1] > x) {
					sum += a[i] + a[i + 1] - x;
					a[i + 1] -= Math.min(a[i] + a[i + 1] - x, a[i + 1]);
				}
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 60468
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;



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

    vector<int> B(N);
    rep(i,N){
        
        B[i] = A[i] - (i+1);
    }

    sort(B.begin(), B.end());
/*
    ll x = B[N/2];
    ll ans = 0;
    rep(i,N){
        ans += abs(A[i]-B[i]);
    }

    cout << ans << endl;

*/

    ll ans = 0;
    rep(i,N){
        ans += abs(B[i]-B[N/2]);
    }
    cout << ans << endl;
/*
    vector<int> median;
    median.push_back(B[(N-1)/2]);
    if (N%2 == 0){
        median.push_back(B[N/2]);
    }
    ll ans = INF;
    ll res = INF;
    rep(i,median.size()){
        ll tmp = 0;
        rep(j,N){
            tmp += abs(A[j]-(median[i]-(i+1)));
        }
        if (res > tmp){
            ans = median[i];
        }
        res = tmp;
    }

    cout << ans << endl;
*/
}



Measured memory_bytes: 4844
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		char[] s=sc.next().toCharArray();
		BIT[] count=new BIT[26];
		for(int j=0; j<26; j++){
			count[j]=new BIT(1+s.length);
		for(int i=1; i<=s.length; i++){
			if((s[i-1]-'a')==j){
				count[j].add(i,1);
			}
		}
		}
		int q=sc.nextInt();
		for(int i=0; i<q; i++){
			int a=sc.nextInt();
			int b=sc.nextInt();
			if(a==1){
				char c=sc.next().charAt(0);
				count[c-'a'].add(b,1);
				count[s[b-1]-'a'].add(b,-1);
				s[b-1]=c;
			}else{
				int c=sc.nextInt();
				int ans=0;
				for(int j=0; j<26; j++){
					if(count[j].get(c)-count[j].get(b-1)>0){
						ans++;
					}
				}
				System.out.println(ans);
			}
		}
	}
	static class BIT{
		int n;
		int[] data;
		BIT(int n){
			this.n=n;
			data = new int[n+1];
		}
		void add(int i,int v){
			for(;i<=n;i+=i&(-i))data[i]+=v;
		}
		int get(int i){
			int res = 0;
			for(;i>0;i-=i&(-i))res+=data[i];
			return res;
		}
	}
}


Measured memory_bytes: 127492