akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
using int64    = long long;
using PII      = pair<int, int>;
const int MAXN = 100005;
const int INF  = 0x3f3f3f3f;

int64 a[MAXN];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    if(a[0]==0) cout << 0 << endl;
    else {
        long double res = 1;
        int64 ans = 1;
        for(int i=0;i<n;i++) {
            res *= a[i];
            if(res>1e18) {
                cout << -1 << endl;
                return 0;
            }
            ans *= a[i];
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,i;string S,T;cin>>N>>S>>T;
  for(i=N;i>0;i--){
    if(S.substr(N-i,i)==T.substr(0,i))break;
  }
  cout<<2*N-i<<endl;
}

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

signed main() {
	int a, b; cin >> a >> b;
	int c = __gcd(a, b);
	int ans = 1;
	
	for (int i = 2; i * i <= c; i++) {
		if (!(c % i)) ans++;
		while (!(c % i)) {
			c /= i;
		}
	}
	if (c != 1) {
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
const int N = 1e5+7 ;
int a[N],b[N],c[N] ;
long long dp[3][N] ;

int main(){
fast ;
int n ;
cin >> n ;
for(int i=1;i<=n;i++)
	cin >> a[i] >> b[i] >> c[i] ;

dp[0][1] = a[1] ;dp[1][1] = b[1] ; dp[2][1] = c[1] ;
for(int i=2;i<=n;i++){
	dp[0][i] = a[i] + max(dp[1][i-1],dp[2][i-1]) ;
	dp[1][i] = b[i] + max(dp[0][i-1],dp[2][i-1]) ;
	dp[2][i] = c[i] + max(dp[1][i-1],dp[0][i-1]) ;
} 
cout << max({dp[0][n],dp[1][n],dp[2][n]}) << endl ;
}



Measured memory_bytes: 3840
#include <iostream>

int main() {
  long long a, b;
  char op;
  std::cin >> a >> op >> b;
  if (op == '+') {
    std::cout << a + b << "\n";
  }
  if (op == '-') {
    std::cout << a - b << "\n";
  }
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;

int n, m;
int a[3010], b[3010];
int dp[3010][3010];

void LCS(string a, string b){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(a[i - 1] == b[j - 1]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	
	vector<char> lcs(dp[n][m]);
	int r = n, c = m, ind = dp[n][m];
	
	while(r > 0 && c > 0){
		if(a[r - 1] == b[c - 1]){
			lcs[--ind] = a[r - 1];
			r--, c--;
		}
		else if(dp[r - 1][c] > dp[r][c - 1]){
			r--;
		}
		else{
			c--;
		}
	}
	
	for(int i = 0; i < lcs.size(); i++){
		cout << lcs[i];
	}
	cout << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    string a, b;
    
    cin >> a >> b;
    
    n = a.size(), m = b.size();
	
	LCS(a, b);
    
	return 0;
}




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

signed main(){
  int N, M;
  cin >> N >> M;
  int sum = 0;
  int A[100010];
  rep(i,M){
    cin >> A[i];
    sum+=A[i];
  }
  if(N < sum)cout << -1;
  else cout << N - sum;
}


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



int main(){
	int X , Y ;
	cin >> X >> Y ;
	int a[4] = {0,300000 , 200000 , 100000 } ;
	int sum = 0 ;
	if( X >= 1 && X <= 3 ) sum += a[X] ;
	if( Y >= 1 && Y <= 3 ) sum += a[Y] ;
	if( X == 1 && Y == 1) {
		sum += 400000 ;
	}
	cout << sum << endl ;

	return 0 ;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let k: i32 = read();
    let mut heights: Vec<i32> = vec![];
    for _ in 0..n {
        heights.push(read());
    }
    let mut dp = vec![0; n as usize];
    for i in 1..n as usize {
        dp[i] = std::i32::MAX;
        for j in 1..(k + 1) as usize {
            if i < j {
                break;
            }
            dp[i] = std::cmp::min(dp[i], dp[i - j] + (heights[i - j] - heights[i]).abs());
        }
    }
    println!("{}", dp[n as usize - 1]);
}


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

using namespace std;

/*int N, M, a[109];
set < vector < int > > S;

int mod (int x)
{
    if (x<0)return -x;
    return x;
}

void back (int pos)
{
    vector < int > curr;
    for (int i=1; i<=N; i++)
        curr.push_back (a[i]);
    if (S.find (curr) != S.end ()) return;
    S.insert (curr);
    bool ok = 1;
    for (int i=1; i<=N; i++)
        if (a[i] != i && a[i] != -i)
            ok = 0;
    if (ok)
    {
        for (int i=1; i<=N; i++)
            if (a[i] > 0) printf ("0");
            else printf ("1");
        printf ("\n");
    }
    //if (pos == M + 1) return ;
    for (int i=2; i<N; i++)
    {
        a[i] = -a[i];
        swap (a[i - 1], a[i + 1]), a[i - 1] = -a[i - 1], a[i + 1] = -a[i + 1];
        back (pos + 1);
        a[i] = -a[i];
        swap (a[i - 1], a[i + 1]), a[i - 1] = -a[i - 1], a[i + 1] = -a[i + 1];
    }
}*/

int inv[2], N, a[4][100009], b[100009], aib[100009];

void No ()
{
    printf ("No\n");
    exit (0);
}

void Clear(){for(int i=1;i<=N;i++)aib[i]=0;}
void U (int pos) {while(pos<=N) aib[pos]++, pos+=pos-(pos&(pos - 1));}
int Qry (int pos){int sum=0; while(pos) sum+=aib[pos], pos&=pos-1; return sum;}
int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);//, M = N + 9;
/*for (int i=1; i<=N; i++)
    a[i] = i;
back (1);
for (auto it = S.begin (); it != S.end (); it ++, printf ("\n"))
    for (auto it2 = (*it).begin (); it2 != (*it).end (); it2 ++)
        printf ("%2d ", *it2);*/
for (int i=1; i<=3; i++)
    for (int j=1; j<=N; j++)
        scanf ("%d", &a[i][j]);
for (int j=1; j<=N; j++)
    if (a[2][j] % 3 != 2) No ();
    else b[j] = a[2][j] / 3 + 1;
for (int i=1; i<=N; i++)
    if (b[i] % 2 != i % 2) No ();
for (int j=1; j<=N; j++)
{
    int x = 3 * b[j] - 3 + 1, y = x + 1, z = y + 1;
    //printf ("%d %d %d\n", x, y, z);
    if (a[2][j] != y) No ();
    if (a[1][j] != x && a[1][j] != z) No ();
    if (a[3][j] != x && a[3][j] != z) No ();
    if (a[1][j] != x) inv[j % 2] ^= 1;
}
/*for (int i=1; i<=N; i++)
    printf ("%d", b[i]);
printf ("\n");
return 0;*/
int cnt[2];cnt[0]=cnt[1] = 0;
for (int i=N; i>=1; i-=2)
{
    if (Qry (b[i]) & 1) cnt[i%2] ^= 1;
    U (b[i]);
}
Clear ();
for (int i=N-1; i>=1; i-=2)
{
    if (Qry (b[i]) & 1) cnt[i%2] ^= 1;
    U (b[i]);
}
if (cnt[0] != inv[1] || cnt[1] != inv[0]) No ();
printf ("Yes\n");
return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> arr;
  map<ll, int> amap;
  ll tmp;
  ll ans = 0;
  for(int i=0;i<N;++i){
    cin>>tmp;
    ans += tmp;
    if(amap[tmp]==0) arr.push_back(tmp);
    amap[tmp]++;
  }
  int Q;
  cin>>Q;
  ll B, C;
  for(int i=0;i<Q;++i){
    cin>>B>>C;
    ans -= B*amap[B];
    ans += C*amap[B];
    amap[C] += amap[B];
    amap[B] = 0;
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 9420
//////////////////////////////
// Author: whatisit
// Date: 2020-05-18 09:39 
//////////////////////////////
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5+2;
long long n, k, ans;

void solve() {
	cin >> n >> k;
	for (int i = k; i <= n+1; ++i) {
		ans += (((n-i+1) * i + 1) % 1000000007);
		ans %= 1000000007;
	}

	cout << ans;
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(0);
	solve();
	return 0;
}

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

int main() {
  string ans = "YES";
  set<int> st;
  int n;
  cin >> n;

  while ( n-- > 0 ) {
    int a;
    cin >> a;
    if ( st.find(a) != st.end() ) {
      ans = "NO";
    } else {
      st.insert(a);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12960
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pqueue = priority_queue<int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
 
int main(){
  long n,m;
  cin >> n >> m;
  vector<pair<long, long>> data(n);
  long a,b;
  rep(i,n){
    cin >> a >> b;
    data.at(i) = make_pair(a,b);
  }
  sort(data.begin(),data.end());
  priority_queue<long> pq;
  long j = 0;
  long answer = 0;
  bool fin = false;
  rep(i,m){
    while(!fin){
      if(data.at(j).first != i+1) break;
      pq.push(data.at(j).second);
      j++;
      if(j == n) break;
    }
    if(!pq.empty()) {
      answer += pq.top();
      pq.pop();
    }
    if(j >= n) fin = true;
  }
  cout << answer << endl;
}

Measured memory_bytes: 2936
N=int(input())
tmp=input()
tmp=tmp.split(' ')
a=[]
for i in range(N):
  a.append(int(tmp[i]))
  
if all(x % 2 == 0 for x in a) == False:
  print(0)
else:
  count=0
  while all(x % 2 == 0 for x in a) == True:
    a=[x/2 for x in a]
    count+=1
    
  print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int ab,bc,ca;
    cin >> ab >> bc >> ca;
    cout << ab * bc /2;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }



int collatz(int n){
    int a=n;
    if(a%2 == 0)a/=2;
    else a = a*3+1;
    return a;
}

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

    cout << "Christmas";
    rep(i,25-D){
        cout << " Eve" ;

    }
    cout << endl;


}



Measured memory_bytes: 3568
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
template<class T>
void MN(T& a, T b) {
    if (a > b) a = b;
}

int main() {
    int i;
    int dp1 = 0;
    int dp2 = 1073709056;
    int nx1;
    int nx2;

    int N; string S;
    cin >> S;
    N = S.size();
    S += '0';

    for (i = 0; i < N; i++)
        S[i] -= '0';

    for (i = N; i >= 1; i--)
        S[i] = S[i - 1];
    

    S[0] = 0;
    for (i = N; i >= 0; i--) {
        nx1 = nx2 = 1073709056;
        //다음 숫자에서 빌려오지 않음
        MN(nx1, dp1 + S[i]);
        MN(nx1, (dp2 + 1) + S[i]);
        //다음 숫자에서 10빌려옴
        MN(nx2, dp1 + 10 - S[i]);
        MN(nx2, dp2 + (10 - S[i]) - 1); //원래 현재에서 빌린 1을 하나 위에서 빌려오는 것으로 해결되므로 -1을 가중해준다.

        dp1 = nx1;
        dp2 = nx2;
    }

    cout << dp1 << '\n';
    return 0;
}
//int main() {
//    ios_base::sync_with_stdio(false);
//    cout << fixed << setprecision(12);
//    cin.tie(nullptr);
//    int n, k;
//    cin >> n >> k;
//    ll neg(0), zero(0), pos(0);
//    vl a(n);
//    for (int i = 0; i < n; i++) {
//        cin >> a[i];
//        if (a[i] > 0) pos++;
//        else if (a[i] < 0) neg++;
//        else zero++;
//    }
//    sort(all(a));
//
//    ll nneg = neg * pos, nzero = neg + pos,
//        npos = neg * (neg - 1) / 2 + pos * (pos - 1) / 2;
//    if (k <= nneg) {
//        vl ans;
//        for (int i = 0; i < neg; i++) {
//            for (int j = neg + zero; j < n; j++) {
//                ans.push_back(a[i] * a[j]);
//            }
//        }
//        sort(all(ans));
//        cout << ans[k - 1];
//    }
//    else if (k <= (nneg + nzero)) {
//        cout << "0\n";
//    }
//    else {
//        vl ans;
//
//    }
//
//    return 0;
//}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n = 0): n(n), d(n + 1, 0) {}
  void add(int i, T x = 1) {
    for (; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
};

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<pair<ll, ll>> p(n + 1, {0, 0});
  rep(i, n) p[i + 1].first = p[i].first + a[i] - k;
  rep(i, n + 1) p[i].second = i + 1;
  sort(p.begin(), p.end());
  BIT<ll> bit(n + 10);
  ll ans = 0;
  rep(i, n + 1) {
    ans += bit.sum(p[i].second);
    bit.add(p[i].second);
  }
  cout << ans << '\n';

  

  




  
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7

ULL GCD(ULL a,ULL b){
    if(b == 0)return a;
    return GCD(b,a%b);
}


int main(){
    int k;
    cin >> k;
    ULL ans = 0;
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= k; ++j){
            for(int l = 1; l <= k; l++){
                ans += GCD(i,GCD(j,l));
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(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))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, x;
VL A, cost;

int main() {
    cin >> N >> x;
    REP(i, N) A.emplace_back(IN());
    cost.assign(N, LINF);
    ll ans = LINF, tmp = 0;
    REP(k, N) {
        tmp = 0;
        REP(i, N) {
            cost[i] = min(cost[i], A[(i - k + N) % N]);
            tmp += cost[i];
        }
        ans = min(k * x + tmp, ans);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#define X 500000
#define Y 1000000001

void Merge(int *, int, int, int);
void MergeSort(int *, int, int);
void Print(int *);
int count = 0;

main(){
  int i, n;
  int A[X];
  

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);


  MergeSort(A, 0, n);

  for(i = 0; i < n; i++)
    if(i == n - 1)
      printf("%d\n",A[i]);
    else
      printf("%d ",A[i]);
  printf("%d\n",count);
  
  return 0;
}



void Merge(int *A, int B, int C, int D){
  int i, j, k, N1, N2;
  int La[X], Ra[X];
  
  N1=C-B;
  N2=D-C;

  for(i = 0; i < N1; i++){
    La[i] = A[B+i];
  }
  for(i = 0; i < N2; i++){
    Ra[i] = A[C+i];
  }
  
  La[N1] = Y;
  Ra[N2] = Y;
  
  i = 0; 
  j = 0;
  
  for(k = B; k <= D - 1; k++){
    count++;
    if( La[i] <= Ra[j] )
      A[k] = La[i++];
    else
      A[k] = Ra[j++];
  }
  
  
}


void MergeSort(int *A, int B, int D){  
  int C;
  
  if( B+1 < D ){
    C=(B+D) / 2;
    
    MergeSort(A, B, C);
    MergeSort(A, C, D);
    Merge(A, B, C, D);
  }
}

Measured memory_bytes: 4324
C=[]
for _ in range(3):
    a=list(map(int,input().split()))
    b=min(a)
    for i in range(3):
        a[i]-=b
    C.append(a)
if C[0]==C[1] and C[1]==C[2] and C[0]==C[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
  ll ans = (a/2LL)*2LL + b + (d/2LL)*2LL + (e/2LL)*2LL;
  if(a&&d&&e) ans = max(ans, ((a-1)/2)*2LL+b+((d-1)/2)*2LL+((e-1)/2)*2LL+3LL);
  cout << ans << endl;
}
  

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    string s;
    int a=0;
    
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='o'){
            a++;
        }
    }
    
    if(8-a<=15-s.size()){
        YES;
    }else{
        NO;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    cout << a.at(0) << b.at(0) << c.at(0) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int N = 0, d[100] = { 0 }, i = 0, Pa = 0, j = 0, Po = 0, M = 0, didI[100] = {0}, didJ[100] = {0};

	scanf("%d", &N);
	for (i = 1; i <= N; i++)
	{
		scanf("%d", &d[i]);
	}

	for (i = 1; i <= N; i++)
	{
		//Pa = (N*(N - 1)) / 2;
		for (j = i+1; j <= N; j++)
		{
			Po = Po + d[i] * d[j];
		}
	}

	printf("\n%d\n", Po);
	return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
p = list(map(int, input().split()))

p = list(map(lambda x: (1+x)/2, p))
s = [0]
num = 0
for i in range(n):
  num += p[i]
  s.append(num)
l = []
for i in range(n - k + 1):
  l.append(s[i+k]-s[i])

print(max(l))


Measured memory_bytes: 32280
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> A;
    for(int i=0; i < n; i++){
        int tmp = 0;
        cin >> tmp;
        A.push_back(tmp);
    }

    //デバッグ用
    //for(int i=0; i < n; i++) cout << A[i] << endl;

    //解答
    int cnt = n + x; //第一項目＋残り
    int day = d - 1;
    for(int i=0; i < n; i++) cnt += day / A[i];

    cout << cnt << endl;

    return 0;
}


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

int a[100000][3];

int main()
{
	int f=1, i, j, n;
	cin >> n;
	
	for(i=0; i<n; i++)
	{
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		if((a[i][2]+a[i][1]>a[i][0])||a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0;
	}
	
	if(f==1)
	   cout<<"Yes";
	else
	   cout<<"No";
	
	return 0;
} 

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	int sum = 0;
	REP(i, N) sum+=A[i];
	REP(i, N) A[i]*=N;
	int mi=100000;
	int mind = -1;
	REP(i, N){
		int j= N-i-1;
		if(abs(A[j]-sum)<=mi){
			mind = j;
			mi = abs(A[j]-sum);
		}
	}
	cout << mind << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    VI cnts;
    int cnt = 0, c = 0;
    rep(i,n){
        if (s[i] != '0'+c){
            cnts.push_back(cnt);
            c ^= 1;
            cnt = 0;
        }
        cnt++;
    }
    cnts.push_back(cnt);
    if (cnts.size() % 2 != 0) cnts.push_back(0);

    int sz = cnts.size();
    VI sum(sz+1);
    rep(i, sz){
        sum[i+1] = sum[i] + cnts[i];
    }

    int ans = 0;
    int left = 0, right = min(2 * k, sz);
    while(right <= sz){
        int val = sum[right] - sum[max(left-1, 0)];
        ans = max(ans, val);
        left += 2;
        right += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4212
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int N, D;
  scanf("%d %d", &N, &D);
  int A[10][10];
  int k, l;
  for(k=0; k<N; k++){
    for(l=0; l<D; l++){
      scanf("%d", &A[k][l]);
    }
  }
  int count=0;
  int m;
  for(k=0; k<N; k++){
    for(l=k+1; l<N; l++){
      double ret=0;
      for(m=0; m<D; m++){
        ret+=(A[k][m]-A[l][m])*(A[k][m]-A[l][m]);
      }
      ret=sqrt(ret);
      if(ret-ceil(ret)==0){
        count++;
      }
    }
  }
  printf("%d", count);
}

Measured memory_bytes: 128
object Main{
 
def main(args: Array[String]): Unit = {
  
    val arr1 = io.StdIn.readLine().split(' ')
    val n = arr1(0).toInt
    val arr2 = io.StdIn.readLine().split(' ')
    val h = arr2.map(_.toInt)

    var yes = true

    var base = -2
    h.indices.map{
      i =>
        if(i != n - 1){
        val res = h(i + 1) - h(i)
        
        if(res > 0) {
          base = -2
        }else if(res <= base){
          yes = false
        }else{
          base = base - res
        }
        
        
    }
    }
  
    if(n == 1) {
      yes = true
    }
    
    
    if(yes) println("Yes") else println("No")
  
  
}
}

Measured memory_bytes: 49016
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val m = mutableMapOf<Int, Int>()
    while (sc.hasNext()) {
        val n = sc.nextInt()
        m[n] = m.getOrDefault(n, 0)+1
    }
    val l = m.toList()
    val max = l.maxBy { it.second }!!.second
    for ((a, _) in l.filter { it.second == max }.sortedBy { it.first }) println(a)
}


Measured memory_bytes: 29568
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll n; cin>>n;
    ll fib[50];
    fib[0] = fib[1] = 1;
    FOR(i, 2, 50){
        fib[i] = fib[i-1] + fib[i-2];
    }
    cout << fib[n] << endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B,C,D;
    string S,T;
int main(){
    cin>>A>>B;

    if(A<=8&&B<=8)cout<<"Yay!";
    else cout<<":(";
    return 0;

}


Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()]
dp = [0] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
print(dp[N-1])


Measured memory_bytes: 52208
#include<stdio.h>
int main()
{
    int a,b,ave,acu_ave;
    scanf("%d %d",&a,&b);
    if((a+b)%2==0)
    {
        ave=(a+b)/2;
        printf("%d\n",ave);
    }
    else
    {
        ave=(a+b)/2;
        acu_ave=ave+1;
        printf("%d\n",acu_ave);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string C;
  int N;
  cin >> N;
  int i;
  int count;
  for(i=0; i<N; i++){
    cin >> C;
    if(C=="Y")
      count++;
  }
  
  if(count>0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}
    

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(ll (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

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

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

struct union_find {
	vector<int> p;
	union_find(int n) : p(n, -1) {};
	bool unite(int u, int v) {
		if ((u = find(u)) == (v = find(v))) return false;
		if (p[u] > p[v]) swap(u, v);
		p[u] += p[v]; p[v] = u;
		return true;
	}
	bool same(int u, int v) { return find(u) == find(v); }
	int find(int u) { return p[u] < 0 ? u : p[u] = find(p[u]); }
	int usize(int u) { return -p[find(u)]; }
};

int n, k, l, a, b;
union_find x(200200), y(200200);
pii p[200200];

signed main() {
	cin >> n >> k >> l;
	rep(i,k) {
		cin >> a >> b;
		a--, b--;
		x.unite(a,b);
	}
	rep(i,l) {
		cin >> a >> b;
		a--, b--;
		y.unite(a,b);
	}
	// iから道路でも鉄道でも行ける都市の数 == これ↓と一致するペアの数
	rep(i,n) p[i] = {x.find(i),y.find(i)};
	sort(p,p+n);
	rep(i,n) {
		pii tmp = {x.find(i),y.find(i)};
		cout << upper_bound(p,p+n,tmp) - lower_bound(p,p+n,tmp) << (i==n-1 ? '\n' : ' ');
	}
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (B <= A) {
        cout << "delicious" << endl;
    } else if (B <= A+X) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
if b == 7:
    if a == 5 and c == 5:
        print("YES")
    else:
        print("NO")
elif c == 7:
    if a == 5 and b == 5:
        print("YES")
    else:
        print("NO")
elif a == 7 :
    if b == 5 and c == 5:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let q = read::<usize>();
    let mut ss = vec![0; n + 2];
    let mut ts = vec![0; m + 2];
    let mut xs = vec![0; q];
    ss[0] = -(1i64 << 50);
    ss[n + 1] = 1i64 << 50;
    ts[0] = -(1i64 << 50);
    ts[m + 1] = 1i64 << 50;
    for i in 0..n {
        ss[i + 1] = read::<i64>();
    }
    for i in 0..m {
        ts[i + 1] = read::<i64>();
    }
    for i in 0..q {
        xs[i] = read::<i64>();
    }
    for i in 0..q {
        let x = xs[i];
        let index1 = match ss.binary_search(&x) {
            Ok(v) => v,
            Err(v) => v,
        };
        let index2 = match ts.binary_search(&x) {
            Ok(v) => v,
            Err(v) => v,
        };
        let l1 = ss[index1 - 1];
        let r1 = ss[index1];
        let l2 = ts[index2 - 1];
        let r2 = ts[index2];
        let mut ans = 1 << 50;
        ans = std::cmp::min(ans, (std::cmp::max(r1, r2) - x).abs());
        ans = std::cmp::min(ans, (std::cmp::min(l1, l2) - x).abs());
        ans = std::cmp::min(ans, (x - r1).abs() + (r1 - l2).abs());
        ans = std::cmp::min(ans, (x - l1).abs() + (l1 - r2).abs());
        ans = std::cmp::min(ans, (x - r2).abs() + (r2 - l1).abs());
        ans = std::cmp::min(ans, (x - l2).abs() + (l2 - r1).abs());
        println!("{}", ans);
    }
}


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

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

    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));

    if(y < 2019){
        cout << "Heisei" << endl;
        return 0;
    }
    if(y == 2019){
        if(m < 4 || m == 4 && d <= 30){
            cout << "Heisei" << endl;
            return 0;
        }
    }

    cout << "TBD" << endl;
}


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

int main()
{
  int k,l;
  cin>>k>>l;
  int c=0;
  for(int i=k; i<=l; i++)
  {
    string str=std::to_string(i);
    if((str[0]==str[4])&&(str[1]==str[3])) c++;
  }
  cout <<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long
int main(){
	ll n;
	scanf("%lld", &n);
	if (n < 10){
		printf("%lld\n", n);
		return 0;
	}
	ll a[10][10], ans = 0;
	for (ll i = 1; i <= 9; i++){
		for (ll j = 1; j <= 9; j++){
			a[i][j] = 0;
			if (i == j) a[i][j]++;
			ll k = 10;
			while (true){
				ll t = i * k + j;
				if (t > n) break;
				ll l = 0, r = k / 10 - 1;
				while (l < r){
					ll mid = (l + r) / 2 + (l + r) % 2;
					if (t + mid * 10 <= n){
						l = mid;
					}else{
						r = mid - 1;
					}
				}
				a[i][j] += l + 1;
				k *= 10;
			}
		}
	}
	for (ll i = 1; i <= 9; i++){
		for (ll j = 1; j <= 9; j++){
			ans += a[i][j] * a[j][i];
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
int main()
{
  int h,w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  queue<pi> q;
  q.push({0, 0});
  while(!q.empty()) {
    pi p = q.front(); q.pop();
    rep(i,2) {
      int nx = p.F + dx[i+2];
      int ny = p.S + dy[i+2];
      if(0 <= nx && nx < h && 0 <= ny && ny < w) {
	if(s[nx][ny] == '#') {
	  cout << "Impossible" << "\n";
	  return 0;
	}
      }
    }
    bool f = false;
    rep(i,2) {
      int nx = p.F + dx[i];
      int ny = p.S + dy[i];
      if(0 <= nx && nx < h && 0 <= ny && ny < w) {
	if(s[nx][ny] == '#') {
	  if(!f) {
	    q.push({nx, ny});
	    f = true;
	  }
	  else {
	    cout << "Impossible" << "\n";
	    return 0;
	  }
	}
      }      
    }
    s[p.F][p.S] = '.';
  }
  rep(i,h) {
    rep(j,w) {
      if(s[i][j] == '#') {
	cout << "Impossible" << "\n";
	return 0;
      }
    }
  }
  cout << "Possible" << "\n";
  
  return 0;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10 ** 6)
n = int(input())
s = list(input())

ans = 0
num = [str(i) for i in range(10)]
for i in num:
    for l in range(n):
        if s[l] == i:
            for j in num:
                for m in range(l+1,n):
                    if s[m] == j:
                        for k in num:
                            for p in range(m+1, n):
                                if s[p] == k:
                                    ans += 1
                                    break
                            continue
                        break
            break

print(ans)

Measured memory_bytes: 42732
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ①決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ②最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ③
 */

/*
 DP
 ①DPはある程度決め打ちをするべき(解を帰納的に構成できないか？)
 */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll lb=0,ub=n+1;
	while(ub-lb>1) {
		ll mid=(lb+ub)/2;
		if(mid*(mid+1)/2<n) lb=mid;
		else ub=mid;
	}
	REP(i,ub) {
		if(i+1==ub*(ub+1)/2-n) continue;
		else cout<<i+1<<endl;
	}
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
 
public class Main {
	static Scanner in;
	static int n, a[];
	static long ans = 0;
	public static void main(String[] args) throws FileNotFoundException {
//		in = new Scanner(new File("input.txt"));
		in = new Scanner(System.in);
		n = in.nextInt();
		a = new int[n + 1];
		for(int i = 1;i <= n;i++){
			a[i] = in.nextInt();
		}
		for(int i = 1;i <= n;i++){
			int j = a[i];
			if(j <= n && j >= 1){
				if(a[j] == i) ans++;
			}
		}
		System.out.println(ans/2);
	}
}

Measured memory_bytes: 32588
#include<bits/stdc++.h>
 
using namespace std;
 
int N, W[300], dp[300][300];
 
int rec(int l, int r)
{
  if(l >= r) return (0);
  if(~dp[l][r]) return (dp[l][r]);
  int ret = 0;
  if(abs(W[l] - W[r]) <= 1 && rec(l + 1, r - 1) == r - l - 1) ret = r - l + 1;
  for(int m = l; m < r; m++) ret = max(ret, rec(l, m) + rec(m + 1, r));
  return (dp[l][r] = ret);
}
 
int main()
{
  while(scanf("%d", &N), N) {
    for(int i = 0; i < N; i++) {
      scanf("%d", &W[i]);
    }
    memset(dp, -1, sizeof(dp));
    printf("%d\n", rec(0, N - 1));
  }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    double sum=0;
    rep(i,N){
        double a; cin >> a;
        sum+=1.0/a;
    }
    cout << fixed << setprecision(10);
    cout << 1.0/sum << endl;
}

Measured memory_bytes: 256
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself
        
*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define pb push_back
#define mp make_pair
#define d(x) cout<<x<<"\n"

int32_t main(void)
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int x=n%1000;
        if(x==0)
        cout<<0<<"\n";
        else
        cout<<1000-x<<"\n";
        
        
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

vll l(50), p(50);

ll f(int n, ll x) {
    if (n == 0) return 1;
    else if (x == 1) {
        return 0;
    } else if (x <= 1 + l[n-1]) {
        return f(n-1, x-1);
    } else if (x == 1 + l[n-1] + 1) {
        return p[n-1] + 1;
    } else if (x <= 1 + l[n-1] + 1 + l[n-1]) {
        return p[n-1] + 1 + f(n-1, x - (1 + l[n-1] + 1));
    } else {
        return p[n-1] + 1 + p[n-1];
    }
}

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

    int n;
    ll x;
    cin >> n >> x;
    rep(i, 50) {
        if (i == 0) {
            l[i] = 1;
            p[i] = 1;
        } else {
            l[i] = 2*l[i-1] + 3;
            p[i] = 2*p[i-1] + 1;
        } 
    }
    cout << f(n, x) << endl;
}

Measured memory_bytes: 256
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


a, b = map(int, input().split())

if a%2 == 0 or b%2 == 0:
    print('Even')
else:
    print('Odd')

Measured memory_bytes: 21768
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

const int mod = 1e9 + 7;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; ++i) {
    cin >> a[i];
  }
  vector<vector<int>> dp(h, vector<int>(w, 0));
  dp[0][0] = 1;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#') continue;
      if (i + 1 < h && a[i+1][j] == '.') {
        dp[i+1][j] += dp[i][j];
        if (dp[i+1][j] >= mod) {
          dp[i+1][j] -= mod;
        }
      }
      if (j + 1 < w && a[i][j+1] == '.') {
        dp[i][j+1] += dp[i][j];
        if (dp[i][j+1] >= mod) {
          dp[i][j+1] -= mod;
        }
      }
    }
  }
  cout << dp[h-1][w-1] << '\n';
  return 0;
}


Measured memory_bytes: 9436
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e6;
    
     int mod= 1e9+7;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
   
  
      
     void solve(){
       int q;
       cin>>q;
       
       vi v;
       
       while(q--){
		   int x;
		   cin>>x;
		   v.pb(x);   
	   }
	  
	   vi nax(sz(v));
	   nax=v;
	   sort(all(nax));	
	      
	   int len=sz(v);
	 
	   rep(i,0,len){
		   
		   if(nax[len-1]==v[i])
			   cout<<nax[len-2]<<endl;
		   
		   
		   else
		     cout<<nax[len-1]<<endl;
		  }
     }
   
   
   
   
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 4848
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void ABCxxx() {
	int n;
	cin >> n;

	cout << "ABC" << n << endl;

}
int main() {

	ABCxxx();
	return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	string s, t;
	cin >> s >> t;
	if (t.find(s) == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3628