akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/rope"
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
#define lambdify(x) [&](auto &&...args){ return x(forward<decltype(args)>(args)...); }
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i];
	}
	vector<long long> pref(n + 1);
	for(auto i = 0; i < n; ++ i){
		pref[i + 1] = pref[i] + a[i];
	}
	long long res = numeric_limits<long long>::max();
	for(auto i = 1; i < n; ++ i){
		ctmin(res, abs(pref[i] - (pref[n] - pref[i])));
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  int i, result[127];
  char moji;
  
  for(i=0;i<127;i++) result[i]=0;

  while(1){
    if( scanf("%c",&moji)==EOF) break;
    result[moji]++;
  }

  for(i=0;i<26;i++) printf("%c : %d\n",i+97,result[i+65]+result[i+97]);
  
  return 0;
}



Measured memory_bytes: 2136
#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(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int 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[]) {
    ll n; cin>>n;
    ll v = 0, s = 0;
    ll e = 0;
    rep(i,n) {
        s += (i+1);
        v += s;
    }

    rep(i,n-1) {
        ll a,b; cin>>a>>b;
        if (a > b) swap(a,b);
        ll tmp = a * (n-b+1);
        e += tmp;
    }

    cout << v-e << '\n';
    return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <tuple>
#include <numeric>
#include <functional>
#include <algorithm>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAX = 2e5 + 5;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

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

	printf("%d", min(a + b + 1, c) + b);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
  int N;
  std::cin >> N;
  int flag = 0;
  for (int i=0; i<N+1; i +=4 ) {
    for (int j=0; j+i<N+1; j += 7) {
      if (i+j == N) {
        flag=1;
        break;
      }
    }
    if (flag) {
      break;
    }
  }
  if (flag) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
}

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

const int INF = 1e9;
const int MAX_N = 3010, MAX_E = 10000;
int n, m; //????????° ???????????¬??°
vector<pair<int, int> > G[MAX_N];//??°???????????¨?????£??\????????? fi:to se:cost
int d[MAX_N]; //s?????????????????????
typedef pair<int, int> P;//first??????????????¢,second??????????????????
int k; vector<int> shop;//???????¨????

void dijkstra(void){
	priority_queue<P, vector<P>, greater<P> > que;//first????°?????????????
    rep(i, n)d[i] = INF;//?????????
    
    //k????????????????????°????????????
    for(auto i : shop){
    	d[i] = 0;
    	que.push(make_pair(0, i));
    }
  
    while(!que.empty()){
       	auto p = que.top(); que.pop();
       	int v = p.second;
       	if(d[v] < p.first) continue;
       	for(auto e : G[v]){//e.fi:??£??\??????????????????????????? e.se:?????????????????§????????????
       		if(d[e.first] > d[v] + e.second){//???????????¢?????´??°???????????¨???
       			d[e.first] = d[v] + e.second;
       			que.push(make_pair(d[e.first], e.first));
       		}
       	}
    }
}

int main(void){
    cin >> n >> m >> k;
    rep(i, m){
        int a, b, l; cin >> a >> b >> l;
        a--; b--;
       	G[a].push_back(make_pair(b, l)); G[b].push_back(make_pair(a, l));
    }
    rep(i, k){
    	int s; cin >> s; s--;
    	shop.push_back(s);
    }
    dijkstra();//????????????????????????????°?????????????
    //?????????????????¶????????????????°?????????????
    double ans = 0.0;
    //??????????????????????????¢????????¨???????????????????????¶???????????´?????????????????????????????¢?????????
    // rep(i, n) printf("%d\n", d[i]);
   	for (int x = 0; x < n; ++x){
   		for(auto y : G[x]){
   			if(d[x] == 0 || d[y.first] == 0) continue;
   			double tmp = (d[x] + d[y.first] + y.second) / 2.0;//+1????????¨?????\??¨
   			ans = max(tmp, ans);
   		}
   	}
   	cout << round(ans) << endl;
   	return 0;
}

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

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> s(H);
	vector<int> cnt(H);
	for (int i = 0; i < H; i++) {
		cin >> s[i];
		cnt[i] = count(s[i].begin(), s[i].end(), '#');
	}
	int it = 1;
	vector<vector<int>> A(H, vector<int>(W));
	for (int i = 0; i < H; ) {
		int lb = i;
		while (i < H && cnt[i] == 0) ++i;
		++i;
		while (i < H && cnt[i] == 0) ++i;
		int ub = i;
		vector<int> sum(W);
		for (int j = 0; j < W; j++) {
			int cc = 0;
			for (int k = lb; k < ub; k++) {
				cc += s[k][j] == '#';
			}
			sum[j] = cc;
		}
		for (int j = 0; j < W;) {
			int l2 = j;
			while (j < W && sum[j] == 0) ++j;
			++j;
			while (j < W && sum[j] == 0) ++j;
			int r2 = j;
			for (int x = lb; x < ub; x++) {
				for (int y = l2; y < r2; y++) {
					A[x][y] = it;
				}
			}
			++it;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << A[i][j] << " \n"[j + 1 == W];
		}
	}
	return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <string>

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s = buf;

  for (size_t i = 0; i < s.length(); i += 2)
    if (s[i] == 'L') return puts("No"), 0;
  for (size_t i = 1; i < s.length(); i += 2)
    if (s[i] == 'R') return puts("No"), 0;

  puts("Yes");
}


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

signed main(){
  string S;
  cin>>S;
  if(S=="Sunny")cout<<"Cloudy"<<endl;
  if(S=="Cloudy")cout<<"Rainy"<<endl;
  if(S=="Rainy")cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  // input
    int n,m;cin >> n >> m;
    vector<int> k(n + 1);
    vector<vector<int>> a(n + 1, vector<int>(m + 1));
    for(int i = 1;i < n + 1; i++) {
        for(int j = 1; j < m + 1 ; j++){
            a[i][j] = 0;
        } 
    }

    for(int i = 1;i < n + 1 ; i++) {
        cin >> k[i];
        for(int j = 1; j < k[i] + 1; j++){
            cin >> a[i][j];
        } 
    }

  // compute 
    int ans = 0;
    vector<int> suki(m + 1);
    for(int i = 1;i < m + 1; i++) {
            suki[i] = 0;       
    }

    for(int i = 1;i < n + 1; i++) {
        for(int j = 1; j < k[i] + 1 ; j++){
            suki[a[i][j]]++;
        } 
    } 

    for(int i = 1;i < m + 1; i++) {
        if(suki[i] == n){
            ans++;
        }
    }

  // output  
    cout << ans << endl;

}

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

struct point {
  double x;
  double y;
};

int koch(point start, point end, int n, int depth) {
  if (n == depth) {
    cout << start.x << " " << start.y << endl;

    return 0;
  }

  point s, t, u;
  if ((start.y == end.y) && (start.x < end.x)) {
    double lx = (end.x - start.x) / 3;

    s.x = start.x + lx;
    s.y = start.y;

    t.x = start.x + 2 * lx;
    t.y = start.y;

    u.x = start.x + 1.5 * lx;
    u.y = (u.x - s.x) * sqrt(3.0) + start.y;
  }
  else if ((start.x < end.x) && (start.y > end.y)) {
    double lx = (end.x - start.x) / 3;
    double ly = (start.y - end.y) / 3;
    
    s.x = start.x + lx;
    s.y = start.y - ly;

    t.x = start.x + 2 * lx;
    t.y = start.y - 2 * ly;

    u.x = end.x;
    u.y = s.y;
  }
  else if ((start.x > end.x) && (start.y > end.y)) {
    double lx = (start.x - end.x) / 3;
    double ly = (start.y - end.y) / 3;

    s.x = start.x - lx;
    s.y = start.y - ly;

    t.x = start.x - 2 * lx;
    t.y = start.y - 2 * ly;

    u.x = start.x;
    u.y = t.y;
  }
  else if ((start.y == end.y) && (start.x > end.x)) {
    double lx = (start.x - end.x) / 3;

    s.x = start.x - lx;
    s.y = start.y;

    t.x = start.x - 2 * lx;
    t.y = start.y;

    u.x = start.x - 1.5 * lx;
    u.y = start.y - (s.x - u.x) * sqrt(3.0);
  }
  else if ((start.x > end.x) && (start.y < end.y)) {
    double lx = (start.x - end.x) / 3;
    double ly = (end.y - start.y) / 3;

    s.x = start.x - lx;
    s.y = start.y + ly;

    t.x = start.x - 2 * lx;
    t.y = start.y + 2 * ly;

    u.x = end.x;
    u.y = start.y + ly;
  }
  else if ((start.x < end.x) && (start.y < end.y)) {
    double lx = (end.x - start.x) / 3;
    double ly = (end.y - start.y) / 3;

    s.x = start.x + lx;
    s.y = start.y + ly;

    t.x = start.x + 2 * lx;
    t.y = start.y + 2 * ly;

    u.x = start.x;
    u.y = start.y + 2 * ly;
  }

  koch(start, s, n + 1, depth);
  koch(s, u, n + 1, depth);
  koch(u, t, n + 1, depth);
  koch(t, end, n + 1, depth);

  return 0;
}

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

  point start, end;
  start.x = 0;
  start.y = 0;
  end.x = 100;
  end.y = 0;
  koch(start, end, 0, depth);
  cout << end.x << " " << end.y << endl;

  return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
struct mat{
	ll a[3][3];
	friend mat operator *(mat a,mat b){
		mat c;memset(c.a,0,sizeof(c.a));
		for(int i=0;i<3;i++){
			for(int p=0;p<3;p++){
				for(int j=0;j<3;j++) c.a[i][p]=(c.a[i][p]+a.a[i][j]*b.a[j][p])%mod;
			}
		}
		return c;
	}
}dan,dan1;
int n,m,a[100005];
mat quick_pow(mat a,int b){
	mat ans;memset(ans.a,0,sizeof(ans.a));
	ans.a[0][0]=ans.a[1][1]=ans.a[2][2]=1;
	for(;b;b>>=1,a=a*a)
		if(b&1) ans=ans*a;
	return ans;
}
int main(){
	dan.a[0][0]=2;
	dan.a[0][1]=2;
	dan.a[0][2]=1;
	dan.a[1][0]=1;
	dan.a[1][1]=1;
	dan.a[2][0]=1;
	dan.a[2][1]=2;
	dan.a[2][2]=1;
	dan1.a[0][0]=1;
	dan1.a[1][0]=1;
	dan1.a[1][1]=1;
	dan1.a[2][0]=1;
	dan1.a[2][1]=2;
	dan1.a[2][2]=1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
	mat ans;memset(ans.a,0,sizeof(ans.a));
	ans.a[0][0]=ans.a[1][1]=ans.a[2][2]=1;
	for(int i=1;i<=m;i++){
		ans=quick_pow(dan,a[i]-a[i-1]-1)*ans;
		ans=dan1*ans;
	}
	ans=quick_pow(dan,n-a[m]-1)*ans;
	dan.a[0][0]--;
	ans=dan*ans;
	printf("%lld",ans.a[0][0]);
	return 0;
}

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

int main(){
  int A, B;
  cin >> A>> B;
  
  if( A >= 13){
  cout << B << endl;
  }
  else if(6 <= A && A <= 12){
    cout << B/2 << endl;
  }
  else cout << 0 << endl;

}

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

using namespace std;

int main() {
  set<int,greater<int> > w,k;
  int n,i;

  for(i=0;i<10;i++){
    cin >> n;
    w.insert(n);
  }
  for(;i<20;i++){
    cin >> n;
    k.insert(n);
  }
  
  int total_w=0,total_k=0;
  set<int>::iterator it;
  for(it=w.begin(),i=0;i<3;i++,it++){
    total_w += *it;
  }
  
  for(it=k.begin(),i=0;i<3;i++){
    total_k += *it++;
  }
  cout << total_w << " " << total_k << endl;
  
  return 0;
}

Measured memory_bytes: 2976
import itertools

h, w, k = map(int, input().split())

dp = [[0] * w for _ in range(h + 1)]
dp[0][0] = 1

bits = []
for r in range(w + 1):
    for bit in itertools.combinations(range(w - 1), r):
        if all(y - x > 1 for x, y in zip(bit, bit[1:])):
            bits.append(bit)

mod = 10 ** 9 + 7

for i in range(h):
    for j in range(w):
        for bit in bits:
            if j in bit:
                dp[i + 1][j + 1] += dp[i][j]
                dp[i + 1][j + 1] %= mod
            elif (j - 1) in bit:
                dp[i + 1][j - 1] += dp[i][j]
                dp[i + 1][j - 1] %= mod
            else:
                dp[i + 1][j] += dp[i][j]
                dp[i + 1][j] %= mod

print(dp[h][k - 1])



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

using namespace std;
typedef long long ll;
#define int ll

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; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }
template <typename T> T lcm(T a, T b) { return a / gcd(a,b) * b; }

map<ll, ll> PrimeFactor(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++res[i];
            n /= i;
        }
        if(LLINF / i <= i) { break; }  // オーバーフロー警察
    }
    if(n != 1) { res[n] = 1; }
    return res;
}

int N, M;
vector<int> A, B;

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

    cin >> N >> M;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
        A[i] /= 2;
    }

    // 何回 2 で割れるか
    auto Check = [](int num) {
        int ret = 0;
        while(num % 2 == 0) {
            num /= 2;
            ret++;
        }
        return ret;
    };
    // 2 の個数チェック
    int check = Check(A[0]);
    REP(i, N) {
        if(check != Check(A[i])) {
            printf("0\n");
            return 0;
        }
        A[i] >>= check;
    }

    M >>= check;

    int lcm_a = 1; 
    REP(i, N) {
        lcm_a = lcm(lcm_a, A[i]);
    }

    int ans = M / lcm_a;
    ans = (ans + 1) / 2;

    printf("%lld\n", ans);

    return 0;
}


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

const int N = 2e5+10;
int p[N];
int find(int x) {return p[x] < 0 ? x : p[x] = find(p[x]);}
int par[N], value[N];

struct frac {
    int top, bottom;
};

bool operator< (const frac &i, const frac &j) {
    return 1LL*i.top*j.bottom < 1LL*j.top*i.bottom;
}

signed main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    cin >> n;
    fill(p, p+n+2, -1);
    for(int i = 2; i <= n; ++i) {
        cin >> par[i];
    }
    set<pair<frac, int>> st;
    vector<frac> fractions(n+1);
    for(int i = 1; i <= n; ++i) {
        cin >> value[i];
        frac curr = {1-value[i], value[i]};
        fractions[i] = curr;
        st.insert({curr, i});
    }
    ll res = 0;
    for(int i = 1; i <= n || st.size(); ++i) {
        auto it = st.end();
        //assert(it != st.begin());
        --it;
        int node = find(it->second);
        //cout << "\nprocessing node: " << node << '\n';
        int numZeros = it->first.top;
        int numOnes = it->first.bottom;
        st.erase(it);
        if(node == 1) continue;
        int currPar = find(par[node]);
        //assert(node != currPar);
        //cout << "adding: " << value[currPar]*numZeros << " to answer\n";
        res += 1LL*value[currPar]*numZeros;
        st.erase({fractions[currPar], currPar});
        value[currPar] += numOnes;
        //cout << "merging: " << node << ' ' << currPar << '\n';
        p[currPar] += p[node];
        p[node] = currPar;
        fractions[currPar] = {-p[currPar]-value[currPar], value[currPar]};
        //cout << "setting fraction of: " << currPar << " to: " << fractions[currPar].top << ' ' << fractions[currPar].bottom << '\n';
        st.insert({fractions[currPar], currPar});
    }
    cout << res << '\n';
}



























Measured memory_bytes: 16640
#include<stdio.h>
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
string z = "keyence";
int main()
{
	string s;
	for (int i = 0; i < 4; i++)
	{
		char z;
		cin >> z;
		s.push_back(z);
	}
	sort(s.begin(), s.end());
	printf((s=="1479") ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
from math import ceil

D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    tp, tc = map(int, input().split())
    P.append(tp)
    C.append(tc)

ans = float('inf')
for mask in range(1 << D):
    s = 0
    num = 0
    rest_max = -1
    for i in range(D):
        if mask >> i & 1:
            s += 100 * (i + 1) * P[i] + C[i]
            num += P[i]
        else:
            rest_max = i
    if s < G:
        rest_max_point = 100 * (rest_max + 1)
        need = ceil((G - s) / rest_max_point)
        if need < P[rest_max]:
            num += need
        else:
            continue
    ans = min(ans, num)

print(ans)


Measured memory_bytes: 3064
n = int(input())
A = list(map(int, input().split()))
A_j = {}
for i, a in enumerate(A):
    if A_j.get(i - a):
        A_j[i - a] += 1
    else:
        A_j[i - a] = 1

r = 0
for i, a in enumerate(A):
    t = A_j.get(a + i)
    if t:
        r += t

print(r)


Measured memory_bytes: 40360
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	long long int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k;
	}
	else if (k <= a + b) {
		cout << a;
	}
	else {
		cout << a - (k - a-b);
	}

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] cut = line.split("");

		int x = Integer.parseInt(cut[0]);
		int y = Integer.parseInt(cut[1]);
		int z = Integer.parseInt(cut[2]);
		System.out.println(x+y+z);

	}

}

Measured memory_bytes: 21332
// Aizu 0536: Shuffle
// 2017.10.26 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int x1, x2; } TABA;
TABA taba[2][10005]; int sz;
int k1, k2;

int split(int x)
{
	int s, i, k;

	for (s = 0, i = 0; ; i++) {
		k = taba[k1][i].x2 - taba[k1][i].x1 + 1;
		if (s + k == x) return i;
		if (s + k > x) break;
		s += k;
	}

// don't using memcpy() for overlap memory copy on Linux 
//	memcpy(taba[k1]+i+1, taba[k1]+i, sizeof(TABA)*(sz-i)), sz++;
	memmove(taba[k1]+i+1, taba[k1]+i, sizeof(TABA)*(sz-i)), sz++;

	x = (x-s)+taba[k1][i].x1-1;
	taba[k1][i].x2 = x, taba[k1][i+1].x1 = x+1;
	return i;
}

void shuffle(int x, int y)
{
	int i, j, s;

	i = split(x), j = split(y);
	s = 0;
	memcpy(taba[k2],   taba[k1]+j+1, sizeof(TABA)*(sz-j-1)); s += sz - j - 1;
	memcpy(taba[k2]+s, taba[k1]+i+1, sizeof(TABA)*(j-i));    s += j-i;
	memcpy(taba[k2]+s, taba[k1],     sizeof(TABA)*(i+1));
	k1 = k2, k2 = !k2;
}

char buf[130], *pp;
int getInt(void)
{
	int n = 0;
	while (*pp >= '0') n = (n<<3) + (n<<1) + (*pp++ & 0xf);
	return n;
}
int main()
{
	int n, m, p, q, r, x, y;
	int i, ans;

	while (fgets(pp=buf, 128, stdin) && *buf != '0') {
		n = getInt();
		fgets(pp=buf, 128, stdin), m = getInt();
		fgets(pp=buf, 128, stdin), p = getInt(), pp++, q = getInt(), pp++, r = getInt();
		taba[0][0].x1 = 1, taba[0][0].x2 = n, k1 = 0, k2 = 1, sz = 1;
		while (m--) {
			fgets(pp=buf, 128, stdin), x = getInt(), pp++, y = getInt();
			shuffle(x, y);
		}
		x = 0; if (p > 1) x = split(p-1) + 1;
		y = split(q);
		for (ans = 0, i = x; i <= y; i++) {
			if (taba[k1][i].x1 > r) continue;
			if (taba[k1][i].x2 <= r) ans += taba[k1][i].x2 - taba[k1][i].x1 + 1;
			else 			         ans += r - taba[k1][i].x1 + 1;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    ll a, b;
    cin >> a >> b;

    auto x = [](ll in) -> ll {
        if ((in + 1) % 2 == 0) {
            if ((in + 1) % 4 == 0)
                return 0;
            else
                return 1;
        } else {
            if (in % 4 == 0)
                return (0 ^ in);
            else
                return (1 ^ in);
        }
    };

    ll fa = x(a - 1);
    ll fb = x(b);
    print(fa ^ fb);

    return 0;
}

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

int main()
{
  int n,i,a,b,c=0,x,y;
  cin>>n>>a>>b;
  for(i=1;i<=n;i++)
  {
    cin>>x>>y;
    if(x>=a && y>=b)
      c++;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from pprint import pprint


# Digit DP
def solve(N: int):
    s = str(N + 1)
    n = len(s)
    # dp[idx][smaller][started][3][5][7]
    dp = [[[[[[0 for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(n + 1)]
    dp[0][0][0][0][0][0] = 1
    for i in range(0, n):
        for smaller in range(2):
            for started in range(2):
                for i1 in range(2):
                    for i2 in range(2):
                        for i3 in range(2):
                            for nex in [0, 3, 5, 7]:
                                if not smaller and nex > int(s[i]):
                                    #print(i, nex)
                                    continue
                                if started and nex == 0:
                                    continue
                                #print(i, smaller, started, i1, i2, i3)
                                #print(dp[0][0][0][0][0][0])
                                #if not (smaller | nex < int(s[i])):
                                #    print(' --- ')
                                #    print(i, smaller, started, i1, i2, i3, nex, int(s[i]), nex < int(s[i]))
                                #    print(smaller, nex < int(s[i]))
                                #    print(smaller or nex < int(s[i]))
                                #    print(' --- ')

                                #dp[i + 1][smaller | nex < int(s[i])][started | nex > 0][i1 | nex == 3][i2 | nex == 5][i3 | nex == 7] += \
                                dp[i + 1][smaller or nex < int(s[i])][started or nex > 0][i1 or nex == 3][i2 or nex == 5][i3 or nex == 7] += \
                                    dp[i][smaller][started][i1][i2][i3]
        #pprint(dp[i])
        #print()
    ret = dp[n][1][1][1][1][1]
    #pprint(dp[n])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e9
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
ll mod = 1e9 + 7;

long long fast_exp(long long a, long long b)
{
	if(b <= 0)
	   return 1;
	else
	{
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
	}
}

typedef long double ld;




int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	int n,p;
	cin >> n >> p;
	string s;
	cin >> s;
	int a[n];
	//int inv = fast_exp(10,p-2,p);
	for(int i = 0; i<n ; i++)
		a[i] = s[i] - '0';
	int cur = 1;
	for(int i = n-1 ; i>=0 ; i--)
	{
		a[i] = (a[i] * cur) % p;
		cur = (cur * 10) % p;
	}
	int cumul[n+1] = {};
	for(int i = 0; i<n ; i++)
	{
		cumul[i+1] = (cumul[i] + a[i]) % p;
	}
	int freq[100000] = {};
	freq[0] = 1;
	ll count = 0;
	
	if (p != 2 && p != 5)
		for(int i = 1; i<=n ; i++)
		{

			count += freq[(cumul[i] % p)];
			freq[(cumul[i] % p )]++;
		}
		
	else
	{
		if(p == 2)
		{
			for(int i = 0 ; i < n ; i++)
			{
				if((s[i] - '0')%2 == 0)
					count += i+1;
			}
		}
		else
		{
			for(int i = 0 ; i < n ; i++)
			{
				if((s[i] - '0')%5 == 0)
					count += i+1;
			}
		}

	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 2580
def checkbingo(bingo,bs):
  for b in bingo:
    cnt = 0
    for n in bs:
      if n in b:
        cnt +=1
    if cnt == len(b):
      return True
  return False

list1 = input('').split(' ')
list2 = input('').split(' ')
list3 = input('').split(' ')
bingo = [list1,list2,list3]
bingo.append([list1[0],list2[0],list3[0]])
bingo.append([list1[1],list2[1],list3[1]])
bingo.append([list1[2],list2[2],list3[2]])
bingo.append([list1[0],list2[1],list3[2]])
bingo.append([list1[2],list2[1],list3[0]])
max_n = int(input(''))
bs = []
result = False
for n in range(0,max_n):
  bs.append(input(''))

if checkbingo(bingo,bs):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3064
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();
        int ansh = 0;
        int ansm = 0;
        int ans = 0;
        if(m2 >= m1){
        	ansm = m2 - m1;
            ansh = h2 - h1;
        }else if(m2 < m1){
        	m2 += 60;
            h2 -= 1;
            ansm = m2 - m1;
            ansh = h2 - h1;
        }
        ans = (ansh * 60) + ansm;
        if((ans - k) <= 0){
        	System.out.println("0");
        }else{
        	System.out.println(ans - k);
        }
    }
}

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

int A, B, ans=0;

int main(){
  cin >> A >> B;
  for(int i = A; i<=B; i++){
	string str = to_string(i);
	ans++;
	for(int j = 0; j < str.size(); j++){
	  if(str[j]!=str[str.size()-j-1]){
		ans--;
		break;
	  }
	}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main( void )
{
  for( int i = 0; ; i++ ){
    int x;
    cin >> x;
    if( x == 0 ){
      break;
    }
    cout << "Case " << i+1 << ": " << x << endl;
  }
  return( 0 );
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	float log;
	float log2;
	
	while (scanf("%f %f", &log, &log2) != EOF){
		if (log < 35.5 && log2 < 71.0){
			printf("AAA");
		}
		else if (log < 37.5 && log2 < 77.0){
			printf("AA");
		}
		else if (log < 40.0 && log2 < 83.0){
			printf("A");
		}
		else if (log < 43.0 && log2 < 89.0){
			printf("B");
		}
		else if (log < 50.0 && log2 < 105.0){
			printf("C");
		}
		else if (log < 55.0 && log2 < 116.0){
			printf("D");
		}
		else if (log < 70.0 && log2 < 148.0){
			printf("E");
		}
		else {
			printf("NA");
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 612
# -*- coding: utf-8 -*-
x,y=map(int,input().split())
s=0
#鶴を基準に考える
for i in range(x+1):
  kame=x-i
  asi=i*2+kame*4
  if asi==y:
    s+=1
    print("Yes")
    break
if s==0:
  print("No")

Measured memory_bytes: 9016
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;

const LL INF=1<<30;
const LL MOD=1000000007;






int main(){
    int n,m;
    cin>>n>>m;
    int kai=pow(2,m);
    cout<<kai*((n-m)*100+m*1900)<<endl;

}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n;
    string s;
    cin >> n;
    cin >> s;
    ll r = 0, g = 0, b = 0;
    rep(i, 0, s.size())
    {
        if (s[i] == 'R')
            r++;
        else if (s[i] == 'G')
            g++;
        else
            b++;
    }
    ll res = r*g*b;
    rep(i, 0, s.size() - 1)
        rep(j, i+1, s.size())
        {
            if (s[i] == 'R' && s[j] == 'B' && j+(j-i) < s.size() && s[j+(j-i)] == 'G')
                res--;
            if (s[i] == 'R' && s[j] == 'G' && j+(j-i) < s.size() && s[j+(j-i)] == 'B')
                res--;
            if (s[i] == 'G' && s[j] == 'B' && j+(j-i) < s.size() && s[j+(j-i)] == 'R')
                res--;
            if (s[i] == 'G' && s[j] == 'R' && j+(j-i) < s.size() && s[j+(j-i)] == 'B')
                res--;
            if (s[i] == 'B' && s[j] == 'R' && j+(j-i) < s.size() && s[j+(j-i)] == 'G')
                res--;
            if (s[i] == 'B' && s[j] == 'G' && j+(j-i) < s.size() && s[j+(j-i)] == 'R')
                res--;
        }
    cout << res;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		String s=scan.next();
		int x=0,max = 0;
		for (int i = 0; i < n; i++) {
			if(s.charAt(i)=='I') x++;
			else if(s.charAt(i)=='D') x--;
			max=Math.max(x, max);
		}
		System.out.println(max);
	}
	

}


Measured memory_bytes: 26960
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int m;
	cin>>a;
	int s=a.length();
	for (int i=0;i<s;i++)
	{
		m=a[i]-'0';
		if (m==9)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
} 

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split("").filter { it.isNotEmpty() }
    println(op143c(n, d))
}

fun op143c(n: Int, d: List<String>): Int {
    val result = mutableListOf<String>()
    d.forEachIndexed { index, s ->
        if (index == 0) {
            result.add(s)
        } else if (result.last() != s) {
            result.add(s)
        }
    }
    return result.count()
}




Measured memory_bytes: 45160
import math
x=0
y=0
theta=90
while 1:
    a,b=map(float,raw_input().split(','))
    if a==0 and b==0:break
    r=math.radians(theta)
    x+=a*math.cos(r)
    y+=a*math.sin(r)
    theta-=b
print int(x)
print int(y)

Measured memory_bytes: 4424
class UnionFindNode(object):
    """
    Union-Find構造
    ノードのグループ併合や、所属グループ判定を高速に処理する
    """

    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        template = "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})"
        return template.format(self.group_id_, self.parent_, self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.root()
        return parent.group_id_

    def size(self):
        parent = self.root()
        return parent.size_

    def unite(self, unite_node):
        parent = self.root()
        unite_parent = unite_node.root()

        if parent.group_id_ != unite_parent.group_id_:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_

    def same(self, node):
        return self.root() == node.root()


n, m = map(int, input().split())
uf = [UnionFindNode(i) for i in range(n)]
a = reversed([list(map(lambda x:int(x) - 1, input().split()))
              for _ in range(m)])
ans = n * (n - 1) // 2
res = []
for i, r in enumerate(a):
    res.append(ans)
    if not uf[r[0]].same(uf[r[1]]):
        ans -= uf[r[0]].size() * uf[r[1]].size()
    uf[r[0]].unite(uf[r[1]])
for num in reversed(res):
    print(num)

Measured memory_bytes: 61424
N = int(input())
task_list = [list(map(int, input().split())) for i in range(N)]

task_list.sort(key=lambda task_list: task_list[1])
time = 0
flag = True

for i in range(N):
    x = task_list[i]
    time += x[0]
    if time > x[1]:
        flag = False
        break

if flag:
    print("Yes")

else:
    print("No")




#りゅうせいの解答1　実行時エラー、実行時間超過
# N = int(input())
# task_list = [list(map(int,input().split())) for i in range(N)]
#
# task_list.sort(key= lambda task_list: task_list[1])
# time = 0
#
# while(len(task_list)):
#     x = task_list.pop(0)
#     time += x[0]
#     if time > x[1]:
#         print("No")
#         exit(1)
#
#     else:
#         continue
#
# print("Yes")

Measured memory_bytes: 53724
#include <stdio.h>

int main(void) {
    char c;
    scanf("%c", &c);
    if(c == 'A'){
        printf("T\n");
    }
    if(c == 'T'){
        printf("A\n");
    }
    if(c == 'C'){
        printf("G\n");
    }
    if(c == 'G'){
        printf("C\n");
    }
}


Measured memory_bytes: 128
var
        ans,x,y,i:longint;
        s:string;
begin
        readln(s);
        for i:=1 to length(s) do
        begin
                if x=y then
                begin
                        inc(x);
                        if s[i]='p' then dec(ans);
                end
                else
                begin
                        inc(y);
                        if s[i]='g' then inc(ans);
                end;
        end;
        writeln(ans);
end.


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    LL N;
    cin >> N;
    N-=1;
    LL A,B;
    cin >> A >> B;
    LL T=B-A;
    LL C,D;
    cin >> C >> D;
    LL S=D-C;
    for(int i=0;i<=N;i++){
        if(D*i-C*(N-i)-S*N<=T&&T<=D*i-C*(N-i)){
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def is_prime(n):
    i = 3
    while i <= n**0.5:
        if not n % i: return False
        i += 2

    return True

def main():
    prime = [2]
    prime_2017 = [0] * (10**5+1)
    
    for i in range(3, 10**5+1):
        prime_2017[i] = prime_2017[i-1]
        if not i % 2: continue
    
        if is_prime(i): prime.append(i)
        else: continue
        if (i+1)//2 in prime: prime_2017[i] += 1
    
    for i in range(int(input())):
        l, r = map(int, input().split())
        
        print(prime_2017[r] - prime_2017[l-1])
    
if __name__ == '__main__':
    main()

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

int main() { 
  int N, K, x=1;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    int a, b;
    a = x*2;
    b = x+K;
    if(a<b){
      x = a;
    }
    else{
      x = b;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,c,k;
  cin>>n>>c>>k;
  int t[n];
  for(int i=0;i<n;i++) cin>>t[i];
  sort(t,t+n);
  int ans=0,cur=0,num=0;
  for(int i=0;i<n;i++){
    if(t[i]>cur||num>=c){
      ans++;
      cur=t[i]+k;
      num=1;
    }else{
      num++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  string s;
  cin >> s;
  rep(i,s.size()){
    if(s[i] != s[s.size()-1-i]){
      cout << "No" << endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    s = input()

    power = 1
    dic = [0] * 2019
    dic[0] = 1
    x = 0
    dic1 = {i:j for i,j in zip('0123456789',range(10))}
    for i in range(len(s)-1,-1,-1):
        x += power * dic1[s[i]]
        x %= 2019
        dic[x] += 1
        power *= 10
        power %= 2019
    
    ans = 0
    for v in dic:
        ans += v*(v - 1)//2
    print(ans)
if __name__ == '__main__':
    main()

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(a) (a).begin(),(a).end()

int main(){

  int n, k;cin>>n>>k;
  vector<int> v(k);
  REP(i, k) cin>>v[i];
  vector<bool> used(n+1);
  for(int i = k - 1; i >= 0; i--)
  {
    if(used[v[i]]) continue;
    used[v[i]] = true;
    cout << v[i] << endl;
  }
  for(int i = 1; i < n + 1; i++)
  {
    if(!used[i]) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 3368
#include<iostream>
using namespace std;
typedef long long ll;

ll n,k;
ll w[100000];

bool check(int x){
  ll cost=0,cnt=0;
  for(ll i=0;i<n;i++){
    cost+=w[i];
    while(cost>x){
      cost=w[i];
      cnt++;
      if(cnt==k)return false;
    }
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(ll i=0;i<n;i++)cin>>w[i];
  ll l=0,r=1000000000LL,m;
  while(l<r){
    m=(l+r)/2;
    if(check(m))r=m;
    else l=m+1;
  }
  cout<<l<<endl;
  return 0;
}

Measured memory_bytes: 1972
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second

#define ALL(V)  V.begin(),V.end()

#define MX1     100000LL
#define MX2     1000000LL
#define Inf     1000000000000000LL
#define mod		1000000007LL
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    string s;
    cin>>s;

    s[3]='8';

    cout<<s;








 return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i, n;
string s;

void solve()
{
    cin >> s;
    if (s[sz(s) - 1] == 's')
        s += "es";
    else
        s += "s";
    cout << s;
}

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


Measured memory_bytes: 3644
import sys

N, M = map(int, input().split())
if N < 2 and M < 2:
    print(1)
    sys.exit()

if N == 1 or M == 1:
    print(max(N, M) - 2)
    sys.exit()

ans = (N * M) - (2 * N) - (2 * (M - 2))
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();
			String data2 = scanner.nextLine();

			char[] s =  data1.toCharArray();
			char[] t =  data2.toCharArray();

			long count = 0;
			for (int i = 0; i < s.length; i++) {
				if (s[i] != t[i]) {
					count++;
				}
			}

			System.out.println(count);
		}
	}
}

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

int main ()
{
    int N ;
    int a , b ;
    cin >> N ;

    if (N == 1)
    {
        cout << "Hello World" ;
    }
    else if (N == 2)
    {
        cin >> a >> b ;
        cout << a+b ;
    }

    return 0 ;

}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
int count;
void merge(int left,int mid,int right,int A[]){
  int i,j=0,k;
  int n1 = mid-left;
  int n2 = right-mid;
  int L[n1],R[n2];
  for(i = 0;i<n1;i++)L[i]=A[left+i];
  for(i = 0;i<n2;i++)R[i]=A[mid+i];
  
    L[n1]=R[n2]=999999999;
  i=0;
  for(k = left;k< right;k++){
   count++;
   if(L[i]<=R[j])A[k]=L[i++];
    else A[k]=R[j++];
  }
  
}
void mergeSort(int left,int right,int A[]){
  if(left >= right-1 )return;
  int mid = (left+right)/2;
  mergeSort(left,mid,A);
  mergeSort(mid,right,A);
  merge(left,mid,right,A);
  
}
int main (void){
  int size,A[MAX];
  int i;
  scanf("%d",&size);
  for(i = 0;i<size;i++)scanf("%d",&A[i]);
  mergeSort(0,size,A);
  for(i = 0;i<size;i++){
    if(i==0)printf("%d",A[i]);
    else printf(" %d",A[i]);
  }
  printf("\n%d\n",count);
  
  
  return 0;
}

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

bool is_prime(int x){
	bool ans=true;
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){
			ans=false;
			break;
		}
	}
	return ans;
}
int main(){
	cin>>x;
	for(int i=x;;i++){
		if(is_prime(i)){
			cout<<i<<endl; 
			break;
		}
	}
	return 0;
} 

Measured memory_bytes: 256