akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

int _find(int a,int b,int c){
    if(a==b && b==c){
        return 0;
    }
    vector<int> v={a,b,c};
    sort(all(v));
    a=v[0];b=v[1];c=v[2];
    if(a==b && c==b+1){
        return 1+_find(a+1,b+1,c);
    }
    return 1+_find(a+2,b,c);
}

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<_find(a,b,c)<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3624
n = int(input())
l = list(map(int, input().split(" ")))
dp = [float('inf')]*n
dp[0] = 0
dp[1] = abs(l[0] - l[1])
for i in range(2, n):
    dp[i] = min(dp[i-2]+abs(l[i-2]-l[i]), dp[i-1]+abs(l[i-1]-l[i]))
print(dp[-1])


Measured memory_bytes: 13928
#include<stdio.h>
int main(void)
{
	int a[3],i,j,w;
	for(i=0;i<3;i++){
	    scanf("%d",&a[i]);
	}
	for(i=0;i<2;i++){
	    for(j=i+1;j<3;j++){
		    if(a[i]>a[j]){
			    w=a[i];
				a[i]=a[j];
				a[j]=w;
			}
		}
	}
	for(i=0;i<3;i++){
	    if(i==2){
		    printf("%d",a[i]);
		}
		else{
	    printf("%d ",a[i]);
	    }
	}
	printf("\n");
	return 0;
}

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

int INF = 1'000'000'000;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> distance(n, vector<int>(n, INF));
    for (int i = 0; i < n; i++) distance[i][i] = 0;
    int a, b ,c;
    queue<tuple<int, int, int>> que;
    for (int i = 0; i < m; i++){
        cin >> a >> b >> c;
        a--; b--;
        distance[a][b] = c;
        distance[b][a] = c;
        que.push(tie(a, b, c));
    }
    for (int k = 0; k < n; k++){
        for (int i = 0; i< n; i++){
            for (int j = 0; j < n; j++){
                distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j]);
            }
        }
    }
    int ans = 0;
    while (que.size()){
        if (distance[get<0>(que.front())][get<1>(que.front())] != get<2>(que.front())) ans++;
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
  sc.Scan()
  i, e := strconv.Atoi(sc.Text())
  if e != nil {
    panic(e)
  }
  return i
}

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  x := make([]int, n)
  for i := 0; i < n; i++ {
    x[i] = nextInt()
  }
  var max,cnt int
  for N := 0; N+1 < n-1; N++{
    cnt = 0
    for x[N] >= x[N+1] && N+1 < n-1 {
      cnt++
      N++
    }
    if N+1 == n-1 {
      cnt++
    }
    if max < cnt{
      max = cnt
    }
  }
  fmt.Println(max)
}

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

using namespace std;

int main() {
    unsigned int n;
    unsigned int k;
    cin >> n >> k;
    //N mosters K times special move;
    unsigned int arr[n];
    for(unsigned int i=0;i<n;i++){
        cin >> arr[i];
    }
    unsigned long int sum =0;
    sort(arr,arr+n);
    if(n <= k){
        cout << 0 ;
    }else{
        for(unsigned int i=0;(i)<(n-k);i++){
            sum = sum + arr[i];
           // cout << sum << endl;
        }
        cout << sum ;
    }
    
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

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

void Main(){
	ll n,m; cin >> n >> m;
	if(n > m) swap(n,m);
	if(n > 2){
		cout << (n-2) * (m-2) << endl;
	}else if(n == 2){
		cout << 0 << endl;
	}else{
		if(m == 1){
			cout << 1 << endl;
		}else{
			cout << m-2 << endl;
		}
	}
}


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


bool is_kaibun(string s) {
    // s[0] - s[8] (9) i = 0 - 3
    // s[0] - s[7] (8) i = 0 - 3
    for (int i = 0; i < (s.length() / 2); i++) {
        if (s[i] != s[s.length() - 1 - i]) {
            return false;
        }
    }
    return true;
}
int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    if (is_kaibun(s) && is_kaibun(s.substr(0, (s.length() - 1) / 2)) && is_kaibun(s.substr((s.length() + 1) / 2, s.length() - (s.length() + 3) / 2 + 1))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  string S; cin >> S;
  ll K; cin >> K;
  ll count1 = 0;
  for (ll j=0; j < S.length(); ++j) {
    if (S[j] == '1') {
      count1 += 1;
    } else {
      break;
    }
  }
  if (K <= count1) {
    cout << 1 << endl;
  } else {
    cout << S[count1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

dp = [0]*N
dp[1] = abs(H[0]-H[1])
for i in range(2,N):
  dp[i] = min(abs(H[i]-H[i-1])+dp[i-1], abs(H[i]-H[i-2])+dp[i-2])
print(dp[N-1])

Measured memory_bytes: 13928
a = parse(Int64,readline())
b = parse(Int64,readline())
c = parse(Int64,readline())
x = parse(Int64,readline())

res = 0
for i = 0:a, j = 0:b, k = 0:c
  if 500*i+100*j+50*k == x
    res += 1
  end
end
print(res)


Measured memory_bytes: 117980
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int N;

int main() {
	cin>>N;
	cout<<N*32<<endl;



	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    string S;
    cin>>S;
    int h=S.size();
    int a=S.size();
    for(int i=1; i<S.size(); i++)
    {
        if(S[i]!=S[i-1])
    h=min(h,max(i,a-i));
    }
    cout<<h<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <queue>
#include <cmath>

using namespace std;

typedef struct st1
{
	int x;
	int y;
}coord;

typedef struct st2
{
	double sumofx;
	int count;
}up;

int w,h;
char p[60][10];
bool visit[60][10];
bool stable;

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

void find_blocks(int x,int y,coord c[4])
{
	queue <coord> q;
	coord co,tmp_co;
	
	co.x = x; 
	co.y = y;
	q.push(co);
	visit[y][x] = true;
	
	int idx = 0;
	c[idx].x = x;
	c[idx].y = y;
	++idx;
	
	while (!q.empty())
	{
		co = q.front();
		q.pop();
		
		for (int i=0;i<4;++i)
		{
			tmp_co.x = co.x + dx[i];
			tmp_co.y = co.y + dy[i];
			if (0<=tmp_co.x && tmp_co.x < w&&0<=tmp_co.y&&tmp_co.y<h&&(!visit[tmp_co.y][tmp_co.x])&&(p[tmp_co.y][tmp_co.x] == p[y][x]))
			{
				c[idx].x = tmp_co.x;
				c[idx].y = tmp_co.y;
				++idx;
				q.push(tmp_co);
				visit[tmp_co.y][tmp_co.x] = true;
			}
		}
	}
	
}

up dfs(int x, int y)
{
	up res;
	coord block[4];
	int left = 60;
	int right = -1;
	
	res.sumofx = 0;
	res.count = 0;
	
	if (!stable) return res;
	find_blocks(x,y,block);
	
	for (int i=0;i<4;++i)
	{
		res.sumofx += block[i].x + 0.5;
		res.count++;
		
		if (block[i].y == 0)
		{
			left = min(left,block[i].x);
			right = max(right,block[i].x);
		}else 
		{
			if ((p[block[i].y-1][block[i].x]!='.')&&(p[block[i].y-1][block[i].x]!=p[block[i].y][block[i].x]))
			{
				left = min(left,block[i].x);
				right = max(right,block[i].x);
			}
		}
		
		if (!stable) return res;
		if ((block[i].y+1<h)&&(p[block[i].y+1][block[i].x]!='.')&&(p[block[i].y+1][block[i].x]!=p[block[i].y][block[i].x])&&(!visit[block[i].y+1][block[i].x]))
		{
			up u = dfs(block[i].x,block[i].y+1);
			res.sumofx += u.sumofx;
			res.count += u.count;
		}
	}
	
	double avg=res.sumofx/res.count;
    if (!(left<avg && avg<right+1)) stable = false;
	
	return res;
}

int main()
{
	cin >> w >> h;
	while (w+h > 0)
	{
		memset(visit,0,sizeof(visit));
		stable = true;
		
		for (int i=h-1;i>=0;--i)
		{
			for (int j=0;j<w;++j)
			{
				cin >> p[i][j];
			}
		}
		
		for (int i=0;i<w;++i)
		{
			if (p[0][i] != '.' )
			{
				dfs(i,0);
				break;
			}
		}
		
		if (stable) cout <<"STABLE" << endl;
		else cout << "UNSTABLE" << endl;
		
		cin >> w >> h;
	}
	return 0;
}

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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#define debug(x) cerr << #x << ": <" << (x) << ">\n"
#else
#define debug(x)
#endif
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp(x, y)  make_pair(x, y);
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second
#define mod       1000000007

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
  ioThings();

  int x;
  cin >> x;

  int a = 0;
  for (;;) {
    double p = pow(a, 5) - x;
    double res = pow(abs(p), 0.2);
    if (abs(res - round(res)) < 1e-9) {
      cout << a << ' ' << (p < 0 ? -1 : 1) * round(res);
      break;
    }

    if (a <= 0) a = -a + 1;
    else a = -a;
  }

  return 0;
}


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

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

    int a, b;
    a = floor(N / 1.08);
    b = a + 1;
    for (int i = a; i <= b; ++i){
        if (floor(i*1.08) == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

H, W, N = map(int, input().split())
query = [list(map(int, input().split())) for i in range(N)]
list_star = defaultdict(set)
H_max = 0
W_max = 0
for y, x in query:
    H_max = max(H_max, y)
    W_max = max(W_max, x)
    list_star[y - 1].add(x - 1)

dx = [0, 0, 1, 1, 1, 0, -1, -1, -1]
dy = [0, 1, 1, 0, -1, -1, -1, 0, 1]


lista = [0] * 10

def counter(x, y):
    if x <= 0 or W - 1 <= x or y <= 0 or H - 1 <= y:
        return 0
    cnt = 0
    for i in range(9):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx < W and 0 <= ny < H:
            if nx in list_star[ny]:
                cnt += 1
    return cnt

star_list = set()
for y, x in query:
    x -= 1
    y -= 1
    for l in range(9):
        nx = x + dx[l]
        ny = y + dy[l]
        star_list.add((nx, ny))

star_list = list(star_list)
for x, y in star_list:
    if not (x <= 0 or W - 1 <= x or y <= 0 or H - 1 <= y):
        lista[counter(x, y)] += 1

left = (H - 2) * (W - 2) - sum(lista)
lista[0] = left
for i in lista:
    print(i)

Measured memory_bytes: 247028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int n, m;
struct Req {
    int a;
    int b;
}req[100000];
bool cmp(Req r1, Req r2) {
    if (r1.b < r2.b) {
        return true;
    }
    else if (r1.b == r2.b) {
        if (r1.a < r2.a) {
            return true;
        }
    }
    return false;
}
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> req[i].a >> req[i].b;
    }
    sort(req, req+m, cmp);
    int ans = 1;
    int right = req[0].b;
    for (int i = 1; i < m; i++) {
        if (req[i].a >= right) {
            ans++;
            right = req[i].b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define MAX 500001

void maxHeapify(int);

int H, A[MAX];

int main()
{
  int i;
  
  scanf("%d", &H);
  
  for( i = 1 ; i <= H ; i++ ) scanf("%d", &A[i]);
  
  for( i = H/2 ; i >= 1 ; i-- ) maxHeapify(i);
  
  for( i = 1 ; i <= H ; i++ ) printf(" %d", A[i]);
  printf("\n");
  
  return 0;
}

void maxHeapify(int i)
{
  int l, r, largest, tmp;

  l = 2 * i;
  r = 2 * i + 1;
  
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if( r <= H && A[r] > A[largest] ) largest = r;
  
  if( largest != i ){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

Measured memory_bytes: 2552
/** @Date    : 2017-08-20 19:50:42
  * @FileName: C.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoungEarlf@gmail.com)
  * @Link    : https://github.com/
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;

int a[N];
map<int,int>q;
int main()
{
	int n;
	while(cin >> n)
	{
		q.clear();
		for(int i = 0; i < n; i++)
		{
			scanf("%d", a + i);
			q[a[i]]++;
		}
		sort(a, a + n);
		LL ans = 0;
		for(int i = n - 1; i >= 0; i--)
		{
			//cout << a[i];
			if(q[a[i]] >= 2 && !ans)
			{
				ans = a[i];
				if(q[a[i]] >= 4)
				{
					ans = (ans * (LL)a[i]);
					break;
				}
				//cout << ans << endl;
			}
			else if(ans && q[a[i]] >= 2 && a[i] != ans)
			{
				ans = (ans * (LL)a[i]);
				break;
			}
			
		}
		printf("%lld\n", ans);
	}
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str;
	cin >> str;
	unsigned int tmpa=0,tmpz=0;
	for( unsigned int i=0 ; i<str.size()  ; i++ ){
		if( str[i] == 'A' ){
			tmpa = i;
			break;
		}
	}
	for( unsigned int i=str.size() ; i>=0 ; i-- ){
		if( str[i] == 'Z' ){
			tmpz=i;
			break;
		}
	}
	cout << tmpz-tmpa +1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v[n];
    int p[m],y[m];
    for(int i=0;i<m;i++){
        cin>>p[i]>>y[i];
        v[--p[i]].push_back(y[i]);
    }
    for(int i=0;i<n;i++){
        sort(v[i].begin(),v[i].end());
        //v[i].erase(unique(v[i].begin(),v[i].end()),v[i].end());
    }
    for(int i=0;i<m;i++){
        int t=lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin();
        printf("%06d%06d\n",p[i]+1,t+1);
    }
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

int N;
unsigned long long A[200000];
unsigned long long suma[200001], xora[200001], diffa[200001];
multiset<ll> a;

int main(){
  cin>>N;
  REP(N)cin>>A[i];
  suma[0] = xora[0] = 0;
  REP(N)suma[i+1]=suma[i]+A[i];
  REP(N)xora[i+1]=xora[i]^A[i];
  unsigned long long ans = 0;
  int tmp = 0;
  for (int i = 0; i < N;i++) {
    while(tmp<N+1&&(suma[tmp]-suma[i]) == (xora[tmp]^xora[i]))tmp++;
    tmp--;
    int cnt = tmp-i;
    ans += cnt;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long int ll;
int main(){
	int N;
	ll a[10000], b[10000];
	cin >> N;
	ll sum_a = 0, sum_b = 0;
	for(int i = 0; i < N; i++){
		cin >> a[i];
		sum_a += a[i];
	}
	for(int i = 0; i < N; i++){
		cin >> b[i];
		sum_b += b[i];
	}
	ll cnt = sum_b - sum_a;
	ll num_a = 0, num_b = 0;
	for(int i = 0; i < N; i++){
		if(a[i] < b[i] && (b[i] - a[i]) % 2 == 0){
			num_a += (b[i] - a[i]) / 2;
		}else if(a[i] < b[i]){
			num_a += (b[i] - a[i]) / 2 + 1;
			num_b++;
		}else if(a[i] > b[i]){
			num_b += a[i] - b[i];
		}
	}
	if(num_a <= cnt && num_b <= cnt) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
from sys import stdin
import string

h,w = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(stdin.readline().rstrip().split()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if li[i][j] == "snuke":
            print(string.ascii_uppercase[j]+str(i+1))

Measured memory_bytes: 3768
import Data.List
main=do
 [n,k]<-map read.words<$>getLine
 v<-map read.words<$>getLine
 print$maximum[solve((take i v)++(drop(n-j)v))(k-i-j)|i<-[0..n],j<-[0..n-i],i+j<=k]
solve y k=(sum y)-(sum$take k(filter(0>)$sort y))

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var N = r[0].ToDecimal();
            var K = r[1].ToDecimal();
            var r2 = ReadSplit();
            var ar = new List<decimal>();
            for (int i = 0; i < N; i++)
            {
                ar.Add(r2[i].ToDecimal());
            }
            ar.Sort();
            ar.Reverse();
            for (int i = 0; i < K; i++)
            {
                if (N <= i) break;
                ar[i] = 0;
            }
            Write(ar.Sum());
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
            Read();
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



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

using namespace std ;
#define rep(i,n) for(int i =0 ; i < int (n); i++)
typedef long long ll;
typedef pair <int , int >pi;
typedef vector <int> vi ;
typedef vector <string> si;



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

	int a ; 
	cin>> a;
	if(a % 1000 == 0){
		cout << 0;
	}
	else{
		int ans = 1000 - a % 1000 ;
		cout << ans;
	}
	

	return 0 ;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <regex>

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

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

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

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

    string s;
    cin >> s;

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

    return 0;
}



Measured memory_bytes: 39808
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int dx[2] = { 1,0 };
int dy[2] = { 0,1 };
int INF = 1000000007;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> mp(h, vector<char>(w));
	rep(i, h)rep(j, w) cin >> mp[i][j];
	vector<vector<int>> ans(h, vector<int>(w));
	ans[0][0] = 1;
    rep(i,h)rep(j,w){
      if(mp[i][j]!='.') continue;
      if(i>0&&mp[i-1][j]=='.') ans[i][j]+=ans[i-1][j];
      if(j>0&&mp[i][j-1]=='.') ans[i][j]+=ans[i][j-1];
      ans[i][j]%=INF;
    }
	cout << ans[h - 1][w - 1] << endl;
}

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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ll long long

int main() {
    int n;
    cin >> n;
    int flag = 0;
    for (int i = 1; i <= 9; ++i) {
        if ( n%i == 0 ) {
            if ( 1 <= n/i && n/i <= 9 ) {
                flag = 1;
            }
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define max2(a,b) ((a)>(b)?(a):(b))   
#define min2(a,b) ((a)<(b)?(a):(b)) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef pair<ll,ll>     pll;
typedef pair<int,int>   pii;
typedef vector<ll>      vll;
typedef vector<int>      vi;
typedef vector< pll >  vpll;
typedef vector< pii >  vpii;
typedef set<ll>         sll;
typedef set<int>         si;
typedef set< pll >     spll;
typedef set< pii >     spii;
clock_t clk=clock();       

ll i,j,k;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
// #define cerr if(0)cerr

int n;
vi node[200005];
int val[200005];
int ans[200005];
bool vis[200005];

void dfs(int idx,int sum)
{
  vis[idx]=1;
  sum+=val[idx];

  ans[idx]=sum;

  for(auto it: node[idx])
     if(!vis[it])
        dfs(it,sum);

}
void solve()
{
  int q;
  cin>>n>>q;
  rep(i,1,n-1)
  {
  	int x,y; cin>>x>>y;
  	node[x].pb(y);
  	node[y].pb(x);
  }

  while(q--)
  {
     int v,p; cin>>v>>p;
     val[v]+=p;
  }

  dfs(1,0);

  rep(i,1,n) cout<<ans[i]<<' ';
  cout<<'\n';
}

Measured memory_bytes: 19456
fun main() = ABC162C.main()

object ABC162C {
    fun log(message: Any?) {
        //println(message)// TODO: ←消す
    }

    fun main() {
        val K = readInt()
        var ans = 0
        (1..K).forEach { a ->
            (1..K).forEach { b ->
                (1..K).forEach { c ->
                    ans += Gcd.get(a, Gcd.get(b, c))
                }
            }
        }

        println(ans)
        log("calcCount=${Gcd.calcCount}")
    }


    /*####################################################################################*/
    object Gcd {
        var calcCount = 0
            private set
        private val cache = hashMapOf<Pair<Int, Int>, Int>()

        fun get(a: Int, b: Int): Int {
            val (m, n) = if (a > b) listOf(a, b) else listOf(b, a)
            val cached = cache[m to n]
            return if (cached == null) {
                val gcd = calc(m, n)
                cache[m to n] = gcd
                gcd
            } else cached
        }

        private fun calc(m: Int, n: Int): Int { // m > n
            assert(m > n)
            var m = m
            var n = n
            while (n != 0) {
                val r = m % n
                m = n
                n = r
            }
            calcCount++
            return m
        }
    }

    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
}

Measured memory_bytes: 62900
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define tr1(x)                cout<<#x<<": "<<x<<endl
#define tr2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define tr4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define tr3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define db1(x) cerr << #x << ": " << x <<'\n'
#define db2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define db3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int, int> &a,const pair<int, int> &b)
{
    return (a.ss<b.ss);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b, int c){
    return(max( max(a,b), c ));
}
int min(int a, int b, int c){
    return (min ( min(a,b) , c));
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;
 
    return res;
}
int findlcm(int arr[], int n)
{
    // Initialize result
    int ans = arr[0];
 
    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (__gcd(arr[i], ans)));
 
    return ans;
}
bool prime[100001];
void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));
 
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}
bool double_is_int(double trouble) {
   double absolute = abs( trouble );
   return absolute == floor(absolute);
}
//Define mx for maximum range and MOD for large numbers
#define mx 500005
#define mod 1000000007
 
// Declare all the variables and global functions here -
int t;
int32_t main(){
    IOS;
    string s;
    cin >> s;
    map<char, int> m;
    rep(i, 0, 4){
        m[s[i]]++;
    }

    if(m.size() == 2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dx[8] = {1,0,-1,0,1,-1,-1,1};//右、上、左、下、右上、左上、左下、右下のつもり
int dy[8] = {0,1,0,-1,1,1,-1,-1};//実際は色々反転している。どうせ4か8方向調べるから関係ないとしている。
bool seen[60][60]={true};
int main(void){
    int n;cin >> n;
    vector<vector<int> > x(n+1);
    for(int i=0;i<n;i++){
	int a,b; cin >> a >> b;
	for(int j=0;j<b;j++){
	    int c;cin >> c;
	    x[a].push_back(c);
	}
    }
    
    vector<int> dist(n+1,-1);
    queue<int> que;
    dist[1]=0;que.push(1);
    while(!que.empty()){
	int v = que.front();que.pop();
	for(int i=0;i<x[v].size();i++){
	    if(dist[x[v][i]]!=-1) continue;
	    dist[x[v][i]] = dist[v] + 1; 
	    que.push(x[v][i]);
	}
    }
    for(int i=1;i<=n;i++){
	cout << i << " " << dist[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> cnt(N, 0);
  for (ll i = 1; i < N; ++i) {
    ll temp = 1;
    while (temp * i < N) {
      cnt.at(temp * i) += 1;
      temp += 1;
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    // cout << cnt.at(i) << "\n";
    ans += cnt.at(i);
  }
  cout << ans << "\n";
}


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



int main(){
	int a,b,c,A[10],MX;
	cin >> A[0] >> A[1] >> A[2];
	
	a=abs(A[0]-A[1]);
	b=abs(A[1]-A[2]);
	c=abs(A[2]-A[0]);
	
	MX=max(a,max(b,c));
	
	cout << a + b + c - MX << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,d=0,r=0;
	double f=0;
	
	scanf("%d %d",&a,&b);
	
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 1860
#include <stdio.h>

int main()
{
    int card[55] = {};
    int save[55] = {};
    int n, r, p, c;

    scanf("%d", &n);
    while (n != 0) {
        scanf("%d", &r);

        for (int i = 0; i < n; i++) {
            card[i] = n - i;
        }

        for (int i = 0; i < r; i++) {
            scanf("%d %d", &p, &c);

            for (int j = 0; j < n; j++) {
                save[j] = card[j];
            }

            for (int j = 0; j < p - 1; j++) {
                save[j + c] = card[j];
            }

            for (int j = 0; j < c; j++) {
                save[j] = card[j + p - 1];
            }

            for (int j = 0; j < n; j++) {
                card[j] = save[j];
            }

        }

        printf("%d\n", card[0]);

        scanf("%d", &n);
    }

    return 0;
}



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

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; 
typedef double db;
typedef complex<db> cd;

ll qpow(ll x,ll k,ll mod)
{
    ll ret=1;
	while(k)
	{
	   if(k&1)	
	   {
	   	 ret=ret*x;
	   	 ret=ret%mod;
	   }
	   x=x*x;
	   x=x%mod;
	   k=(k>>1);
	}
	return ret;	
}
#define MP make_pair
#define FF first
#define SS second
#define LB lower_bound
#define UB upper_bound
#define PB push_back
#define lc ((p<<1)+1)
#define rc ((p<<1)+2)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define all(v) (v).begin(),(v).end()
#define clean(v,a) memset(v,a,sizeof(v))
#define PQ priority_queue

/*
 * high precision: printf("%.12lf",(db)ans);
 *
 * clear output buffer: fflush(stdout);
 *
 * sync off: ios::sync_with_stdio(false);
 *
 */

int n,k;

int main()
{
	scanf("%d%d",&n,&k);
	ll ans;
	if(k&1)
	{
		ans=(ll)(n/k)*(n/k)*(n/k);
	}
	else
	{
		ans=(ll)(n/k)*(n/k)*(n/k);
		ans+=(ll)((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
//Created Time:2019年12月19日 星期四 21时02分54秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define N 100005

using namespace std;

int n;
int val[N];

vector < int > G[N], s[N];

void dfs(int ,int);

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", val + i);
	for(int i = 1; i < n; ++i){
		int u, v; scanf("%d%d", &u, &v);
		G[u].push_back(v); G[v].push_back(u);
	}
	if(n == 2){
		if(val[1] != val[2]) puts("NO");
		else puts("YES");
		return 0;
	}
	for(int i = 1; i <= n; ++i){
		if(G[i].size() == 1) continue;
		dfs(i, 0);
		if(val[i]) puts("NO");
		else puts("YES");
		return 0;
	}
	return 0;
}

void dfs(int u, int fa){
	int sz = G[u].size(); long long sum = 0;
	if(sz == 1) return ;
	for(int i = 0; i < sz; ++i){
		int v = G[u][i]; if(v == fa) continue;
		dfs(v, u); sum += val[v]; s[u].push_back(val[v]);
	}
	if(sum < val[u] || val[u] * 2 < sum){ puts("NO"); exit(0); }
	long long x = sum - val[u]; sz -= (fa != 0); int pos = sz - 1; val[u] -= x;
	sort(s[u].begin(), s[u].end());
	for(int i = 0; i < sz && x && i < pos; ++i){
		if(x >= s[u][i]){
			if(s[u][pos] >= s[u][i]) s[u][pos] -= s[u][i];
			else s[u][i] -= s[u][pos--], s[u][pos] -= s[u][i];
			x -= s[u][i];
		}
		else{
			if(s[u][pos] > x) s[u][pos] -= x;
			else s[u][pos - 1] -= x - s[u][pos];
			x = 0;
		}
	}
	if(x && pos == sz - 1){puts("NO"); exit(0);}
	return ;
}


Measured memory_bytes: 19584
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()
#define INPUT1(var) FOR(i,countof(var)) var[i] = ri() - 1

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  int n = ri();
  int m = ri();
  cout << n-m+1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const ll mod = (1e+9) + 7;

int main() {
	string S;
	static ll dp[100010][13];
	dp[0][0] = 1;
	cin >> S;
	ll pow = 1;
	for (int i = 0; i < S.length(); ++i) {
		int i_ = S.length() - 1 - i;
		if (S[i_] == '?') {
			for (int j = 0; j < 10; ++j)
				for (int k = 0; k < 13; ++k)
					dp[i + 1][(pow * j + k) % 13] += dp[i][k];
		}
		else {
			int n = (int)(S[i_] - '0');
			for (int k = 0; k < 13; ++k)
				dp[i + 1][(pow * n + k) % 13] += dp[i][k];
		}
		for (int j = 0; j < 13; ++j) dp[i + 1][j] %= mod;
		pow = pow * 10 % 13;
	}
	cout << dp[S.length()][5] << endl;
	return 0;
}

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

int main() {
  int N;
  int ans = 0;
  cin >> N;
  int A[N];
  for(int i = 0; i<N;i++) {
    cin >> A[i];
    if(A[i] != i+1) {
      ans++;
    }
  }
  if(ans <= 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

int n, A, B ,C;
int l[10];
int INF = 1000000000;

int abs(int a){
    if(a < 0){
        a = -a;
    }
    return a;
}

int dfs(int num, int a, int b, int c){
    if(num == n){
        if(0 < a && 0 < b && 0 < c){
            int ans = abs(a - A) + abs(b - B) + abs(c - C) - 30;
            return ans;
        }else{
            return INF;
        }
    }else{
        int dfs0 = dfs(num+1, a, b, c);
        int dfs1 = dfs(num+1, a+l[num], b, c) + 10;
        int dfs2 = dfs(num+1, a, b+l[num], c) + 10;
        int dfs3 = dfs(num+1, a, b, c+l[num]) + 10;
        int ans = min(dfs0, min(dfs1, min(dfs2, dfs3)));
        return ans;
    }
}

int main(){
    cin >> n >> A >> B >> C;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }

    int result = dfs(0,0,0,0);

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

int main() {
    std::string s;
    int k;
    std::cin >> s >> k;
    std::set<std::string> subs;
    for (int i = 0; i < s.size(); ++i) {
        std::string t;
        t.push_back(s[i]);
        subs.insert(t);
        for (int j = i+1; j < s.size() && j < i + 5; ++j) {
            t += s[j];
            subs.insert(t);
        }
    }
    k--;

    auto ans = subs.begin();
    for (int i = 0; i < k; ++i) {
//        std::cout << *ans << std::endl;
        ans++;
    }
    std::cout << *ans << std::endl;
}

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

int main(){
	using ll = long long int ;
	ll n,m ;
	cin >> n >> m ;
	vector<bool> a(n,false) ;
	vector<ll> w(n,0) ;
	ll ac,wa ;
	ac = wa = 0 ;
	int q ;
	string r ;
	for(int i=0;i<m;i++){
		cin >> q >> r ;
		if(!a.at(q-1)){
			if(r=="AC"){
				a.at(q-1) = true ;
				wa += w.at(q-1) ;
				ac++ ;
			}else{
				w.at(q-1)++ ;
			}
		}
	}
	cout << ac << " " << wa << endl ;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int x, y;
    cin >> x >> y;
    x = (x > 4 ? 4 : x);
    y = (y > 4 ? 4 : y);
    cout << (4-x)*100000 + (4-y)*100000
                + (x == 1 && y == 1 ? 400000 : 0) << endl;
    return 0;
}

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

int main(){
    int n; cin >> n;
    int ans = 10000000;
    vector<int> v(n); rep(i,n) cin >> v.at(i);
    
    for(int p = 1; p <= 100; p++){
        int tmp = 0;
        for(int i = 0; i < n; i++){
            tmp += pow(v.at(i) - p, 2);
        }
        ans = min(ans, tmp); 
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, n, ans = 1;
  scanf("%d", &n);
  int x[n], y[n];
  scanf("%d%d", &x[0], &y[0]);
  scanf("%d%d", &x[1], &y[1]);
  for(i = 2; i < n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    if((y[i] - y[i - 2]) * (x[i - 1] - x[i - 2]) - (x[i] - x[i - 2]) * (y[i - 1] - y[i - 2]) < 0) ans = 0;
  }
  if((y[0] - y[n - 2]) * (x[n - 1] - x[n - 2]) - (x[0] - x[n - 2]) * (y[n - 1] - y[n - 2]) < 0) ans = 0;
  if((y[1] - y[n - 1]) * (x[0] - x[n - 1]) - (x[1] - x[n - 1]) * (y[0] - y[n - 1]) < 0) ans = 0;
  printf("%d\n", ans);
  return 0; 
} 


Measured memory_bytes: 2756
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        dif = a // 2
        a -= dif
        b += dif
    else:
        if b % 2 == 1:
            b -= 1
        dic = b // 2
        a += dic
        b -= dic
print(a, b)

Measured memory_bytes: 3060
//https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_K

#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n;//ボール
    long long k;//箱
    cin >> n >> k;

    int ans = (n > k) ? 0 : 1;
    cout << ans << endl;
    return 0;
}

/*
 *
 */


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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector <int> a(n);
    int odd = 0, even = 0;
    for(int i = 0; i < n; i++) {
      cin >> a[i];
      if(a[i] % 2 == 0) {
	even++;
      }
      else {
	odd++;
      }
    }

    long long all = 1, notsim = 1;
    for(int i = 0; i < n; i++) {
      all *= 3;
    }
    for(int i = 0; i < even; i++) {
      notsim *= 2;
    }

    cout << all - notsim << endl;
}

Measured memory_bytes: 256
// AOJ 1030 Cubes Without Holes
// 2018.2.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

char buf[15], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

typedef struct { int id, a, b; } T;
T tbl[201], *end;

int cno;
char f[134217728];
int ans;

void cnt(int x) { if (f[x] != cno) f[x] = cno, ans++; }
int cmp(T *a, T *b) { return a->id - b->id; }

int main()
{
	int n, h, i, t;
	T *tp;

	while (fgets(p=buf, 15, stdin) && *p != '0') {
		n = in(), h = in(), end = tbl+h;
		cno++;

		for (tp = tbl; tp < end; tp++) {
			fgets(p=buf, 15, stdin);
			if      (*p == 'x' && *(p+1) == 'y') tp->id = 0;
			else if (*p == 'x' && *(p+1) == 'z') tp->id = 1;
			else                                 tp->id = 2;
			p += 3, tp->a = in()-1, tp->b = in()-1;
		}
		qsort(tbl, h, sizeof(T), cmp);

		ans = 0;
		for (tp = tbl; tp < end; tp++) {
			if (tp->id) break;
			t = (tp->a << 18) | (tp->b << 9);
			ans += n, i = n; while (i--) f[t|i] = cno;
		}

		for (; tp < end; tp++) {
			if (tp->id == 1) {
				t = (tp->a << 18) | tp->b;
				i = n; while (i--) cnt(t|(i<<9));
			} else {
				t = (tp->a << 9) | tp->b;
				i = n; while (i--) cnt(t|(i<<18));
			}
		}
		printf("%d\n", n*n*n - ans);
	}
	return 0;
}


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

int main() {
  string x,y,ans;
  cin >> x >> y;
  for(int i=0;i<x.size()+y.size();i++) {
    if(i%2==0) {
      ans += x[i/2];
    }else {
      ans += y[i/2];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int q;
  while(cin>>q,q){
    using D = deque<int>;
    auto mv=
      [&](D &a,D &b,D &ax,D &ay,D &bx,D &by){
	if(!bx.empty()&&bx.back()==b.back()) bx.pop_back();
	if(!by.empty()&&by.back()==b.back()) by.pop_back();	  
	
	a.emplace_back(b.back());
	b.pop_back();
	
	if(ax.empty()||ax.back()>a.back()) ax.emplace_back(a.back());
	if(ay.empty()||ay.back()<a.back()) ay.emplace_back(a.back());
      };

    D a,b;
    D ax,ay,bx,by;
    
    while(q--){
      int t,x=-1;
      cin>>t;
      if(t==0||t==4||t==5||t==8||t==9) cin>>x;     

      if(t==0){	
	while(!bx.empty()&&bx.front()>x) bx.pop_front();
	while(!by.empty()&&by.front()<x) by.pop_front();
	b.emplace_front(x);
	bx.emplace_front(x);
	by.emplace_front(x);
      }
      
      if(t==1){
	if(!ax.empty()&&ax.back()==a.back()) ax.pop_back();
	if(!ay.empty()&&ay.back()==a.back()) ay.pop_back();
	cout<<a.back()<<endl;
	a.pop_back();
      }

      if(t==2) cout<<ax.back()<<endl;
      if(t==3) cout<<bx.back()<<endl;

      if(t==4) cout<<ax[ax.size()-x]<<endl;
      if(t==5) cout<<bx[bx.size()-x]<<endl;
            
      if(t==6) cout<<ay.back()<<endl;
      if(t==7) cout<<by.back()<<endl;
      
      if(t==8) cout<<ay[ay.size()-x]<<endl;
      if(t==9) cout<<by[by.size()-x]<<endl;
      
      while(a.size()<b.size())   mv(a,b,ax,ay,bx,by);
      while(a.size()>b.size()+1) mv(b,a,bx,by,ax,ay);

    }
    cout<<"end"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3300
N=int(input())

nlist=[]
while N:
  nlist.append((N-1)%26)  
  N=(N-1)//26
  
nlist.reverse()
#print(nlist)

answer_list=[]
for n in nlist:
  answer_list.append(chr(97+n))
  
print("".join(answer_list))

Measured memory_bytes: 9136
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  int N, A, B;
  scanf("%d%d%d", &N, &A, &B);
  char S[100002];
  scanf(" %s", S);
  string str_S(S);
  int a = 0;
  int b = 0;
  for (int i = 0; i < str_S.length(); i++){
    if ((str_S[i] == 'a') && ((a+b) < (A+B))){
      a++;
      printf("Yes\n");
    }else if ((str_S[i] == 'b') && ((a+b) < (A+B)) && (b < B)){
      b++;
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,d; cin >> n >> m >> d;
    if (m<2){cout << 0 << '\n'; return 0;}
    ll sum=max(n-d,0LL)*2*(m-1);
    if (d==0) sum/=2;
    cout << fixed << setprecision(10);
    cout << (double)sum/(double)(n*n) << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

int main()
{
    ll n;
    cin>>n;
    string ans;
    while (n != 0) {
        ans = (char)('a' + (n-1) % 26) + ans;
        n = (n-1)/26;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

  if(a!=c) cout<<1<<endl;
  else cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
char s[maxn];
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int ans = n - 1;
	for(int i = 2; i <= n; ++i)
		if(s[i] == s[i - 1])
			--ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3800