akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

int main() {
    long long N,K; cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    vector<vector<int>> B(200001);
    for(int i = 0; i < N; ++i) B[A[i]].push_back(i);
    vector<int> C(N);
    for(int i = 0; i < 200001; ++i) {
        if(B[i].empty()) continue;
        for(int j = 0; j + 1 < B[i].size(); ++j){
            C[B[i][j]] = B[i][j+1];
        }
        C[B[i].back()] = B[i].front();
    }
    vector<vector<int>> D(2,vector<int>(N));
    D[0][0] = 1;
    for(int i = 0, from = 0, to; i < N; ++i,from = to) {
        to = C[from];
        D[1][to] = D[0][from] + (from >= to);
        from = to, to = (from + 1) % N;
        if(to == 0) break;
        D[0][to] = D[1][from] + (from >= to);
    }
    long long M = D[1][N-1];
    K %= M;
    corner(!K,"");
    int s;
    for(int i = 0; i < N; ++i) if(K==D[0][i]) s = i;
    vector<int> ans,E(200001,0);
    for(int i = s; i < N; ++i) {
        if(E[A[i]]) {
            while(ans.back()!=A[i]){
                E[ans.back()] = 0;
                ans.pop_back();
            }
            ans.pop_back();
        }
        else{
            ans.push_back(A[i]);
        }
        E[A[i]] ^= 1;
    }
    corner(ans.empty(),"");
    for(int e:ans) cout << e << " ";
    cout << endl;

    
    return 0;
}


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

int main (){
long long n,m,x[10001],y[10001],z[10001],a[10001],i,j,max=0,value;
cin >> n >> m;
for(i=0;i<n;i++) cin >> x[i] >> y[i] >> z[i];
for(j=0;j<8;j++){
for(i=0;i<n;i++) a[i]=(2*(j%2)-1)*x[i]+(2*(((j-j%2)/2)%2)-1)*y[i]+(2*(((j-j%4)/4)%2)-1)*z[i];
sort(a,a+n);
value=0;
for(i=0;i<m;i++) value+=a[n-1-i];
if(max<value) max=value;
}
cout << max << endl;
return 0;
}

Measured memory_bytes: 256
s = str(input())
a = s[0:(len(s) - 1) // 2]
e = s[(len(s) + 1) // 2:len(s)]
if a == e[::-1]:
    if a == a[::-1]:
        if e == e[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int a, b;
	cin >> a >> b;

	int value = a + b;
	if (value % 2 == 2)
	{
		cout << value / 2;
	}
	else
	{
		cout << (value + 1) / 2;
	}

	return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	char a[100000];
	f(i, 100000)a[i] = 0;
	int b[100000];
	char c[100000];
	int k, s;
	int n, m;
	int x, y, z;
	int ans = 0;
	z = 0;
	scanf("%s", a);
	n = strlen(a);
	k = 0;
	x = 0;
	f(i, n){
		if (a[i] != 'x'){
			c[k] = a[i];
			b[k] = x;
			x = 0;
			k++;
		}
		else x++;
	}
	b[k] = x;
	f(i, (k+1) / 2){
		if (c[i] != c[k - i - 1])z = -1;
		ans += max(b[i], b[k - i]) - min(b[i], b[k - i]);
	}

	if (z==-1)printf("-1\n");
	else printf("%d\n",ans);

	return 0;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif


int main()
{
	string s;
	cin >> s;
	int l = s.length()-1;
	l -= l % 2;
	l = l / 2;
	while (true) {
		bool f = true;
		rep(i, l) {
			if (s[i] == s[i+l]) continue;
			f = false;
			break;
		}
		if (f) break;
		l--;
	}
	cout << l*2 << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N, K; 
    cin >> N >> K;
    vector<bool> D(10, true);
    rep(i, K){
        int a;
        cin >> a;
        D[a] = false;
    }

    int ans;
    while(1){
        string S = to_string(N);
        bool flag = true;
        rep(i, S.size()){
            int tmp = S[i] - '0';
            if(!D[tmp]){
                flag = false;
                break;
            }
        }
        if(flag){
            ans = N;
            break;
        }
        N++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#define maxn 100
using namespace std;
int n, a[maxn], p;
long long dp[maxn][2];
int main(){
	cin >> n >> p;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		dp[i][0] += dp[i - 1][0];
		dp[i][1] += dp[i - 1][1];
		if(a[i] & 1){
			dp[i][0] += dp[i - 1][1];
			dp[i][1] += dp[i - 1][0];
		}
		else{
			dp[i][0] += dp[i - 1][0];
			dp[i][1] += dp[i - 1][1];
		}
	}
	cout << dp[n][p] << endl;
	return 0;
}

Measured memory_bytes: 768
#1:初期化
N = int(input())
a = []
for i in range(N):
    a.append(list(map(int,input().split())))
dp = [[0]*3 for _ in range (N+1)]
#print(dp, sep="\n")
#print(a, sep="\n")

#2:初期値(元からゼロなので記述無し)

#3:dp実行部(貰うDP)
for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i-1][j]) #dpは[1]からだが，aは[0]からに注意

#4:出力
dpmax = 0
for i in range(3):
    dpmax= max(dp[N][i], dpmax)
#print(*dp, sep="\n")
print(dpmax)


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

using namespace std;

typedef long long ll;
  
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int x = 0;
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
    if(p.at(i) != i+1) x++;
  }
  if(x <= 2) puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << (b - a == c - b ? "YES" : "NO") << endl;
}


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

void solve(int a,int b){
  if(a>b){
    for(int i = 0; i < a; i++){
      cout << b;
    }
    cout << endl;
  }
  
    else{
    for(int i = 0; i < b; i++){
      cout << a;
    }
    cout << endl;
  }
}

int main(){
  int a,b;
  cin >> a >> b;
  solve(a,b);
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/



int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,K;
    cin >> N >> K;

    if (N % K == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string S;
  cin >> S;
  int ans = 0;
  int memo = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'T' || S.at(i) == 'G') {
      memo++;
    }
    else {
      ans = max(ans, memo);
      memo = 0;
    }
  }
  ans = max(ans, memo);
  cout << ans << endl;
}

Measured memory_bytes: 3584
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
from fractions import Fraction





def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]

    ans = 0
    count = 0
    for now_data in itertools.permutations([i for i in range(num)]):
        for i in range(num - 1):
            now_index = now_data.index(i)
            next_index = now_data.index(i + 1)
            dist = ((data[now_index][0] - data[next_index][0]) ** 2 + (data[now_index][1] - data[next_index][1]) ** 2) ** 0.5
            ans += dist
        count += 1
    ans /= count
    print(ans)





if __name__ == '__main__':
    main()



Measured memory_bytes: 65052
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
main(){
  ll a[20];
  rep(i,1,10)cin>>a[i];
  bool p=true;
  if(a[1]-a[2]!=a[4]-a[5])p=false;
  if(a[1]-a[2]!=a[7]-a[8])p=false;
  if(a[5]-a[8]!=a[6]-a[9])p=false;
  if(a[4]-a[7]!=a[5]-a[8])p=false;
  if(p)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
	int a,b,c,k,ans,x;
	cin >> a >> b >> c >> k ;
	x = max({ a, b, c });
	ans = a + b + c;
	REP(i, k) {
		ans += x;
		x *= 2;
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define max_n 50
#define max_m 50
#define max_w 1000
#define max_h 1000
#define max_k 100010
#define max_l 10000
#define INF 9999999

typedef long long lint;

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


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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> list(N, vector<int>(2));
    for (int i = 0; i < N; i++)
        cin >> list[i][0] >> list[i][1];

    double ans = 0;
    for (int i = 0; i < N; i++)
        for (int j = i; j < N; j++)
            ans += sqrt(pow(list[i][0] - list[j][0], 2) + pow(list[i][1] - list[j][1], 2));

    cout << fixed << setprecision(15) << ans * 2 / N;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, 0, N) cin >> A.at(i);
    cout << (N + K - 3) / (K - 1) << endl;
}

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

const long long mod = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> oks(n + 1, true);
    rep(i, m) {
        int a;
        cin >> a;
        oks[a] = false;
    }

    vector<ll> dp(n + 1);
    dp[0] = 1;
    rep(now, n) {
        for(int next = now + 1; next <= min(n, now + 2); next++) {
            if(oks[next]) {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

int n, k;
ll A[200005], S[200005];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        A[i]--;
        S[i + 1] = (S[i] + A[i] + k) % k;
    }

    ll ans = 0;
    
    map<int, int> mp;

    for(int i = 0; i <= n; i++){
        if (i - k >= 0) mp[S[i - k]]--;
        ans += mp[S[i]];
        mp[S[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	set <string> s;
	cin >> n;
	for(long long i=0;i<n;i++){
		string str;
		cin >> str;
		s.insert(str);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 19220
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int main(){
  int cnt[15]={0};
  REP(i,4){
    int a;cin>>a;
    ++cnt[a];
  }
  if(cnt[1] && cnt[9] && cnt[4] && cnt[7]) puts("YES");
  else puts("NO");
  return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>


int main (void){


    double r = 0;
    
    scanf("%lf",&r);
    
    if(r<0 || 10000<r) return -1;
    
    printf("%f %f\n",r*M_PI*r,r*2*M_PI);
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int size_s = s.size();

    if(s[size_s-4] == s[size_s-3] && s[size_s-2] == s[size_s-1]) cout << "Yes" << endl;
    else cout  << "No" << endl;

    return 0;
}

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

using namespace std;

int main(){
  int total = 0;
  vector<vector<int>> V(3,vector<int>(3,0));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> V[i][j];
      total += V[i][j];
    }
  }
  if(total % 6 == 0) cout << "Yes";
  else{
    int tmp = 0;
    int h = 0;
    int v = 0;
    for(int i = 0; i < 3; i++){
      tmp += V[i][i];
    }
    tmp *= 3;
    if(total == tmp) cout << "Yes";
    else cout << "No";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

typedef long long ll;

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    priority_queue<int> que;
    long long sum = 0;
    for(int i = 0; i < N; ++i){
        // cin >> A[i];
        int tmp;
        cin >> tmp;
        sum += tmp;
        que.push(tmp);
    }
    // cout << "a" << endl;
    if(N == 1){
        while(M > 0){
            A[0] /= 2;
            // cout << A[0] << endl;
            M--;
        }
        cout << A[0] << endl;
        return 0;
    }

    while(M > 0){
        int m = M;
        int tmp, next;
        tmp = que.top();
        que.pop();
        next = que.top();
        sum -= tmp;
        // cout << tmp << " " << next << endl;
        while(m > 0 && tmp >= next){
            m--;
            tmp /= 2;
            // cout << tmp << endl;
        }
        sum += tmp;
        que.push(tmp);
        M = m;
    }
    cout << sum << endl;




    return 0;
}

Measured memory_bytes: 1276
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    inps(n, k);
    vector <bool> a(10, 1);
    for(int i=0; i<k; i++){
        ll x;
        cin >> x;
        a[x] = 0;
    }
    for(ll i=n; ; i++){
        ll j = i;
        bool check = 1;
        while(j){
            ll x = j%10;
            j/=10;
            if(!a[x]){
                check = 0;
            }
        }
        if(check){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
 int n;
ll a[1000000+1];
ll dp[3004][3100];
ll solve(int st,int end ){
  ll ans=0;
  if(st>end)
    return 0;
  if(st==end)
    return a[st];
    if(dp[st][end]!=-1)
    {//cout<<"ys"<<endl;
    return dp[st][end];
    }
  ans=max(a[st]+min(solve(st+1,end-1),solve(st+2,end)),a[end]+min(solve(st+1,end-1),solve(st,end-2)));
  return dp[st][end]=ans;
}
int main(){
    IOS;   
    // int n;
   memset(dp,-1,sizeof dp);
    cin>>n;
    ll ans=0;
  loop(n)
  {cin>>a[i];
  ans+=a[i];
  }
  cout<<(2*solve(0,n-1)-ans)<<endl;
     
}
// https://atcoder.jp/contests/dp/tasks/dp_d
// https://codeforces.com/contest/1131/problem/C
 
//csjosh

Measured memory_bytes: 74112
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <climits>

using namespace std;

bool judge(int x){
	if (x%2==0) return false;
	int cnt=0;
	for (int i =1;i<=x;i++) 
		if (x%i==0) cnt++;
	return cnt==8;
}

int main(){
	int n;
	cin>>n;
	int ans=0;
	for (int i=1;i<=n;i++) if (judge(i)) ans++;
	cout<<ans<<endl;

	return 0;
}

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

int main()
{
    int W, a, b;
    cin >> W >> a >> b;
    if (a > b) {
        int t = a;
        a = b;
        b = t;
    }

    int w1 = b - (a + W);
    int w2 = b - a;

    if (w1 <= 0 || w2 <= 0) {
        cout << 0 << endl;
        return 0;
    }

    if (w2 <= w1 && W != 2) {
        cout << w2 << endl;
    } else {
        cout << w1 << endl;
    }   
}


Measured memory_bytes: 256
import sys
from queue import deque

sys.setrecursionlimit(200000)


def hierarchize(source):
    global edges, hierarchy
    hierarchy = [-1] * n
    queue = deque([(0, source)])
    while queue:
        h, v = queue.popleft()
        if hierarchy[v] != -1:
            continue
        hierarchy[v] = h
        if v == sink:
            return True
        queue.extend((h + 1, target)
                     for remain, target, _ in edges[v] if hierarchy[target] == -1 and remain)
    return False


def augment(v, limit):
    global sink, edges, hierarchy
    if v == sink:
        return limit
    res = 0
    for e in edges[v]:
        remain, target, idx = e
        if remain == 0 or hierarchy[v] >= hierarchy[target]:
            continue
        aug = augment(target, min(limit, remain))
        e[0] -= aug
        edges[target][idx][0] += aug
        res += aug
        limit -= aug
        if not limit:
            break
    return res


n, m = map(int, input().split())
sink = n - 1
edges = [[] for _ in range(n)]

hierarchy = [-1] * n

for _ in range(m):
    s, t, c = map(int, input().split())
    es, et = edges[s], edges[t]
    ls, lt = len(es), len(et)
    edges[s].append([c, t, lt])
    edges[t].append([0, s, ls])

res = 0
while hierarchize(0):
    res += augment(0, 10000001)
print(res)

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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int N, M;
  cin >> N >> M;

  char A[N][N], B[M][M];
  REP(i, N)cin >> A[i];
  REP(i, M)cin >> B[i];
  REP(i, N){
    REP(l, N){
      int po = 0;
      REP(j, M){
        REP(k, M){
          if(A[i+j][l+k] != B[j][k]){
            po = 1;
            break;
          }
          if(j == M - 1 && k == M - 1){
            cout << "Yes" << endl;
            return 0;
          }
        }
        if(po == 1){
          break;
        }
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main() {
  int a, b[20], c, m;
  cin >> a;
  
  c=0;
  m=0;
  for(int i=0;i<a;i++) {
    cin >> b[i];
    //cout << i << " " << b[i] << endl;
    if (b[i]>=m) { m=b[i]; c++; }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, M = mi()

#Nが1段なら、絶対に1通り
if N == 1:
  print(1)
  exit()

As = [int(input()) for _ in range(M)]
#0段目を含めて、階段を配列にする stairs[n]でアクセスする
stairs = ['.'] * (N+1)

#壊れた床を#に変え、1行の文字列にする
for a in As:
  stairs[a] = '#'
stairs = ''.join(stairs)

#そもそも無理なパターン。無理なパターンはこの場合だけ
if '##' in stairs:
  print(0)
  exit()


#n段目までの来方をDP[n]に格納していく
DP = [0]*(N+1)
#初期化
DP[0] = 1
#ループを楽にするため、DP[1]は求めておく ※1段しかない場合は排除済み
DP[1] = 1 if stairs[1] == '.' else 0

#Nに辿り着くまでループを回す
for i in range(2,N+1):
  DP[i] = (DP[i-2]+DP[i-1])%1000000007 if stairs[i] == '.' else 0

print(DP[N])



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

typedef long long ll;

using namespace std;

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

    int vi[101] = {};

    for (int i = 0; i < n; i++) {
        int xi;
        cin >> xi;

        vi[xi] += 1;
    }

    int ans = 0;

    for (int i = 0; i <= 100; i++) {
        if (vi[i] != 0) {
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3604
program abc159f
  implicit none
  integer :: n, s, i, j, ans
  integer,dimension(:),allocatable :: a, dp
  read *, n, s
  allocate(a(n),dp(0:s))
  read *, a
  dp = 0
  ans = 0
  do i = 1,n
     dp(0) = i
     do j = s,a(i),-1
        dp(j) = mod(dp(j)+dp(j-a(i)),998244353)
     end do
     ans = mod(ans+dp(s),998244353)
  end do
  print *, ans
end program abc159f


Measured memory_bytes: 256
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

string multiply(string num1, string num2) 
{ 
    int len1 = num1.size(); 
    int len2 = num2.size(); 
    if (len1 == 0 || len2 == 0) 
    return "0";
    vector<int> result(len1 + len2, 0);   
    int i_n1 = 0;  
    int i_n2 = 0;
    for (int i=len1-1; i>=0; i--) 
    { 
        int carry = 0; 
        int n1 = num1[i] - '0'; 
        i_n2 = 0;
        for (int j=len2-1; j>=0; j--) 
        { 
            int n2 = num2[j] - '0'; 
            int sum = n1*n2 + result[i_n1 + i_n2] + carry;  
            carry = sum/10;
            result[i_n1 + i_n2] = sum % 10;
            i_n2++; 
        }
        if (carry > 0) 
            result[i_n1 + i_n2] += carry;
        i_n1++; 
    }
    int i = result.size() - 1; 
    while (i>=0 && result[i] == 0) 
    i--; 
    if (i == -1) 
        return "0";
    string s = ""; 
    while (i >= 0) 
        s += std::to_string(result[i--]);
    return s;
} 
bool check(string prod)
{
    string c="1000000000000000000";
    
    if(sz(prod)>sz(c))
        return 1;
    if(sz(prod)<sz(c))
        return 0;
    for(int i=0;i<sz(c);i++)
    {
        if(prod[i]>c[i])
            return 1;
    }
    return 0;
}
void solve()
{
    int n;
    cin>>n;
    string prod="1";
    string s[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        if(s[i]=="0")
        {
            cout<<0;
            return;
        }
    }
    for(int i=0;i<n;i++)
    {
        prod=multiply(prod,s[i]);
        if(check(prod))
        {
            cout<<-1;
            return;
        }
    }
    cout<<prod;
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11532
def examA():
    S = SI()
    T = SI()
    N = len(S)
    ans = "No"
    for i in range(N):
        cur = S[i:] + S[:i]
        #print(cur)
        if cur==T:
            ans = "Yes"
    print(ans)
    return

def examB():
    H, W = LI()
    S = [SI()for _ in range(H)]
    flag = True
    ans = 0
    print(ans)
    return

def examC():
    L, R = LI()
    ans = inf
    if R-L>=3000:
        R = L+3000

    for l in range(L, R + 1):
        for r in range(l+1, R + 1):
            now = (l*r) %2019
            ans = min(ans,now)
    print(ans)
    return

def examD():
    T = ["dream", "dreamer", "erase", "eraser"]
    S = SI()
    ans = "NO"
    t = ""
    for s in S[::-1]:
        t += s
        if t[::-1] in T:
            t = ""
    if t=="":
        ans = "YES"
    print(ans)
    return

def examE():
    N = 50
    K = I()
    base = K//N
    A = [base+i for i in range(N)]
    rest = K%N
    for i in range(rest):
        A[-i-1] += 1
    print(N)
    print(" ".join(map(str,A)))
    return

def examF():
    N = 20
    C = [2**i for i in range(N)]
    L = I()
    cur = 1
    V = [[i+1, i+2, 0]for i in range(N-1)]
    now = 1
    while(now<N):
        if C[now]<=L:
            cur = C[now]
            V.append([now,now+1,C[now-1]])
            now += 1
        else:
            break
    #print(cur)


    for i in range(now)[::-1]:
        if C[i]<=L-cur:
            cost = cur
            V.append([i+1,N,cost])
            cur += C[i]

    print(N,len(V))
    for s,t,c in V:
        print(s,t,c)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examF()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main() {
  int N;
  cin >> N;
  if (N<10){
    cout << N <<endl;
  }
  if(N>=10 && N<100){
    cout << "9" <<endl;
  }
  if(N>=100 && N<1000){
    cout << N-90 <<endl;
  }
  if(N>=1000 && N<10000){
    cout << "909" <<endl;
  }
  if(N>=10000 && N<100000){
    cout << N-9090 <<endl;
  }
  if(N>=100000){
    cout << 90909 <<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[101];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		for(int l=i+1;l<=n;l++)
			for(int j=l+1;j<=n;j++)
				if(a[i]+a[l]>a[j]&&a[i]!=a[l]&&a[l]!=a[j])
					ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

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

    sort(a.begin(), a.end());
    int res1 = a[n-1];
    int res2 = a[0];
    int pre = abs(2*a[0]-a[n-1]);
    for (int i = 0; i < n-1; i++){
	int tmp = abs(2*a[i]-a[n-1]);
	if (tmp < pre){
	    res2 = a[i];
	    pre = tmp;
	}
    }

    cout << res1 << " " << res2 << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int main() {
    float n; cin>>n;
    int m=n/1.0;
    float k; cin>>k;
    int a[m];
    int ans=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
	ans=ceil((n-1)/(k-1));
	cout<<ans;	 
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<string> lstWek = new List<string>() { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
            int iOut = 0;
            for (int i = 0; i < lstWek.Count; i++)
            {
                if (lstWek[i] == sS[0]) { iOut = 7 - i; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
loop do
    n, s = gets.split.map(&:to_i)
    break if n == 0
    a = (1..n).map { gets.to_i }.sort
    k = 0
    j = n - 1
    (0..n-2).each do |i|
        j -= 1 until a[i] + a[j] <= s or i >= j
        if i >= j
            k += n - i - 1
        else
            k += n - j - 1
        end
    end
    p k
end



Measured memory_bytes: 7200
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

double fun_distance(int **data, int p, int n){
	double distance = 0.0;

	for(int c=0;c<n;c++){
		distance += pow( abs(data[0][c] - data[1][c]) ,p);
	}
	distance = pow(distance, 1.0/float(p));
	return distance;
}

int main(){
	int n;
	cin >> n;
	double output=0;

	int **data = new int*[2]; 
	for(int i = 0;i < 2; i++){
		data[i] = new int[n]; 
	}

	for(int r=0;r<2;r++){
		for(int c=0;c<n;c++){
			cin >> data[r][c];
		}
	}
	
	//p1
	cout << fixed << setprecision(10) << fun_distance(data, 1, n) << endl;

	//p2
	cout << fixed << setprecision(10) << fun_distance(data, 2, n) << endl;

	//p3
	cout << fixed << setprecision(10) << fun_distance(data, 3, n) << endl;
	
	//pinf
	output = 0; double temp;
	for(int c=0;c<n;c++){
		temp = abs(data[0][c] - data[1][c]);
		if(output < temp)
			output = temp;
	}
	cout << fixed << setprecision(10) << output << endl;

	return 0;
}

Measured memory_bytes: 3400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        { //???????????¢???????¨?  ???     ??????????¨??????????????????????????????????f??????????????? g??????????????? h???????????????// i????????????????????????   ???????????????   
            var abcde = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = abcde[0];// 5
            int b = abcde[1];// 4   
            int c = abcde[2];// 2
            int d = abcde[3];// 2
            int e = abcde[4];// 1
            int f = c - e, g = c + e, h = d + e, i = d - e;
            if (f >= 0 && g <= a && i>= 0 && h <= b)
            {
                Console.WriteLine("Yes");
            }
            else { Console.WriteLine("No"); }



        }
    }
}

Measured memory_bytes: 9352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a = 0,b = 0, c = 0;
    int h1, h2, h3;
    for(int i =0 ;i < n;i++){
        int x;
        cin>>x;
        if(i==0){
            a = 0;
            h1 = x;
            c = 0;
        }
        else if(i == 1){
            h2 = x;
            b = abs(h1-h2);
            c = b;
        }
        else{
            h3 = x;
            c = min(a+abs(h1 - h3), b + abs(h2-h3));
            h1 = h2;
            h2 = h3;
            a = b, b= c;
        }
    }
    cout <<c;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(int,input().split()))
ans = 0
mod = int(1e9+7)
def gcd(a,b):
  while b != 0:
    a, b = b, a % b
  return a
def lcm(a,b):
    return a // gcd(a,b) * b

g = 1
for i in range(n):
    g = lcm(g, s[i])
for i in range(n):
    ans += g // s[i]
print(ans%mod)


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	if(a.back() == b.front() && b.back() == c.front()) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int max_n = 1e5 + 20;
int n, k;
int a[max_n], b[max_n], c[max_n], DP[max_n][3];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    DP[0][0] = a[0];
    DP[0][1] = b[0];
    DP[0][2] = c[0];
    for (int i = 1; i < n; i++) {
        DP[i][0] = max(DP[i - 1][1], DP[i - 1][2]) + a[i];
        DP[i][1] = max(DP[i - 1][0], DP[i - 1][2]) + b[i];
        DP[i][2] = max(DP[i - 1][1], DP[i - 1][0]) + c[i];
    }
    cout << max(max(DP[n - 1][0], DP[n - 1][1]), DP[n - 1][2]);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;


int main(){
    int N;
    cin >> N;
    vector<int> a(N * 3);
    rep(i, N * 3) cin >> a[i];

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

    ll total = 0;
    for(int i = 0; i < N; i++){
        total += a[i * 2 + 1];
    }
    cout << total << endl;
    return 0;
}


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

using namespace std;

int const NMAX = 1e5;
int v[1 + NMAX];

int main() {

  int n, pos = 1, p, ans = 1;
  string GUIDO;
  char MISTA;
  while(cin >> MISTA){
    if(ans % 2){
      cout << MISTA;
    }
    ans++;
  }
  return 0;
}


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

#define f first
#define s second

#define pb push_back
#define mp make_pair

#define ll long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())

using namespace std;

const int MAXN = (int) 2e5 + 10;
const int INF = (int) 2e9 + 7;
const ll LINF = (1LL<<62);

int n;

ll a[MAXN];
bool u[MAXN];
ll all;

ll maxSubarrayXOR(ll set[], int n)
{
    // Initialize index of
    // chosen elements
    int index = 0;

    // Traverse through all
    // bits of integer
    // starting from the most
    // significant bit (MSB)
    for (int i = 60; i >= 0; i--)
    {
        // Initialize index of
        // maximum element and
        // the maximum element
        int maxInd = index;
        ll maxEle = -LINF;
        for (int j = index; j < n; j++)
        {
            // If i'th bit of set[j]
            // is set and set[j] is
            // greater than max so far.
            if ( (set[j] & (1LL << i)) != 0
                     && set[j] > maxEle )
                maxEle = set[j], maxInd = j;
        }

        // If there was no
        // element with i'th
        // bit set, move to
        // smaller i
        if (maxEle == -LINF)
        continue;

        // Put maximum element
        // with i'th bit set
        // at index 'index'
        swap(set[index], set[maxInd]);

        // Update maxInd and
        // increment index
        maxInd = index;

        // Do XOR of set[maxIndex]
        // with all numbers having
        // i'th bit as set.
        for (int j=0; j<n; j++)
        {
            // XOR set[maxInd] those
            // numbers which have the
            // i'th bit set
            if (j != maxInd &&
               (set[j] & (1ll << i)) != 0)
                set[j] = set[j] ^ set[maxInd];
        }

        // Increment index of
        // chosen elements
        index++;
    }

    // Final result is
    // XOR of all elements
    ll res = 0;
    for (int i = 0; i < n; i++)
        res ^= set[i];
    return res;
}

void print(ll x) {
    for (int i = 10; i >= 0; i--) cout << (x>>i)%2;
    cout<<endl;
}

ll f(ll x) {
    return x + (all ^ x);
}

int main() {
    #ifdef sony
        freopen("input.txt", "r", stdin);
    #endif // sony

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        all ^= a[i];
    }
    sort(a, a + n);
    for (int i = 60; i >= 0; i--) {
        for (int j = 0; j < n; j++) {
            if ((all >> i) % 2 && (a[j] >> i) % 2) {
                a[j] -= (1LL << i);
            }
        }
    }
    ll mn = maxSubarrayXOR(a, n);
    cout << f(mn);
    return 0;
}


Measured memory_bytes: 1152
n = int(input())
arr = list(map(int,input().split()))
ans = [0]*(n+1)
ans[0] = 1
c_sum = [0]*(n+1)
c_sum[0] = arr[0]
for i in range(1,n+1):
    c_sum[i] = c_sum[i-1] + arr[i]
root = [0]*(n+1)
for d in range(n+1):
    if d==0:
        ans[d] = min(1,c_sum[-1])
    else:
        ans[d] = min(root[d-1]*2,(c_sum[-1] - c_sum[d-1]))
    root[d] = ans[d] - arr[d]
    if root[d] < 0:
        print(-1)
        exit()
print(sum(ans))




Measured memory_bytes: 26420
# -*- coding: utf-8 -*-


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

    result = 0
    for i in range(n):
        x = v[i] - c[i]
        if x > 0:
            result += x
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-07-05 19:56:16
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    n = int(input())
    print((1000-(n%1000)+1000)%1000)
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


Measured memory_bytes: 62596
#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 argc, char const *argv[])
{
	string s; cin >> s;
	cout << (s[2] == s[3] and s[4] == s[5] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//

        int N, T;
        cin >> N >> T;
        cout << max(N - T,0) << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

constexpr int MAX_LEN = 1000;
char S[MAX_LEN + 1];

void _main() {
  cin >> S;
  int s_len = strlen(S);

  bool flag_n = false;
  bool flag_s = false;
  bool flag_w = false;
  bool flag_e = false;
  rep(i, 0, s_len) {
    switch(S[i]) {
      case 'E': flag_e = true; break;
      case 'W': flag_w = true; break;
      case 'S': flag_s = true; break;
      case 'N': flag_n = true; break;
    }
  }

  if (flag_e == flag_w && flag_s == flag_n)
    cout << "Yes" << "\n";
  else
    cout << "No" << "\n";
}

Measured memory_bytes: 256