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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
int INF = 1001001001;

int main() {
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    rep(i,n) {
        rep(j,i) {
            int l = a[i]+a[j];
            auto it = lower_bound(all(a), l);
            int c = it-a.begin();
            ans += c-i-1;
            //printf("%d %d %d\n", a[j], a[i], l);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    int i=0;
    size_t size=s.length();
    string ans;
    ans="Yes";
    
    for(i=0; i<size; i++){
        if(i%2==0){ 
            if(s[i]=='L'){
                ans="No";
            }
        }
    }
    
    for(i=0; i<size; i++){
        if(i%2 != 0){
            if(s[i]=='R'){
                ans="No";
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

const int M = 80 * 80;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W)), B; B = A;
  for(auto* p: {&A, &B}) for(auto& v: *p) for(auto& i: v) cin >> i;

  bool dp[H][W][M+1] = {};
  dp[0][0][abs(A[0][0]-B[0][0])] = dp[0][0][abs(B[0][0]-A[0][0])] = true;
  int dy[2] = {0, 1};
  int dx[2] = {1, 0};
  for(auto i = 0; i < H; ++i) for(auto j = 0; j < W; ++j) for(auto k = 0; k <= M; ++k) if(dp[i][j][k]) {
    for(auto f: {0, 1}) {
      auto y = i + f;
      auto x = j + (f^1);
      if(y < H && x < W)
        for(auto d: {k + A[y][x] - B[y][x], k - A[y][x] + B[y][x]})
          if(abs(d) <= M)
            dp[y][x][abs(d)] = true;
    }
  }

  for(auto k = 0; k <= M; ++k) if(dp[H-1][W-1][k]) {
    cout << k << endl;
    break;
  }
}


Measured memory_bytes: 40320
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;


int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	if (a + b >= c) {
		cout << b + c << endl;
	}
	else {
		cout << a + 2 * b + 1 << endl;
	}
}

Measured memory_bytes: 256
n, a = map(int, input().split())
x = list(map(int, input().split()))

for i in range(n):
  x[i] -= a

d = [0] * 6000
ans = 0
for dif in x:
  ans += d[-dif+3000]
  if dif == 0:
    ans += 1
  if dif < 0:
    for i in range(6000):
      if 0 <= i+dif < 6000:
        d[i+dif] += d[i]
  else:
    for i in range(5999, -1, -1):
      if 0 <= i+dif < 6000:
        d[i+dif] += d[i]
  d[dif+3000] = d[dif+3000] + 1
  
print(ans)

Measured memory_bytes: 3188
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int check(int n) {
    int ans = 1;
    while (n) {
        n %= __builtin_popcount(n);
        ans++;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    string a;
    cin >> a;
    int cnt = 0;
    forn (i, 0, n) {
        a[i] -= '0';
        cnt += a[i];
    }
    if (cnt == 0) {

    }
    if (cnt == 1) {

    }
    reverse(all(a));
    vector <int> m = {cnt - 1, cnt + 1};
    if (m[0] < 1)
        m[0] = 1;
    vector <vector <int>> b(2, vector <int> (n));
    forn (i, 0, sz(m)) {
        int x = m[i];
        int r = 1;
        forn (j, 0, n) {
            r %= x;
            b[i][j] = r;
            r *= 2;
        }
    }
    vector <int> cur(sz(m));
    forn (i, 0, sz(m)) {
        forn (j, 0, n)
            if (a[j])
                cur[i] = (cur[i] + b[i][j]) % m[i];
    }
    vector <int> ans;
    forn (i, 0, n) {
        if (cnt == 1 && a[i] == 1) {
            ans.pb(0);
            continue;
        }
        int t;
        if (a[i]) {
            t = cur[0];
            t = (t - b[0][i] + m[0]) % m[0];
        } else {
            t = cur[1];
            t = (t + b[1][i]) % m[1];
        }
        cerr << t << " ";
        ans.pb(check(t));
    }
    reverse(all(ans));
    forn (i, 0, n)
        cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 6808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<char,char> C;

vector<C> v;
int N, Q;
string s;

int check(int pos){
	rep (i, Q){
		if (v[i].first == s[pos]){
			if (v[i].second == 'L'){
				--pos;
			}else{
				++pos;
			} // end if
		} // end if
		if (pos < 0) return -1;
		if (pos >= N) return 1;
	} // end rep
	return 0;
}

int left_border(void){
	int l = -1;
	int r = N;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if (check(mid) != -1){
			r = mid;
		}else{
			l = mid;
		} // end if
	} // end while
	return r;
}

int right_border(void){
	int l = -1;
	int r = N;
	while(r - l > 1){
		int mid = (l + r) / 2;
		if (check(mid) != 1){
			l = mid;
		}else{
			r = mid;
		} // end if
	} // end while
	return l;
}


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	v.clear();
	
	cin >> N >> Q;
	cin >> s;

	rep (i, Q){
		char a, b; cin >> a >> b;
		v.push_back(C(a,b));
	} // end rep
	
	int l = left_border();
	int r = right_border();

	int res = max(0, r - l + 1);
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 1100
import math
N, D = map(int, input().split())
P = []
ans = 0
for _ in range(N):
  new_p = [int(x) for x in input().split()]
  for p in P:
    dist = math.sqrt(sum([(new_p_i - p_i)**2 for new_p_i, p_i in zip(new_p, p)]))
    if dist.is_integer():
      ans += 1
  P.append(new_p)
print(ans)

Measured memory_bytes: 3060
n = int(input())
A = list(map(int,input().split()))
money = 1000
stock = 0
for i in range(n-1):
    if A[i] >= A[i+1]:
        money += stock * A[i]
        stock = 0
    elif money >= A[i]:
        stock = money // A[i]
        money -= stock * A[i]
print(stock * A[n-1] + money)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
long long n,x;
bool yes=false;
int main()
{
    cin>>n;
    if (n==2)
    {
        cout<<2;
        return 0;
    }
    for (int i=n;1;i++)
    {
        yes=false;
        for (int j=(i/2)+1;j>1;j--)
        {
            if (i%j==0)
            {
                yes=true;
                break;
            }
        }
        if (!yes)
        {
            cout<<i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, a, b, c, d, ans;
	cin >> a >> b >> c >> d >> n;
	b = min(a * 2, b);
	c = min(b * 2, c);
	d = min(c * 2, d);

	ans = n / 2 * d + (n % 2) * c;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    int  cnt_a=0,cnt_b=0,cnt_c=0,np=0,end=1;

    while(end){
        if(np==0){
            if(cnt_a==sa.size()){
                end=0;
                cout<<'A'<<endl;
            }
            np=sa[cnt_a++]-'a';   
        }
        else if(np==1){
            if(cnt_b==sb.size()){
                end=0;
                cout<<'B'<<endl;
            }
            np=sb[cnt_b++]-'a';
        }
        else{
            if(cnt_c==sc.size()){
                end=0;
                cout<<'C'<<endl;
            }
            np=sc[cnt_c++]-'a';
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mpr make_pair
#define MX 100010
#define ui unsigned int
#define ll long long
#define ld long double 
#define fi first
#define se second
#define endl '\n'
#define debug(bug) cout<<"akshat"<<" "<<bug<<endl
#define printarray(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define printvector(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define dd long double 
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL)
const ll inf=1000000000000;
const int mod=1000000007;
// priority_queue <int, vector<int>, greater<int> > pq; //minimum priority queue
int n,k;
int A[MX];
ll dp[MX];
int main()
{
  fast_io;
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
    cin>>A[i];
  }
  for(int i=0;i<MX;i++)
  {
    dp[i]=inf;
  }
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    for(int j=0;j<=k;j++)
    {
      dp[i]=min(dp[i],(i-j<0?inf:dp[i-j])+abs(A[i]-(i-j<0?0:A[i-j])));
    }
  }

  cout<<dp[n-1]<<endl;

 
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t total=0;
  int64_t a[200010];
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
  cin>>a[i];
  }
  int64_t b=0;
  for(int i=0;i<N;i++){
    total += b*a[i]%1000000007;
     b += a[i];
     b %= 1000000007;
  }
   cout<<total%1000000007<<endl;
}

Measured memory_bytes: 5180
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;


int main(){
    int keys[251];
    
    int H;
    cin >> H;
    
    for (int i = 1; i <= H; i++){
        cin >> keys[i];
    }

    int p, l, r;
    for (int i = 1; i <= H; i++){
        p = i / 2;//parent
        l = 2 * i;//left
        r = 2 * i +1;//right
        cout << "node " << i << ": key = " << keys[i] << ", ";
        if(p != 0){
            cout << "parent key = " << keys[p] << ", ";
        }
        if(l <= H){
            cout << "left key = " << keys[l] << ", ";
        }
        if(r <= H){
            cout << "right key = " << keys[r] << ", ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m, val;
    cin >> n >> m;
    // vector<int> arr(i, 0);
    int acc = 0;
    map<int, int> remain;
    remain[0] = 1;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> val;
        acc += val;
        acc %= m;
        ans += remain[acc];
        remain[acc] += 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC123C
{
    static class Program
    {
        static void Main(string[] args)
        {
            var l = ReadLineOne<long>(6);

            var n = l.FirstOrDefault();

            var min = l.Min();


            WriteLine((long)Math.Ceiling((double)n / min) + 4);


        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14432
# 入力を空白で分割して、それぞれa,bに代入する。
a, b= input().split()

# 文字列を整数に変換する
a = int(a)
b = int(b)


if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")


Measured memory_bytes: 5592
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int[] w = new int[n];

        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }


        int min = Integer.MAX_VALUE;
        for (int t = 0; t < n; t++) {
            int sum1=0, sum2=0;

            for (int i = 0; i < t; i++) {
                sum1 += w[i];
            }
            for (int i = t; i < n; i++) {
                sum2 += w[i];
            }

            min = Math.min(min, (sum1 > sum2) ? sum1 - sum2 : sum2 - sum1);
        }

        System.out.println(min);
    }

}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
string s;
string cand = "357";
set<string> S;

void dfs(int idx, string sum) {
   if (idx >= s.size()) {
      if (count(all(sum), '3') && count(all(sum), '5') && count(all(sum), '7') && atoi(sum.c_str()) <= N) {
         S.insert(sum);
      }
      return;
   }
   rep (i, cand.size()) {
      dfs(idx+1, sum + cand[i]);
      dfs(idx+1, sum);
   }
}

signed main() {
   cin >> N;
   s = to_string(N);

   dfs(0, "");

   // for (string t : S) {
   //    cout << t << endl;
   // }

   cout << S.size() << endl;

   return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int A,B,C; cin>>A>>B>>C;
  if(A+B+C>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/***template***/
#define ll                   long long
#define ___                  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dd                   double
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define pi                   pair<ll,ll>
#define pb                   push_back
#define mp                   make_pair
#define uu                   first
#define vv                   second
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define FOOR(i,a,b)          for(ll i=a;i<=b;i++)
#define LOP(i,a,b)           for(ll i=a;i<b;i++)
#define sorted(s)            sort(s.begin(),s.end())
#define sortedd(s)           sort(s.begin(),s.end(),cmp)
#define reversed(s)          reverse(s.begin(),s.end())
#define contains(a,b)        (find((a).begin(), (a).end(), (b)) != (a).end())
#define MAXN                 100005
#define pii                  3.1415926536
#define mod                  1000000007
#define eps                  0.0000000001
#define inf                  1e18
#define INF                  (1LL<<62)
#define mstt(a,b)            memset((a),(b),sizeof (a))
#define sz(x)                (ll)x.size()
#define uniquee(x)            x.erase(unique(x.begin(), x.end()),x.end())
#define print_vector(v)       for(ll i=0;i<(v.size());i++)cout<<v[i]<<" ";
/****only for priority queue******/
/**struct node
{
    ll nod,d;
    node(ll a,ll b)
    {
        nod=a;
        d=b;
    }
    bool operator<(const node &p)const
    {
        return p.d<d;
    }
};**/

ll Set(ll n,ll pos)
{
    return n=n|(1LL<<pos);
}
ll reset(ll n,ll pos)
{
    return n=n&~(1LL<<pos);
}
bool check(ll n,ll pos)
{
    return (bool)(n&(1LL<<pos));
}
ll mul(ll a,ll b)
{
    ll c;
    c = (a%mod * b%mod)%mod;
    return c;
}
ll add(ll a,ll b)
{
    ll c;
    c = (a%mod + b%mod)%mod;
    return c;
}
ll sub(ll a,ll b)
{
    ll c;
    c = ((a%mod - b%mod)%mod + mod)%mod;
    return c;
}
ll power(ll x,ll y)
{
    ll res = 1;
    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}
long long exgcd(long long x, long long y, long long &a, long long &b)
{
    // ax + by = gcd(x,y)
    int flag = 0;
    long long t, la = 1, lb = 0, ra = 0, rb = 1;
    while(x%y)
    {
        if(flag == 0)
            la -= x/y*ra, lb -= x/y*rb;
        else
            ra -= x/y*la, rb -= x/y*lb;
        t = x, x = y, y = t%y;
        flag = 1 - flag;
    }
    if(flag == 0)
        a = ra, b = rb;
    else
        a = la, b = lb;
    return y;
}
/***template***/
ll a,b,w;
int main()
{
    scl(w);
    scl(a);
    scl(b);

    if(a>b)swap(a,b);

    ll u1=a;
    ll v1=a+w;
    ll u2=b;
    ll v2=b+w;

    cout<<max(u2-v1,0LL)<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#define INF 1e10
using namespace std;

int n;
struct P{
	double x,y,r;
	P(){}
	P(double xx,double yy,double rr){
		x=xx;
		y=yy;
		r=rr;
	}
	bool operator<(const P &p1)const{
		return x<p1.x;
	}
};

bool compare_y(P a,P b){
	return a.y<b.y;
}


double closest_pair(P *a,int n){
	if(n<=1)return INF;
	int m=n/2;
	double x=a[m].x;
	double r=a[m].r;
	double d=min(closest_pair(a,m),closest_pair(a+m,n-m));
	inplace_merge(a,a+m,a+n,compare_y);
	vector<P> b;
	for(int i=0;i<n;i++){
		if(fabs(a[i].x-x)-a[i].r-r>=d)continue;
		for(int j=0;j<b.size();j++){
			double dx=a[i].x-b[b.size()-j-1].x;
			double dy=a[i].y-b[b.size()-j-1].y;
			if(dy>=d+r+a[i].r)break;
			d=min(d,sqrt(dx*dx+dy*dy)-b[b.size()-j-1].r-a[i].r);
		}
		b.push_back(a[i]);
		r=max(a[i].r,r);
	}
	return d;
}

P p[100001];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%lf %lf %lf",&p[i].r,&p[i].x,&p[i].y);
		}
		sort(p,p+n);
		printf("%.9f\n",closest_pair(p,n));
	}
	return 0;
}

Measured memory_bytes: 8840
#include <bits/stdc++.h>
using namespace std;
//#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//const ll INF = 1LL<<60;
//const ll MOD = 1e9+7;    
#define pi 3.14159265359
const double PI = 2 * acos(0);
#define hell 1000000007
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fix(n) cout << fixed << setprecision(n)
#define ins(s) string s;cin>>s
#define mset(a,n) memset(a,n,sizeof a)
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++)
#define repp(i,a,b,p) for(__typeof((b)) i=(a);i<(b);i+=p)
#define ren(i,a,b) for(__typeof((a)) i=(a);i>=(b);i--)
#define lbd lower_bound
#define ubd upper_bound
#define ll  long long
#define ull unsigned long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<pair<int,int>,int>
#define all(v) (v).begin(), (v).end()
#define sz(x) (int)x.size()
#define out(n) cout<<n<<" "
#define outl(n) cout<<n<<endl
#define line cout<<endl
clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
#define bug(n) {outl(n);return;}

ll convert_number(string s,int i,int j){
  string k = s.substr(i,j);
  stringstream str(k); 
    ll x;  
    str >> x; 
    return x;
}
int count_digits(ll n) 
{ 
    return floor(log10(n) + 1); 
}

ll check  (string s){
  for(ll i=0;i<s.length();i++){
    if(s[i]!=s[s.length()-i-1]) return i;
  }
  return -1;
}
vector<int> checkpal(string s){
  vi a = {};
  for(ll i=0;i<s.length()/2;i++){
    if(s[i]!=s[s.length()-i-1]) a.pb(i);
  }
  return a;
}

int divisors(int N){
  int sum=0;
for(int i=1;i*i<=N;i++){
  if(N%i==0){
    if(i*i==N) sum++;
    else sum+=2;
  }
}
return sum;
}



void solve(){


 int n;
 cin >> n;
 int x = n%1000;
 if(x==0) cout << 0;
 else cout << 1000 - x;

}


  




void prep(){
    
}

int main() {
         io;
    int t=1;
    //cin >> t;
    // uncomment if different test cases are there in single input
    prep();
    start = clock(); 
    fix(5);
    while(t--)solve(); // runs t number of times
    return 0;
  
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int a, b;

  cin >> a >> b;

  cout << a * b << endl;
}

Measured memory_bytes: 3636
#include<iostream>  
  using namespace std;  
  
  int main(){  
      string S;  
      int N;  
      cin >> N >> S;  
      auto size = S.size();  
      for(int i = 0; i < size; i++){  
          S[i] += N;  
          if(S[i] > 'Z') S[i] -= 'Z' - 'A' + 1;
      }  
      cout << S << endl;
      return 0;  
  }

Measured memory_bytes: 3644
// 1点更新、区間min取得 (RMQ)
// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_A

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

//const long long INF2 = (((ll)1<<31)-1);

template<class T> class SegTree   // 0-indexed
{
private:
    int n;             // 葉の数
    vector<T> data;    // ノードの値を持つ配列
    T def;                // 初期値かつ単位元
    
    T operation(T a, T b)    // 区間クエリで使う処理
    {
        //return min(a, b);   // 区間minクエリ
        return a+b;           // 区間和クエリ
    }

    T update(T a, T b)      // 点更新で使う処理
    {
        return a+b;   // 加算の場合
        //return b;       // 更新の場合
    }

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }
 
public:
    SegTree(int _n) {     // _n:必要サイズ
        //def = INF2;        // 初期値かつ単位元
        def = 0;        // 初期値かつ単位元（0：区間和の場合）
        n = 1;
        while (n < _n) n *= 2;
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }
 
    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};

int main(int argc, char* argv[])
{
    int n,q;
    scanf("%d%d", &n, &q);
    SegTree<long long> S(n);

    int i;
    for(i=0; i<q; i++) {
        int t,x,y;
        scanf("%d%d%d", &t, &x, &y);
        if(t==0) {
            S.change(x-1,y);
        }
        else {
            ll ans=S.query(x-1,y);
            printf("%lld\n", ans);
        }
    }

    return 0;
}


Measured memory_bytes: 6368
#include<stdio.h>
int main(void){
    int m;
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        int fund,year,n;
        int max=0;
        scanf("%d%d%d",&fund,&year,&n);
        for(int j=0;j<n;j++){
            int flag,fee;
            double r;
            scanf("%d%lf%d",&flag,&r,&fee);
            int A=fund,B,balance=fund;
            int sum=0;
            for(int k=0;k<year;k++){
                if(flag){
                    A=balance;
                    B=A*r;
                    balance=A+B-fee;
                }
                else{
                    A=balance;
                    B=A*r;
                    balance=A-fee;
                    sum+=B;
                }
            }
            if(flag){
                if(max<balance) max=balance;
            }else{
                if(max<balance+sum) max=balance+sum;
            }
        }
        printf("%d\n",max);
    }
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){
  int N;
  cin>>N;
  int M;
  cin>>M;
  map<int,int> np;  //number of penalties for problem;
  set<int> AC;
  int penalty=0;
  while(M--){
      int p;
      string S;
      cin>>p>>S;
      if(AC.count(p))   continue;    //AC received for the problem
      if(S == "AC"){
          penalty += np[p];
          AC.insert(p);
      }else
      {
          ++np[p];
      }
      
  }
  cout<<AC.size()<<" "<<penalty<<endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 9600
#bA
import collections
N = int(input())
S = [input() for i in range(N)]
s = collections.Counter(S) #出現回数をまとめた辞書型作成

maximum = max(s.values()) #
list = sorted(key for key,value in s.items() if value==maximum)
#sを利用して、出現回数が最大のものを辞書順に並べたリストを作成

for i in list:
    print(i)

Measured memory_bytes: 35572
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,l,fa[200001],r[200001],x,y,fa2[200001];
typedef pair<ll,ll>P;
map<P,ll>mp;
void initialize(void){
    for(int i=0;i<=n;i++){
        r[i]=0;
        fa[i]=i;
    }
    return ;
}
ll find(ll x){
    if(fa[x]==x)return x;
    return fa[x]=find(fa[x]);
}
ll find2(ll x){
    if(fa2[x]==x)return x;
    return fa2[x]=find2(fa2[x]);
}
void uni(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y)return ;
    if(r[x]<r[y])fa[x]=y;
    else fa[y]=x;
    if(r[x]==r[y])r[x]++;
}
int main(void){
    cin>>n>>k>>l;
    initialize();
    for(int i=0;i<k;i++){
        cin>>x>>y;
        uni(x,y);
    }
    for(int i=0;i<=n;i++)fa2[i]=fa[i];
    initialize();
    for(int i=0;i<l;i++){
        cin>>x>>y;
        uni(x,y);
    }
    for(int i=1;i<=n;i++){
        mp[{find(fa[i]),find2(fa2[i])}]++;
    }
    for(int i=1;i<=n;i++){
        cout<<mp[{find(fa[i]),find2(fa2[i])}]<<" ";
    }
    cout<<endl;
    //for(int i=0;i<=n;i++){
        //cout<<fa2[i]<<"W"<<endl;
        //cout<<find(fa[i])<<fa2[i]<<endl;
    //}
    //cout<<mp.size()<<endl;
}


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

signed main() {
  int n,m;
  cin >> n >> m;

  int ans = 0;
  int add = min(n,m/2);
  ans += add;
  m -= add*2;
  ans += m/4;
  cout << ans << '\n';
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  int x;
  cin >> x;
  if (x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl
#define mp make_pair
#define fir first
#define sec second

using namespace std;

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

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

int b[N],l[N],r[N];
struct node {
	int x; ll y;
	bool operator < (const node &rhs) const {
		return y > rhs.y;
	}
} V[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	int n = read(),X = read();
	ll sum = 0;
	For(i,1,n) {
		b[i] = read(),l[i] = read(),r[i] = read();
		V[i] = (node){i,1ll * (X - b[i]) * r[i] + 1ll * l[i] * b[i]};
		sum += 1ll * l[i] * b[i];
	}
	if(sum == 0) return puts("0"),0;
	sort(V + 1,V + n + 1);
	ll tot = 0,ans = 0;
	For(i,1,n) {
		if(tot + V[i].y >= sum) {
			int v = INF;
			For(j,1,n) {
				int id = V[j].x,cur = 0;
				if(V[j].y > V[i].y) tot -= V[j].y - V[i].y;
				if(1ll * l[id] * b[id] + tot >= sum) cur = (sum - tot - 1) / l[id] + 1;
				else cur = b[id] + (sum - tot - 1ll * b[id] * l[id] - 1) / r[id] + 1;
				if(V[j].y > V[i].y) tot += V[j].y - V[i].y;
				chkmin(v,cur);
			}
			printf("%lld\n",ans + v);
			return 0;
		}
		tot += V[i].y, ans += X;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX_N=100001;

int N;
int hi[MAX_N];

int main()
{
	scanf("%d", &N);
	for (int i=0; i<N; i++) {
		scanf("%d", &hi[i]);
	}

	bool check = true;

	hi[0]--;
	for (int i=1; i<N; i++)
	{
		if (hi[i-1] == hi[i]) continue;
		else if (hi[i-1] < hi[i]) {
			hi[i]--;
		}
		else {
			check = false;
			break;
		}
	}
	puts(check ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 512
v, e = gets.split.map &:to_i
a = Array.new(v).map { Array.new(v, Float::INFINITY) }
e.times do
  s, t, d = gets.split.map &:to_i
  a[s][t] = d
end

(0..(v-1)).each do |i|
  a[i][i] = 0
end

(0..(v-1)).each do |k|
  (0..(v-1)).each do |i|
    (0..(v-1)).each do |j|
      a[i][j] = [ a[i][j], a[i][k] + a[k][j] ].min
    end
  end
end

is_nega = false
(0..(v-1)).each do |i|
  (0..v-1).each do |j|
    if i == j && a[i][j] < 0
      is_nega = true
      break
    end
    if a[i][j] == Float::INFINITY
      a[i][j] = "INF"
    end
  end
end

if is_nega
  puts "NEGATIVE CYCLE"
else
  (0..v-1).each do |i|
    puts a[i] * ' '
  end
end

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

int main() {
  int N, M;
  
  cin >> N;
  vector<string> vec_1(N);
  for (int i=0; i<N; i++) 
    cin >> vec_1.at(i);
  
  cin >> M;
  vector<string> vec_2(M);
  for (int i=0; i<M; i++) 
    cin >> vec_2.at(i);
  
  int max = 0;
  for (int i=0; i<N; i++) {
    int counter = 0;
      
    for (int s=0; s<N; s++) {
      if (vec_1.at(i) == vec_1.at(s))
        counter++;
    }
    
    for (int t=0; t<M; t++) {
      if (vec_1.at(i) == vec_2.at(t))
        counter--;
    }
    
    if (max < counter)
      max = counter;
  }
  cout << max << endl;
}
      


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 111;
const int MOD = 1e9+7;

int N;

const int A = 0, C = 1, G = 2, T = 3;
ll dp[MAX][4][4][4];

bool check(int i, int j, int k, int l) {
    vi lst(4);
    lst[0] = i;
    lst[1] = j;
    lst[2] = k;
    lst[3] = l;
    bool res = true;
    res &= !(lst[0] == A && lst[1] == G && lst[2] == C);
    res &= !(lst[1] == A && lst[2] == G && lst[3] == C);
    REP (i, 3) {
        swap(lst[i], lst[i+1]);
        res &= !(lst[0] == A && lst[1] == G && lst[2] == C);
        res &= !(lst[1] == A && lst[2] == G && lst[3] == C);
        swap(lst[i], lst[i+1]);
    }
    return res;
}

int solve() {
    dp[0][T][T][T] = 1;
    FOR (n, 1, N+1) {
        REP (i, 4) REP (j, 4) REP (k, 4) REP (l, 4) {
            if (check(i, j, k, l)) {
                (dp[n][j][k][l] += dp[n-1][i][j][k]) %= MOD;
            }
        }
    }
    ll res = 0;
    REP (i, 4) REP (j, 4) REP (k, 4) {
        res += dp[N][i][j][k];
    }
    return res % MOD;
}

int main() {
    cin >> N;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

typedef long long int64;
const int inf = (int)1e9;

int calc(int it1, int it2, vector<pair<int, int> > &b, vector<int> &sum, int n)
{
	while(it1 >= 0 && it2 < b.size()) {
		if(b[it1].second <= 0) {
			it1 -= 1;
			continue;
		}
		if(b[it2].second <= 0) {
			it2 += 1;
			continue;
		}
		if(b[it1].first != b[it2].first || b[it1].second + b[it2].second < 4) 
			break;
		it1 -= 1, it2 += 1;
	}
				
	int score = n - (sum[it2 - 1] - sum[it1]);
	return score;
}

int main()
{
	while(true) {
		
		int n;
		vector<pair<int, int> > b;
		vector<int> sum;
		int prev = -1;
		
		scanf("%d", &n);
		if(n == 0)
			break;
		b.reserve(n);
		for(int i = 0; i < n; ++i) {
			int t;
			scanf("%d", &t);
			if(prev != t)
				b.push_back(make_pair(t, 1));
			else
				b[b.size() - 1].second += 1;
			prev = t;
		}
		sum.resize(b.size(), 0);
		sum[0] = b[0].second;
		for(int i = 1; i < sum.size(); ++i)
			sum[i] = sum[i - 1] + b[i].second;
		
		int ans = n;
		
		for(int start = 0; start < b.size(); ++start) {
			
			b[start].second -= 1;
			
			if(start > 0 && b[start - 1].second >= 3) {
				int it1 = start - 2, it2 = start;
				int score = calc(it1, it2, b, sum, n);
				ans = min(score, ans);
			}
			
			if(start < b.size() - 1 && b[start + 1].second >= 3) {
				int it1 = start, it2 = start + 2;
				int score = calc(it1, it2, b, sum, n);
				ans = min(score, ans);
			}
			
			if(start > 0 && start < b.size() - 1 && b[start].second == 0 && 
				b[start - 1].first == b[start + 1].first &&
				b[start - 1].second + b[start + 1].second >= 3) {
				int it1 = start - 2, it2 = start + 2;
				int score = calc(it1, it2, b, sum, n);
				ans = min(score, ans);
			}
			
			b[start].second += 1;
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}

/* ハラスメントに負けず */
/* 0完太陽にも負けず */
/* はやく人権を獲得したい */
/* nullmineralが書きましたが */
/* 責任はまったくとりません */

Measured memory_bytes: 1264
import bisect

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

A.sort()
B.sort()
C.sort()

ans = 0

for b in B:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect(C, b)
    ans += i * (N - j)
print(ans)





Measured memory_bytes: 29300
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if((i+j) % 2 == 1){
                        System.out.print(".");
                    }else{
                        System.out.print("#");
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}



Measured memory_bytes: 38108
def gcd(a, b):
    return gcd(b, a % b) if b > 0 else a


n = int(input())
a = list(map(int, input().split()))

al = [0] * (n + 2)
ar = [0] * (n + 2)

for i in range(1, n + 1):
    al[i] = gcd(a[i - 1], al[i - 1])

for j in range(n, 0, -1):
    ar[j] = gcd(a[j - 1], ar[j + 1])

ans = 0

for i in range(n):
    num = gcd(al[i], ar[i + 2])
    ans = max(ans, num)

print(ans)


Measured memory_bytes: 87068
import java.util.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(b == 10) {
      System.out.println(Integer.toString(a).length());
    } else {
      int num = 0;
      for(int i = a; i > 0; i /= b) {
        num++;
      }
      System.out.println(num);
    }
  }
}

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

void swap(int& a, int& b)
{
  int tmp = a;
  a = b;
  b = tmp;
}

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (a > c) swap(a, c);
    if (b > c) swap(b, c);

    if(a * a + b * b == c * c)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[][] dp = new long[3][];
		for(int i=0;i<3;i++){
			dp[i] = new long[N];
		}
		dp[0][0] = A[0];
		dp[1][0] = B[0];
		dp[2][0] = C[0];
		
		for(int i=0;i<N-1;i++){
			dp[0][i+1] = Math.Max(dp[0][i+1], dp[1][i] + A[i + 1]);
			dp[0][i+1] = Math.Max(dp[0][i+1], dp[2][i] + A[i + 1]);
			dp[1][i+1] = Math.Max(dp[1][i+1], dp[0][i] + B[i + 1]);
			dp[1][i+1] = Math.Max(dp[1][i+1], dp[2][i] + B[i + 1]);
			dp[2][i+1] = Math.Max(dp[2][i+1], dp[0][i] + C[i + 1]);
			dp[2][i+1] = Math.Max(dp[2][i+1], dp[1][i] + C[i + 1]);
		}
		
		long ans = 0;
		for(int i=0;i<3;i++) ans = Math.Max(ans, dp[i][N-1]);
		Console.WriteLine(ans);
	}
	int N;
	int[] A,B,C;
	public Sol(){
		N = ri();
		A = new int[N];
		B = new int[N];
		C = new int[N];
		for(int i=0;i<N;i++){
			var d = ria();
			A[i] = d[0]; B[i] = d[1]; C[i] = d[2];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18620
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void)
{
	int a, b, c;
	int k;
	cin >> a >> b >> c >> k;
	
	int max = a;
	if (a < b)
	{
		max = b;
	}
	if (max < c)
	{
		max = c;
	}
	int sum = a + b + c - max;
	int result = max;
	for (int i = 0; i < k; i++)
	{
		result *= 2;
	}
	sum += result;
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <tuple>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#pragma GCC target ("avx2")

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  	return vector<T>(a);
}
 
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main(){
  	cin.tie(0);
  	cout.tie(0);
  	ios::sync_with_stdio(false);
	
	long long a, b;
	cin >> a >> b;
	cout << (a * b)/__gcd(a, b) << endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	string S;
	int A, B;
	cin >> A >> B;
	cin >> S;
	bool ans = true;
	REP(i, A + B + 1) {
		char c = S[i];
		if(i == A) {
			if (c != '-') ans = false;
		}
		else {
			if (c  < '0' || c > '9') ans = false;
		}

	}
	if (ans) cout << "Yes";
	else cout << "No";
	system("pause");
	return 0;
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
#include <functional>

using namespace std;

class SegmentTree
{
private:
    int n;
    vector<ll> node;

    void init_size(int sz)
    {
        this->n = 1;
        while(n < sz){
            this->n *= 2;
        }
        this->node = vector<ll>(2 * this->n - 1, 0);
    }

public:
    SegmentTree(int n)
    {
        init_size(n);
    }

    SegmentTree(vector<int> v) {

        int size = v.size();
        init_size(size);

        for(int i=0;i<size;++i)
        {
            node[i+n-1] = v[i];
        }

        for(int i=n-1;i>=0;i--)
        {
            node[i] = max(node[2*i+1], node[2*i+2]);
        }
    }

    void update(int pos, ll val)
    {
        pos += (n - 1);
        node[pos] = val;
        while(pos > 0)
        {
            pos = (pos - 1) / 2;
            node[pos] = max(node[2*pos+1], node[2*pos+2]);
        }
    }

    ll get(int begin, int end, int current=0, int l=0, int r=-1)
    {
        if(r < 0) r = this->n;
        if(r <= begin || end <= l) return 0; // initial value
        if(begin <= l && r <= end) return node[current];

        ll val_left = get(begin, end, 2*current+1, l, (l+r)/2);
        ll val_right = get(begin, end, 2*current+2, (l+r)/2, r);
        return max(val_left, val_right);
    }

    void print()
    {
      for(int i=0;i<n;++i)
      {
        cerr << node[i+(n-1)] << ",\n"[i==n-1];
      }
    }
};

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int h[n] = {};
    ll a[n] = {};

    SegmentTree segtree(n);

    for(int i=0;i<n;++i)
    {
      cin >> h[i];
    }

    for(int i=0;i<n;++i)
    {
      cin >> a[i];
    }

    for(int i=0;i<n;++i)
    {
      int height = h[i];
      ll tmp_max = segtree.get(0, height);
      segtree.update(height-1, tmp_max + a[i]);
      //segtree.print();
    }

    cout << segtree.get(0, n) << endl;
}

Measured memory_bytes: 6656