akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	int N;
	cin >> N;
	ll k = 1,an = 0;
	while (an < N) {
		an += k;
		k++;
	}
	
		rep(i, k-1) {
			if ((an - N) != i + 1) {
				cout << i + 1 << endl;
			}
		}
	}




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

int main()
{
    int X;
    int value=1,ma=0;
    cin >> X;
    if(X <= 3){
        cout << 1 << endl;
        return 0;
    }else{
        for(int i=2; i<=31; i++){
            int j = 2;
            while(pow(i,j) <= X){
                value = pow(i,j);
                j++;
            }
            ma = max(ma,value);
        }
    }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	int arr[9] = {111,222,333,444,555,666,777,888,999};
	int n;
	int cnt , ans;
	cin >> n;
	for(int i = 0 ; i <= 8 ; i++)
	{
		if(arr[i] >= n)
		{
			cout << arr[i] << endl;
			break;
		}
	}
	return 0;
	}

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

int main() {
  double a, b, avr1;
  int flg=0;
  string msg1 =": under 0 <error>";
  string msg2 =": over 100 <error>";
  cin >> a >> b;
  if( a < 0 ){ 
  	cout << "A" + msg1  << endl;
    flg=1;
  }
  else if( a > 100 ){ 
  	cout << "A" + msg2 << endl;
    flg=1;
  }
  if( b < 0 ){
  	cout <<  "B" + msg1  << endl;
    flg=1;
  }
  else if( b > 100){
  	cout <<  "B" + msg2  << endl;
    flg=1;
  }
  if(flg) return 1;
  avr1 = (a+b)/2;
  cout << round(avr1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstring>
#include <stdio.h>

using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

struct point{
	double x,y,z,r;
	point(double _x, double _y, double _z, double _r):x(_x),y(_y),z(_z),r(_r){};
	point():x(0.0),y(0.0),z(0.0),r(0.0){};
};

inline point add(point &p1, point &p2){
	return point(p1.x+p2.x, p1.y+p2.y, p1.z+p2.z, 0.0);
}
inline point sub(point &p1, point &p2){
	return point(p1.x-p2.x, p1.y-p2.y, p1.z-p2.z, 0.0);
}
inline double dot(point &p1, point &p2){
	return p1.x*p2.x+p1.y*p2.y+p1.z*p2.z;
}
inline point mult(point &p, double k){
	return point(p.x*k,p.y*k,p.z*k,0.0);
}
inline double dist(point &p1, point &p2){
	return sqrt(pow(p1.x-p2.x, 2.0)+pow(p1.y-p2.y, 2.0)+pow(p1.z-p2.z, 2.0));
}

point lp[2222];
point ls[22];
int iss[2222];
double lum[22];

bool intersect(point &a, point &b, point &c){
	if(dist(a,c)<c.r-EPS&&dist(b,c)<c.r-EPS)return false;
	if((dist(a,c)-c.r)*(dist(b,c)-c.r)<-EPS)return true;
	point ab=sub(a,b);
	point ac=sub(a,c);
	double t=dot(ab,ac)/dot(ab,ab);
	if(EPS<t && t<1.0-EPS){
		point R=mult(ab, -t);
		point Q=add(a,R);
		if(dist(Q,c)<c.r-EPS)return true;
		else return false;
	}else return false;
}

int main(){
	int n,m,r;
	while(cin>>n>>m>>r, n){
		double ans=0.0;
		point e;
		memset(iss,0,sizeof(iss));
		REP(i,n)scanf("%lf%lf%lf%lf",&lp[i].x,&lp[i].y,&lp[i].z,&lp[i].r);
		REP(i,m)scanf("%lf%lf%lf%lf",&ls[i].x,&ls[i].y,&ls[i].z,&ls[i].r);
		scanf("%lf%lf%lf",&e.x,&e.y,&e.z);
		REP(i,m)lum[i]=ls[i].r/pow(dist(ls[i],e),2.0);
		REP(i,n)REP(j,m)if(intersect(ls[j], e, lp[i]))iss[i]|=1<<j;
		REP(i,1<<m){
			int cost=0;
			double lu=0;
			REP(j,n)if(iss[j]&i)cost++;
			if(cost>r)continue;
			REP(j,m)if(i&(1<<j))lu+=lum[j];
			ans=max(ans,lu);
		}
		printf("%.5f\n", ans);
	}
}

Measured memory_bytes: 1364
S = input()
k = 'keyence'

flag = 0
for i in range(len(k)+1):
    if S[0:i] == k[0:i] and S[len(S)-len(k)+i:] == k[i:]:
        flag = 1
        break
if flag:
    print('YES')
else:
    print('NO')

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

int main() {
  int n;
  cin >> n;
  int a=n%1000;
  int b=n/10;
  int c=a%111;
  int d=b%111;
  
  if(c==0||d==0){
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  string s;
  cin >> s;
  int ans=0;
  f(i,s.length())
  {
      ans+=((s[i]-'0')%10);
  }
  if(ans%9==0)
    cout << "Yes\n";
  else
    cout << "No\n";
  return;
} 

signed main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3740
#include<stdio.h>
#define MAX 250

int main(){
  int n, i;
  int a[MAX+1];
  
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ){
    scanf("%d", &a[i]);
  }
  for ( i = 1; i <= n; i++ ) {
    printf("node %d: key = %d, ", i, a[i]);
    if ( i / 2 >= 1 )printf("parent key = %d, ", a[i/2]);
    if ((i*2) <= n ) printf("left key = %d, ", a[i*2]);
    if ((i*2)+1 <= n ) printf("right key = %d, ", a[(i*2)+1]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>
int puzzle[9][9];
char error[9][9];
void solve() {
	int i, j, k;
	for(i = 0; i < 9; ++ i) {
		for(j = 0; j < 9; ++ j) {
			scanf("%d", &puzzle[i][j]);
			error[i][j] = ' ';
		}
	}
	for(i = 0; i < 9; ++ i) {
		for(j = 0; j < 9; ++ j) {
			for(k = 0; k < 9; k ++) {
				if(k != i && puzzle[k][j] == puzzle[i][j]) {
					error[k][j] = '*';
					error[i][j] = '*';
				}
				if(k != j && puzzle[i][k] == puzzle[i][j]) {
					error[i][k] = '*';
					error[i][j] = '*';
				}
				if(k != i % 3 * 3 + j % 3 && puzzle[i / 3 * 3 + k / 3][j / 3 * 3 + k % 3] == puzzle[i][j]) {
					error[i / 3 * 3 + k / 3][j / 3 * 3 + k % 3] = '*';
					error[i][j] = '*';
				}
			}
		}
	}
}
int main() {
	int N, I, i, j;
	scanf("%d", &N);
	solve();
	for(i = 0; i < 9; ++ i) {
		for(j = 0; j < 9; ++ j) printf("%c%d", error[i][j], puzzle[i][j]);
		printf("\n");
	}
	for(I = 1; I < N; ++ I) {
		solve();
		printf("\n");
		for(i = 0; i < 9; ++ i) {
			for(j = 0; j < 9; ++ j) printf("%c%d", error[i][j], puzzle[i][j]);
			printf("\n");
		}
	}
	return 0;
}

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

int main(void)
{
  int n;
  cin >> n;
  vector<int> h(n);
  int maxv = 0;
  for(int i = 0; i < n; i++)
  {
    cin >> h[i];
    maxv = max(h[i], maxv);
    if(i > 0)
    {
      if(maxv > h[i] + 1)
      {
        cout << "No" << endl;
        return (0);
      }
    }
  }
  cout << "Yes" << endl;
}

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

using namespace std;

int n, m, k;
queue <pair <int, int> > q;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char a[801][801];
int d[801][801];
int sti, stj;

bool check (int x, int y) {
	if (x < 1 || x > n) return 0;
	if (y < 1 || y > m) return 0;
	if (a[x][y] != '.') return 0;
	return 1;
}

int get (int x) {
	return (x - 1) / k + 1;      
}

int main () {
	cin >> n >> m >> k;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			cin >> a[i][j];
			d[i][j] = 1e9 + 7;
			if (a[i][j] == 'S') {
				sti = i;
				stj = j;
			}	
		}
	}
	d[sti][stj] = 0;
	q.push (make_pair (sti, stj));
	while (q.size ()) {
		int x = q.front ().first;
		int y = q.front ().second;
		q.pop ();
		for (int i = 0;i < 4;i ++) {
			int tox = x + dx[i];
			int toy = y + dy[i];
			if (!check (tox, toy)) continue;
			if (d[x][y] + 1 < d[tox][toy]) {
				q.push (make_pair (tox, toy));
				d[tox][toy] = d[x][y] + 1;
			}
		}
	}
	int ans = 1e9 + 7;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
		//	cout << d[i][j] << ' ';
			if (d[i][j] > k) continue;
			int cur = min ({m - j, j - 1, n - i, i - 1});
			if (cur == 0) {
				cout << 1;
				return 0;
			}
			ans = min (ans, get (cur));
		}
		//cout << endl;
	}
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 3328
S = input()[::-1]
l = len(S)
dp = [[0]*2 for _ in range(l+1)]
dp[1][0]=dp[0][0]+int(S[0])
dp[1][1]=dp[0][1]+10-int(S[0])
for i in range(1,l):
  dp[i+1][0]=min(dp[i][0]+int(S[i]),dp[i][1]+int(S[i])+1)
  dp[i+1][1]=min(dp[i][0]+10-int(S[i]),dp[i][1]+10-int(S[i])-1)
  
print(min(dp[-1][0],dp[-1][1]+1))

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

int main(){
  // input
  ll n, m;
  cin >> n >> m;

  // distribute each prefecture
  vector<vector<ll>> r(100010);
  vector<ll> p(m), y(m);
  rep(i, 0, m){
    cin >> p[i] >> y[i];
    r[p[i]].push_back(y[i]);
  }
  
  // in prefecture, x set
  map<ll, bool> seen;
  vector<map<ll, ll>> o(100010); // o[prefecture][year] 
  for(auto t : p){
    if(seen[t]) continue;
    seen[t] = true;
    sort(r[t].begin(), r[t].end());
    rep(i, 0, r[t].size()){
        o[t][r[t][i]] = i + 1;  
    }
  }

  rep(i, 0, m){
    string s = to_string(p[i]);
    // front id
    ll lm = s.size();
    rep(j, 0, 6-lm){
        s = "0" + s;
    }
    // back id
    ll ty = o[p[i]][y[i]];
    string ss = to_string(ty);
    lm = ss.size();
    rep(j, 0, 6-lm){
        ss = "0" + ss;
    }
    cout << s + ss << endl;
  }

  return 0;
}


Measured memory_bytes: 27352
program exam
  implicit none

  integer(8) :: n, i, div, ans
  integer(8), allocatable :: a(:), b(:), d(:)

  read(*,*) n
  allocate(a(n))
  allocate(b(n))
  allocate(d(n))

  read(*,*) a
  read(*,*) b

  
  do i = 1, n
     d(i) = b(i) - a(i)
  end do

  if(sum(d) > 0) then
     ans = -1
  else
     ans = 0
     div = 0
     do i = 1, n
        if(d(i) > 0) then
           ans = ans + 1
           div = div + d(i)
        end if
     end do

     call heapsort(d)

     do i = 1, n
        if (div <= 0) then
           exit
        else
           div = div + d(i)
           ans = ans + 1
        end if

     end do
        
  end if
  
  write(*,*) ans

  deallocate(a, b, d)

  stop

contains
  subroutine heapsort(array)
  implicit none
  integer(8), intent(inout) :: array(:)
  
  integer(8) :: i,k,j,l
  double precision :: t
  
  if(n <= 0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n == 1)return

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j <= k)
        if(j < k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo

  return
end subroutine heapsort
  
end program exam

           
        


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 100000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, m, k, i, j;
    int s, w;
    cin >> s >> w;

    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


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

#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 INF 1000000000000
using ll = long long;


int main(){
  ll l,r;
  cin >> l >> r;
  int ans = 100000;
  //lとrの間に2019の倍数があるか否か
  if((l-1)/2019+1<=r/2019)cout<<0<<endl;
  else{
    int len = r-l+1;
    vector<ll> mod(len);
    rep(i,len) mod.at(i) = (l+i)%2019;
    rep(i,len){
      for(int j = i+1; j < len; j++){
        int tmp = (mod.at(i)*mod.at(j))%2019;
        ans = min(ans,tmp);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
macro_rules! get {
    ($x:expr) => ($x.next().unwrap().parse().unwrap());
}
fn main() {
    use std::io::{Read, stdout, BufWriter, Write};
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let mut sieve : [bool; 100001] = [true; 100001];
    sieve[0] = false;
    sieve[1] = false;
    for i in 2..100001 {
        if !sieve[i] {
            continue;
        }
        for j in 2..100001 {
            if j*i>100000 {
                break;
            }
            sieve[j*i] = false;
        }
    }
    let mut like2017 : [bool; 100001] = [false; 100001];
    for i in 2..100001 {
        if i%2==1&&sieve[i]&&sieve[(i+1)/2] {
            like2017[i]=true;
        }
    }
    let mut imos : [u32; 100001] = [0; 100001];
    for i in 1..100001 {
        if like2017[i] {
            imos[i] = imos[i-1]+1;
        } else {
            imos[i] = imos[i-1];
        }
    }

    let q : u32 = get!(iter);
    for _i in 0..q {
        let l : usize = get!(iter);
        let r : usize = get!(iter);
        writeln!(out, "{}", imos[r]-imos[l-1]).unwrap();
    }
}


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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const int mod = 1e9 + 7;
const int INF = 1e9;

signed main() {
    int n, y;
    cin >> n >> y;
    vector<int> ans;

    REP(i,0, 2001)REP(j,0, 2001){
        int it = i * 1000;
        int jt = j * 5000;
        if(it + jt + (n - i - j) * 10000 == y && n - i - j >= 0) {
            cout << n - i - j << " " << j << " " << i << endl;
            return 0;
        }
    }

    cout << "-1 -1 -1" << endl;

	return 0;
}


Measured memory_bytes: 256
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int a, b;
	cin >> a >> b;
	int le = 0, re = 1, ans = 0;
	for (int i = 2; i <= 999; i++)
	{
		le = re;
		re += i;
		if (le - a == re - b)
			ans = le - a;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
acgt_tmp = 0
acgt_max = 0

for s in S+'$':
  if s in ['A','C','G','T']:
    acgt_tmp += 1
  else:
    if acgt_tmp>acgt_max:
      acgt_max = acgt_tmp
    acgt_tmp = 0

print(acgt_max)

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

int n;

struct Node {
    Node *p, *l, *r;
    int v;
};

Node *root;

void preorder(Node *nd) {
    if (nd == nullptr) return ;
    cout << " "  << nd->v ;
    preorder(nd->l);
    preorder(nd->r);
}

void inorder(Node *nd) {
    if (nd == nullptr) return ;
    inorder(nd->l);
    cout << " "  << nd->v ;
    inorder(nd->r);
}

void print() {
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}

void insert(int k) {
    Node *z = root;
    Node *y = nullptr;

    while (z != nullptr) {
        if (k <= z->v) {
            y = z;
            z = z->l;
        } else {
            y = z;
            z = z->r;
        }
    }
    if (y == nullptr) {
        root = new Node;
        root->p = root->l = root->r = nullptr;
        root->v = k;
        return;
    }
    z = new Node;
    if (k <= y->v) {
        y->l = z;
    } else{
        y->r = z;
    }
    z->p = y;
    z->l = z->r = nullptr;
    z->v = k;
    return;
}


int main() {
    cin >> n;
    int k; string cmd;
    for (int i = 0; i < n; ++i) {
        cin >> cmd ;
        if (cmd == "insert") {
            cin >> k;
            insert(k); }
        else {
            print();
        }
    }
    return 0;
}



Measured memory_bytes: 26552
#include <iostream>
#include <queue>
#define inf 1000000000

using namespace std;

int H, W, K;
char map[805][805];
int sx, sy;
int dist[805][805];
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

int bfs()
{
	for(int x = 0; x < W; x++){
		for(int y = 0; y < H; y++){
			dist[x][y] = inf;
		}
	}
	dist[sx][sy] = 0;
	
	int ret = inf, d;
	queue<int> Q;
	Q.push(sx*1000+sy);
	int x, y, nx, ny;
	while(Q.size()){
		x = Q.front() / 1000;
		y = Q.front() % 1000;
		Q.pop();
		d = min(x, y);
		d = min(d, W-x-1);
		d = min(d, H-y-1);
		ret = min(ret, d);
		if(dist[x][y] == K) continue;
		for(int d = 0; d < 4; d++){
			nx = x + dx[d], ny = y + dy[d];
			if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if(map[nx][ny] == '#') continue;
			if(dist[nx][ny] != inf) continue;
			Q.push(nx*1000+ny);
			dist[nx][ny] = dist[x][y] + 1;
		}
	}
	return ret;
}

int main(void)
{
	cin >> H >> W >> K;
	for(int y = 0; y < H; y++){
		for(int x = 0; x < W; x++){
			cin >> map[x][y];
			if(map[x][y] == 'S'){
				sx = x, sy = y;
				map[x][y] = '.';
			}
		}
	}
	
	int ans = bfs();
	cout << (ans+K-1) / K + 1<< endl;
	return 0;
}

Measured memory_bytes: 3456
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0609?year=2015

#include <bits/stdc++.h>

using namespace std;

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

    //tgt[x]:x回目のターゲット
    int tgt[110];
    for (int i = 0; i < m; ++i) {
        cin >> tgt[i];
    }

    //frd[x][y]:x回目の友達yの回答
    int frd[110][110];
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> frd[i][j];
        }
    }

    //ans[x]:友達x得点
    int ans[110];
    for (int i = 0; i < m; i++) {
        int loser = 0;
        for (int j = 0; j < n; j++) {
            if (frd[i][j] == tgt[i]) {
                ans[j]++;
            } else loser++;
        }
        ans[tgt[i] - 1] += loser;
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int main()
{
 int A, B, C;
 cin >> A >> B >> C;
 if(A == 5 && B == 5 && C == 7){
  cout << " YES " << endl;
}
else if (A == 7 && B == 5 && C == 5){
    cout << " YES " << endl;
}
else if (A == 5 && B == 7 && C == 5){
    cout << " YES " << endl;
}
else {
    cout << " NO " ;
}




    return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll n, m, ans;
string s;
int main(){
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'){
			n++;
			ans += s.size() - 1 - i;
		}
	}
	cout << ans - n*(n-1)/2 << endl;
	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

int N,K;
int D[10];

int check(int n){
  while(n){
    int rem = n % 10;
    REP(i,K) if(rem == D[i]) return false;
    n /= 10;
  }
  return true;
}

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

  cin >> N >> K;
  REP(i,K) cin >> D[i];
  int ans = N;
  while(true){
    if(check(ans)){
        cout << ans << endl;
        return 0;
    }
    ++ans;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 100001
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; }//1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; }//9,8,7,6
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; }//a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); }//aaa,aab
//temmie_のsnippet

int main() {
	char s[21];
	scanf("%s",s);
	printf("%c%c%c", s[0], s[1], s[2]);
	
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define INF -9999999

using namespace std;

int main ()
{
	int d, n, a[205], b[205], c[205], t[205], dp[205][205], ans=0;
	memset(dp, 0, sizeof(dp));
	cin>>d>>n;
	for (int i=1; i<=d; i++) cin>>t[i];
	for (int i=1; i<=n; i++) cin>>a[i]>>b[i]>>c[i];
    for (int i=1; i<=n; i++) if (t[1]<a[i] || t[1]>b[i]) dp[1][i]=INF;
    for (int i=2; i<=d; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (t[i]<a[j] || t[i]>b[j]) dp[i][j]=INF;
            else
            {
                for (int k=1; k<=n; k++)
                {
                    dp[i][j]=max(dp[i][j], dp[i-1][k]+abs(c[j]-c[k]));
                }
            }
        }
    }
    for (int i=1; i<=n; i++) ans=max(ans, dp[d][i]);
    cout<<ans<<'\n';
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

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

ll N, C;
ll ans = (ll)1e18;

void solve() {
    cin >> N >> C;
    ll D[C][C];
    ll c[N][N];
    rep(i,C) rep(j,C) cin >> D[i][j];
    rep(i,N) rep(j,N) cin >> c[i][j];
    ll cnt[3][100] = {};
    rep(i,N) rep(j,N) {
        cnt[(i+j)%3][c[i][j]-1]++;
    }
    rep(i,C) {
        rep(j,C) {
            if (i == j) continue;
            rep(k,C) {
                if (i == k || j == k) continue;
                ll sum = 0;
                rep(a,C) sum += cnt[0][a] * D[a][i] + cnt[1][a] * D[a][j] + cnt[2][a] * D[a][k];
                ans = min(ans, sum);
            }
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

//#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll ans[SIZE];
ll dp[SIZE];
vector<int> tree[SIZE];
ll mod = 1;

// {a, {b, c}} : a = gcd(p, q) = bp + cq
pair<ll,pair<ll,ll>> ext_gcd(ll p, ll q) {
  if (q == 0) return {p, {1, 0}};
  auto r = ext_gcd(q, p%q);
  return {r.first, {r.second.second, r.second.first - p/q*r.second.second}};
}



ll power(ll k, ll n, int M){
  if(n==0) return 1;
  if(n==1) return k % M;

  ll res = power(k, n/2, M);

  res = res * res % M;

  if(n % 2)
    res = k % M * res % M;

  return res;
}

void dfs(int now, int prev = -1) {
  dp[now] = 1;

  for(int to : tree[now]) {
    if (to == prev) continue;
    dfs(to, now);
    dp[now] = (dp[now] * (dp[to] + 1)) % mod;
  }
}


void dfs2(int now, int prev = -1, ll val = 0) {
  debug(val);
  ans[now] = dp[now] * (val + 1) % mod;

  int n = tree[now].size();
  ll calcL[n], calcR[n];

  for(int i=0; i<n; i++){
    int to = tree[now][i];
    if (to == prev) calcL[i] = calcR[i] = 1;
    else calcL[i] = calcR[i] = dp[to] + 1;
  }

  for(int i=0; i+1<n; i++){
    calcL[i+1] = calcL[i+1] * calcL[i] % mod;
    calcR[n-i-2] = calcR[n-i-2] * calcR[n-i-1] % mod;
  }

  for(int i=0; i<n; i++) {
    int to = tree[now][i];
    if (to == prev) continue;
    ll L = i == 0 ? 1 : calcL[i-1];
    ll R = i == n-1 ? 1 : calcR[i+1];
    dfs2(to, now, L * R % mod * (val + 1) % mod);
  }
}

int main(){
  int n, m;

  scanf("%d%d", &n, &m);
  mod = m;

  for(int i=0;i<n-1;i++){
    int x, y;
    scanf("%d%d", &x, &y);
    x--; y--;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }

  dfs(0);
  dfs2(0);

  for(int i=0;i<n;i++){
    printf("%lld\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	if(N < 10) cout << N << endl; 
	else if(N < 100) cout << 9 << endl; 
	else if(N < 1000) cout << N - 90 << endl; 
	else if(N < 10000) cout << 909 << endl; 
	else if(N < 100000) cout << N - 9090 << endl; 
	else if(N == 100000) cout << 90909 << endl;
}

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

struct team{
  int point;
  int mun;
  string name;
};

class LessAn {
public:
    bool operator()(const team& a, const team& b)
    {
      if(a.point==b.point)
        return a.mun < b.mun;
      return a.point > b.point;
    }
};




int main()
{
  bool x=false;
  int n;
  for(;cin>>n,n;)
    {
      if(x)
	cout<<endl;
      else
	x=true;
      vector<team> t;      
      for(int i=1;n--;i++)
      {
	string tt;
	int x,y,z;
	team a;
	cin>>tt>>x>>y>>z;
	a.point=x*3+z;
	a.name=tt;
	a.mun=i;
	t.push_back(a);
      }
      sort(t.begin(), t.end(),LessAn());
	for(int i=0;i<t.size();i++)
	  {
	    cout<<t[i].name<<","<<t[i].point<<endl;
	  }
    }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    ll D;
    cin >> N >> D;

    int res = 0;
    for (int i=0; i<N; ++i) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= D * D) ++res;
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][2][105];

void Main() {
    string K;
    int D;
    cin >> K >> D;
    int N = (int) K.size();
    dp[0][0][0] = 1;

    rep(i, N) {
        int x = K[i] - '0';
        rep(j, 2) {
            if (j != 0) {
                x = 9;
            }
            rep(d, D) {
                rep(k, x + 1) {
                    if (j == 0) {
                        if (k != x) {
                            dp[i + 1][1][(d + k) % D] += dp[i][0][d];
                            dp[i + 1][1][(d + k) % D] %= MOD;
                        } else {
                            dp[i + 1][0][(d + k) % D] += dp[i][0][d];
                            dp[i + 1][0][(d + k) % D] %= MOD;
                        }
                    } else {
                        dp[i + 1][1][(d + k) % D] += dp[i][1][d];
                        dp[i + 1][1][(d + k) % D] %= MOD;
                    }
                }
            }
        }
    }
    ll ans = dp[N][1][0] + dp[N][0][0] - 1;
    if (ans < 0) ans += MOD;
    cout << ans % MOD << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 18688
#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define ll long long

struct F{
  ll A, B;
  F(ll A, ll B): A(A), B(B){}
};

struct Cmp_A { bool operator()(F l, F r) const { return l.A<r.A; } };

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

  multiset<F, Cmp_A> foods;
  
  for(ll n=0; n<N; ++n){
    ll A, B;
    cin >> A >> B;
    F f(A,B);
    foods.insert(f);
  }


  vector<ll> dp(T+3001, -1);
  dp[0]=0;
  for(auto itr=foods.begin(); itr!=foods.end(); ++itr){
    ll A = itr->A;
    ll B = itr->B;

    for(ll t=dp.size()-1; t-A>=0; --t) {
      if(t-A<T && dp[t-A]!=-1 && dp[t-A]+B>dp[t]) dp[t] = dp[t-A]+B;
    }
  }
  
  ll ans = 0;
  for(ll i=dp.size()-1; i>=0; --i) { if(ans < dp[i]) ans = dp[i]; }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
require 'set'

N = gets.chomp.to_i

S = Set.new
def add(a, b)
  if (a > b)
    S << [b, a]
  else
    S << [a, b]
  end
end

if N % 2 == 0
  # Now, we make N/2 pairs.
  1.upto(N/2).each do |i|
    p = N+1-i
    # i is the pair of (N+1-i).
    # We make pair with all others.
    1.upto(N).each do |j|
      if (j != i) && (j != p)
        add(i, j)
        add(p, j)
      end
    end
  end
else # odd
  # Now, we make N/2 + 1 pairs
  # [1,N-1],[2,N-2],..[(N-1)/2,(N-1)/2+1], N
  1.upto(N/2).each do |i|
    # i is the pair of N-i.
    p = N-i
    1.upto(N-1).each do |j|
      if (i != j) && (p != j)
        add(i, j)
        add(p, j)
      end
    end
    add(i, N)
    add(p, N)
  end
end
  
p S.size
S.each do |(i, j)|
  print "#{i} #{j}\n"
end

Measured memory_bytes: 4604
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

// DIVISORS IN sqrt(n)

lli divisors(long long int n)
{
	lli cnt = 0;
	for (long long int i = 1; i <= sqrt(n); i++)
	{
		if (n % i == 0)
		{

			if (n / i == i)
				cnt++;
			else
				cnt += 2;
		}
	}
	return cnt;
}
void solve()
{
	lli n, i, j, k, c = 0, s = 0;
	cin >> n;
	for (i = 1; i < n + 1; i++)
	{
		c += n / i;
	}
	cout << (c - divisors(n)) << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();
	return 0;
}


Measured memory_bytes: 3692
#!/usr/bin/python

# AtCoder Beginner Contest 076
# C - Dubious Document 2

from sys import stdin

def match(S, pos, T):
  for i in range(len(T)):
    if S[pos + i] != '?' and S[pos + i] != T[i]:
      return False
  return True

def solve(S, T):
  minS = '~' * len(S)
  for pos in range(len(S) - len(T) + 1):
    # S[pos : pos + len(T)] matches T ?
    if match(S, pos, T):
      S_ = S[:pos] + T + S[pos + len(T):]       # replace the mid part with T
      S_ = [c if c != '?' else 'a' for c in S_] # replace '?' with 'a'
      if minS > S_: minS = S_
  return ''.join(minS) if minS[0] != '~' else 'UNRESTORABLE'

S = stdin.readline().strip()
T = stdin.readline().strip()
print(solve(S, T))

Measured memory_bytes: 2692
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
//#include <vector>

int main(int argc, char* argv[])
{
    long a[3];
    scanf("%ld %ld %ld", &(a[0]), &(a[1]), &(a[2]));
    std::sort( a + 0, a + 3 );

    printf("%d\n", a[2]-a[0]);

    return 0;
}


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

#define ll long long
const int mod = 1e9 + 7;
ll int INF = 1e17;

ll int arr[3005];
ll int dp[3005][3005][2];

ll int kil(int l, int r, int player)
{
  if(l == r)
  {
    if(player)
      return arr[l];
    return -arr[l];
  }

  if(dp[l][r][player] != -1)
    return dp[l][r][player];

  if(player)
  {
    dp[l][r][player] = -1e15;
    dp[l][r][player] = max(dp[l][r][player], kil(l+1, r, 1-player) + arr[l]);
    dp[l][r][player] = max(dp[l][r][player], kil(l, r-1, 1-player) + arr[r]);
  }
  else
  {
    dp[l][r][player] = 1e15;
    dp[l][r][player] = min(dp[l][r][player], kil(l+1, r, 1-player) - arr[l]);
    dp[l][r][player] = min(dp[l][r][player], kil(l, r-1, 1-player) - arr[r]);
  }

  return dp[l][r][player];
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  memset(dp, -1, sizeof dp);

  int n, k, res;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>arr[i];

  cout<<kil(0, n-1, 1)<<endl;

  return 0;
}


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

int main () {
  int k, s;
  cin >> k >> s;
  int count = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (z >= 0 && z <= k) count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	week := map[string]int{
		"SUN": 7,
		"MON": 6,
		"TUE": 5,
		"WED": 4,
		"THU": 3,
		"FRI": 2,
		"SAT": 1,
	}

	scanner.Scan()
	fmt.Println(week[scanner.Text()])
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<int> A(N, 0);
    REP(i, Q){
        int a;
        cin >> a;
        A[a - 1]++;
    }

    REP(i, N){
        if(K - (Q - A[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


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

int main(){
  int  tk_HP, tk_AT, ao_HP, ao_AT; 
  cin >> tk_HP >> tk_AT >> ao_HP >> ao_AT;
  while(1){
    ao_HP -= tk_AT;
    if(ao_HP <= 0) {
      cout << "Yes" << endl;
      break;
    }
    tk_HP -= ao_AT;
    if(tk_HP <= 0){
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  int N, Z, W; cin >> N >> Z >> W;

  int A[N + 1];
  A[0] = W;
  for (int i = 1; i <= N; i++) cin >> A[i];

  cout << max(abs(A[N] - W), abs(A[N] - A[N - 1])) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define fo(i,l,r,x) for(int i=(l);i<=(r);i+=x)
using namespace std;
const int N=3e5+10,inf=1e9;
int n,a[N],s1,s2,f[N];
bool check(int x){
    int mn=0;
    fo(i,1,n,2) (f[i]-mn>=x)?mn=min(f[i+1],mn):0;
    return mn==-inf;
}
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",a+i),i&1?s1+=a[i]:s2+=a[i];
    if(!(n&1)){if(s1<s2) swap(s1,s2);printf("%d %d\n",s1,s2);return 0;}
    rep(i,1,n) f[i]=i&1?f[i-1]+a[i]:f[i-1]-a[i];f[n+1]=-1e9;
    int l=-inf,r=inf,t=-inf;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid)) l=mid+1,t=mid;
        else r=mid-1;
    }
    int x=s2+t,y=s1+s2-x;
    printf("%d %d\n",x,y);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    rep(i,n - 2){
        if(s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

typedef complex<double> P;
typedef pair<P, P> L;
#define X real()
#define Y imag()

double dot(P& a, P& b){
  return a.X * b.X + a.Y * b.Y;
}
double cross(P& a, P& b){
  return a.X * b.Y - a.Y * b.X;
}

int sign(double x){
  if(x > EPS) return 1;
  if(x < -EPS) return -1;
  return 0;
}

//a -> b, a -> c
int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(sign(cross(b, c)) > 0) return 1; //反時計
  if(sign(cross(b, c)) < 0) return -1; //時計
  if(sign(dot(b, c)) < 0) return +2; //c-a-b
  if(norm(b) < norm(c)) return -2; //a-b-c
  return 0; //a-c-b
}

double min_d(P a, P b, P c){
  double d1 = abs(c - a);
  double d2 = abs(c - b);
  b -= a; c -= a;
  double k = dot(b, c) / norm(b);
  if(0 < k && k < 1) return abs(c - k * b);
  else return min(d1, d2);
}

string solve(P p[3], P c, double r){
  if(ccw(p[0], p[1], p[2]) == -1) swap(p[1], p[2]);
  double maxdist = 0, mindist = 1e18;
  int ccw_v[3];
  REP(i, 3){
    maxdist = max(maxdist, abs(p[i] - c));
    mindist = min(mindist, min_d(p[i], p[(i + 1) % 3], c));
    ccw_v[i] = ccw(p[i], p[(i + 1) % 3], c);
  }
  if(sign(maxdist - r) <= 0) return "b";
  if(ccw_v[0] == ccw_v[1] && ccw_v[1] == ccw_v[2] && ccw_v[0] == 1){
    if(sign(mindist - r) >= 0) return "a";
    else return "c";
  }else{
    if(sign(mindist - r) > 0) return "d";
    else return "c";
  }
}

int main(){
  P p[3];
  P c; double r;
  while(cin>>p[0].X>>p[0].Y>>p[1].X>>p[1].Y>>p[2].X>>p[2].Y>>c.X>>c.Y>>r){
    cout<<solve(p, c, r)<<endl;
  }
  return 0;
}

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

int main(){
 int N,M;
  cin>>N>>M;
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i);
  }
  int s=0;
  for(int i=0;i<M;i++){
    s=s+A.at(i);
  }
  if(N>=s){
    cout<<N-s<<endl;
  }
  else{
    cout<<-1<<endl;
  }
  
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int N,K;
set<int>D,D_N,intersect;
void getDigits(int N,set<int>*D){
  set<int>&xs=*D;
  xs.clear();
  while(N){
    xs.insert(N%10);
    N/=10;
  }
}
main(){
  cin>>N>>K;
  for(int i=0;i<K;++i){
    int x;
    cin>>x;
    D.insert(x);
  }
  while(true){
    getDigits(N,&D_N);
    intersect.clear();
    set_intersection(
        D.begin(),D.end(),D_N.begin(),D_N.end(),
        inserter(intersect,intersect.begin()));
    if(intersect.empty()){
      cout<<N<<endl;
      return 0;
    }
    ++N;
  }
}


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

int main() {
   int A, B;
   cin >> A >> B;
   string s;
   cin >> s;

   if(s[A] != '-') {
      cout << "No" << endl;
      return 0;
   }

   for(int i=0; i<A; i++) {
      if(s[i] < '0' || s[i] > '9') {
         cout << "No" << endl;
         return 0;
      }
   }

   for(int i=A+1; i<=A+B; i++) {
      if(s[i] < '0' || s[i] > '9') {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
}

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

using namespace std;

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

	char str[n+1];
	cin >> str;

	int flag_2=0, flag_3=0, no=0;
	for(int i=a; i<c; i++) {
		if(flag_2 == 2) break;
		if(str[i] == '#') flag_2++;
		else flag_2 = 0;
	} 
	if(flag_2 == 2) no = 1;
	flag_2 = 0;
	for(int i=b; i<d; i++) {
		if(flag_2 == 2) break; 
		if(str[i] == '#') flag_2++;
		else flag_2 = 0;
	}
	if(flag_2 == 2) no = 1;
	if(d < c) {
		for(int i=b-1; i<d; i++) {
			if(str[i-1] == '.' && str[i] == '.' && str[i+1] == '.') { flag_3=1; break; }
		}
		if(!flag_3) no = 1; 
	}
	if(no) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 384