akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var x = cin.ReadInt();
            var a = cin.ReadInt();
            var b = cin.ReadInt();
            if (b - a <= 0) WriteLine("delicious");
            else if (b - a <= x) WriteLine("safe");
            else WriteLine("dangerous");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



Measured memory_bytes: 13268
//Warmdust Code
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define db double
#define ll long long
#define ull unsigned long long
#define ft float
#define PI acos(-1)
#define L(i,a,b) for(int i=a;i<=b;i++)
#define R(i,a,b) for(int i=a;i>=b;i--)
#define inf 0x3f3f3f3f
#define linf  0x3f3f3f3f3f3f3f3f
#define Warmdust int main(){
#define RETURN return 0;}
#define TvT ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn = 100+7;
const int mod = 10000+7;
Warmdust
	TvT;
	int a,b;
	cin >> a >> b;
	int sum=0;
	L(i,1,a){
		int x;
		cin >> x;
		if(x>=b) sum++; 
	}
	cout << sum << endl;
RETURN 


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <immintrin.h>
#include <bitset>
#include <string>
using namespace std;


int main(){
    uint64_t n;
    cin>>n;
    uint64_t max=sqrt(n);
    uint64_t mina=114514;

    for(long i=1;i<=max;i++){
        if(n%i!=0){continue;}
        long j=n/i;
        if(i>j){continue;}
        
        uint64_t a=j;
        uint64_t index=to_string(a).length();

        if(index<mina){mina=index;}
    }


    if(mina==114514){
        //cout<<63-__builtin_clzll(n));
        cout<<to_string(n).length()<<endl;;
    }
    else{
     cout<<mina<<endl;
    }
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args){
		java.util.Scanner sc = new java.util.Scanner (System.in);
			int W = sc.nextInt();
			int H = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int r = sc.nextInt();

			if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
	}
}

Measured memory_bytes: 26376
nOp1 dif = if dif>0 then 0 else (-dif`div`2)
nOp2 dif = if dif>0 then dif else (dif`mod`2)

solvable diff = nOp >= maximum [sum$map nOp1 diff, sum$map nOp2 diff]
 where nOp = -sum diff

compute a b = if solvable (zipWith (-) a b) then "Yes" else "No"

main = do
 n <- readLn :: IO Int
 x <- getLine
 let a = map read (words x) :: [Int]
 x <- getLine
 let b = map read (words x) :: [Int]
 putStrLn $ compute a b

Measured memory_bytes: 9596
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

// #define NDEBUG
#include "atcoder/all"
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a;
    int nums;
};

// struct F {
//     mint a, b;
// };
using F = int;

mint pows[int(2e5 + 1)];
mint ones[int(2e5 + 1)];
S op(S l, S r) { return S{l.a * pows[r.nums] + r.a, l.nums + r.nums}; }
S e() { return S{0, 0}; }
S mapping(F l, S r) { r.a = l == -1 ? r.a : ones[r.nums] * l; return r; }
F composition(F l, F r) { return l == -1 ? r : l; }
F id() { return -1; }

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    pows[0] = 1;
    for(int i = 1; i < n; i++){
        pows[i] = pows[i - 1] * 10;
        ones[i] = (pows[i] - 1) / 9;
        // cerr << i << ' ' << pows[i].val() << '\n';
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(n, S{1, 1}));
    // lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
    // for(int i = 0; i < n; i++){
    //     seg.set(i, S{1, n - i - 1});
    // }
    // cerr << seg.all_prod().a.val() << '\n';
    for(int i = 0; i < q; i++){
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l, r, d);
        // cerr << l << ' ' << r << ' ' << d << '\n';
        // for(int i = 0; i < n; i++){
        //     cerr << seg.get(i).a.val() << ',' << seg.get(i).nums << ' ';
        // }
        // for(int i = 0; i < n; i++){
        //     // cout << seg.prod(i, i + 1).a.val();
        //     cerr << seg.prod(i, i + 1).a.val() << ' ';
        // }
        // // cout << '\n';
        // cerr << '\n';
        cout << seg.all_prod().a.val() << '\n';
    }
}


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

using namespace std;

#define intt long long

const int N = 1005;

const int MOD = 1000000007;

char a[N][N];

intt dp[N][N];

int n, m;

int main() {

	cin >> n >> m;

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

	dp[1][1] = 1;

	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) {
			if (i == 1 && j == 1) continue;
			if (i != 1 && a[i - 1][j] == '.') {
				dp[i][j] += dp[i - 1][j];
				dp[i][j] %= MOD;
			}
			if (j != 1 && a[i][j - 1] == '.') {
				dp[i][j] += dp[i][j - 1];
				dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[n][m] << '\n';
	return 0;
}

Measured memory_bytes: 9088
n=int(input())
t0=x0=y0=0
f=0
for i in range(n):
  t,x,y=map(int,input().split())
  t1=t-t0
  x1=abs(x-x0)
  y1=abs(y-y0)
  if t1<x1+y1 or t1%2!=(x1+y1)%2:
    f=1
  t0=t
  x0=x
  y0=y
if f==1:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3064
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    lb = rli()
    ans = 0
    for i in range(n):
        if la[i] <= lb[i]:
            ans += la[i]
            lb[i] -= la[i]
        else:
            ans += lb[i]
            lb[i] = 0
        b2 = min(lb[i], la[i+1])
        ans += b2
        la[i+1] -= b2
    print(ans)


if __name__ == '__main__':
    main()


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

class Dice {
  private:
    int *numbers;
  public:
    Dice() {}
    Dice(int *numbers) {
      this->numbers = numbers;
    }
    void setNumbers(int *numbers) {
      this->numbers = numbers;
    }
    int getTop() {
      return numbers[0];
    }
    int getFront() {
      return numbers[1];
    }
    int getRight() {
      return numbers[2];
    }
    int getLeft() {
      return numbers[3];
    }
    int getBack() {
      return numbers[4];
    }
    int getBottom() {
      return numbers[5];
    }

    void roll(char direction) {
      switch (direction) {
        case 'N':
          rollToNorth();
          break;
        case 'S':
          rollToSouth();
          break;
        case 'E':
          rollToEast();
          break;
        case 'W':
          rollToWest();
          break;
      }
    }

    void rollToNorth() {
      swap(numbers[0], numbers[1]);
      swap(numbers[1], numbers[5]);
      swap(numbers[5], numbers[4]);
    }

    void rollToSouth() {
      swap(numbers[0], numbers[4]);
      swap(numbers[4], numbers[5]);
      swap(numbers[5], numbers[1]);
    }

    void rollToEast() {
      swap(numbers[0], numbers[3]);
      swap(numbers[3], numbers[5]);
      swap(numbers[5], numbers[2]);
    }

    void rollToWest() {
      swap(numbers[0], numbers[2]);
      swap(numbers[2], numbers[5]);
      swap(numbers[5], numbers[3]);
    }

    void turnRight() {
      swap(numbers[1], numbers[2]);
      swap(numbers[2], numbers[4]);
      swap(numbers[4], numbers[3]);
    }

    bool equals(Dice other) {
      for (int i = 0; i < 6; i++) {
        if (_equals(other)) return true;
        if(i % 2 == 0) {
          rollToNorth();
        } else {
          rollToEast();
        }
        for (int i = 0; i < 4; i++) {
          if (_equals(other)) return true;
          turnRight();
        }
      }
      return false;
    }

    bool _equals(Dice other) {
      return getTop() == other.getTop()
        && getFront() == other.getFront()
        && getRight() == other.getRight()
        && getLeft() == other.getLeft()
        && getBack() == other.getBack()
        && getBottom() == other.getBottom();
    }
};

int main() {
  int n;
  int numbers[100][6];
  bool isSame = false;
  Dice dices[100];

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> numbers[i][j];
    }
    dices[i] = Dice(numbers[i]);
  }

  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (dices[i].equals(dices[j])) {
        isSame = true;
        break;
      }
    }
  }

  if (isSame == true) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(void){
    int N,T;
    cin>>N>>T;
    vector<int> c(N);
    vector<int> t(N);
    for (int i=0; i<N; i++) {
        cin>>c[i]>>t[i];
    }
    vector<int> d;
    for (int i=0; i<N; i++) {
        if (t[i]<=T) {
            d.push_back(c[i]);
        }
    }
    if (d.size()==0) {
        cout<<"TLE"<<endl;
    }else{
        sort(d.begin(), d.end());
        cout<<d[0]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> a[i];
    }
    int U = 0; 
    int D = 0;
    int R = 0; 
    int L = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == 1) {
            L = max(L, x[i]);
        } else if (a[i] == 2) {
            R = max(R, w-x[i]);
        } else if (a[i] == 3) {
            D = max(D, y[i]);
        } else {
            U = max(U, h-y[i]);
        }
    }
    ll ans = (h-(U+D)) * (w-(R+L));
    if (h-(U+D) <= 0 || w-(R+L) <=- 0) ans = 0;
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> v(n);
  int a;
  for(int i = 0; i < n; i++) {
    cin >> a;
    v[a - 1] = i;
  }
  cout << v[0] + 1;
  for(int i = 1; i < n; i++) {
    cout << ' ' << v[i] + 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define INF 1000000000 //1e9

ll gcd(ll a, ll b) {
    return b!= 0 ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a,b) * b;
}

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

    int N;
    cin >> N;
    ll T[110];
    REP(i,N) cin >> T[i];
    if (N==1) {
        cout << T[0] << endl;
        exit(0);
    }

    ll ans = lcm(T[0], T[1]);
    FOR(i,2, N) {
        ans = lcm(T[i], ans);
    }

    cout << ans << endl;
}

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


public class Main{
    public static void main(String[] args) throws IOException
    {
        Scanner scanner = new Scanner(System.in);

        String num = scanner.nextLine();
        int n = Integer.parseInt(num);

        int a[] = new int[100];

        for(int i = 0; i< n;i++){
            String str = scanner.next();
            int x = Integer.parseInt(str);
            a[i]=x;
        }

        for(int i = n - 1; i >=0;i--){
            if(i == 0){
                System.out.print(a[i]+"\n");
            }else{
                System.out.print(a[i]+" ");
            }
        }

    }
}



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

int main()
{
    int N;
    cin>>N;
    vector<int> v;
    int price=0,max=0;
    for(int i=0; i<N; i++){
        cin>>price;
        if(max<price){ max = price;}
        v.push_back(price);
    }
    int sum=0,flag=0;
    for(int i=0; i<N; i++){
        if(v[i]==max && flag==0){
            sum += v[i]/2;
            flag=1;
        }else{
            sum+=v[i];
        }
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 109, M = 2e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    string s, t;    cin >> s >> t;
    t.pop_back();

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

Measured memory_bytes: 3616
MOD = 10**9+7

n = int(input())

s = input()

dic = {}

for i in s:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 1

for i in list(dic):
    ans = (ans *(dic[i]+1)) % MOD

print(ans-1)

Measured memory_bytes: 39408
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	div4 = 0
	div2 = 0
	divn = 0
	for i in a:
		if i % 4 == 0:
			div4 += 1
		elif i % 2 == 0:
			div2 += 1
		else:
			divn += 1
	if div2 > 0:
		divn += 1
	if div4 + 1 >= divn:
		print('Yes')
	else:
		print('No')
resolve()

Measured memory_bytes: 62576
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int a = s.size();
  for(int i = 0; i < a; i++) {
    if(s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3132
using System;

namespace AtCoderABC126B
{
    class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();

            int F = int.Parse(s.Substring(0, 2));
            int B = int.Parse(s.Substring(2, 2));

            if (F > 0 && F < 13)
            {
                if (B > 0 && B < 13)
                {
                    Console.WriteLine("AMBIGUOUS");
                }
                else
                {
                    Console.WriteLine("MMYY");
                }
            }
            else
            {
                if (B > 0 && B < 13)
                {
                    Console.WriteLine("YYMM");
                }
                else
                {
                    Console.WriteLine("NA");
                }
            }

        }
    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> mp(h);
  cin>>mp;

  auto bfs=[&](){
    queue<P> Q;
    Q.push(P(0,0));
    vector<vector<int> >D(h+1,vector<int>(w+1,INF));
    D[0][0] = 0;
    int dx[] = {0,0,1,-1};
    int dy[] = {1,-1,0,0};
    
    while(!Q.empty()){
      int y,x;
      tie(y,x) = Q.front();Q.pop();
      int cost = D[y][x];
      if(y == h - 1 && x == w - 1) return cost+1;
      for(int i=0;i<4;i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        int ncost = cost + 1;
        if(nx < 0 || ny < 0 || nx >= w || ny >= h || mp[ny][nx] == '#') continue;
        if(D[ny][nx] != INF) continue;
        D[ny][nx] = ncost;
        Q.push(P(ny,nx));
      }      
    }
    return (int)-1;
  };
  
  int d = bfs();
  if(d == -1){
    cout<<-1<<endl;
    return 0;
  }
  
  int ans = h * w - d;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) if(mp[i][j] == '#') ans--;

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


Measured memory_bytes: 256
import sys
N,M=map(int,input().split())
s=[]
c=[]
for i in range(M):
    x,y=map(int,input().split())
    s.append(x)
    c.append(y)

if N==1:
    if M==0:
        print(0)
        sys.exit(0)
    for i in range(M):
        if c[i]!=c[0]:
            print(-1)
            sys.exit(0)
    print(c[0])
    sys.exit(0)

elif N==2:
    if M==0:
        print(10)
        sys.exit(0)
    for i in range(M):
        if s[i]==1 and c[i]==0:
            print(-1)
            sys.exit(0)
    for i in range(M):
        for j in range(M):
            if s[i]==s[j] and c[i]!=c[j]:
                print(-1)
                sys.exit(0)
    x=1
    y=0
    for i in range(M):
        if s[i]==1:
            x=c[i]
        if s[i]==2:
            y=c[i]
    print(10*x+y)
    sys.exit(0)

elif N==3:
    if M==0:
        print(100)
        sys.exit(0)
    for i in range(M):
        if s[i]==1 and c[i]==0:
            print(-1)
            sys.exit(0)
    for i in range(M):
        for j in range(M):
            if s[i]==s[j] and c[i]!=c[j]:
                print(-1)
                sys.exit(0)
    x=1
    y=0
    z=0
    for i in range(M):
        if s[i]==1:
            x=c[i]
        if s[i]==2:
            y=c[i]
        if s[i]==3:
            z=c[i]
    print(100*x+10*y+z)
    sys.exit(0)



Measured memory_bytes: 3192
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;

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

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
import math

N, D = map(int, input().split())
Dists = [list(input().split()) for i in range(N)]

count = 0
distance = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(D):
            distance += (int(Dists[i][k]) - int(Dists[j][k])) ** 2
        distance = math.sqrt(distance)

        if distance.is_integer():
            count += 1
        distance = 0

print(count)


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  string small="abcdefghijklmnopqrstuvwxyz";
  string big="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for(int i=0;i<26;i++){
    if(a.at(0)==small.at(i)){
      cout << big.at(i);
    }
  }
 for(int i=0;i<26;i++){
    if(b.at(0)==small.at(i)){
      cout << big.at(i);
    }
  } 
  for(int i=0;i<26;i++){
    if(c.at(0)==small.at(i)){
      cout << big.at(i);
    }
  }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
i64 gcd(i64 a, i64 b) { if (a % b == 0) return b; else return gcd(b, a % b); }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
template <class T> bool amax(T &x, T y) { if (x < y) { x = y; return 1; } else return 0; }
template <class T> bool amin(T &x, T y) { if (x > y) { x = y; return 1; } else return 0; }
template <class T> i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template <class T> i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }

i64 solve(i64 x) {
  switch (x % 4) {
    case 0: return x;
    case 1: return 1;
    case 2: return x + 1;
    case 3: return 0;
  }
}

int main() {
  ioinit();
  i64 a, b;
  cin >> a >> b;
  cout << (solve(a - 1) ^ solve(b)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,d[100000];
int main(void){
	cin>>N;
	for(int i=0;i<N;i++)cin>>d[i];
	sort(d,d+N);
	cout<<d[N/2]-d[N/2-1];
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
bool triangle(int s1, int s2, int s3){
    if(s1 == s2 || s1 == s3 || s2 == s3) return false;
    return((s1 + s2 > s3) &&
           (s1 + s3 > s2) &&
           (s2 + s3 > s1));
}
int main(){
    Hello
    int n, ans = 0;
    cin >> n;
    int l[n];
    for(int i = 0; i < n; i++)
        cin >> l[i];
    for(int i = 0; i < n; i++)
        for(int j = i + 1; j < n; j++)
            for(int k = j + 1; k < n; k++)
                if(triangle(l[i], l[j], l[k]))
                    ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) Yes;
    else No;
}

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



int main()
{
    ll t,c=0;
        ll n,b,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,x=0;
        cin>>n;
        //ll l1[n+1];
        for(int i=1;i<=n;i++){
            cin>>b;
            if(b>=1&&b<=399&&a1==0)a1++;
            else if(b>=400&&b<=799&&a2==0)a2++;
            else if(b>=800&&b<=1199&&a3==0)a3++;
            else if(b>=1200&&b<=1599&&a4==0)a4++;
            else if(b>=1600&&b<=1999&&a5==0)a5++;
            else if(b>=2000&&b<=2399&&a6==0)a6++;
            else if(b>=2400&&b<=2799&&a7==0)a7++;
            else if(b>=2800&&b<=3199&&a8==0)a8++;
            else if(b>=3200)x++;
        }
        ll s,mi,ma;
        s=a1+a2+a3+a4+a5+a6+a7+a8;
        //cout<<s<<endl;
        //cout<<x<<endl;
        if(n-x>0)mi=s;
        else mi=1;
        ma=x+s;
        cout<<mi<<" "<<ma<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

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

    vector<tuple<ll, ll, ll> > a(n);
    rep(i, n){
        int st, tt, xt;
        cin >> st >> tt >> xt;
         st -= xt;
         tt -= xt;
        a[i] = tie(xt, st, tt);
    }

    vector<ll> d(q);
    rep(i, q)   cin >> d[i];

    
    set<pair<int, int> > s;
    rep(i, q){
        s.insert(make_pair(d[i], i));
    }

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

    vector<ll> ans(q, -1);
    rep(i, n){
        int x, l, r;
        tie(x, l, r) = a[i];
        auto it = s.lower_bound(make_pair(l, -1));
        while(it != s.end()){
            if(it->first >= r)    break;
            ans[it->second] = x;
            s.erase(it++);
        }
    }

    rep(i, q){
        cout << ans[i] << endl;
    }


}

Measured memory_bytes: 19072
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;

const int N = 2e5 + 5;
int a[N];
int n;
int h;

bool isval(int x)
{
	bool mark[N];
	for (int i = 0; i < n; i++)
	{
		mark[i] = false;
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= x)
		{
			mark[i] = true;
		}
	}
	int md = n / 2;
	if (mark[md] == mark[md + 1] || mark[md] == mark[md + 1])
	{
		if (mark[md] == true)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	int check = true;
	for (int i = 0; i < n - 1; i++)
	{
		if (mark[i] == mark[i + 1])
		{
			check = false;
		}
	}
	if (check)
	{
		if (mark[md] && h % 2 == 1)
		{
			return true;
		}
		if (mark[md] && h % 2 == 0)
		{
			return false;
		}
		if (!mark[md] && h % 2 == 0)
		{
			return true;
		}
		if (!mark[md] && h % 2 == 1)
		{
			return false;
		}
	}
	for (int i = md, j = md; i < n && j >= 0; i++, j--)
	{
		if (mark[i] == mark[i + 1])
		{
			if (mark[i] == true)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		if (mark[j] == mark[j - 1])
		{
			if (mark[j] == true)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
}

int search()
{
	int up = n + 1;
	int down = -1;
	while (up - down > 1)
	{
		int md = (up + down) / 2;
		if (isval(md))
		{
			down = md;
		}
		else
		{
			up = md;
		}
	}
	return down;
}

int main()
{
	cin >> n;
	for (int i = 0; i < 2 * n - 1; i++)
	{
		cin >> a[i];
	}
	h = n;
	n = 2 * n - 1;
	cout << search();

}

	
            




Measured memory_bytes: 1280
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<vector>
#include<bitset>
#define DB double
#define LL long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
  
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int x){
    if(x>9) Out(x/10);
    putchar('0'+x%10);
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
LL qpow(LL x,LL y,LL P){
    LL re=1;
    while(y){
        if(y&1) re=re*x%P;
        x=x*x%P;y>>=1;
    }
    return re;
}
const DB eps=1e-6;
const LL P=1e9+7;
const DB PI=acos(-1);
const int N=1e5+50;
int n;
char s[N];
LL a[30];
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;++i){
		a[s[i]-'a']++;
	} 
	LL ans=1;
	for(int i=0;i<26;++i){
		ans=ans*(a[i]+1)%P;
	}
	ans=(ans-1+P)%P;
	cout<<ans<<endl;
}
/*

*/

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

int main() {
  int N;
  cin >> N;
  int x = 0;

  
  // ここにプログラムを追記
  for (int i = 0; i < N; i ++) {
    int l,r;
    cin >> l >> r;
    x += r - l + 1;
  }
  cout << x << endl;
  
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool ans = false;
    for(int i = 0;i < b;i++){
        if((a*i)%b==c){
            ans = true;
            break;
        }
    }   
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    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,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  vector<ll> a(N);
  REP(i, N) a[i] = nextLong();

  ll have = 1000;
  for (int i = 0; i + 1 < N; i++) {
    if (a[i] < a[i+1]) {
      ll s = have / a[i];
      have -= s * a[i];
      have += a[i+1] * s;
    }
  }
  cout << have << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3692
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=1000111;
const int mod=998244353;

inline void add(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(LL)ret*x%mod;
		x=(LL)x*x%mod;
		y>>=1;
	}
	return ret;
}
int n,a[maxn],inv[maxn],cnt[maxn],ans;

int main()
{
	get1(n);
	for(int i=1;i<=n;i++)
	{
		get1(a[i]);
		cnt[a[i]]++;
	}
	
	for(int i=1;i<maxn;i++)inv[i]=qpow(i,mod-2);
	for(int i=1;i<maxn;i++)
	{
		int sum=(LL)cnt[i]*i%mod;
		for(int j=i+i;j<maxn;j+=i)
		{
			add(inv[j],mod-inv[i]);
			add(sum,(LL)cnt[j]*j%mod);
		}
		add(ans,(LL)inv[i]*sum%mod*sum%mod);
	}
	for(int i=1;i<maxn;i++)add(ans,mod-(LL)cnt[i]*i%mod);
	if(ans&1)ans+=mod;ans>>=1;
	printendl(ans);
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    string s; cin >> s;
    for (int i = 0; i + 1 < (int) s.size(); ++i) if (s[i] == s[i + 1]) {
        cout << i + 1 << ' ' << i + 2 << '\n';
        return 0;
    }
    for (int i = 0; i + 2 < (int) s.size(); ++i) if (s[i] == s[i + 2]) {
        cout << i + 1 << ' ' << i + 3 << '\n';
        return 0;
    }
    cout << -1 << ' ' << -1 << '\n';
    return 0;
}


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


int main() {
	int a,b,d,r;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	double f = (double)a / (double)b;
	printf("%d %d %lf",d,r,f);
	return 0;
}

Measured memory_bytes: 3192
package main

import (
	"fmt"
)

const inf = int(1e9) + 1

func maxm(a []int) int {
	r := -inf
	for i := 0; i < len(a); i++ {
		if a[i] > r {
			r = a[i]
		}
	}
	return r
}
func minm(a []int) int {
	r := inf
	for i := 0; i < len(a); i++ {
		if a[i] < r {
			r = a[i]
		}
	}
	return r
}

func main() {
	var s string
	fmt.Scan(&s)
	set := make(map[byte]int, 0)
	set['a'] = 0
	set['b'] = 0
	set['c'] = 0
	for i := 0; i < len(s); i++ {
		set[s[i]]++
	}
	vs := make([]int, 0)
	for _, v := range set {
		vs = append(vs, v)
	}
	ans := "YES"
	if maxm(vs)-minm(vs) > 1 {
		ans = "NO"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
from collections import Counter

N = int(input())
src = list(map(int,input().split()))

cums = [0]
for a in src:
    cums.append(cums[-1] + a)
ctr = Counter(cums)

ans = 0
for v in ctr.values():
    if v == 1: continue
    ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 41720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if( c =='a' ||  c =='i'|| c =='u' ||c =='e' || c =='o'){
  cout << "vowel" << endl;
  }else{
   cout << "consonant" << endl;
  }
 
}

Measured memory_bytes: 256
K = int(input())
def gcd(a, b):
    while b != 0:
        r = a%b
        a = b
        b = r
    return a
gcd_ab = [gcd(a,b) for a in range(1, K+1) for b in range(1, K+1)]
gcd_abc = [gcd(a_b,c) for a_b in gcd_ab for c in range(1, K+1)] 
print(sum(gcd_abc))

Measured memory_bytes: 71780
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

     n=3;

     ll ara[n+2];

     input(ara,n);

     sort(ara,ara+n);

     cout<<ara[0]+ara[1]<<endl;













}



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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

class Card
{
    public:
    ll written_number;
    ll number_of_cards;
};

vector<Card> Card_Counter(ll N)
{
    map<ll,ll> counter;
    for(ll i=0;i<N;i++)
    {
        ll a;
        cin >> a;
        counter[a]++;
    }
    vector<Card> ret;
    for(auto x : counter)
    {
        Card add;
        add.written_number = x.first;
        add.number_of_cards = x.second;
        ret.push_back(add);
    }
    return ret;
}

void ALLOUT_CARDS(vector<Card> Cards)
{
    for(auto x : Cards)
    {
        cout << x.written_number << ' ' << x.number_of_cards << endl;
    }
}

void Sort_Cards(vector<Card>& Cards)
{
    sort(ALL(Cards),
    [](Card& A, Card& B)
    {
        return (A.number_of_cards==B.number_of_cards) ? (A.written_number < B.written_number) : (A.number_of_cards > B.number_of_cards);
    });
}

ll Eat_Cards(vector<Card>& Cards)
{
    ll two_count = 0;
    for(auto& x : Cards)
    {
        while(x.number_of_cards >= 3)
        {
            x.number_of_cards -= 2;
        }
        if(x.number_of_cards == 2)
        {
            two_count++;
        }
    }
    if(two_count%2==0)
    {
        return Cards.size();
    }
    else
    {
        return Cards.size() - 1;
    }
}

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

    vector<Card> Cards = Card_Counter(N);

    Sort_Cards(Cards);

    OUT0(Eat_Cards(Cards));

    return 0;
}

Measured memory_bytes: 8696
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
 
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int i, j;

	for (i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int al = 0, bo = 0;
	for (i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			al += a.at(i);
		}
		else
		{
			bo += a.at(i);
		}
	}
	cout << al - bo << endl;

}



/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    char c[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
            if (i == j)
                cout << c[i][j];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(abs(c-a)<=d)cout<<"Yes"<<endl;
  else if(abs(b-a)<=d && abs(c-b)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
ll solve(ll n, ll a[], ll b[]){
	ll dp[n + 1];
	dp[0] = 0;
	for (ll i = 1; i <= n; i++){
		dp[i] = i;
		for (ll j = 0; j < 3; j++){
			if (i - a[j] >= 0) dp[i] = max(dp[i], dp[i - a[j]] + b[j]);
		}
	}
	return dp[n];
}
int main(){
	ll n, a[4], b[4];
	scanf("%lld", &n);
	for (ll i = 0; i < 3; i++) scanf("%lld", &a[i]);
	for (ll i = 0; i < 3; i++) scanf("%lld", &b[i]);
	a[3] = 1;
	b[3] = 1;
	ll t = solve(n, a, b);
	printf("%lld\n", solve(t, b, a));
}

Measured memory_bytes: 195456
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 500005
using namespace std;
typedef long long ll;
struct P{
	double t;
	ll v;
}a[N],q[N];
int n,L;
int main(){
	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++) scanf("%lf%lld",&a[i].t,&a[i].v);
	int tou=1,wei=1;
	ll sum=a[1].v;
	double T=a[1].t*a[1].v;
	q[1]=a[1];
	printf("%.8lf\n",a[1].t);
	for(int i=2;i<=n;i++){
		sum+=a[i].v;T+=a[i].t*a[i].v;
		while(sum>L){
			if(q[tou].v>sum-L) q[tou].v-=sum-L,T-=q[tou].t*(sum-L),sum=L;
			else sum-=q[tou].v,T-=q[tou].t*q[tou].v,tou++;
		}
		ll v=a[i].v;double t=a[i].t;
		while(tou<=wei&&t<q[wei].t){
			t=(t*v+q[wei].t*q[wei].v)/(v+q[wei].v);
			v+=q[wei].v;
			wei--;
		}
		q[++wei].t=t;q[wei].v=v;
		printf("%.8lf\n",T/sum);
	}
	return 0;
}

Measured memory_bytes: 25216
n = gets.to_i
vs = gets.split.map(&:to_i)
cs = gets.split.map(&:to_i)

pairs = []
n.times do |i|
  pairs << [vs[i], cs[i]]
end

pairs.sort!{|b,a| (a[0] - a[1]) <=> (b[0] - b[1])}

ans = 0
pairs.each do |p|
  break if p[0] - p[1] < 0
  ans += (p[0] - p[1])
end

puts ans


Measured memory_bytes: 1788
n,k = map(int,input().split())
ans = 0
if k == 0:
    print(n**2)
    exit()

for b in range(k+1,n+1):
    ans += (b-k)*(n//b)
    if n%b-k >= 0:
        ans += n%b-k+1

print(ans)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main(){
	var sc = bufio.NewScanner(os.Stdin)
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	N, _ := strconv.Atoi(s)
	if sc.Scan() {
		s = sc.Text()
	}
	arrN := make([]int, 0, N)
	for i := 0; i < N; i++ {
		arrN = append(arrN, i+1)
	}
	ps := strings.Split(s, " ")
	pArr := make([]int, 0, len(ps))
	for _, p := range ps {
		pNum, _ := strconv.Atoi(p)
		pArr = append(pArr, pNum)
	}
	diff := make([]int, 0, N)
	for i := 0; i < N; i++ {
		if arrN[i] == pArr[i] {
			continue
		}
		diff = append(diff, i)
	}
	if len(diff) > 2 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}



Measured memory_bytes: 640
fn func(input_str: &str) -> u32 {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let mut h_s: Vec<u32> = iter.take(n).map(|x| x.parse().unwrap()).collect();
    h_s.sort();
    let mut ans = std::u32::MAX;
    for i in 0..(n - k + 1) {
        let d = h_s[i + k - 1] - h_s[i];
        ans = std::cmp::min(d, ans);
    }
    ans
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}

Measured memory_bytes: 6396
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>

using namespace std;

int main() {

	char b; cin >> b;

	if (b == 'A') {
		cout << "T" << endl;
	}
	else if (b == 'T') {
		cout << "A" << endl;
	}
	else if (b == 'G') {
		cout << "C" << endl;
	}
	else if (b == 'C') {
		cout << "G" << endl;
	}




}

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

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

    string s;
    int w;
    cin >> s >> w;

    rep(i, s.size()){
        if(i%w == 0) cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define H 250

int main(){
  int h,i;
  int data[H];

  scanf("%d",&h);
  for(i = 1;i < h+1;i++){
    scanf("%d",&data[i]);
  }

  for(i = 1;i < h+1;i++){
    printf("node %d: key = %d, ",i,data[i]);
    if(i != 1 && 1 <= i/2 && i/2 < h+1) printf("parent key = %d, ",data[i/2]);
    if(1 <= 2*i && 2*i < h+1) printf("left key = %d, ",data[2*i]);
    if(1 <= (2*i+1) && (2*i+1) < h+1) printf("right key = %d, ",data[2*i+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2052
S=input()
N=len(S)
L=[0]*(N+1)
for i in range(len(S)):
    if S[i]=="<":
        L[i+1]+=L[i]+1

for i in range(len(S)-1,-1,-1):
    if S[i]==">":
        L[i]=max(L[i+1]+1,L[i])
print(sum(L))

Measured memory_bytes: 23324
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   ll x; cin>>x;
   
   vector<ll> divisors;

   for(ll i = 1; i *i <= x; i++){
       if(x%i == 0)divisors.pb(i);
       if(x/i != i)divisors.pb(x/i);
   }

   for(auto d : divisors){
       for(ll a = -1000; a <= 1000; a++){
           ll b = a-d;
           if(pow(a, 5) - pow(b, 5) == x){
               cout<<a<<" "<<b<<endl;
               return 0;
           }
       }
   }

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}




Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <numeric>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i=1;i<N-1;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i+1]<p[i]&&p[i]<p[i-1])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
	ll N; cin >> N;
	vector<vector<P>> XY(N, vector<P>());
	rep(i, N) {
		int a, x, y;
		cin >> a;
		rep(j, a) {
			cin >> x >> y;
			x--;
			XY[i].push_back(P(x, y));
		}
	}

	int cmax = 0;
	rep(i, 1<<N) {
		bool ok = true;
		rep(j, N) {
			if (!(i & (1<<j))) continue;
			for (auto p : XY[j]) {
				if (p.second == 1) {
					if (!(i & (1<<p.first))) ok = false;
				}
				if (p.second == 0) {
					if ( (i & (1<<p.first))) ok = false;
				}
			}
		}
		if (ok) {
			cmax = max(cmax, __builtin_popcount(i));
		}
	}

	cout << cmax << endl;
	return 0;
}


Measured memory_bytes: 256