akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <unordered_map>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	unordered_map<int, int> m;
	auto o = [&m](int i) {
		bool r = m[i] & 1;
		m.erase(i);
		return r;
	};
	for (int a, b;;)
		if (scan(a, b))
			if (a)
				m[a]++, m[b]++;
			else {
				outl(o(1) && o(2) &&
					 none_of(m.begin(), m.end(), [](auto x) {return x.second & 1;}) ? "OK" : "NG");
				m.clear();
			}
		else
			break;
}


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

#define CMD_LEN_MAX 256

typedef struct Node
{
    int key;
    struct Node *prev, *next;
} Node;

class DLL
{
private:
    Node *head;

    Node *allocNode(int key, Node *prev, Node *next)
    {
        Node *tmp = (Node *)malloc(sizeof(Node));
        tmp->key = key;
        tmp->prev = prev;
        tmp->next = next;
        return tmp;
    };

    Node *searchNode(int key)
    {
        Node *tmp = head->next;
        while (tmp != head)
        {
            if (tmp->key == key)
                return tmp;
            tmp = tmp->next;
        }
        return NULL;
    };

public:
    DLL()
    {
        head = allocNode(-1, NULL, NULL);
        head->prev = head;
        head->next = head;
    };

    void insertNode(int key)
    {
        Node *tmp = head->next;
        head->next = allocNode(key, head, head->next);
        tmp->prev = head->next;
    };

    void deleteNode(int key)
    {
        Node *tmp;
        if ((tmp = searchNode(key)) != NULL)
        {
            tmp->next->prev = tmp->prev;
            tmp->prev->next = tmp->next;
            free(tmp);
        }
    };

    void deleteFirst()
    {
        Node *tmp = head->next;
        head->next = head->next->next;
        head->next->prev = head;
        free(tmp);
    };

    void deleteLast()
    {
        Node *tmp = head->prev;
        head->prev = head->prev->prev;
        head->prev->next = head;
        free(tmp);
    };

    void print()
    {
        Node *tmp = head->next;

        while (tmp != head)
        {
            printf("%d", tmp->key);
            tmp = tmp->next;
            if (tmp != head)
                printf(" ");
        }
        printf("\n");
    };
};

int main()
{
    DLL list;
    int n;
    scanf("%d", &n);

    char cmd[CMD_LEN_MAX];
    int key;
    while (n--)
    {
        scanf("%s", cmd);

        if (!strcmp(cmd, "insert"))
        {
            scanf("%d", &key);
            list.insertNode(key);
        }
        else if (!strcmp(cmd, "delete"))
        {
            scanf("%d", &key);
            list.deleteNode(key);
        }
        else if (!strcmp(cmd, "deleteFirst"))
            list.deleteFirst();
        else if (!strcmp(cmd, "deleteLast"))
            list.deleteLast();
    }
    list.print();
}


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

// loop and test case
#define ft    int t; scanf("%d", &t); for(int c=1; c<=t; c++)
#define whilecase while (tc--)
#define eof while (cin >> n)
#define forloop for (pos=1; pos<=tc; pos++)
#define arrayloop for (i=0; i<n; i++)

//memset function
#define setz(a) memset(a, 0, sizeof(a))
#define setneg(a) memset(a, -1, sizeof(a))

#define sf scanf
#define pf printf

// integer input
#define isc(a) scanf("%d", &a)
#define isc2(a,b) scanf("%d%d", &a,&b)
#define isc3(a,b,c) scanf("%d%d%d", &a,&b,&c)



// double input
#define dsc(a) scanf("%lf", &a)
#define dpf2(a) printf("%.2f", a)
#define dpf3(a) printf("%.3f", a)

//Case printing
#define casepf(a) printf("Case %d: ", a)
#define casestr(a, b) printf("Case %d: %s\n", a,b)
#define nl printf("\n") //new line

#define fl(a) floor(a)
#define cl(a) ceil(a)


#define pb(a) push_back(a)
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)

typedef long long ll;
typedef unsigned long long ull;
int a[10]={1,3,5,7,8,10,12},b[5]={4,6,9,11},c[1]={2};
int main(){
int x,y,d=0,e=0,f=0;
isc2(x,y);
for(int i=0;i<7;i++){
    if(a[i]==x){
        d++;
    }

}
for(int i=0;i<7;i++){
    if(a[i]==y){
        d++;
    }

}
for(int i=0;i<4;i++){
    if(b[i]==x){
        e++;
    }
}
for(int i=0;i<4;i++){
    if(b[i]==y){
        e++;
    }
}
for(int i=0;i<1;i++){
    if(c[i]==x){
        f++;
    }
}
for(int i=0;i<1;i++){
    if(c[i]==y){
        f++;
    }
}
if(d==2 || e==2 || f==2){
    cout<<"Yes"<<endl;
}
else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;

int main(){
  string s;
  cin >> s;
  while(true){
    if(s.size() >= 5 && (s.substr(s.size() - 5, 5) == "dream" || s.substr(s.size() - 5, 5) == "erase")){
      s = s.substr(0, s.size() - 5);
    }else if(s.size() >= 7 && s.substr(s.size() - 7, 7) == "dreamer"){
      s = s.substr(0, s.size() - 7);
    }else if(s.size() >= 6 && s.substr(s.size() - 6, 6) == "eraser"){
      s = s.substr(0, s.size() - 6);
    }else{
      break;
    }
  }
  cout << ((s.size() == 0) ? "YES" : "NO") << endl;
  return 0;
} 


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>

using namespace std;

struct Piece{
	int w,h;
	Piece(){}
	Piece(int _w,int _h){ w=_w,h=_h; }
};

bool operator<(const Piece &p,const Piece &q){
	return p.w*p.h<q.w*q.h;
}

int main(){
	for(int n,w,h;scanf("%d%d%d",&n,&w,&h),w;){
		Piece pc[101];
		pc[0]=Piece(w,h);
		for(int i=0;i<n;i++){
			int p,s;	scanf("%d%d",&p,&s);
			p--;
			int w=pc[p].w,h=pc[p].h;

			for(int j=p;j<i;j++)	pc[j]=pc[j+1];

			s%=(w+h+w+h);
			int dir,d;
			if     (s<w)	dir=1,d=s;
			else if(s<w+h)	dir=0,d=s-w;
			else if(s<w+h+w)dir=1,d=w-(s-w-h);
			else			dir=0,d=h-(s-w-h-w);

			if(dir==0){
				pc[i]=Piece(w,d);
				pc[i+1]=Piece(w,h-d);
			}
			else{
				pc[i]=Piece(d,h);
				pc[i+1]=Piece(w-d,h);
			}
			if(pc[i+1]<pc[i])	swap(pc[i],pc[i+1]);
		}

		sort(pc,pc+n+1);
		for(int i=0;i<n+1;i++){
			if(i)	putchar(' ');
			printf("%d",pc[i].w*pc[i].h);
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <complex>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  int a[n + 2], b[n + 2];
  a[0] = 0;
  a[n + 1] = 0;
  b[0] = 0;

  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }

  for (int i = 1; i <= n + 1; i++) {
    b[i] = b[i - 1] + abs(a[i] - a[i - 1]);
  }

  int total = b[n + 1];

  for (int i = 1; i <= n; i++) {
    int prev = a[i - 1];
    int cur = a[i];
    int next = a[i + 1];
    int d = (abs(cur - prev) - abs(prev - next)) + abs(cur - next);
    printf("%d\n", total - d);
  }

  return 0;
}


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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

int n, k;
string s[2020];
bool can[2020][10020], ok[2020][10020];
string ans;

vector<int> z_algo(string s) {
  vector<int> z(20020, 0);
  for (int i = 1, l = 0, r = 1; i < len(s); i++) {
    if (i >= r) {
      l = r = i;
      while (i + z[i] < len(s) && s[z[i]] == s[i + z[i]]) z[i]++, r++;
    } else if (r - i > z[i - l]) {
      z[i] = z[i - l];
    } else {
      z[i] = r - i;
      l = i;
      while (i + z[i] < len(s) && s[z[i]] == s[i + z[i]]) z[i]++, r++;
    }
  }
  return z;
}

void solve() {
  cin >> n >> k;
  rep(i, 1, n) { cin >> s[i]; }

  can[n + 1][0] = true;
  per(i, n, 1) {
    rep(j, 0, k) {
      if (!can[i + 1][j]) continue;
      can[i][j] = true;
      if (j + len(s[i]) > k) continue;
      can[i][j + len(s[i])] = true;
    }
  }

  ok[0][0] = true;
  ans = "";
  rep(i, 1, n) {
    int ans_prefix_len = -1;
    vector<int> z = z_algo(s[i] + ans);
    rep(j, 0, k) {
      if (!ok[i - 1][j]) continue;
      ok[i][j] = true;

      int new_len = j + len(s[i]);
      if (new_len > k) continue;
      if (!can[i + 1][k - new_len]) continue;

      // new_str = ans.substr(0, j) + s[i]
      // 1. new_str is prefix of ans - OK
      // 2. ans is prefix of new_str - OK, UPDATE ans
      // 3. new_str is higher than ans - SKIP
      // 4. new_str is lower than ans - RESET

      if (z[len(s[i]) + j] >= len(s[i])) {
        ok[i][new_len] = true;
      } else if (z[len(s[i]) + j] <= len(s[i]) &&
                 j + z[len(s[i]) + j] == len(ans)) {
        ok[i][new_len] = true;
        ans_prefix_len = j;
      } else if (s[i][z[len(s[i]) + j]] > ans[j + z[len(s[i]) + j]]) {
        continue;
      } else {
        int prefix_len = j + z[len(s[i]) + j];
        rep(l, 0, prefix_len) { ok[i][l] |= ok[i - 1][l]; }
        rep(l, prefix_len + 1, k) { ok[i][l] = false; }
        ok[i][new_len] = true;
        ans_prefix_len = j;

        break;
      }
    }

    if (ans_prefix_len != -1) {
      ans = ans.substr(0, ans_prefix_len) + s[i];
    }

    // cout << s[i] << "\t: ";
    // rep(j, 0, k) {
    //   if (ok[i][j]) cout << ans.substr(0, j) << ' ';
    // }
    // cout << nl;
  }
  cout << ans;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}

Measured memory_bytes: 43140
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <deque>

using namespace std;

long long n, sum = 0;

int litres[100000];

int mountaines[100000];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> litres[i];
		sum += litres[i];
	}
	for (int i = 0; i < n - 1; i += 2) {
		sum -= litres[i] * 2;
	}
	mountaines[n - 1] = sum;
	mountaines[0] = litres[n - 1] * 2 - sum;
	for (int i = 1; i < n - 1; ++i)
		mountaines[i] = litres[i - 1] * 2 - mountaines[i - 1];
	for (int i = 0; i < n; ++i)
		cout << mountaines[i] << " ";
}

Measured memory_bytes: 2048
program sample
	implicit none
    integer(8) :: X,N,i,j,count
    integer(8),allocatable :: a(:),b(:)
    
    read(*,*) X,N
    
    allocate(a(N))
    
    allocate(b(N))
    
    count = X
    
    if (N==0) then
    	write(*,*) X
    else
    	read(*,*) a
    	do i=0,N
        	do j=1,N
            !write(*,*) i
            !write(*,*) count+i*(-1)**i
            	if (a(j) == count+i*(-1)**i) then
                	b(j) = 0
            	else
                	b(j) = count+i*(-1)**i
                end if
                
            end do
            count = count+i*(-1)**i
            if (minval(b) == maxval(b)) then
            	exit
            end if
        end do
        write(*,*) minval(b)
    end if
    
    
    deallocate(a)
    deallocate(b)
    stop
end program sample

Measured memory_bytes: 2788
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using pint = pair<int64_t, int64_t>;
using vint = vector<int64_t>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<(itr==--v.end())?"\n":" ";}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    int n, k; cin >> n >> k;
    vint a(n); vin(a);
    map<int, int> m; rfor(x, a) m[x]++;
    if(m.size() <= k) {
        println(0);
        return 0;
    }
    vpint vp;
    rfor(x, m) vp.push_back(x);
    sort(all(vp), [](pint x, pint y){return x.second < y.second;});
    int ans = 0, len = m.size();
    rep(i, len - k) {
        ans += vp[i].second;
    }
    println(ans);
    return 0;
}


Measured memory_bytes: 15476
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<bool> nb(n, true);
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            nb[a-1] = false;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(nb[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<iostream>
#include<cmath>
#define LL long long
#define N (200005)
using namespace std;
int n,tt;
LL a[N],sum[N];
LL ans=9e18,x,now; 
template <typename T> void read(T&t) {
	t=0;
	bool fl=true;
	char p=getchar();
	while (!isdigit(p)) {
		if (p=='-') fl=false;
		p=getchar();
	}
	do {
		(t*=10)+=p-48;p=getchar();
	}while (isdigit(p));
	if (!fl) t=-t;
}
int main(){
	read(n),read(x);
	for (int i=1;i<=n;i++) read(a[i]),sum[i]=sum[i-1]+a[i];
	for (int i=1;i<=n;i++){
		now=x*(i+n);
		tt=3;
		for (int j=n;j>=1;j-=i){
			if (tt==3) now+=(sum[j]-sum[max(0,j-i)])*5;
			else now+=(sum[j]-sum[max(0,j-i)])*tt;
			tt+=2;
			if (now>=ans) break; 
		}
		ans=min(ans,now);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int A = N.charAt(0) - 48;
		int B = N.charAt(1) - 48;
		int C = N.charAt(2) - 48;
		int D = N.charAt(3) - 48;
		
		for (int i = 0; i < 8; i++) {
			String bit = Integer.toBinaryString(i);
			bit = String.format("%3s", bit).replaceAll(" ", "0");
			int count = 0;
			count = bit.charAt(0) == '0' ? A - B : A + B;
			count = bit.charAt(1) == '0' ? count - C : count + C;
			count = bit.charAt(2) == '0' ? count - D : count + D;
			
			if (count == 7) {
				char op1 = bit.charAt(0) == '0' ? '-' : '+';
				char op2 = bit.charAt(1) == '0' ? '-' : '+';
				char op3 = bit.charAt(2) == '0' ? '-' : '+';
				System.out.println(A + "" +  op1 + "" + B + "" + op2 + "" + C + "" + op3 + "" + D + "=7"); 
				break;
			}
		}
	}
}

Measured memory_bytes: 23124
#!/usr/bin/python3
from collections import defaultdict

(n, m) = map(int, input().split())

paths = defaultdict(list)

for i in range(m):
    (a, b) = map(int, input().split())
    paths[a].append(b)
    paths[b].append(a)

checked = set([1])
ct = set([1])
rp = defaultdict(int)

while ct:
    nt = set()
    for r in ct:
        for nr in paths[r]:
            if nr in checked:
                continue
            rp[nr] = r
            checked.add(nr)
            nt.add(nr)
            
            
    ct = nt

print('Yes')
for i in range(2, n + 1):
    print(rp[i])


    



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

int main() {
    ll n, x;
    cin >> n;
    vector<ll> nums, left(n,0), right(n,0);
    for (ll i=0; i<n; i++) {
        cin >> x;
        nums.push_back(x);
    }
    ll res = nums[0];
    for (ll i=0; i<n; i++) {
        res = __gcd(nums[i],res);
        left[i] = res;
    }
    res = nums[n-1];
    for (ll i=n-1; i>=0; i--) {
        res = __gcd(nums[i],res);
        right[i] = res;
    }
    vector<ll> gcds;
    for (ll i=0; i<n; i++) {
        if (i==0) gcds.push_back(right[i+1]);
        else if (i==n-1) gcds.push_back(left[i-1]);
        else gcds.push_back(__gcd(left[i-1],right[i+1]));
    }
    sort(gcds.begin(),gcds.end());
    cout << gcds[n-1];
    return 0;
}

Measured memory_bytes: 7156
<?php
$N = (int)fgets(STDIN);
$total = 0;
for ($i = 0; $i < $N; $i++) {
    list($x, $u) = explode(' ', trim(fgets(STDIN)));
    if ($u == 'BTC') {
        $total += 380000.0 * $x;
    } else {
        $total += $x;
    }
}

echo $total . "\n";

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;

main(){
    int size; scanf("%d",&size);
    int arr[size+1];
    int num;
    for(int i=1;i<=size;++i){
        scanf("%d",&num);
        arr[i] = num;
    }
    bool visited[size+1];
    for(int i=0;i<=size;++i) visited[i] = false;
    int actual = 1;
    bool possible = true;
    int cont = 0;
    while(possible){
        visited[actual] = true;
        cont++;
        actual = arr[actual];
        if(actual==2) break;
        if(visited[actual]) possible = false;
    }
    if(possible) printf("%d",cont);
    else printf("-1");
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char c;
    scanf("%c", &c);
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')printf("vowel\n");
    else printf("consonant\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;
const int MAX = 100;

int bubbleSort(int A[], int n)
{
    int num{0};
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = n - 1; j > i; j--)
        {
            if (A[j] < A[j - 1])
            {
                swap(A[j], A[j - 1]);
                num++;
            }
        }
    }
    return num;
}

void trace(int A[], int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        printf("%d ", A[i]);
    }
    printf("%d", A[n - 1]);
}

int main()
{
    int n;
    int A[MAX];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    int ans = bubbleSort(A, n);
    trace(A, n);
    printf("\n%d\n", ans);
    return 0;
}


Measured memory_bytes: 2760
#include <iostream>
using namespace std;
#include <vector>
int main(){
	int X,N;
	cin >> X >> N;
	int p[101] = {};
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        p[a] = -1;
    }
	int l = X, r = X;
  	for(int i = 0; i < N; i++){
   	 	if(p[l] == -1)
          l--;
     	if(p[r] == -1)
          r++;
  	}
  if(X-l <= r-X){
   cout << l << endl;
  }else{
   	cout << r << endl; 
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int po(int x){
  if(x==1)return 2;
  if(x==2)return 4;
  if(x==3)return 8;
  if(x==4)return 16;
  else return 32;
}

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,m;cin>>n>>m;
  int ans=(1900*m+100*(n-m))*po(m);
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a > b)
    ans = a * 2 - 1;
  else if (b > a)
    ans = b * 2 - 1;
  else
    ans = a + b;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
const int MAXN = 2e5+3;
ll A[MAXN],N;
ll dp[MAXN][3];
ll dfs(int now, int left){
	if(left < 0 || now >= N) return -1e18;
	if(now+left >= N) return -1e18;
	if(now+left == N-1) return dp[now][left] = A[now]; 
	if(dp[now][left] != -1) return dp[now][left];
	return dp[now][left] = max(dfs(now+2,left),max(dfs(now+3,left-1),dfs(now+4,left-2)))+A[now];
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	memset(dp,-1,sizeof(dp));
	if(N&1){
		ll ans = max(dfs(0,2),max(dfs(1,1),dfs(2,0)));
		cout << ans << '\n';
	}
	else{
		ll ans = max(dfs(0,1),dfs(1,0));
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 19272
import java.util.Scanner;

import java.util.Scanner;

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

		int n = scan.nextInt();
	
		int a[];
		a = new int[n];
		
		for(int i = 0;i < n;i++){
			a[i] = scan.nextInt();
		}
		
		for(int i = n-1;i >= 0;i--){
			System.out.print(a[i]);
			if(i!=0){
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 26396
#include <bits/stdc++.h>
#define L long long

using namespace std;

L h,w,d;
L a[1555][1555];

char ct[]={'R','G','B','Y'};

L ok(L x,L y){
	return 1<=x&&x<=h&&1<=y&&y<=w;
}



int main()
{
	scanf("%lld %lld %lld",&h,&w,&d);
	L i,j,k,l;
	if(d%2)
	{
		for(i=1;i<=h;i++)
		{
			for(j=1;j<=w;j++)
			{
				printf("%c",(i+j)%2?'R':'B');
			}
			puts("");
		}
		return 0;
	}
	L hf=d/2,det;
	for(i=1;(i-2)*hf+1<=h;i++)
	{
		for(j=0;(j-1)*hf+1<=w;j++)
		{
			L x=j;
			if(i%4>=2) x+=2;
			
			if((i+j)%2) continue;
			if(i%2==1&&x%4==1) det=1;
			else if(i%2==0&&x%4==2) det=2;
			else if(x%4==3) det=3;
			else det=4;
			for(k=0;k<hf;k++)
			{
				for(l=(j-1)*hf+1+k;l<=(j-1)*hf+d-k;l++)
				{
					if(ok((i-1)*hf+1-k,l))
						a[(i-1)*hf+1-k][l]=det;
					if(ok((i-1)*hf+1+k,l))
						a[(i-1)*hf+1+k][l]=det;
				}
			}
		}
	
	}
	
			
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			printf("%c",ct[a[i][j]-1]);
		}
		puts("");
	}
	
}

Measured memory_bytes: 5888
#include<stdio.h>
int main(void){
  int n,ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    int a,b;
    scanf("%d%d",&a,&b);
    ans+=(b-a)+1;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

# exit if $0 != __FILE__

n, = cin
hs = {}
"ACGT".each_char do |x1|
  "ACGT".each_char do |x2|
    "ACGT".each_char do |x3|
      hs[x1+x2+x3] = 1
    end
  end
end
hs.delete("AGC")
hs.delete("ACG")
hs.delete("GAC")

MO = 10**9+7
NG = "AGC"

(n-3).times do
  nhs = Hash.new(0)
  hs.keys.each do |k|
    "ACGT".each_char do |x|
      s = k + x
      next if s[1]+s[2]+s[3] == NG
      next if s[0]+s[1]+s[3] == NG
      next if s[0]+s[2]+s[3] == NG
      next if s[2]+s[1]+s[3] == NG
      next if s[1]+s[3]+s[2] == NG
      nhs[s.slice(1,3)] = (nhs[s.slice(1,3)] + hs[k]) % MO
    end
  end
  hs = nhs
end
p hs.values.inject {|s,x| (s+x)%MO}

Measured memory_bytes: 1788
n,m,K=map(int,input().split())
mod=998244353

U=2*10**5
mod=998244353

fact=[1]*(U+1)
fact_inv=[1]*(U+1)

for i in range(1,U+1):
    fact[i]=(fact[i-1]*i)%mod
fact_inv[U]=pow(fact[U],mod-2,mod)

for i in range(U,0,-1):
	fact_inv[i-1]=(fact_inv[i]*i)%mod

def comb(n,k):
    if k<0 or k>n:
        return 0
    x=fact[n]
    x*=fact_inv[k]
    x%=mod
    x*=fact_inv[n-k]
    x%=mod
    return x

ans=0
for k in range(K+1):
    ans=(ans+comb(n-1,k)*m*pow(m-1,n-k-1,mod)%mod)%mod
print(ans)

Measured memory_bytes: 24716
#include<stdio.h>
#include<string.h>

int saikoro[6];
/*
上：0
左：1
右：2
前：3
後：4
下：5
*/
int changeD(int opt);

int main(void){

	int i,n;
	int opt;
	int sum;
	char order[6];

	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		
		sum = 1;

		saikoro[0] = 1;
		saikoro[1] = 4;
		saikoro[2] = 3;
		saikoro[3] = 5;
		saikoro[4] = 2;
		saikoro[5] = 6;


		for(i = 0; i < n; i++){

			opt = 0;

			scanf("%s",&order);

			if(strcmp(order,"Right") == 0){
				opt = 0;
			}
			else if(strcmp(order,"Left") == 0){
				opt = 1;
			}
			else if(strcmp(order,"North") == 0){
				opt = 2;
			}
			else if(strcmp(order,"South") == 0){
				opt = 3;
			}
			else if(strcmp(order,"West") == 0){
				opt = 4;
			}
			else if(strcmp(order,"East") == 0){
				opt = 5;
			}
			
			sum += changeD(opt);

		}

		printf("%d\n",sum);
		
	}

	return 0; 

}


int changeD(int opt){

	int tmp;


	switch(opt){
		case 0:
			tmp = saikoro[3];
			saikoro[3] = saikoro[1];
			saikoro[1] = saikoro[4];
			saikoro[4] = saikoro[2];
			saikoro[2] = tmp;
			break;
		case 1:
			tmp = saikoro[3];
			saikoro[3] = saikoro[2];
			saikoro[2] = saikoro[4];
			saikoro[4] = saikoro[1];
			saikoro[1] = tmp;
			break;
		case 2:
			tmp = saikoro[0];
			saikoro[0] = saikoro[4];
			saikoro[4] = saikoro[5];
			saikoro[5] = saikoro[3];
			saikoro[3] = tmp;
			break;
		case 3:
			tmp = saikoro[0];
			saikoro[0] = saikoro[3];
			saikoro[3] = saikoro[5];
			saikoro[5] = saikoro[4];
			saikoro[4] = tmp;
			break;
		case 4:
			tmp = saikoro[0];
			saikoro[0] = saikoro[2];
			saikoro[2] = saikoro[5];
			saikoro[5] = saikoro[1];
			saikoro[1] = tmp;
			break;
		case 5:
			tmp = saikoro[0];
			saikoro[0] = saikoro[1];
			saikoro[1] = saikoro[5];
			saikoro[5] = saikoro[2];
			saikoro[2] = tmp;
			break;
	}

	return saikoro[0];

}

Measured memory_bytes: 600
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    ll int a; cin >> a;
    double b; cin >> b;
    
    // これだとなぜかACにならない
    b *= 100; // 小数点以下2桁を利用して整数にする
    b += 0.001;
    ll int bb = static_cast<ll int>(b);
    // ll int bb = b*100 + 0.001;

    ll int ans = a * bb;
    ans /= 100;
    
    cout << ans;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

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

  // vector<char> ans;

  // while (N > 0)
  // {
  //   ans.push_back('0' + (N % K));
  //   N = N / K;
  // }

  // rep(i, ans.size()) {
  //   cout << ans[ans.size() - i -1];
  // }
  // cout << endl;

  int cnt = 0;
  while (N > 0)
  {
    N = N / K;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int tikai(int a,int b){
  if(a<b)
    return 'A';
  else
    return 'B';
}
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  printf("%c",tikai(abs(a-b),abs(a-c)));
    
  return 0;
}


Measured memory_bytes: 2060
#include <stdio.h>

int main(){
    int i,N;
    int A[1000];
    double inv;
    double ans = 0.0;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    for(i=0;i<N;i++) ans += 1 / (double)A[i];
    inv = 1 / ans;
    // printf("%d\n",A[1]);
    printf("%lf\n",inv);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int Product(int c, int d){
  if(c * d % 2 == 0){
    printf("Even\n");
  }else
  {
    printf("Odd\n");
  }
}

int main(){
  int a,b;
  scanf("%d %d",&a, &b);
  Product(a,b);

  return 0;
}

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

using namespace std;

using ll = long long;
#define long long long

int main(void) {
    ll n;
    cin >> n;
    
    ll r = 0;
    for(ll i=1; i<=n; i+=2) {
        ll s = 0;
        for(ll j=1; j<=n; j++)
            s += i % j == 0;
        if(s == 8) r++;
    }
    cout << r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
void sb(long long int*x,long long int*y)
{
    long long int t;
    if(*x-*y>0){
        t=*x;
        *x=*y;
        *y=t;
    }
}

long long int st(long long int H,long long int W)
{
	long long int ans1=W*H,ans2=W*H,ans3=W*H,i=1,s,t;
	long long int a,b,c;
	for(i=1;(ans1-ans2>=0)&&i<=H;i++){
		ans1=ans2;
		a=i*W;
		b=(H-i)*(W/2);
		c=W*H-a-b;
		sb(&a,&c);
		sb(&b,&c);
		sb(&a,&b);
		ans2=c-a;
		//printf("ans2 %lld\n",ans2);
	}
	ans2=ans1;
	ans1=W*H;
	for(i=1;(ans1-ans3>=0)&&i<=H;i++){
		ans1=ans3;
		a=i*W;
		b=W*((H-i)/2);
		c=W*H-a-b;
		sb(&a,&c);
		sb(&b,&c);
		sb(&a,&b);
		ans3=c-a;
		//printf("ans3 %lld\n",ans3);
	}
	ans3=ans1;
	sb(&ans2,&ans3);
	return ans2;
}	

int main()
{
	long long int H,W,A1,A2;
	scanf("%lld %lld",&H,&W);
	A1=st(H,W);
	A2=st(W,H);
	sb(&A1,&A2);
	printf("%lld",A1);
	return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int N;
  cin >> N;
  int counnnt=0;
  for(int i=1;i<=N;i+=2){
    int count=0;
    for(int j=1;j<=i;j+=2){
      if(i%j==0) count++;
    }
    if(count==8) counnnt++;
  }
  cout << counnnt;
  return 0;
}


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

int main(){
    ll x; cin >>x;
    if(1<=x%11&&x%11<=6)cout << (x/11)*2+1 <<endl;
    else cout <<((x-1)/11)*2+2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli,lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ff  first
#define ss  second
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int t;cin>>t;while(t--)
#define clean(x) memset(x,0,sizeof(x))
#define FOR(x,y) for(int i=x;i<=y;i++)
const lli maxn = 2e5+9;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli lcm(lli a,lli b){lli ans=(a*b)/(__gcd(a,b));return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}

string X="IF THE CONSTRAINTS ARE LOW JUST BRUTE FORCE IT!!!!!!!!!!!!!!!!!!!!!";
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///

vector<string>a;
void solve()
{
    string b;cin>>b;
    int n=b.size();
    string c="";
    for(int i=0;i<n;i++)
    {
        if(b[i]==',')
        {
            a.pb(c);c="";
        }
        else c+=b[i];
    }
    if(c.size()!=0)a.pb(c);
    for(auto i:a)cout<<i<<" ";
    cout<<endl;
}
int main()
{
    solve();
}


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

int main() {
    long long int w,h,s;
    cin>>w>>h;

    if(w==1 || h==1){
        s=1;
    }
    else if(w%2==1 && h%2==1){
        s=w*h/2 + 1;
    }
    else{
        s=w*h/2;
    }
        cout<<s<<endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

#define fs first
#define sc second

int main() {
    int N, Q;
    cin >> N >> Q;
    ll d[N];
    for(int i = 0; i < N; i++) cin >> d[i];

    vector<ll> ans;

    for(int q = 0; q < Q; q++) {
        ll n, x, m;
        cin >> n >> x >> m;

        // <の数を数えたい
        // <の数 = n - 1 - (=の数) - (>の数)
        vector<ll> dm(N, 0);
        for(int i = 0; i < N; i++) {
            dm[i] = d[i] % m;
        }

        ll cnt_eq = 0;
        ll tmp = 0;
        for(int i = 0; i < N; i++) {
            if(dm[i] == 0) tmp++;
        }
        cnt_eq += (n - 1) / N * tmp;
        for(int i = 0; i < (n - 1) % N; i++) {
            if(dm[i] == 0) cnt_eq++;
        }

        ll cnt_left = 0;
        ll dn = x % m;
        tmp = 0;
        for(int i = 0; i < N; i++) {
            tmp += dm[i];
        }
        dn += (n - 1) / N * tmp;
        for(int i = 0; i < (n - 1) % N; i++) {
            dn += dm[i];
        }
        cnt_left = dn / m;

        //cout << cnt_eq << endl;
        //cout << cnt_left << endl;

        ans.push_back(n - 1 - cnt_eq - cnt_left);
    }

    for(ll val : ans) {
        cout << val << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
# define ll  long long int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	int n;
	ll d;
	cin >> n >> d;
	vector<pair<ll,ll>> arr;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		ll x,y;
		cin >> x >> y;
		if(x*x + y*y <= d*d)
			cnt++;
	}
	cout << cnt << "\n";
}

int  main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
    #endif
     IOS
     int t = 1;
     //cin >> t;
     while(t--){
     	solve();
     }
     return 0;
}

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

int main() {
    int H, W, A, B;
    cin>>H>>W>>B>>A;
    if((H/2 < A) || (W/2 < B)) {
        cout<<"No"<<endl;
    }
    else {
        for(int i=0;i<H;++i){
            for(int j=0;j<W;++j){
                if ((i<=A-1 & j<=B-1) || (i>A-1 & j>B-1)) {
                    cout<<1;
                    //ans[i][j] = 1;
                }
                else{
                    cout<<0;
                    //ans[i][j] = 0;
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1280
#N

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

S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+a[i]


#dp[i][j]は[i,j)の範囲で全てをマージする最小コスト
inf=10**15
dp=[[inf]*(N+1) for _ in range(N+1)]

#区間[i,j)を[i,k)+[k,j)に分けて考える
for d in range(1,N+1):#dはj-i
    for i in range(N+1):
        j=i+d
        if j>N:
            break
        if d==1:
            dp[i][j]=0
        else:
            for k in range(i,j):
                dp[i][j]=min(dp[i][j] , dp[i][k]+dp[k][j]+S[j]-S[i])
            
print(dp[0][-1])
            



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

using namespace std;

int p, q, r, res = 0, pt;
string str;

int solve_rec()
{
	if( str[pt] == '0' )
		return 0;
	else if( str[pt] == '1' )
		return 1;
	else if( str[pt] == '2' )
		return 2;
	else if( str[pt] == 'P' )
		return p;
	else if( str[pt] == 'Q' )
		return q;
	else if( str[pt] == 'R' )
		return r;
	else if( str[pt] == '-')
	{
		pt++;
		int a = solve_rec();
		return 2-a;
	}
	else if( str[pt] == '(')
	{
		pt++;
		int a = solve_rec();
		pt++;
		char op = str[pt];
		pt++;
		int b = solve_rec();
		pt++;

		if( op == '*' )
			return min(a, b);
		else if( op == '+' )
			return max(a, b);
	}
	else
	{
		pt++;
	}
}


void solve()
{
	for( p = 0; p <= 2; p++ )
		for( q = 0; q <= 2; q++ )
			for( r = 0; r <= 2; r++ )
			{
				pt = 0;
				
				if( solve_rec() == 2 )
					res++;
			}

	return;
}

int main()
{
	while(cin >> str, str[0] != '.')
	{
		res = 0;
		solve();
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
      	int a = int.Parse(Console.ReadLine());
		for(int i=1; i<=9; i++)
		{
			if(a%i == 0 && a/i >= 1 && a/i <= 9)
			{
				Console.WriteLine("Yes");
				return;
			}
		}
      	Console.WriteLine("No");
    }
}


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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  bool hantei=false;
  if(abs(a-b)<=d){
    if(abs(b-c)<=d){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(abs(a-c)<=d){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

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

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

  int v[32] = {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};
  cout << v[k-1] << endl;
  return 0;
}

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

using namespace std;
using namespace atcoder;

using lint = long long;
#define rep(i, n) for(lint i = 0; i < lint(n); i++)
#define repu(i, a, b, s) for(lint i = lint(a); i < lint(b); i += lint(s))
#define repd(i, a, b, s) for(lint i = lint(a); i > lint(b); i += lint(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {

    lint T;
    cin >> T;

    rep(i, T) {
        lint N, M, A, B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N, M, A, B) << endl;
    }
}

int main(int argc, char *argv[]) {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
#define pb insert
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
typedef std::pair<int, int> pr;
std::set<int> s[2][maxn];
std::set<std::pair<int, int>> set;
int fa[maxn];
int n, x, y;
inline void ins(int x,int y,int id) {
	if(x != y) {
		s[id][x].emplace(y), s[id][y].emplace(x);
		if(s[!id][x].count(y)) set.emplace(std::min(x, y), std::max(x, y));
	}
}
inline void del(int x,int y,int id) {
	s[id][x].erase(y), s[id][y].erase(x);
	if(s[!id][x].count(y)) set.erase(pr(std::min(x, y), std::max(x, y)));
}
inline int find(int x) {
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 1, n - 1) cin >> x >> y, ins(x, y, 0);
	rep(i, 1, n - 1) cin >> x >> y, ins(x, y, 1);
	int ans = 0;
	for(;set.size();) {
		pr p = * set.begin(); set.erase(set.begin()); ++ ans;
		int x = p.first, y = p.second;
		if(s[0][x].size() + s[1][x].size() < s[0][y].size() + s[1][y].size()) 
			std::swap(x, y);
		std::vector<int> v0(s[0][y].begin(), s[0][y].end()), v1(s[1][y].begin(), s[1][y].end());
		for(int i : v0) del(y, i, 0), ins(x, i, 0);
		for(int i : v1) del(y, i, 1), ins(x, i, 1);
		fa[y] = x;
	}
	cout << (ans == n - 1 ? "YES" : "NO") << '\n';
}


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

int main() {
    int N;
    cin >> N;
    double x = 0;
    for(int i=0; i < N; i++){
         double a;
        cin >> a;
        x += 1/a;
    }
    cout << fixed << setprecision(10) << 1/x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is #" << (x) <<"#" <<endl
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 1e5+5;
const ll inf = 1e18+7;

ll n,k,h[MAX];
ll dp[MAX];

ll DP(ll caso){
  if(caso==1) return 0;
  ll &ans = dp[caso];
  if(ans!=inf) return ans;
  f(i,caso-k,caso){
    if(i<=0) continue;
    ans = min(ans,DP(i)+abs(h[caso]-h[i]));
  }
  return ans;
}


int main() {
  fastio;
  k=2;
  cin>>n;
  f(i,0,n+5) dp[i]=inf;
  f(i,1,n+1) cin>>h[i];
  cout<<DP(n)<<"\n";
  return 0; 
}

Measured memory_bytes: 7520
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(void){
    char divide[4][8] = {"dream\0","dreamer\0","erase\0","eraser\0"};
    int divide_S[4] = {5,7,5,6};
    char S[100001]; 
    int S_size;
    scanf("%s",&S);
    S_size = strlen(S);
    // printf("%d\n",S_size);
    
    int i = 0;
    int flag1 = 1, flag2 = 1;
    while(flag1 == 1){
 
        for(i = 0;i < 4;i++){
            // printf("%s",&divide[i][0]);
            // printf("\n%s",&S[S_size - divide_S[i]]);
            // printf("\n%d",strcmp(&S[S_size - divide_S[i]],&divide[i][0]));
            flag2 = 0;
            if(S_size >= divide_S[i] && strcmp(&S[S_size - divide_S[i]],&divide[i][0]) == 0){
                S[S_size - divide_S[i]] = '\0';
                S_size = strlen(S);
                flag2 = 1;
                break;    
                }   
            
            }
 
        if(S_size == 0){
            printf("YES\n");
            return 0;
        }
 
        if(i == 4 && flag2 == 0){
                flag1 = 0;    
            }
    }
    printf("NO\n");
 
    return 0;
}

Measured memory_bytes: 256
n = int(input())
N = 10 ** 4

l = [0 for _ in range(N + 1)]

for i in range(1, 42):
    for k in range(1, 99):
        for j in range(i, k+1):
            s = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if s > N:
                continue
            d = len(set([i, j, k]))
            if d == 3:
                l[s] += 6
            elif d == 2:
                l[s] += 3
            elif d == 1:
                l[s] += 1

for i in range(1, n+1):
    print(l[i])

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

int main() {
	const ll INF = 1e18;
	const int Size = 1e5 + 10;
	ll N, W;
	cin >> N >> W;
	vector<ll> w(N + 1);
	vector<ll> v(N + 1);
	for (int i = 1; i <= N; ++i) {
		cin >> w[i] >> v[i];
	}

	vector<vector<ll>> dp(N + 1, vector<ll>(Size, INF));
	dp[0][0] = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j < Size; ++j) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			if (j <= v[i]) {
				dp[i][j] = min(dp[i][j], w[i]);
			} else if (dp[i - 1][j - v[i]] != INF) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}
	}

	int res = 0;
	for (int i = 0; i < Size; ++i) {
		if (dp[N][i] <= W) {
			res = max(res, i);
		}
	}

	cout << res << endl;

	return 0;
}


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

int main(){
    int N, Y, first = -1, middle = -1, last = -1;
    cin >> N >> Y;
    for(int i = 0; i <= N; i++){
        for(int j = 0; i + j <= N; j++){
            int k = N - i - j;
            if(10000 * i + 5000 * j + 1000 * k == Y){
                first = i;
                middle = j;
                last = k;
            }
        }
    }
    cout << first << " " << middle << " " << last << endl;
}

Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        k: usize,
        s: String
    }
    if s.len() <= k {
        println!("{}", s);
    } else {
        println!("{}...", &s[0..k]);
    }
}
/* vim:set foldmethod=marker: */


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

int main() {
	int n;
	cin >> n;
	int x = n;
	int sn = 0;
	while (x > 0) {
		sn += x % 10;
		x /= 10;
	}
	if (n % sn == 0)cout << "Yes" << endl;
	else cout << "No" << 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 int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int sa[100005], sb[100005], ta[100005], tb[100005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	int q;
	cin >> s >> t >> q;
	int n = s.size();
	int m = t.size();
	rep(i,n){
		sa[i+1] = sa[i] + (s[i] == 'A');
		sb[i+1] = sb[i] + (s[i] == 'B');
	}
	rep(j,m){
		ta[j+1] = ta[j] + (t[j] == 'A');
		tb[j+1] = tb[j] + (t[j] == 'B');
	}
	rep(qi,q){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int A = (sa[b] - sa[a-1]) % 3;
		int B = (sb[b] - sb[a-1]) % 3;
		int C = (ta[d] - ta[c-1]) % 3;
		int D = (tb[d] - tb[c-1]) % 3;
		bool ok = false;
		rep(i,3){
			int AA = (A + i) % 3;
			int BB = (B + i) % 3;
			if(AA == C && BB == D){
				ok = true;
				break;
			}
		}
		if(ok) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 5280