akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    vector<tuple<int,int,int>> v;
    rep(i,N){
        int a,b;
        cin >> a >> b;
        v.emplace_back(a+b,a,b);
    }
    sort(all(v));
    reverse(all(v));
    ll sum=0;
    rep(i,N){
        if(i%2==0)sum+=get<1>(v[i]);
        else sum-=get<2>(v[i]);
    }
    cout << sum;
    


}

/*



 */



Measured memory_bytes: 1912
# coding: utf-8
# Your code here!
MOD=10**9+7

def dot(a, b):
    res = [[0] * n for _ in range(n)]
    for i in range(n):
        for k, aik in enumerate(a[i]):
            for j,bkj in enumerate(b[k]):
                res[i][j] += aik*bkj
                res[i][j] %= MOD
    return res


n,k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(n)]

ans = [[0] * n for _ in range(n)]
for i in range(n):
    ans[i][i] = 1

while k:
    k, i = divmod(k, 2)
    if i:
        ans = dot(ans, A)
    A = dot(A, A)

res = 0
for i in range(n):
  for j in range(n):
    res += ans[i][j]
    res %= MOD
print(res)

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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(int, char**)
{
  int n, k;
  cin >> n >> k;

  vector<int> pos, neg;
  rep(i,n) {
    int tmp;
    cin >> tmp;
    if (tmp > 0) pos.push_back(tmp);
    if (tmp < 0) neg.push_back(-tmp);
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());

  int ns = neg.size();
  int ps = pos.size();

  mint ans = 1;

  bool canpos = false;
  if (k <= ns/2*2) {
    if(k%2==0 || ps > 0) canpos = true;
  } else {
    if (ps >= k - ns/2*2) canpos = true;
  }

  if (!canpos) {
    if (ns == n && k%2 == 1) {
      rep(i,k) ans *= neg[i];
      cout << -ans << endl;
    } else if (k == n && ns%2 == 1) {
      rep(i,ns) ans *= neg[i];
      rep(i,ps) ans *= pos[i];
      cout << -ans << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }

  if (k%2==1) {
    ans *= pos.back();
    pos.pop_back();
    k--;
  }

  vector<ll> dbl;
  while (pos.size() > 1) {
    ll tmp = pos.back(); pos.pop_back();
    tmp *= pos.back(); pos.pop_back();
    dbl.push_back(tmp);
  }
  while (neg.size() > 1) {
    ll tmp = neg.back(); neg.pop_back();
    tmp *= neg.back(); neg.pop_back();
    dbl.push_back(tmp);
  }
  sort(dbl.rbegin(), dbl.rend());
  rep(i,k/2) ans *= dbl[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5432
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 8; i++)cout << s[i];
	cout << endl;
	ll
}

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

int N, A, B, C;
vector<int> L(8);
int DFS(int cur, int a, int b, int c) {
    if (cur == N) {
        if (min({a,b,c}) == 0) return 1<<30;
        else return abs(A-a) + abs(B-b) + abs(C-c) - 30;
    }
    int r0, r1, r2, r3;
    r0 = DFS(cur + 1, a, b, c);
    r1 = DFS(cur + 1, a + L[cur], b, c) + 10;
    r2 = DFS(cur + 1, a, b + L[cur], c) + 10;
    r3 = DFS(cur + 1, a, b, c + L[cur]) + 10;
    int r4 = min({r0, r1, r2, r3});
    //printf("%d %d %d %d: %d\n", cur, a, b, c, r4);
    return r4;

}

int main() {
    cin >> N >> A >> B >> C;
    rep(i,N) cin >> L.at(i);
    cout << DFS(0, 0, 0, 0) << endl; 
}

Measured memory_bytes: 256
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut counts: HashMap<isize, isize> = HashMap::new();
    let mut ans: isize = 0;
    for _ in 0..n {
        let ai: isize = iterator.next().unwrap().parse().unwrap();
        ans += ai;
        *counts.entry(ai).or_insert(0) += 1;
    }

    let mut result = String::new();
    let q: usize = iterator.next().unwrap().parse().unwrap();
    for _ in 0..q {
        let bi: isize = iterator.next().unwrap().parse().unwrap();
        let ci: isize = iterator.next().unwrap().parse().unwrap();
        if let Some(x) = counts.get(&bi) {
            ans += (ci - bi) * *x;
            *counts.entry(ci).or_insert(0) += *x;
            counts.remove(&bi);
        }
        result.push_str(&format!("{}\n", ans));
    }

    return result.trim().to_string();
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define endl '\n'
 
const ll MOD = 1000000007;
 
int main() {
   int x, y, a, b, c;
   scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
   vector<int> p(a), q(b), r(c);
   for (int &i : p)
      scanf("%d", &i);
   for (int &i : q)
      scanf("%d", &i);
   for (int &i : r)
      scanf("%d", &i);
   sort(all(p), greater<int>());
   sort(all(q), greater<int>());
   sort(all(r), greater<int>());
   vector<int> sol;
   for (int i = 0; i < x; i++)
      sol.pb(p[i]);
   for (int i = 0; i < y; i++)
      sol.pb(q[i]);
   sort(all(sol), greater<int>());
   int cur = -1;
   while (!sol.empty() && cur < c - 1 
      && sol.back() < r[cur + 1]) {
      sol.pop_back();
      cur++;
   }
   ll ans = 0;
   for (int i : sol)
      ans += i;
   for (int i = 0; i <= cur; i++)
      ans += r[i];
   printf("%lld", ans);
   return 0;
}

Measured memory_bytes: 5356
N = int(input())
L = list(map(int,input().split()))

result = True
for n in L:
    if n % 2 == 0:
        if ((n % 6) != 0) and ((n % 10) != 0):
            result = False
            break

if result:
    print('APPROVED')
else:
    print('DENIED')

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

int main() {
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int g = __gcd(n, m);

  for (int i = 0; i < g; i++){
    int x = n / g * i;
    int y = m / g * i;
    if (s[x] != t[y]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << (long long)n / g * m << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    
    string S;
    cin >> S;
    bool l = 1;
    int cnt = 0;
    char x;
    int t;
    for(int i = 1; i < S.size(); i++){
        if(S.at(i) - 'a' < 0){
            cnt++;
            x = S.at(i);
            t = i;
        }
    }
    if(cnt != 1 || x != 'C' || S.at(0) != 'A' || t == 1 || t == S.size()-1){
        l = 0;
    }
    if(l){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}


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

int main()
{
  int X;
  long res=1;//including 1                                                      
  cin >> X;

  for(long i=2;i<=X;i++){
    long num=i*i;
    if(num<=X) res = max(res, num); //2                                         
    if(i>10) continue;
    for(int j=3;j<=10;j++){
      num *= i;
      if(num<=X) res = max(res, num);
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
N,X = map(int,input().split())
A = list(map(int,input().split()))
A = [0] + A + [0]
cnt = 0
for i in range(1,N+1):
    S = A[i]+A[i+1]
    if S>X:
        d = S-X
        cnt += d
        A[i+1] = max(0,A[i+1]-d)
print(cnt)

Measured memory_bytes: 14592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		if((10 * g + b) % 4 == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}


	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int dp[41][401][401];

int a[41];
int b[41];
int c[41];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(dp,-1,sizeof(dp));
	int ma, mb;
	int n;
	cin>>n>>ma>>mb;
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	dp[0][0][0] = 0;
	dp[0][a[0]][b[0]] = c[0];
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j <= 400; j++)
		{
			for(int k = 0; k <= 400; k++)
			{
				dp[i][j][k] = 100000000;
				if(dp[i-1][j][k]!=-1)
				{
					dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
				}
				if(j>=a[i]&&k>=b[i]&&dp[i-1][j-a[i]][k-b[i]]!=-1)
				{
					dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a[i]][k-b[i]]+c[i]);
				}
				
				if(dp[i][j][k]>=100000000) dp[i][j][k]=-1;
			}
		}
	}
	int ans = 100000000;
	for(int i = 1; i*max(ma,mb)<=400; i++)
	{
		if(dp[n-1][i*ma][i*mb]!=-1) ans=min(ans,dp[n-1][i*ma][i*mb]);
	}
	if(ans==100000000) cout<<-1<<'\n';
	else cout<<ans<<'\n';
}


Measured memory_bytes: 25984
#include <stdio.h>
#define H 251
/*
void swap(int a, int b){
  int temp;
  temp = a;
  a = b;
  b = temp;
}

void Max_Heapify( int *A, int i){

  int l = i*2;
  int r = i*2 + 1;
  int largest;

  if(l <= H && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }

  if(r <= H && A[i] > A[largest]){
    largest = r;
  }
  if(largest != i){
    swap(A[i] , A[largest]);
    Max_Heapify(A, largest);
  }
}
*/

int main(){

  int A[H], heap, i;

  A[0] = 0;

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

  // Max_Heapify( A, heap/2);


  for(i = 1; i <= heap; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(i/2 >= 1){
      printf("parent key = %d, ", A[i/2]);
    }
    if(i*2 <= heap){
      printf("left key = %d, ", A[i*2]);
    }
    if(i*2 + 1 <= heap){
    printf("right key = %d, ", A[i*2 + 1]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for(ll i = (x); i < (n); i++)
#define rrep(i, x, n) for(ll i = (x); i >= (n); i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
using ll = long long int;
using ld = long double;
using pii = pair< ll, ll >;
using vi = vector< ll >;
using vvi = vector< vi >;
const ll MOD = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ld PI=3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n'

int main() {
	boost
	ll n, x;
	cin >> n;
	map<ll, ll> s;
	rep(i, 0, n) {
		cin >> x;
		s[x]++;
	}
	auto it = s.begin();
	pii a = *it++, b;
	if(s.size() > 1) b = *it++;
	if(s.size() == 1) {
		if(a.ff) cout << "No\n";
		else cout << "Yes\n";
	} else if(s.size() == 2) {
		if(a.ff or b.ss != (2 * a.ss)) cout << "No\n";
		else cout << "Yes\n";
	} else if(s.size() == 3) {
		if(a.ss != b.ss or b.ss != (*it).ss or (a.ff ^ b.ff) != (*it).ff) cout << "No\n";
		else cout << "Yes\n";
	} else cout << "No\n";
}


























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

int main() {
	long long int a, b, x;
	
	cin>>a>>b>>x;
	long long int  u=b/x;
	
	if(a%x==0) cout<<u-a/x+1;
	else cout<<u-a/x;
	
}

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

struct Matrix {
    int N;
    LL mat[MAXN + 3][MAXN + 3];

    Matrix(int n) {
        N = n;
    }
};

Matrix multiply(Matrix m1, Matrix m2) {
    Matrix result(m1.N);

    for (int i = 0; i < m1.N; i++) {
        for (int j = 0; j < m1.N; j++) {
            result.mat[i][j] = 0;
            for (int k = 0; k < m1.N; k++)
                result.mat[i][j] = (result.mat[i][j] + m1.mat[i][k] * m2.mat[k][j])%MOD;
        }
    }

    return result;
}

Matrix expo(Matrix m, LL power) {
    if (power == 1)
        return m;

    Matrix half = expo(m, power/2);
    Matrix halfhalf = multiply(half, half);

    if (power%2 == 0)
        return halfhalf;
    else
        return multiply(halfhalf, m);
}

int N;
LL K, answer;

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

    Matrix adjMatrix = Matrix(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> adjMatrix.mat[i][j];
        }
    }

    Matrix result = expo(adjMatrix, K);

    answer = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            answer = (answer + result.mat[i][j])%MOD;
        }
    }

    cout << answer << endl;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>                          
using namespace std;
int n,y;
int main() {
    cin>>n>>y;
	for(int i=0;i<=2000;i++){
        for(int j=0;j+i<=2000&&i+j<=n;j++){
            if(i*10000+j*5000+(n-i-j)*1000==y)
            {
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int l[4]={0};
	int r[4]={0};
	double onel,oner;
	while(scanf("%lf %lf",&onel,&oner)==2) {
		if(onel<0.2)l[3]++;
		else if(onel<0.6)l[2]++;
		else if(onel<1.1)l[1]++;
		else l[0]++;
		if(oner<0.2)r[3]++;
		else if(oner<0.6)r[2]++;
		else if(oner<1.1)r[1]++;
		else r[0]++;
	}
	printf("%d %d\n",l[0],r[0]);
	printf("%d %d\n",l[1],r[1]);
	printf("%d %d\n",l[2],r[2]);
	printf("%d %d\n",l[3],r[3]);
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VL xs(N);
  cin >> xs;

  auto f = [&](LL x){
	LL res = 0;
	REP(i,N){
	  res += abs(xs[i] - (x + i));
	}
	return res;
  };

  LL lb = -1e10, ub = 1e10;
  LL ans = 1e15;
  while(ub - lb > 2){
	LL x1 = (lb*2 + ub) / 3;
	LL y1 = f(x1);
	LL x2 = (lb + ub*2) / 3;
	LL y2 = f(x2);

	mini(ans, min(y1, y2));
	if(y1 < y2){
	  ub = x2;
	}
	else{
	  lb = x1;
	}
  }
  FOR(x,lb,ub+1) mini(ans, f(x));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,m; cin>>n>>m;
  VVI A;
	rep(i,n){
		int a,b; cin>>a>>b;
		VI H;
		if(a<=m){
			H.PB(a); H.PB(b); A.PB(H);
		}
	}
	int ans = 0;
	n = A.size();



	if(n!=0){
		sort(ALL(A));
		// rep(i,n){
		// 	cout << A[i][0] SP A[i][1] << endl;
		// }
		priority_queue<int> q;
		int idx = 0;
		int day = 1;
		while(day<=m){
			if(idx<n){
				while(A[idx][0]<=day){
					// cout << idx << endl;
					q.push(A[idx][1]); idx++;
					if(idx==n) break;
				}
			}

			if(q.size()!=0){
				ans += q.top(); q.pop();
				// cout << ans << endl;
			}
			// cout << day SP idx SP ans SP q.size() << endl;
			day++;

		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define MAX             100005
#define MOD             1000003
#define eps             1e-6
int fx[] =              {1,-1,0,0};
int fy[] =              {0,0,1,-1};

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0);
#define fRead           freopen("in.txt","r",stdin);
#define fWrite          freopen ("out.txt","w",stdout);

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(a)          a.begin(),a.end()

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

//// ***************************************************** TEMPLETE ***************************************************** ////

int main()
{
    FastRead
    int n;
    cin >> n;
    int cnt[MAX]={0};
    int temp,m=0;
    REP(i,n)
    {
        cin >> temp;
        cnt[temp]++;
        m=max(m,cnt[temp]);
        cnt[temp-1]++;
        m=max(m,cnt[temp-1]);
        cnt[temp+1]++;
        m=max(m,cnt[temp+1]);
    }
    cout << m << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


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

    if(d==0){
        if(n==100) cout(101);
        else cout(n);
    }
    if(d==1){
        if(n==100) cout(10100);
        else cout(100*n);
    }
    if(d==2){
        if(n==100) cout(1010000);
        else cout(10000*n);
    }

    return 0;
}

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

bool prime(int a){
    for(int i=2;i<sqrt(a);i++){
        double f=a%i;
        if(f == 0){
            return false;
            break;
        }
    }
    return true;
}


int main(){
    int x;
    bool che = true;
    cin >> x;
    for(int i=0;i<1000000;i++){
        if(prime(x+i) == true){
        cout << x+i <<endl;
        break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
 
const int MN = 100100;
vector<int> g[MN], rg[MN];
int used[MN];
int ec = 0;
array<ll, 3> visit;
bool err = false;
void dfs(int p, int c) {
    if (used[p] != -1) {
        if (used[p] != c) err = true;
        return;
    }
    used[p] = c;
    visit[c]++;
    for (int d: g[p]) {
        ec++;
        dfs(d, (c+1)%3);
    }
    for (int d: rg[p]) {
        dfs(d, (c+2)%3);
    }
}
 
int main() {
    fill_n(used, MN, -1);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        rg[b].push_back(a);
    }
    ll sm = 0;
    for (int i = 0; i < n; i++) {
        if (used[i] != -1) continue;
        visit = {0, 0, 0};
        ec = 0;
        err = false;
        dfs(i, 0);
        if (err) {
            ll v = visit[0]+visit[1]+visit[2];
            sm += v*(v-1);
            sm += v;
        } else {
            if (min(min(visit[0], visit[1]), visit[2]) == 0) {
                sm += ec;
            } else {
                sm += visit[0]*visit[1];
                sm += visit[1]*visit[2];
                sm += visit[2]*visit[0];
            }
        }
    }
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 16256
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    """
    ユークリッドの互除法より
    aの逆元 ax = 1 (mod N)を満たすxを返す。
    O(log a)
    """

    def extgcd(a, b):
        """
        Extended Great Common Divisor
        ax + by = gcd(a, b) = dを満たすx, y, dを返す。
        """
        d = fractions.gcd(a, b)
        if b == 0:
            return 1, 0, a
        else:
            q, r = divmod(a, b)
            x, y, d = extgcd(b, r)
            s, t = y, x - q * y
            return s, t, d

    return extgcd(a, N)[0]


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  # yの２進数表示の桁数
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = []

for i in range(max(a, b)):
    inv_list.append(inv_mod(i + 1, MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)


Measured memory_bytes: 123992
#include <iostream>
using namespace std;
int main(){
    int a,b,c,i,s=0,b2,p=0;
    cin >>a>>b;
    b2=b;
    while(b2>0){
        s++;
        b2/=10;
    }
    for(i=0;i<s;i++){
        a*=10;
    }
    c=a+b;
    for(i=1;i*i<=c;i++){
        if(i*i==c){
            p=1;
            break;
        }
    }
    if(p==1)
        cout <<"Yes";
    else
        cout <<"No";
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());
		int[] kk = new int[11];
		kk[a]++;
		kk[b]++;
		kk[c]++;
		System.out.println(kk[5] == 2 && kk[7] == 1 ? "YES" : "NO");
	}
}


Measured memory_bytes: 21332
#include<stdio.h>
int main(){
  int a;
  scanf("%d", &a);
  char s[11];
  scanf("%s",s);
  if(a<3200 && 2800<=a){
    printf("red\n");
  }
  else if(a<5000 && 3200<=a){
    printf("%s\n",s);
  }
  return 0;
}

Measured memory_bytes: 128
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    b = list(map(int, input().rstrip('\n').split()))
    c = list(map(int, input().rstrip('\n').split()))
    t = sum(b)
    for i in range(n):
        if i != 0 and a[i] - 1 == a[i-1]:
            t += c[a[i-1]-1]
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int n, y;

int main() {
	cin >> n >> y;
	y /= 1000;
	for (int i =0; i <= y / 10; i ++) {
		for (int j = 0; j <= (y - i * 10) / 5; j ++) {
			if ((i + j <= n) && (i * 10 + j * 5 + (n - i - j) == y)) {
				cout << i << ' ' << j << ' ' << n - i - j;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;

vector<int> zalgo(string &T) {
    int N = T.size();
    vector<int> Z(N);

    Z[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i + j < N && T[i + j] == T[j])j++;
        Z[i] = j;

        if (j == 0) { i++; continue; }

        int k = 1;
        while (k + Z[k] < j && i + k < N) {
            Z[i + k] = Z[k];
            k++;
        }
        
        i += k;
        j -= k;

    }

    return Z;
}


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

    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        string T = s.substr(i);
        auto z = zalgo(T);

        for (int j = 0; j < T.size(); j++) {
            int len = min(j, z[j]);
            ans = max(ans, len);
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    vector<ll> v(N + 1);
    REP(i, N) { v[i + 1] = a[i] + v[i]; }

    ll ans = INF32;

    FOR(i, 1, N) {

        ll sum = abs(v[i] - (v[N] - v[i]));
        chmin(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> l(2*n);
    REP(i,2*n) cin>>l[i];
    sort(all(l));
    int ans = 0;
    for(int i = 0; i<2*n; i+=2) ans+=l[i];
    print(ans);
    return 0;
}

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

bool g[10][10];
int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    g[a][b] = g[b][a] = true;
  }
  
  vector<int> v(n);
  rep(i,n) v[i] = i;
  int res = 0;
  
  do{
    if(v[0]!=0) break;
    bool ok = true;
    rep(i,n-1){
      if(!g[v[i]][v[i+1]]) ok = false;
    }
    if(ok) res++;
  }while(next_permutation(v.begin(),v.end()));
  
  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, upto;
cin>>n>>upto;
int arr[n];
for(int i = 0 ; i  < n;i++){
	cin>>arr[i];
	arr[i] = arr[i]/2;
}
int dp[n];
for(int i = 0 ; i <  n;i++){
 int val = arr[i];
 int cnt = 0;
 while(val%2 == 0){
  val=val/2;
  cnt++;
  if(val == 0)break;
 }
 dp[i] = cnt;
}
map<int , int> m;
int odd = 0;
for(int i = 0 ; i < n ;i++){
  if(dp[i] > 0){
   m[dp[i]]++;
  }
  else{
      odd++;
  }
}

if(((int)m.size()>=1 && odd != 0) || ((int)m.size() >= 2)){
   cout<<0<<endl;
   return 0;
}
// only odd values ,
int cnt = 0;
for(auto it:m)cnt = it.s;
//cout<<cnt<<endl;
int lcm = arr[0];
	for(int i = 1 ; i < n; i++){
		//arr[i] = 2*arr[i];
	     lcm = (lcm*arr[i])/(__gcd(lcm , arr[i]));
	}
	//for(int i = 0 ; i < cnt ; i++)lcm*=2;
	if(cnt)
	cout<<((upto/(lcm))+1)/2<<endl;
	else
    cout<<((upto/lcm)+1)/2<<endl;
   return 0;
	
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long ret = b / x - a / x;
		if (a % x == 0) {
			ret++;
		}
		System.out.println(ret);
	}
}

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

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

  vector<int> prices;
  rep(i, n) {
    int p;
    cin >> p;
    prices.push_back(p);
  }

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

  int total = 0;
  rep(i, k) { total += prices[i]; }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>

int main(){
 int A,B,C,D;
 std::cin>>A>>B>>C>>D;

 while(1){
  C-=B;
  if(C<=0){
    std::cout<<"Yes\n";
    return 0;
  }
  A-=D;
  if(A<=0){
   std::cout<<"No\n";
   return 0;
  }
 }

 return 0;
}

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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 1e5 + 10 ;

int arr[MAX] ;
long long n , k ;

vector< vector<int> >adj(MAX) ;

long long ans = 1ll ;

void dfs(int node , int par , int lvl)
{
	long long cnt = 0 ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		long long x = max(0ll , k-min(2 , lvl+1)*1ll-cnt) ;
		ans = (ans * x) % mod ;
		dfs(child , node , lvl+1) ;
		cnt++ ;
	}
	return ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}
	ans = k ;
	dfs(1 , -1 , 0) ;
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 11648
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N;

  long long a[11111], b[11111], c[11111] = {0}, d[11111] = {0};

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  for (int i = 0; i < N; i ++)
    std::cin >> b[i];

  for (int i = 0; i < N; i ++)
    if (a[i] == b[i]) {
      ;
    }
    else if (a[i] > b[i]) {
      d[i] = a[i] - b[i];
    }
    else {
      int l = b[i] - a[i];
      
      if (l % 2 == 0) {
        c[i] = l / 2;
      }
      else {
        c[i] = (l + 1) / 2;
        d[i] = 1;
      }
    }

  long long s = std::accumulate(c, c + N, 0LL);
  long long t = std::accumulate(d, d + N, 0LL);

  std::cout << (s < t ? "No" : "Yes") << std::endl;
  
  return 0;
}


Measured memory_bytes: 1016
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	N, M, XX, YY = map(int, input().split(" "))
	X = input().split(" ")
	X = [int(s) for s in X]
	Y = input().split(" ")
	Y = [int(s) for s in Y]
	
	X.sort()
	Y.sort()
	
	if X >= Y:
		print("War")
		sys.exit()
	
	tmp = Y[0] - X[len(X)-1]
	if tmp < 1:
		print("War")
		sys.exit()
		
	for i in range(X[len(X)-1]+1, Y[0]+1):
		if i <= YY and XX < i:
			print("No War")
			sys.exit()
	
	print("War")
		
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3440
#include<stdio.h>
long long gcd(long long x,long long y)
{
    return x?gcd(y%x,x):y;
}
int main()
{
	long long  x,y,a;
	scanf("%lld %lld",&x,&y);
	a=x/gcd(x,y)*y;
	printf("%lld",a);
	return 0;
}


Measured memory_bytes: 128
def SS(n, a):
    count = 0
    for i in range(n):
        mini = i
        for j in range(i,n):
            if a[j] < a[mini]:
                mini = j
        a[i], a[mini] = a[mini], a[i]
        count += 1 if i != mini else 0
    return count, a
    
n = int(raw_input())
a = map(int, raw_input().split())

n, a = SS(n, a)
print " ".join(map(str, a))
print n

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

#define __INIT_CC__ ios::sync_with_stdio(false); \
	cin.tie(0);

#ifdef __WIN32__
	char getchar_unlocked() {return getchar();}
#endif

#define FOR(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<(_t);++(_i))
#define FORN(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i<=(_t);++(_i))
#define FORD(_i,_n,_m) for(int (_i)=(_n),_t=(_m);_i>=(_t);--(_i))
#define RESET(_a,_value) memset(_a,_value,sizeof(_a))
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ff first
#define ss second
#define mp make_pair
#define SIZE(_a) (int)_a.size()
#define VSORT(_a) sort(_a.begin(),_a.end())
#define SSORT(_a,_val) sort(_a,_a+(_val))
#define ALL(_a) _a.begin(),_a.end()
#define mt make_tuple
#define _get(_tuple,_i) get<_i>(_tuple)
#define eb emplace_back
 
using namespace std;

using vi = vector<int>;
using ii = pair<int,int>;
using vii = vector<ii>;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll,ll>;
using vpll = vector<pll>;
using vll = vector<ll>;
using pdd = pair<double,double>;
using vpdd = vector<pdd>;
template <typename T> using uset = unordered_set<T>;
template <typename T> using umultiset = unordered_multiset<T>;
template <typename K, typename V> using umap = unordered_map<K, V>;
template <typename K, typename V> using umultimap = unordered_multimap<K, V>;

const int dr[] = { 1, 0,-1, 0, 1, 1,-1,-1};
const int dc[] = { 0, 1, 0,-1, 1,-1,-1, 1};
const double eps = 1e-9;
const int INF = 0x7FFFFFFF;
const ll INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);

template <typename T> T take(queue<T> &O) {T tmp=O.front();O.pop();return tmp;}
template <typename T> T take(stack<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <typename T> T take(priority_queue<T> &O) {T tmp=O.top();O.pop();return tmp;}
template <typename T>
inline bool inRange(const T& z, const T& a, const T& b){return a <= z && z <= b;}

void OPEN(const string& in = "input.txt", const string& out = "output.txt")
{
	freopen(in.c_str(), "r", stdin);
	freopen(out.c_str(), "w", stdout);
	return ;
}

//using sokokaleb's template v4.0

#define N 100005
const int MOD = 1000000007;
int p1, p2;
int pos[N];
int n;
int ans[N];
int a, b, c;

void add(int& a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	if (a < 0) a += MOD;
}

int pkt(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) {
			res = (1LL * res * a) % MOD;
		}
		a = (1LL * a * a) % MOD;
		b >>= 1;
	}
	return res;
}

int fact[N * 2];
int invfact[N * 2];

int C(int n, int k) {
	if (n < k) return 0;
	return (1LL * fact[n] * invfact[k]) % MOD * invfact[n - k] % MOD;
}

int main(int argc, char** argv) {
	__INIT_CC__
	cin >> n;
	n += 1;
	RESET(pos, -1);
	FOR (i, 0, n) {
		int a;
		cin >> a;
		if (pos[a] != -1) {
			tie(p1, p2) = mt(pos[a], i);
			break ;
		} else {
			pos[a] = i;
		}
	}

	a = p1;
	b = p2 - p1 - 1;
	c = n - (a + b + 2);

	ans[1] = n - 1;

	fact[0] = 1;
	invfact[0] = 1;
	FORN (i, 1, 2 * n + 1) {
		fact[i] = (1LL * fact[i - 1] * i) % MOD;
		invfact[i] = pkt(fact[i], MOD - 2);
	}

	FORN (i, 2, n) {
		ans[i] = C(n, i);
		add(ans[i], -C(a + c, i - 1));
	}
	
	FORN (i, 1, n) {
		cout << ans[i] << "\n";
	}
}


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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var n=Input();
            var s = new string[n];
            var ans = 1;
            for ( int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();

            }
            Array.Sort(s);
            for (int i = 0; i < n-1; i++)
            {
                if (s[i] != s[i + 1]) ans++; 
            }
            Console.WriteLine(ans);



        }






    





        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


Measured memory_bytes: 38352
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> st;
    FOR(i, a, min(a+k-1, b)) {
        cout << i << endl;
        st.insert(i);
    }
    FOR(i, max(a, b-k+1), b) {
        if (st.find(i) == st.end()) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)

if n % 2 == 0:
    ans = n // 2
    tmp = set()
    x = n // 2 - 1
    for cnt in range(0, n // 2):
        tmp.add(s[x-cnt])
        tmp.add(s[x+1+cnt])
        if len(tmp) == 2:
            ans = cnt
            break

    print(ans + n // 2)

else:
    x = n // 2
    tmp = {s[x]}
    ans = n // 2 + 1
    for cnt in range(1, n // 2 + 1):
        tmp.add(s[x-cnt])
        tmp.add(s[x+cnt])
        if len(tmp) == 2:
            ans = cnt
            break
    print(ans + n // 2)

Measured memory_bytes: 3188
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        for(int i = 0;i < c.length;i++){
            if(c[i] == '7'){
                System.out.println("Yes");
                return;
            }
                
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35688
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    lli t, i, j, zc=0, oc=0;
    string s;
    cin >> s;
    for(i=0; i<s.size(); i++) {
        if(s[i]=='0') zc++;
        else oc++;
    }
    t = min(zc, oc);
    cout << t*2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdlib> // abs(x-y)
#include <iomanip> // 出力の桁数指定
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int max = 0;
  int x = 0;

  rep (i, 0, n) {
    if (s.at(i) == 'I')
      x++;
    else
      x--;
    if (x > max)
      max = x;
  }
  cout << max << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
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 (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

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

  reps(i, 10000) {
    int x = (i * 8)/100, y = (i * 10)/100;
    if(a == x && b == y){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3692