akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <regex>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main() {
    std::regex re("(dream|dreamer|erase|eraser)*");

    string s;
    cin >> s;

    bool ans = std::regex_match(s, re);
    cout << (ans ? "YES" : "NO") << endl;

    return 0;
}



Measured memory_bytes: 39808
N = input()

li = list(map(int,input().split()))

list.sort(li,reverse=True)

#print(li)
#print(len(li))
l = 0
g = 0

for i in range(0,(len(li)),2):
    #l =[int(x) for x in list(str(i))]
    l += li[i]
#print(l)


for j in range(1,(len(li)),2):
    #m =[int(y) for y in list(str(j))]
    g += li[j]
#print(g)

print(l-g)




Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    bool flag = false;
    for (int i = 0; i <= n / 4; i++) {
        if ((n - 4 * i) % 7 == 0) {
            flag = true;
            break;
        }
    }   
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,D,H,K,L,M,N,T,W,X,Y;
  //string S;
  cin >>  X >> Y >> A >> B >> C;
  vector<long long> p(A),q(B),r(C),s(X+Y+C,0);
  
  D=0;
  
  for (long long i=0;i<A;i++) {cin >> p[i];}
  for (long long i=0;i<B;i++) {cin >> q[i];}
  for (long long i=0;i<C;i++) {cin >> r[i];}
  
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  
  
  for (long long i=0;i<X+Y+C;i++) {
    if (i<X) {s[i]=p[A-X+i];}
	if (i>=X && i<X+Y) {s[i]=q[B-Y+i-X];}
	if (i>=X+Y) {s[i]=r[i-X-Y];}
    //cout << s[i] << endl;
  }
  
 sort(s.begin(),s.end());
 reverse(s.begin(),s.end());
 
 for (long long i=0;i<X+Y;i++) {D+=s[i];}
 cout << D << endl;
  
  
  
  
}

Measured memory_bytes: 4736
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int h,w;cin >> h >> w;
    vvi bo(h,vi(w,-1));
    queue<P> que;
    rep(i, h) {
        rep(j, w) {
            char c;cin >> c;
            if(c=='#') {
                que.push({i,j});
                bo[i][j]=0;
            }
        }
    }
    // vi ans;
    // ans.pb(0);
    int ans = 0;
    while(!que.empty()) {
        P p = que.front();
        que.pop();
        rep(i, 4) {
            int x = p.first+dx[i],y = p.second+dy[i];
            if(x<0||x>=h||y<0||y>=w||bo[x][y]!=-1) continue;
            bo[x][y]=bo[p.first][p.second]+1;
            // ans.pb(bo[x][y]);
            chmax(ans,bo[x][y]);
            que.push({x,y});
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27192
#include <stdio.h>

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    int j;
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            int tmp = A[j];
            i++;
            A[j] = A[i];
            A[i] = tmp;
        }
    }
    A[r] = A[i + 1];
    A[i + 1] = x;
    return i + 1;
}

int main(void) {
    int n, i, q;
    int A[100000];
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    q = partition(A, 0, n - 1);
    for (i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == q) printf("[%d]", A[i]);
        else printf("%d", A[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2188
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll R,S,P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    vector<char> v[100010];
    rep(i,0,N){
        ll amari = i % K;
        if(T[i] == 'r') v[amari].push_back('p');
        else if(T[i] == 'p') v[amari].push_back('s');
        else v[amari].push_back('r');
    }
    ll ans = 0;
    rep(i,0,K){
        ll sz = v[i].size();
        ll cnt = 1;
        rep(j,1,sz){
            if(v[i][j-1] == v[i][j]){
                cnt++;
            }else{
                char c = v[i][j-1];
                if(c == 'r'){
                    ans += R * ((cnt+1)/2);
                }else if(c == 'p'){
                    ans += P * ((cnt+1)/2);
                }else{
                    ans += S * ((cnt+1)/2);
                }
                cnt = 1;
            }
        }
        char c = v[i][sz-1];
        if(c == 'r'){
            ans += R * ((cnt+1)/2);
        }else if(c == 'p'){
            ans += P * ((cnt+1)/2);
        }else{
            ans += S * ((cnt+1)/2);
        }
    }
    print(ans);

    

}

Measured memory_bytes: 5456
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;cin>>n;
	char a[50][2],b[50][2];
	REP(i,n)cin>>a[i];
	memcpy(b,a,n*2*sizeof(char));
	REP(i,n){
		RFOR(j,n,i+1){
			if(b[j][1] < b[j-1][1])swap(b[j],b[j-1]);
		}
	}
	REP(i,n){if(i)cout << ' ';
		cout << b[i][0] << b[i][1];
		
	}cout << '\n' << "Stable" << endl;
	
	REP(i,n){
		int mini = i;
		FOR(j,i,n){
			if(a[j][1] < a[mini][1])mini = j;
		}
		if(mini != i)swap(a[mini],a[i]);
	}
	bool stable = true;
	REP(i,n){if(i)cout << ' ';
		cout << a[i][0] << a[i][1];
		if(b[i][0] != a[i][0])stable = false;
	}cout << '\n';
	if(stable)cout << "Stable" << endl;
	else cout << "Not stable" << endl;
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

int c[101010];
int r[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		c[i]=1;
	}
	r[1]=1;
	for (int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		int rr=r[x];
		if (c[x]==1){
			r[x]=0;
		}
		c[x]--;
		c[y]++;
		r[y]|=rr;
	}
	int v=0;
	for (int i=1;i<=n;i++){
		if (r[i]) v++;
	}
	cout<<v<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<inttypes.h>
#include<string.h>
int main(){
  uint64_t a;
  scanf("%" SCNu64 ,&a);
  char s[12];
  int i;
  for(i=0;a;i++){
    s[i]='a'+--a%26;
    a/=26;
  }
  for(i--;i>=0;i--)printf("%c",s[i]);
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main(void){
  char buf[128] = { 0 };
  short grid[64][64] = { {0} };
  int H,W;
  
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d", &H, &W);
  
  for(int i = 0; i < H; i++){
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    for(int j = 0; j < W; j++)
      if(buf[j] == '#') grid[i+1][j+1] = 1;          
  }
  
  int flag = 0;
  for(int i = 1; i < H+1; i++){
    for(int j = 1; j < W+1; j++){
      if(grid[i][j] == 0) continue;
      else{
        if(grid[i-1][j] != 1 && grid[i][j-1] != 1 
           && grid[i+1][j] != 1 && grid[i][j+1] != 1){
          flag = 1;
          break;
        }
      }
    }
    if(flag) break;
  }
  if(flag == 0) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

int main(){
        int N;
        int a[110];
        int sum, ave, ans;
        cin >> N;
        rep(i,N) cin >> a[i];
        sum = 0;
        rep(i,N) sum += a[i];
        ave = round((double)sum / N);
        ans = 0;
        rep(i,N) ans += pow((a[i] - ave),2);
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    a=max(a,c);
    b=min(b,d);
    cout<<max(0ll,b-a)<<endl;
}
return 0;
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val S = in.next()
  val Q = in.next().toInt

  var vec = S.toVector
  var flag = 0

  for (_ <- 1 to Q) {
    val com = in.next().toInt

    if (com == 1) {
      flag += 1
      flag %= 2
    }
    else if (com == 2) {
      val p = in.next().toInt
      val c = in.next()(0)

      if (flag == 0) {
        if (p == 1)
          vec = c +: vec
        else
          vec = vec :+ c
      }
      else if (flag == 1) {
        if (p == 1)
          vec = vec :+ c
        else
          vec = c +: vec
      }

    }
  }


  val ans = vec.mkString
  if (flag == 0) {
    println(ans)
  }
  else {
    println(ans.reverse)
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 80888
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str1= Console.ReadLine().Split(' ');
            string[] str2= Console.ReadLine().Split(' ');

            int N=int.Parse(str1[0]);
            long K=Convert.ToInt64(str1[1]);
            
            int[] ord = Enumerable.Repeat<int>(-1, N).ToArray();

            int[] A = new int[N];
            for(int i=0;i<N;i++)
            {
                A[i] = int.Parse(str2[i]);
            }

            int[] M = new int[N];
            int c=0,l=0;
            {
                int v=0,s=0;
                while(ord[v]==-1){
                    ord[v] = s;
                    M[s] = v+1;
                    v = A[v]-1;
                    s++;
                }
                c = s - ord[v];
                l = ord[v];
            }

            if(K<l) Console.WriteLine(M[K]);
            else{
                K -= l;
                K %= c;
                Console.WriteLine(M[K+l]);
            }


        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 44512
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <cmath>


bitset<1000000> isPrime;
//素数テーブル作成
void makePrimeTable(int n){  
    isPrime = bitset<1000000>(0);//コンストラクタ呼び出し
    //まずはすべて１にする
    for(ll i = 2LL;i <= n;i++) isPrime.set(i);

    //倍数をすべて0にする
    for(ll i = 2LL;i <= n;i++){
        for(ll j = 2 * i;j <= n;j += i){
            //倍数番目をオフにする
            if(isPrime[j]) isPrime.reset(j);
        }
    }
    
}


int main(){

    int N_MAX = 55555;
    makePrimeTable(N_MAX);

    int n;
    cin >> n;

    vector<int> primeSeq;
    int index = 0;
    //N_MAXまでの素数を配列にすべて格納する
    for(int i = 2;i <= N_MAX;i++){
        if(isPrime[i] && i % 5 == 1) primeSeq.push_back(i);
    }

    //指定の長さ分出力する
    for(int i=0;i < n;i++) cout << primeSeq[i] << " ";
    
    return 0;
}

Measured memory_bytes: 384
def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    l = [a,b,c,d,e]

    l = sorted(l, key=lambda x: (x-1)%10, reverse=True)
    # print(l)

    ans = 0
    for i in range(len(l)-1):
        x = l[i]
        if x % 10 == 0:
            ans += x
        else:
            ans += x + (10 - x%10)
    ans += l[-1]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,ma,mi;
	cin>>x>>y;
	ma=x*4;
	mi=x*2;
	if(y>ma||y<mi||y%2==1)
	{
		cout<<"No";
	}
	else
	{
		cout<<"Yes";
	}
	return 0;
} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
//26

int e[100];
int calc(int n){
	int ans = 0;
	while(n > 0){
		ans += n%10;
		n /= 10;
	}
	return ans;
}

signed main(){
	int n, x = 1;
	scanf("%lld", &n);
	e[0] = 1;
	rrep(i,18)e[i] = e[i-1]*10;
	rep(i,n){
		printf("%lld\n", x);
		x++;
		int s = calc(x);
		P p = dmp(x, s);
		for(int j = 0;e[j] <= x;j++){
			int tmp = (x%e[j+1])/e[j];
			x += (9-tmp)*e[j];
			s += (9-tmp);
			if(x*p.se < s*p.fi)p = dmp(x, s);
		}
		x = p.fi;
	}
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c[110],cnt=1,e=0;
signed main()
{
	cin>>a>>b;
	rep(i,a){
		cin>>c[i];
		if(e+c[i]<=b){
			cnt++;
		}
		e+=c[i];
	}
	cout<<cnt;
}

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

using namespace std;
using ll = long long;

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

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

    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ll l = a[i - 1]; ll r = a[i];
        if (l <= r) continue;
        ans += l - r;
        a[i] = l;
    }
    cout << ans << endl;
}

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

int N, a[100];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N, greater<int>());
  int A=0, B=0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) A += a[i];
    else B += a[i];
  }
  cout << A - B << endl;
  return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const double PI=acos(-1);

typedef complex<double>Point;
int N;
double R,T;
bool ok[20][20][20];
Point ps[20];

const double INF=1e12;
double dp[10010][20][20];

signed main(){
    cin>>N>>R>>T;
    T=T/180*PI;
    rep(i,N){
        double x,y;cin>>x>>y;
        ps[i]=Point(x,y);
    }
    rep(i,N)rep(j,N)rep(k,N){
        if(i==j||j==k||k==i)continue;
        complex<double>a=ps[j]-ps[i],b=ps[k]-ps[j];
        double tmp=real(a)*real(b)+imag(a)*imag(b);
        tmp/=abs(a*b);
        tmp=acos(tmp);
        if(tmp<=T)ok[i][j][k]=true;
    }

    fill_n(**dp,10010*20*20,INF);
    for(int i=1;i<N;i++)dp[1][i][0]=abs(ps[i]-ps[0]);

    for(int i=1;i<R;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                for(int l=0;l<N;l++){
                    if(!ok[k][j][l])continue;
                    chmin(dp[i+1][l][j],dp[i][j][k]+abs(ps[l]-ps[j]));
                }
            }
        }
    }

    int ma=0;
    rep(i,R+1)rep(j,N)rep(k,N)if(dp[i][j][k]<=R)chmax(ma,i);
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 34796
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 7;

int dp[N];
vector<int> g[N];

void dfs(int cur, int p) {
	int c = 0;
	for (auto t : g[cur]) {
		if (t != p) {
			dfs(t, cur);
			dp[cur] += dp[t];
			if (dp[t] == 0) {
				c++;
			}
		}
	}
	dp[cur] += max(0, c - 1);
}

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

	int n;
	cin >> n;
	for (int i = 0; i + 1 < n; i++) {
		int u, v;
		cin >> u >> v;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for (int i = 0; i < n; i++) {
		if ((int)g[i].size() > 2) {
			dfs(i, -1);
			cout << dp[i] << '\n';
			return 0;
		}
	}
	cout << 1 << '\n';
}


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

int main () {
  int N, b, c;
  b = 1;
  c = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  while (b != 2) {
    b = a.at(b - 1);
    c++;
    if (c > N) {
      break;
    }
  }
  if (c > N) {
    cout << -1 << endl;
  }
  else {
    cout << c << endl;
  }
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
int main()
{
 ll a,b,n;
 cin>>a>>b>>n;
 
 if(n<b)
  cout<<(a*n)/b<<"\n";
 else
    cout<<(a*(b-1))/b<<"\n";
 return 0;
}

Measured memory_bytes: 3608
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)

const int MOD = 1000000007;
const int MAX = 1000000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    COMinit();
    int x,y;
    cin >> x >> y;
    if((2*y-x)%3!=0){
        cout << 0;
        return 0;
    }
    int a = (2*y-x)/3;
    int b = y-2*a;
    if(a<0 || b<0){
        cout << 0 << endl;
        return 0;
    }
    cout << COM(a+b,a) << endl;
}



Measured memory_bytes: 23680
n, m ,k = map(int, input().split())

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

a=[0]
b=[0]
for i in range(n):
  a.append(a[i]+A[i])
for j in range(m):
  b.append(b[j]+B[j])

ans, j = 0, m
for i in range(n+1):
  if a[i]>k:
    break
  while b[j]>k-a[i]:
    j-=1
  ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47648
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long A = nextLong();
        long B = nextLong();
        long K = nextLong();

        if(A>=K){
            println((A-K) + " " + B);
        }else{
            long ans = K-A;
            long ans2 = ans>B ? 0 : B-ans;
            println(0 + " " + ans2);
        }
    }

    static long a(long n){
        return n < 2L ? 1L : n*a(n-2);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 23636
#include <iostream>

const int MAXN = (int)1e7 + 1;

int divisor_num[MAXN];

int64_t solve(int n) {
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      ++divisor_num[j];
    }
  }
  int64_t ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += 1LL * i * divisor_num[i];
  }
  return ans;
}

int main() {
  int n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 42620
N = int(input())
P = list(map(float, input().split()))

dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(0, i+1):
        dp[i][j] = dp[i-1][j] * (1 - P[i-1])
        if j > 0:
            dp[i][j] = dp[i-1][j-1] * P[i-1] + dp[i-1][j] * (1 - P[i-1])
# print(*dp, sep='\n')
print(sum(dp[N][N//2+1:]))


Measured memory_bytes: 255752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		int A = scanner.nextInt();

		int B = scanner.nextInt();

		int T = scanner.nextInt();

		log((T / A) * B);

	}

	private static void log(String str) {
		System.out.println(str);
	}

	private static void log(int str) {
		System.out.println(str);
	}

}

Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);
		
		String a = sc.next();
		String b = sc.next();
		int count = 0;
		
		for(int i = 0; i < a.length(); i++) {
			
			if(a.charAt(i) != b.charAt(i))
				count++;
		}
		pr.println(count);
		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 37408
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll X, K, D, Ans = 0;cin >> X >> K >> D;
  
if(X < 0)X *= -1;

Ans = X%D;

ll a = X/D;

if(a > K){cout << X - D*K;exit(0);}

if(a%2 == K%2){cout << Ans;exit(0);}

if(a%2 != K%2)cout << abs(Ans - D);

}

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

Measured memory_bytes: 256
N=int(input())
s=list(input())
s.append(s[0])
A=[list("SS"+"?"*(N)),list("WS"+"?"*(N)),list("SW"+"?"*(N)),list("WW"+"?"*(N))]
for a in A:
  for i in range(2,N+2):
    if a[i-2:i]==["S","S"] and s[i-1]=="o":
      a[i]="S"
    elif a[i-2:i]==["S","S"] and s[i-1]=="x":
      a[i]="W"
    elif a[i-2:i]==["W","S"] and s[i-1]=="o":
      a[i]="W"
    elif a[i-2:i]==["W","S"] and s[i-1]=="x":
      a[i]="S"
    elif a[i-2:i]==["S","W"] and s[i-1]=="o":
      a[i]="W"
    elif a[i-2:i]==["S","W"] and s[i-1]=="x":
      a[i]="S"
    elif a[i-2:i]==["W","W"] and s[i-1]=="o":
      a[i]="S"
    elif a[i-2:i]==["W","W"] and s[i-1]=="x":
      a[i]="W"
  if a[0]==a[N] and a[1]==a[N+1]:
    print("".join(a[:N]))
    exit()
    
print(-1)
  
    
    
    
     
  

Measured memory_bytes: 80020
N=int(input())
#N=17



input=input()
#input="13 76 46 15 50 98 93 77 31 43 84 90 6 24 14 0 1"
masu=[int(r) for r in input.split()]
ans=[]

for i in range(1,N+1,2):

    if masu[i-1]%2==1:
        ans.append(i)

print(len(ans))

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    long long n;
    cin>>n;
    long long i;
    long long ans = 1;
    for(i=1; i<=n; i++){
        ans = (ans*i)%1000000007;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

int main(void){
    int N, K, Q;
    scanf("%d %d %d",&N, &K, &Q);

    int A[Q+1]; //A[1]~A[Q]に格納
    for(int i=1;i<=Q;i++){
        scanf("%d",&A[i]);
    }

    int B[N+1]; //B[1]~B[N]に格納、B[i]はi番目の人の得点
    for(int i=1;i<=N;i++){
        B[i]=K-Q;
    }

    for(int i=1;i<=Q;i++){
        B[A[i]]++;
    }

    for(int i=1;i<=N;i++){
        if(B[i]>0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		for(int i = 0; i < b; i++) {
			a -= sc.nextInt();
		}
		if(a<0) System.out.println(-1);
		else System.out.println(a);
	}
}


Measured memory_bytes: 46480
n,m=map(int, input().split())
lst=list(map(int,input().split()))
weight=[0,2,5,5,4,5,6,3,7,6]
DP=[-1]*(n+1)
DP[0]=0
for i in range(n+1):
  for x in lst:
    if i+weight[x]<n+1:
      DP[i+weight[x]]=max(DP[i+weight[x]], DP[i]*10+x)
print(DP[n])

Measured memory_bytes: 20464
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 19, Mod = 1e9 + 7;
int n, k, c, A[N], B[N];
string S;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k >> c;
    cin >> S;
    int now = 0;
    for (int i = 0; i < (int)S.size() && now < k; i ++)
        if (S[i] != 'x')
        {
            now ++;
            A[i] = now;
            i = i + c;
        }
    now = 0;
    for (int i = (int)S.size() - 1; i >= 0 && now < k; i --)
        if (S[i] != 'x')
        {
            now ++;
            B[i] = now;
            i = i - c;
        }
    for (int i = 0; i < (int)S.size(); i ++)
        if (A[i] != 0 && B[i] != 0 && A[i] == k - B[i] + 1)
            printf("%d\n", i + 1);
    return 0;
}

Measured memory_bytes: 6676
#include <stdio.h>
#include <math.h>


int main(void) {
	int n, k, x;
	int ans = 0;
	scanf("%d", &n);
	scanf("%d", &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x);
		if (x*2 < abs(k - x)*2) {
			ans += x*2;
		}
		else {
			ans += abs(k - x)*2;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e5 + 10;
#define fi first
#define se second
#define pb push_back
const LL mod=1e9+7;
LL fac[N],inv[N];
LL km(LL a,LL b){
  LL ans=1;
  while(b){
    if(b&1)ans=a*ans%mod;
    b>>=1;
    a=a*a%mod;
  }
  return ans;
}
void P(){
  fac[0]=1;
  for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%mod;
  inv[N-1]=km(fac[N-1],mod-2);
  for(int i=N-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(int a,int b){
  return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int n,k;
int main() {
  ios::sync_with_stdio(false);
  P();
  cin>>n>>k;
  if(k>=n){
    k=n;
    cout<<C(n+k-1,k-1);
  }else{
    LL tot=C(2*n-1,n-1);
    for(int i=1;i<n-k;i++){//>= n-k 个位置为1
      int j=n-i;//i个位置非空
      tot-=1ll*C(n,i)*C(n-i+i-1,i-1)%mod;
      tot+=mod;
      tot%=mod;
    }
    cout<<tot<<'\n';
  }
  return 0;
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main(void) {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int total = 0;
    int sugar = 0;
    double density = 0.0;
    for(int i=0; i<=30; i++) {
        for(int j=0; j<=15; j++) {
            int water_tmp = 100*(A*i+B*j);
            if(water_tmp > F || water_tmp == 0) {
                break;
            }
            for(int k=0; k<=3000; k++) {
                for(int l=0; l<=1500; l++) {
                    int sugar_tmp = C*k+D*l;
                    int total_tmp = water_tmp + sugar_tmp;
                    if(total_tmp > F) {
                        break;
                    } else {
                        int limit = water_tmp / 100 * E;
                        if(sugar_tmp <= limit) {
                            double density_tmp = 100.0 * (double)sugar_tmp / (double)total_tmp;
                            if(density_tmp > density) {
                                density = density_tmp;
                                total = total_tmp;
                                sugar = sugar_tmp;
                            }
                        }
                    }
                }
            }
        }
    }

    if(total == 0) {
        cout << 100*A << " " << 0 << endl;
    } else {
        cout << total << " " << sugar << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int k;
  cin>>k;
  cout<<50<<endl;
  int a=k/50;
  for(int i=0;i<50;i++){
    if(i)cout<<" ";
    if(i>=(k%50))cout<<a+i-(k%50);
    else cout<<a+i-(k%50)+1+50;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;

int main(){
    si(x);
    if(x==1)    cout<<0;
    if(x==0)    cout<<1;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int n,cnt,ans;
    cnt = ans = 0;
    string c;
    cin >> n >> c;
    rep(i,n) if(c[i] == 'R') cnt++;
    rep(i,n-cnt){
        if(c[i+cnt] == 'R') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

    if (0<=k && k<=a)
    {
        cout << k << endl;
    }
    if (a<k && k<=a+b)
    {
        cout << a << endl;
    }
    if (a+b<k && k<=a+b+c)
    {
        cout << 2*a+b-k << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    //入力始まり
    string S;
    int Q;
    cin >> S >> Q;
    vector<int>T(Q);
    vector<int>F(Q,0);
    vector<char>C(Q);
    for(int i=0;i<Q;i++){
        cin >> T[i];
        if(T[i]==2){
            cin >> F[i];
            cin >> C[i];
        }
    }
    //入力終わり
 
    int counter=0;
    for(int i=0;i<Q;i++){
    if(T[i]==1){
        counter++;
    }else{
        if(F[i]==1){
            if(counter%2==1){
            S.insert(S.end(),C[i]);
            }else{
                S.insert(S.begin(),C[i]);
            }
        }else{
            if(counter%2==1){
            S.insert(S.begin(),C[i]);
            }else{
                S.insert(S.end(),C[i]);
            }
 
        }
    }}
    if(counter%2==1){
        reverse(S.begin(),S.end());
    }
    cout << S << endl;
    return 0;
}
 

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

#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

constexpr int MAX = 100001;

// dp[i] :== i に行くコストの最小値
int dp[MAX];
int N;
vector<int> h;

int main() {
    cin >> N;
    h = vector<int>(N+1);

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


    dp[0] = dp[1] = 0;
    for (int i = 2; i <= N; ++i) {
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
b = [0]
for _ in range(n):
    b.append(int(input()))

def solve():
    pushed = [False] * (n + 1)
    cur = 1
    cnt = 0
    while cur != 2:
        pushed[cur] = True
        cur = b[cur]
        cnt += 1
        if pushed[cur]:
            print(-1)
            return
    print(cnt)

solve()

Measured memory_bytes: 7848
fun main(args:Array<String>):Unit {
    repeat(readLine()!!.toInt()){
        println(countRensa(Array(12){readLine()!!.trim()}))
    }
}
class UnionFindTree{
    private var mRank:Int = 1
    private var mParent:UnionFindTree? = null
    private fun parent():UnionFindTree {
        return when(mParent){
            null -> this
            else -> {
                mParent = mParent?.parent()
                mParent!!
            }
        }
    }
    fun rank():Int {
        return when(mParent){
            null -> mRank
            else -> parent().rank()
        }
    }
    fun isSameUnion(other:UnionFindTree):Boolean {
        return parent() == other.parent()
    }
    fun merge(other:UnionFindTree):Unit {
        if (!isSameUnion(other)){
            val newRank = rank() + other.rank()
            parent().mParent = other.parent()
            parent().mRank = newRank
        }
    }
}
data class Point(val x:Int, val y:Int) {
    fun neighbors():Iterable<Point> = listOf(Point(x - 1, y), Point(x + 1, y), Point(x, y - 1), Point(x, y + 1))
}
data class Puyo(val point:Point, val color:Char){
    fun down():Puyo = Puyo(Point(point.x, point.y + 1), color)
}
fun countRensa(state:Array<String>):Int {
    //println(state.joinToString("\n", postfix = "\n"))
    val puyo = state.map{it.map{UnionFindTree()}}
    val moved = state.map(String::toCharArray).toTypedArray()
    for (i in 1 until state.size) for (j in 0 until state[0].length) {
        if (state[i][j] !in listOf('O', '.') && state[i - 1][j] == state[i][j]){
            puyo[i][j].merge(puyo[i - 1][j])
        }
    }
    for (i in 0 until state.size) for (j in 1 until state[0].length){
        if (state[i][j] !in listOf('O', '.') && state[i][j - 1] == state[i][j]){
            puyo[i][j].merge(puyo[i][j - 1])
        }
    }
    for (i in 0 until state.size) for (j in 0 until state[0].length){
        if (puyo[i][j].rank() >= 4){
            moved[i][j] = '.'
            Point(j, i).neighbors().filter{it.y in 0 until state.size && it.x in 0 until state[0].length}.filter { state[it.y][it.x] == 'O' }.forEach {
                moved[it.y][it.x] = '.'
            }
        }
    }
    var movable = (0 until state.size).flatMap{y -> (0 until state[0].length).filter{x -> moved[y][x] != '.'}.map{x -> Puyo(Point(x, y), moved[y][x])}}
    while(movable.count{
                it.point.y + 1 < state.size && moved[it.point.y + 1][it.point.x] == '.'
            } != 0)  {
        val m = movable.filter{it.point.y + 1 < state.size && moved[it.point.y + 1][it.point.x] == '.'}
        movable = movable.map{
            if (it.point.y + 1 < state.size && moved[it.point.y + 1][it.point.x] == '.') {
                Puyo(it.point.copy(y = it.point.y + 1), it.color)
            }else{
                it
            }
        }
        m.forEach {
            moved[it.point.y][it.point.x] = '.'
            moved[it.point.y + 1][it.point.x] = it.color
        }
    }
    return if (puyo.any{it.any{it.rank() >= 4}}) 1 + countRensa(moved.map{it.joinToString("")}.toTypedArray())
        else 0
}


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

int main() {
  int n,m;
  int a=0;
  int b=0;
  cin >> n >> m;
    vector<int> h(n);
    vector<int> z(n,1);
  for (int i = 0; i < n; i++) {
      cin >> h.at(i);
  }
  for (int i = 0; i < m; i++) {
      cin >> a >> b;
        if(h.at(a-1)==h.at(b-1)){
            z.at(a-1)=0;
            z.at(b-1)=0;
        }else if(h.at(a-1)<h.at(b-1)){
            z.at(a-1)=0;
        }else{
            z.at(b-1)=0;

        }
  }
    int value_to_remove = 0;
z.erase(std::remove(z.begin(), z.end(), value_to_remove), z.end());
cout << z.size() << endl;
} 

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    cin>>str;
    if(str.size()%2 == 0) {
        while(str.substr(0,2) == "hi") {
            str = str.substr(2);
        }
    }
    if(str.size() != 0) 
        cout<<"No"<<"\n";
    else
        cout<<"Yes"<<"\n";
        
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 1000000007
#define PI 3.1415926535897932384
#define F first
#define S second
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair


void solve(){ 

ll n;
cin>>n;
n%=1000;
if(n==0) n=1000;
cout<<1000-n;


}
int main()
{   FAST;
    
   
    ll test;
    test=1;
   
    //cin>>test;
    while(test--)
    {
        solve();
    }
    // cerr<<endl<<"maut : "<<elasped_time<<endl;
    return 0;
}
 
    



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    int k; cin >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int lb=0, ub=INF;
    auto C = [&](int x) {
        int num = 0;
        rep(i,n) {
            int tmp = ceil((double)a[i]/x)-1;
            num += tmp;
        }
        if (num <= k) return true;
        else return false;
    };
    while (ub-lb>1) {
        int mid = (lb+ub)/2;
        if (C(mid)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;
}

Measured memory_bytes: 3892
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>

int main(void)
{
    int64_t N;
    std::cin >> N;

    std::vector<std::pair<int64_t, int64_t>> coords(N);

    for (auto& coord : coords) {
        std::cin >> coord.first >> coord.second;
    }

    double dist[N][N];
    for (int64_t i = 0; i < N - 1; ++i) {
        for (int64_t j = i + 1; j < N; ++j) {
            int64_t dx = coords.at(i).first - coords.at(j).first;
            int64_t dy = coords.at(i).second - coords.at(j).second;
            double distance = std::sqrt(dx*dx + dy*dy);
            dist[i][j] = distance;
        }
    }

    double total = 0;
    for (int64_t i = 0; i < N; ++i) {
        for (int64_t j = 0; j < N; ++j) {
            if (i == j) continue;
            int64_t small = std::min(i, j);
            int64_t big = std::max(i, j);
            total += dist[small][big];
        }
    }

    int64_t num = 1;

    for (int64_t i = 1; i <= N; ++i) {
        num *= i;
    }

    total *= (num / N);

    double ans = total / num;
    std::cout << std::setprecision(20) << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
    int N;
    cin >> N;
    while(N--) {
        string s1, s2;
        cin >> s1 >> s2;
 
        if(s1.size() > 80 || s2.size() > 80) {
            cout << "overflow" << endl;
            continue;
        }
        char buf[81] = {0};
        int p1 = s1.size()-1, p2 = s2.size()-1, pb = 79;
        int carry = 0;
        while(p2 >= 0) buf[pb--] = s2[p2--];
        pb = 79;
        while(pb >= 0 && (p1 >= 0 || carry > 0)) {
            int bd = buf[pb];
            if(bd > 0) bd -= '0';
            int bp = 0;
            if(p1 >= 0) bp = s1[p1--]-'0';
            int d = bp + bd + carry;
            carry = d / 10;
            d %= 10;
            buf[pb--] = d+'0';
        }
        while(pb >= 0 && buf[pb]) pb--;
        if(pb == -1 && carry > 0) cout << "overflow" << endl;
        else cout << (char*)(buf+(pb+1)) << endl;
    }
    return 0;
}

Measured memory_bytes: 1212