akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;for(ll i=1;i<=a;i++)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

ll A, B, h, w;
string white=".";
string black="#";

vector<string> str(string c1, string c2, int cnt)
{
  vector<string> ans;
  string base = string(99,c1[0]);
  string tmp = base;
  ans.push_back(base);
  REP(i,cnt) {
    if(i%49==0 && i > 0) {
      ans.push_back(tmp);
      ans.push_back(base);
      tmp = base;
    }
    tmp[(i%49)*2+1] = c2[0];
  }
  ans.push_back(tmp);
  ans.push_back(base);
  return ans;
}

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B;
  if(A==1 || B==1) {
    if (A==1 && B==1) {
      cout << "1 2\n";
      cout << "#.\n";
      return 0;
    }
    string C = (A==1)?white:black;
    string D = (A==1)?black:white;
    int cnt = A*B;
    auto ans = str(C,D,cnt);
    cout << ans.size() << " " << 99 << endl;
    for(auto s : ans) cout << s << endl;
  } else {
    auto ans1 = str(white, black, B-1);
    auto ans2 = str(black, white, A-1);
    cout << ans1.size()+ans2.size() << " " << 99 << endl;
    for(auto s : ans1) cout << s << endl;
    for(auto s : ans2) cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 384
# coding:utf-8

cal = {
       "+": lambda a, b: b+a,
       "-": lambda a, b: b-a,
       "*": lambda a, b: b*a
       }

stack = []

for i in input().split():
    if i in cal:
        stack.append(cal[i](stack.pop(), stack.pop()))
    else:
        stack.append(int(i))

print(stack[-1])

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

int main () {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()) {
    if(s.at(i) != t.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a ;
  int b ;
  double c ;
  int d ;
  int e ;
  cin >> a >> b;
  d = 2;
  e = a + b;
  c = (e + (d - 1)) / d;
  cout << c << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N, K;
    sll(N);
    sll(K);
    vector<ll> ps(N);
    vector<ll> exp_double(N);
    vector<ll> exp_acm(N+1, 0);
    rep(i, N){
        sll(ps[i]);
        exp_double[i] = ps[i] + 1;
        exp_acm[i+1] = exp_acm[i] + exp_double[i];
    }

    ll max_e = 0;
    ll max_i = -1;
    for(ll i=K-1;i<N;i++){
        ll this_exp = exp_acm[i+1] - exp_acm[i+1-K];
        if(this_exp > max_e){
            max_i = i;
            max_e = this_exp;
        }
    }

    double ans = (double)max_e * 0.5;

    cout << fixed << setprecision(10) << ans << endl;


}

int main(){
    Main();
}

Measured memory_bytes: 7620
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    int c = sc.nextInt();

	    if (a < b && b < c) {
			System.out.println("Yes");

	    } else {
			System.out.println("No");

		}

    }
}

Measured memory_bytes: 17160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
    int ans, n, e0 = 0, e1 = 0, o0 = 0, o1 = 0;
    string s;
    cin >> s;

    n = s.length();

    for(int i = 0;i < n;i++){
        if(i % 2 == 0){
            if(s[i] == '0'){
                e0++;
            }
            else{
                e1++;
            }
        }
        else{
            if(s[i] == '0'){
                o0++;
            }
            else{
                o1++;
            }
        }
    }
    
    if(e1 + o0 > e0 + o1){
        ans = e0 + o1;
    }
    else{
        ans = e1 + o0;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc167/abc167_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  ll K;
  cin >> N >> K;

  vector<int> c(N);
  rep(i, N) {
    cin >> c[i];
    c[i]--;
  }

  vector<int> a(N, -1);
  // 街iに何回目に訪れたか
  vector<int> fin(N, -1);

  a[0] = 0;
  fin[0] = 0;

  int s = -1, e = -1;

  repi(i, 1, N) {
    int next = c[a[i - 1]];
    a[i] = next;
    if (fin[next] != -1) {
      // 閉路があった
      s = fin[next];
      e = i;
      break;
    } else {
      fin[next] = i;
    }
  }

  // printf("%d %d\n", s, e);
  // print_vec(a);

  // ループの開始位置で判定
  int n = 0;
  if (s != -1) {
    if (K <= s) {
      n = K;
    } else {
      ll k = K - s;
      int lp = e - s;
      n = (k % lp) + s;
    }
  } else {
    // ループがないケース？
    n = N % K;
  }

  ll ans = a[n] + 1;
  cout << ans << endl;
}

Measured memory_bytes: 5576
#include <iostream>
#include <cmath>
using namespace std;
#define MaxN 100010
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
typedef long long LL;
typedef pair<int,int> PII;
typedef unsigned long long ULL;
int main(){
	LL n;
	cin>>n;
	cout<<(LL)(ceil(1.0*n/1000)*1000)-n<<endl;
	return 0;
}

Measured memory_bytes: 3260
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t
#include <math.h>

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 200000
#define ELEM_MAX 1000000

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    fget_array(arr, num);

    static int map[ELEM_MAX+1];
    int i;
    for(i = 0; i < num; i++) {
        map[arr[i]]++;
    }
    int ans = 0;
    if(map[1]==1) {
        ans = 1;
        goto finish;
    } else if (map[1] > 1) {
        ans = 0;
        goto finish;
    }

    int d;
    int cnt = 0;
    // assume that a[i] > 1 for all i
    for(i = 0; i < num; i++) {
        int val = arr[i];
        int val_2 = sqrt(0.5 + val);
        int flag = 0;
        if(map[val]>1) flag = 1;
        for(d = 2; d <= val_2; d++) {
            if(val%d) continue;
            if(map[d]) flag = 1;
            if(map[val/d]) flag = 1;
            if(flag) break;
        }
#ifdef DEBUG
        printf("%d -> flag: %d\n", i, flag);
#endif
        cnt += flag;
    }
    ans = num-cnt;
finish:
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 6732
#include<iostream>
#include<cmath>

double toDegree(double a){
	return M_PI / 180 * a;
}

int main(){
	const double R = 6378.1;
	double a, b, c, d;
	while(std::cin >> a >> b >> c >> d, a != -1){
		//弧度法に変換
		a = toDegree(a);
		b = toDegree(b);
		c = toDegree(c);
		d = toDegree(d);
		double delta_x = d-b,
			dist = R*acos(sin(a)*sin(c)+cos(a)*cos(c)*cos(delta_x));
		std::cout << static_cast<int>(dist+0.5) << std::endl;
	}
}

Measured memory_bytes: 1288
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main(){
	string str;
char x[82];
int s=0;
int d=1;int p=0;
//while(scanf("%s",x)!=EOF){
while(cin>>str){
	for(int i=0;i<str.size();i++){
//int T=x[i]-'0';
	int T=str[i]-'0';
	
	if(T>=0&&T<=9){
p*=10;
p+=T;
//d*=10;
//printf("%d\n",i);
}
else{s+=p;p=0;d=1;}

}
s+=p;p=0;
}
printf("%d\n",s);

return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    ll m = 0;
    int n = s.length();
    rep(i,n) m += (s[i]-'0');
    if (m % 9 == 0) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 3748
n=int(input())
v_list=list(map(int,input().split(" ")))

v_sorted=sorted(v_list, reverse=False)

ans = 0
for i in range(n):
  if i == 0:
    ans=v_sorted[i]
  else:
    ans=(ans + v_sorted[i])/2
    
print(ans)

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

int main() {
    int n;
    string s;
    cin >> n >> s;

    auto rpos = vector<int>();
    auto gpos = vector<int>();
    auto bpos = vector<int>();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R')
            rpos.emplace_back(i);
        if (s[i] == 'G')
            gpos.emplace_back(i);
        if (s[i] == 'B')
            bpos.emplace_back(i);
    }

    auto sum = rpos.size() * gpos.size() * bpos.size();
    auto badsum = 0LL;

    for (int step = 1; step <= n / 2; ++step) {
        for (int i = 0; i < n; ++i) {
            int j = i + step;
            int k = j + step;
            if (k >= n)
                break;

            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k])
                ++badsum;
        }
    }

    cout << (sum - badsum);
    return 0;
}


Measured memory_bytes: 3656
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		// 計算
		int result = ((n+m)*(n+m-1)/2) - n*m;
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    int lM = 1;
    int rm = N;
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        lM = max(a,lM);
        rm = min(b,rm);
    }
    cout<<max(rm-lM+1,0)<<endl;
}

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

int main() {
    int A,B;
    int ans;

    cin >> A >> B;
    if( A >= 13) {
        ans = B;
    } else if(A >= 6) {
        ans = B / 2;
    } else {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

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

signed main() {
#ifdef LOCAL
  assert(freopen("b.in", "r", stdin));
#endif
  int n;
  cin >> n;
  vector<string> g(n);
  for (int i = 0; i < n; ++i) {
    cin >> g[i];
  }
  int res = -1;
  for (int s = 0; s < n; ++s) {
    vector<int> q{s};
    vector<int> dist(n, -1);
    dist[s] = 0;
    bool fail = false;
    for (int ii = 0; ii < (int) q.size(); ++ii) {
      int u = q[ii];
      for (int v = 0; v < n; ++v) {
        if (g[u][v] == '0') {
          continue;
        }
        if (dist[v] != -1) {
          if (abs(dist[v] - dist[u]) != 1) {
            fail = true;
          }
          continue;
        }
        dist[v] = dist[u] + 1;
        q.push_back(v);
      }
    }
    if (!fail) {
      res = max(res, *max_element(dist.begin(), dist.end()) + 1);
    }
  }
  cout << res << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,n=0;
	cin>>a>>b;
	if(a==b)
	n=a+b;
	else
	n=max(a,b)+max(a,b)-1;
	cout<<n;
	return 0;
 } 

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

int main() {
  int a,b,c;cin>>a>>b>>c;
  if (c>=a-b) {
    cout<<c-(a-b)<<endl;
  }
  else {
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int x, y; cin >> x >> y;
    rep(tsuru, x+1) {
        int kame = x-tsuru;
        if ((tsuru*2 + kame*4)==y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout <<"No" << endl;
    return 0;
}

Measured memory_bytes: 3616
n = int(input())
l = list()
c = 0
for i in range(n):
    a, b = map(int, input().split())
    l.append([a, b])
for i in range(n - 1):
    for j in range(i + 1,n):
        c += ((l[i][0] - l[j][0]) ** 2 + (l[i][1] - l[j][1]) ** 2) ** 0.5
print(c * 2 / n)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int x;
	cin>>x;
	if(x>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main(void){
    int n, l, big=0, i=0, all=0;
    int len[10];
        cin >> n;
    for(i=0;i<n;i++){
        cin >> l;
        len[i]=l;
        all=all+len[i];
        if(big<l){
            big=l;
        }
    }
    all=all-big;
    if(big<all){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;




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

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

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

	if (m == 1) {
		cout << 2 * a[n - 1] << endl;
		return 0;
	}
	if (m == 1LL * n * n) {
		cout << 2 * n* sum[n] << endl;
		return 0;
	}

	ll r = 2 * a[0];
	ll l = 2 * a[n - 1];
	ll mid = (r + l) / 2;

	ll ans = 0;
	while (r != mid || ans == 0) {
		int j = n - 1;
		ll cnt = 0;
		ll s = 0;
		for (int i = 0; i < n;i++) {
			while (j >= 0) {
				if (mid <= a[i] + a[j]) {
					j--;
				}
				else {

					break;
				}

			}

			cnt += (n - 1 - j);


			s += (sum[n] - sum[j + 1]) + (n - 1 - j) * a[i];



		}




		if (cnt >= m) {
			r = mid;
			ans = s - mid * (cnt - m);
		}
		else {
			l = mid;
		}
		mid = (r + l) / 2;

	}


	cout << ans << endl;

}



Measured memory_bytes: 1920
#include<stdio.h>
int main()
{
  int r0,w0,c,r;
  double now;
  int result;
  while(1)
    {
      scanf("%d%d%d%d",&r0,&w0,&c,&r);
      if((r0==0)&&(w0==0)&&(c==0)&&(r==0)) break;
      now=(double)r0/(double)w0;
      for(result=0;(double)c>now;result++)
	{
	  r0+=r;
	  now=(double)r0/(double)w0;
        }
      printf("%d\n",result);
    }
  return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
vector<LL> v;
int main(){
    int N;
    cin>>N;
    REP(i,N){
        LL a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end(),std::greater<LL>());
   // REP(i,N){
   //     cout<<v[i]<<"a"<<endl;
   // }
    int check=N-1;
    REP(i,N-1){
        //端を判定
        if(v[i+1]<i+2){
           check=i;
           break;
        }
    }
    LL t=(v[check]-check-1);
    LL l=0;
    for(int i=check+1;i<N;i++){
        if((check+1)!=v[i])break;
        l++;
    }
//cout<<check<<t<<l;
    if(t%2==0&&l%2==0){
       cout<<"Second"<<endl;
    }else{
       cout<<"First"<<endl;
    }

}

Measured memory_bytes: 1400
N,M=map(int,input().split())

limit=pow(10,9)+7
#print(limit)
A=list(map(int,input().split()))
B=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)

A.append(-1)
B.append(-1)

answer=1
possibleA=0
possibleB=0

for i in range(N*M,0,-1):
  if i==A[possibleA] and i==B[possibleB]:
    possibleA+=1
    possibleB+=1
  elif i==A[possibleA]:
    answer*=possibleB
    possibleA+=1
  elif i==B[possibleB]:
    answer*=possibleA
    possibleB+=1
  else:
    answer*=(possibleA*possibleB-(N*M-i))
  answer=answer%limit

print(answer)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e12;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;


int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    int cnt = 1, ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(v[i] != cnt)
            ans++;
        else
            cnt++;
    }
    if(ans == n)
        cout << -1;
    else
        cout << ans;
    return 0;
}

Measured memory_bytes: 1792
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
long long n,d;
long long a[300005];
long long dp[2][300005];
int main()
{
	long long res=0;
	scanf("%lld%lld",&n,&d);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		res+=a[i];
	}
	res+=d*(n-1);
	dp[0][1]=a[1];
	for(long long i=2;i<=n;i++)
	{
		dp[0][i]=min(dp[0][i-1]+d,a[i]);
	}
	dp[1][n]=a[n];
	for(long long i=n-1;i>=1;i--)
	{
		dp[1][i]=min(dp[1][i+1]+d,a[i]);
	}
	for(long long i=2;i<n;i++)
	{
		res+=min(dp[0][i],dp[1][i]);
		//cout<<dp[0][i]<<" "<<dp[1][i]<<endl;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
    set<char> s;
    int N;
    
    cin>>N;
	
    for(int i = 0; i < N; i++){
        char c;
        cin>>c;
        
        s.insert(c);
    }
    
    if(s.size() == 3) cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
	
	return 0;
}

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

#define ll long long int

const int mod=1e9+7;

ll p(ll a,ll b){
	a%=mod;
	ll res=1;
	while(b){
		if(b&1)	res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

vector<ll> d,f;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			d.emplace_back(i);
			if(i*i!=n)
				d.emplace_back(n/i);
		}
	}
	sort(d.begin(),d.end());
	ll ans=0;
	for(int i=0;i<d.size();i++){
		f.emplace_back(p(k,(d[i]+1)/2));
		for(int j=0;j<i;j++)
			if(d[i]%d[j]==0)
				f[i]=f[i]-f[j]+mod;
		f[i]%=mod;
		if(d[i]%2==0)
			ans=(ans+d[i]*f[i]%mod*p(2,mod-2))%mod;
		else
			ans=(ans+d[i]*f[i])%mod;
	}
	cout<<ans<<endl;

}


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

typedef long long int llint;

int main()
{
  int a, b;
  string s;
  cin>> a >> b >> s;

  bool flg = true;

  for(int i = 0; i < a + 1 + b; i++) {
    if(i == a) {
      if(s[a] != '-') flg = false;
    } else if(s[i] < '0' || '9' < s[i]) {
      flg = false;
    }
  }

  cout<< (flg ? "Yes" : "No") <<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k; cin >> n >> m >> k;

	rep(i, m + 1)rep(j, n + 1) {
		if (i * (n - j) + j * (m - i) == k) {
			puts("Yes");
			return 0;
		}
	}

	puts("No");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.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 pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

bool used[100001];
int main(){
    int k;
    cin>>k;
    deque<pint> dq;
    dq.push_back(mp(1,1));
    while(!dq.empty()){
        pint pi=dq.front();dq.pop_front();
        if(pi.first==0){
            cout<<pi.second<<endl;
            return 0;
        }
        used[pi.first]=true;
        if(!used[(pi.first+1)%k]){
            dq.push_back(mp((pi.first+1)%k,pi.second+1));
        }
        if(!used[pi.first*10%k]){
            dq.push_front(mp(pi.first*10%k,pi.second));
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int a,b,c;cin >> a >> b >> c;
    cout << (a+b >= c?"Yes":"No") << endl;   
    return 0;
}

Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		int a = 0;
		int b = 0;
		int c = 0;
		int answer = 0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] result = str.split(" ");

		a = Integer.parseInt(result[0]);
		b = Integer.parseInt(result[1]);
		c = Integer.parseInt(result[2]);

		for (int i = a; i <= b; i += 1) {
			if (c % i == 0) {
				answer++;
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 24384
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll mod=1000000007;
int main()
{
	fast;
	int n;cin>>n;
	string s;cin>>s;
	for(int i=0;i<s.length();i++)
	{
		cout<<(char)((s[i]-'A'+n)%26+65);
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll A,B,C,D; cin>>A>>B>>C>>D;
  ll t=0, a=0;
  t = C/B;
  if (C%B)
    t++;
  a = A/D;
  if(A%D)
    a++;
  if(t<=a)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("out2.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n;
		string s;
		cin >>s;
		string ss,sss;
		for(int i =0 ;i < n /2;i++)ss+=s[i];
		for(int i =n/2;i<n;i++)sss+=s[i];
		if(n&1)cout<<"No\n";
		else if(ss ==sss)cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    cout.precision(10);
    cout << (double)(n-n/2)/(double)n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool use[51][51],vi[51]; 
int n,m,a,b,ans=0;
void dfs(int v){
    vi[v]=true;
    for(int i=0;i<m;i++){
        if(use[v][i]==false){continue;}
        if(vi[i]==true){continue;}
        dfs(i);
    }
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    vector<int> G[n];
    vector<pair<int,int>> p(m);
    bool bo;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        p[i]=make_pair(a,b);
        use[a][b]=true;
        use[b][a]=true;
    }
    for(int i=0;i<m;i++){
        bo=false;
        int A=p[i].first,B=p[i].second;
        use[A][B]=false;
        use[B][A]=false;
        for(int i=0;i<n;i++){vi[i]=false;}
        dfs(0);
        for(int i=0;i<n;i++){if(vi[i]==false){bo=true;}}
        if(bo){ans++;}
        use[A][B]=true;
        use[B][A]=true;
    }
    cout<<ans;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.reverse()
a.append(0)
a.reverse()
a.append(0)
totalprice=0
for i in range(n+2):
  totalprice+=abs(a[i]-a[i-1])
for i in range(1,n+1):
  print(totalprice-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))

  

Measured memory_bytes: 63980
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

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


int n;
int a[101010];
int dp[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < n; i++) dp[i] = INF;
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		chmin(dp[i+1], dp[i]+abs(a[i]-a[i+1]));
		chmin(dp[i+2], dp[i]+abs(a[i]-a[i+2]));
	}
	
	cout << dp[n-1] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))
#define MAX_A 1000000 + 1

int sum_array(vi &C, int start, int end, int step){
	int c = 0;
	rpd(i, start, end, step) c += C[i];
	return c;
}

int main(){
	int N; cin>>N;
	vi C(MAX_A, 0);
	int g = 0;
	rpd(i, 0, N, 1){
		int a; cin>>a;
		C[a]++;
		g = gcd(g, a);
	}
	int t = 0;
	if(sum_array(C, 2, MAX_A, 2) > 1) t = 1;
	else
		rpd(i, 3, MAX_A, 2) if(sum_array(C, i, MAX_A, i) > 1){
			t = 1;
			break;
		}
	if(t == 1 && g != 1) t = 2;
	cout<< vector<string>{"pairwise","setwise","not"}[t] <<" coprime\n";
}


Measured memory_bytes: 7224
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

string s;

int main()
{
	cin >> s;
	if (s[0] == s[1] && s[0] == s[2] ||
		s[1] == s[2] && s[1] == s[3]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
H,W=map(int, input().split())
one = ""
for i in range(W+2):
  one = one + "."
S_map = [one]
for i in range(H):
  s = str(input())
  S_map.append("."+s+".")
S_map.append(one)

for i in range(1,1+H):
  count = ""
  for k in range(1,1+W):
    if S_map[i][k] == "#":
      count = count + "#"
    else:
      check_map=S_map[i-1][k-1:k+2]+S_map[i+1][k-1:k+2]
      check_map=check_map+S_map[i][k-1]+S_map[i][k+1]
      count = count + str(len([1 for check in check_map if check=="#"]))
  print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int ans[10500];

void AddReciprocal(int x){
	int t=1;
	REP(i,0,10200){
		if(!t) break;
		ans[i]+=t/x;
		t%=x;
		t*=10;
	}
}

void CarryUp(){
	for(int i=10199; i>=0; --i){
		ans[i-1]+=ans[i]/10;
		ans[i]%=10;
	}
}

void Solve(){
	int n,m,k,r;
	while(true){
		cin >> n >> k >> m >> r;
		if(n+m+k+r==0) break;

		fill(ans,ans+10500,0);
		AddReciprocal(n);
		if(m==1){
			REP(i,1,n){
				AddReciprocal(i*n);
			}
		}
		CarryUp();
		
		cout << ans[0] << '.';
		REP(i,1,r+1) cout << ans[i];
		cout << endl;
	}
}

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

Measured memory_bytes: 1240
import sys

N,Y = map(int,input().split())

for a in range(N+1):
    for b in range(N-a+1):
        c = N - a - b
        if 10000 * a + 5000 * b + 1000 * c == Y:
            print(a,b,c)
            sys.exit()

print("-1 -1 -1")

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

ll powll(ll a,ll n){
  if(n==0)
  {
    return 1;
  }
  return powll(a,n-1)*a;
}


int main() {
   ll i,j,k;
   ll x,ans=0;
   cin >>x; 
   
   ans+=(x/500)*1000;
   x%=500;
   ans+=(x/5)*5;
   cout<<ans  <<endl;
}

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

int main() {
    int N;
    cin >> N;
    
    vector<string> S(N + 1);
    cout << 0 << endl;
    string str;
    cin >> str;
    if (str == "Vacant") return 0;
    S[0] = str;
    S[N] = str;
    int left = 0;
    int right = N;
    while (true) {
        int mid = (right + left) / 2;
        cout << mid << endl;
        cin >> str;
        if (str == "Vacant") return 0;
        S[mid] = str;
        if ((mid - left) % 2 == 0) {
            if (S[left] == S[mid]) left = mid;
            else right = mid;
        } else {
            if (S[left] != S[mid]) left = mid;
            else right = mid;
        }
    }
    return 0;
}


Measured memory_bytes: 1620
from collections import Counter

n = int(input())
nlist=[]
for i in range(n):
  nlist.append(input())
m = int(input())
mlist = []
for j in range(m):
  mlist.append(input())
cn = Counter(nlist)
cm = Counter(mlist)
csum = cn-cm
if not csum.most_common():
  print(0)
else:
  print(csum.most_common()[0][1])

Measured memory_bytes: 3316
import sys

N, M = map(int, input().split())
A = list(map(int, input().split()))
p = [(A[i], 1) for i in range(N)]

for line in sys.stdin:
    B, C = map(int, line.split())
    p.append((C, B))

p.sort(reverse=True)

ans, remainingCardsToChoose = 0, N
for cardValue, availableCardCount in p:
    chooseCount = min(availableCardCount, remainingCardsToChoose)
    ans += chooseCount * cardValue
    remainingCardsToChoose -= chooseCount

print(ans)


Measured memory_bytes: 31020
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n = int(input())
    A = list(map(int, input().split()))

    A.sort()
    A.reverse()
    a = A[0::2]
    b = A[1::2]
    print(sum(a) - sum(b))


if __name__ == '__main__':
    main()


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

int main(){
  string s;
  cin >> s;
  int l = stoi(s.substr(0,2)), r = stoi(s.substr(2,2));
  if(l > 0 and l <= 12 and r > 0 and r <= 12) cout << "AMBIGUOUS" << endl;
  else if(l > 0 and l <= 12) cout << "MMYY" << endl;
  else if(r > 0 and r <= 12) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


Measured memory_bytes: 256
# set
h = gets.chomp.to_i
chk_binary = 1
chk_multiplier = 0 
attack_count = 0

# main
loop do
  break if h < chk_binary
  chk_multiplier += 1
  chk_binary *= 2
end

0.upto(chk_multiplier - 1) do |i|
  attack_count += 2 ** i
end

print ("#{attack_count}\n")

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    long x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x = -x;
    if (x / d >= k) {
        cout << x - d * k << endl;
    } else {
        k -= x / d;
        x %= d;
        if ((k&1) == 1) {
            cout << d - x << endl;
        } else {
            cout << x << endl;
        }
    }
}


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

ll pot(ll a, ll b){
	ll r=1;
	while(b>0){
		if(b%2==1){
			r=(r*a)%N;
		}
		a=(a*a)%N;
		b>>=1;
	}
	return r;
	
}
int main() {
	ll x;
	cin>>x;
	ll d=pot(10,x);
	ll m=pot(8,x);
	ll p=(2*pot(9,x))%N;
	ll s=(m+d)%N;
	cout<<(s-p+N)%N;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test long int t;cin>>t; while(t--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll a,b,k;
        cin>>a>>b>>k;
        if(a>=k)
        {
        	a-=k;
        }
        else
        {
        	k=k-a;
        	a=0;
        	if(b>=k)
        	{
        		b=b-k;
        	}
        	else
        	{
        		b=0;
        	}
        }
        cout<<a<<" "<<b<<"\n";
        return 0;
}



Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  double ans;
  double a, b, x;
  cin >> a >> b >> x;
  double y = b - (x / a) / a;
  if (2 * y < b)
  {
    ans = atan(2 * y / a) * 180 / acos(-1);
  }
  else
  {
    ans = atan(a * b * b / (2 * x)) * 180 / acos(-1);
  }
  printf("%.10f\n", ans);
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int i,j,n,num;
    int c[4][13]={};
    char pi;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("\n%c %d",&pi,&num);
        switch(pi){
            case 'S':
                c[0][num-1]=1;
                break;
            case 'H':
                c[1][num-1]=1;
                break;
            case 'C':
                c[2][num-1]=1;
                break;
            case 'D':
                c[3][num-1]=1;
                break;
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(c[i][j]==0){
                if(i==0)
                    printf("%c %d\n",'S',j+1);
                else if(i==1)
                    printf("%c %d\n",'H',j+1);
                else if(i==2)
                    printf("%c %d\n",'C',j+1);
                else
                    printf("%c %d\n",'D',j+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int M,D;
  cin >> M >> D;
  int count = 0;
  for(int i = 1; i <= M; i++){
  	for(int j = 1; j <= D; j++){
    	int d_one = j % 10;
      	int d_ten = (j - d_one) / 10;
      	if(d_one >= 2 && d_ten >= 2 && i == d_one * d_ten){
        	count++;
        }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long a,ans,b,c,z;
	cin>>a>>ans>>z>>b>>c>>z>>z;
	long long cnt=0,dnt=0;
	dnt+=a/2*2;
	dnt+=b/2*2;
	dnt+=c/2*2;
	if(a&&b&&c){
		cnt+=3;
		a--,b--,c--;
	}
	cnt+=a/2*2;
	cnt+=b/2*2;
	cnt+=c/2*2;
	cout<<ans+max(cnt,dnt)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10
const int MAX_N =10000000;


bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll par[MAX_N],ranking[MAX_N];

void init(ll n){
    rep(i,n){
        par[i]=i;
        ranking[i]=0;
    }
}

ll find(ll x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(ranking[x]<ranking[y]) par[x]=y;
    else{
        par[y]=x;
        if(ranking[x]==ranking[y]) ranking[x]++;
    }
}

bool same(ll x,ll y){
    return find(x)==find(y);
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=0;
    cin>>n;
    
    vector<ll> a(100000,0);
    rep(i,n){
        ll b;
        cin>>b;
        sum+=b;
        a[b]++;
    }
    ll q;
    cin>>q;
    rep(i,q){
        ll f,b;
        cin>>f>>b;
        sum+=(b-f)*a[f];
        a[b]+=a[f];
        a[f]=0;
        cout<<sum<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3988
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;



int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i = k+1;i <= n;i++) {
        int l = i - k;
        int m = n / i;
        ans += l * m;
        ans += max(0LL,n % i - (k-1));
    }
    if(k==0)ans=n*n;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
using static ConsoleReader;

class Program
{
    static void Main(string[] args)
    {
        var x = Read<int>();
        var y = Read<int>();
        var isOk = false;
        (x + 1).Times(cranes => {
            var turtles = x - cranes;
            if (turtles * 4 + cranes * 2 == y)
            {
                isOk = true;
            }
        });
        Console.WriteLine(isOk ? "Yes" : "No");
    }
}

public static class IntExtentions
{
    public static void Times(this int n, Action<int> action)
    {
        for (var i = 0; i < n; i++)
        {
            action(i);
        }
    }

    public static void Times(this (int n, int m) dimensions, Action<int, int> action)
    {
        var (n, m) = dimensions;
        n.Times(i => m.Times(j => action(i, j)));
    }
}

public static class ConsoleReader
{
    public static T Read<T>()
        where T : IConvertible
    {
        var inputBuffer = new StringBuilder();
        int currChar;

        while ((currChar = Console.Read()) != -1)
        {
            if (!char.IsWhiteSpace((char)currChar))
            {
                inputBuffer.Append((char)currChar);
            }
            else if (inputBuffer.Length != 0)
            {
                break;
            }
        }

        return (T)Convert.ChangeType(inputBuffer.ToString(), typeof(T));
    }

    public static T[] ReadArray<T>(int count)
        where T : IConvertible
    {
        if (count < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(count), $"'{nameof(count)}' must be >= 0");
        }

        var result = new T[count];

        for (var i = 0; i < count; i++)
        {
            result[i] = Read<T>();
        }

        return result;
    }
}

Measured memory_bytes: 27564
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int w, n;
	int a, b;
	cin >> w >> n;
	int *W = new int[w];
	for (int i = 0; i < w; i++)
		W[i] = i + 1;

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

	for (int i = 0; i < w; i++)
		cout << W[i] << endl;

	delete[] W;
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int h=0,w=0;
  char a[101]={};
  scanf("%d %d",&h,&w);
  for (size_t i = 0; i < w+2; i++) {
    printf("#");
  }
  printf("\n");
  for (size_t i = 0; i < h; i++) {
    printf("#");
    scanf("%s",a);
    for (size_t j = 0; j < w; j++) {
      printf("%c",a[j]);
    }
    printf("#\n");
  }
  for (size_t i = 0; i < w+2; i++) {
    printf("#");
  }
  return 0;
}


Measured memory_bytes: 128