akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
import heapq

N, M = map(int,input().split())
A = list(map(int, input().split()))
a = list(map(lambda x: x * -1, A))
heapq.heapify(a)
tmp = 0

for i in range(M):
    tmp = -1 * heapq.heappop(a) // 2
    heapq.heappush(a, -1 * tmp)
print(-1 * sum(a))

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  
  if(n%k==0){
    cout<<0;
  }else{
    cout<<1;
  }
  
  return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
int main() {
#ifdef AIM
  freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
  //freopen("/home/alexandero/ClionProjects/ACM/output.txt", "w", stdout);
  //freopen("out.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  //cin >> t;
  int testNum = 1;
  while (t--) {
    //cout << "Case #" << testNum++ << ": ";
    //cerr << testNum << endl;
    solve(true);
    //cerr << testNum - 1 << endl;
  }
  cout.flush();
#ifdef AIM1
  while (true) {
      solve(false);
  }
#endif

#ifdef AIM
  cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

  return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
  if (!w)
    return 1 % mod;
  if (w & 1)
    return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}

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

template <typename T>
void make_unique(vector<T>& a) {
  sort(all(a));
  a.erase(unique(all(a)), a.end());
}

void precalc() {}

template<typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}

template<typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}

//#define int li
//const int mod = 1000000007;

void solve(bool read) {
    string s;
    cin >> s;
    if (s.length() >= 4 && s.substr(0, 4) == "YAKI") {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(vi a(3),b(3);cin>>a[0]>>b[0]>>a[1]>>b[1]>>a[2]>>b[2];){
		vi ds(4);
		rep(i,3){
			ds[a[i]-1]++;
			ds[b[i]-1]++;
		}
		int odd=0;
		rep(i,4) odd+=ds[i]&1;
		cout<<(odd<=2?"YES":"NO")<<endl;
	}
}


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

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

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

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

int N;

int digits_sum(int num) {
    string s = to_string(num);
    int res = 0;
    REP(i, s.length()) {
        int digit = s[i] - '0';
        res += digit;
    }
    return res;
}
signed main()
{
    cin >> N;

    int ans = INF;
    for(int A = 1; A < N; ++A) {
        int B = N - A;
        ans = min(ans, digits_sum(A) + digits_sum(B));
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        while (true)
        {
            string s = Console.ReadLine();
            if (s == null) break;

            string[] sp = s.Split();

            int sum = int.Parse(sp[0]) + int.Parse(sp[1]);

            Console.WriteLine( sum.ToString().Length );


        }

    }
}




Measured memory_bytes: 15912
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    rep(i,n){
        set<char> st;
        st.insert(a[i]), st.insert(b[i]), st.insert(c[i]);
        ans += len(st)-1;
    }
    cout << ans << "\n";
    return 0;
}

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

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

int main(){
  int s;
  cin >> s;
  map<int, int>m;
  m[s]++;
  for(int i=2; i<1000005; i++){
    s=func(s);
    if(m[s]!=0){
      cout << i;
      return 0;
    }
    else m[s]++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    int p[n];
    int swap = 0;
    int flag = false;
    for(int i=1;i<n;i++) cin >> p[i];
    int a = 0;
    for(int i=1;i<n;i++){
        if(i != p[i]) a++;
    }
    if(a <= 2){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define INF 1200000000
int L[250010],R[250010];
int cnt=0;

void merge(int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++)L[i]=A[left+i];
    for(int i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1]=INF;R[n2]=INF;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
            cnt++;
        }
        else{
            A[k]=R[j];
            j++;
            cnt++;
        }
    }
}
    

void mergesort(int A[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergesort(A,left,mid);
        mergesort(A,mid,right);
        merge(A,left,mid,right);
    }
}


int main(){
    int n,S[500100];
    cin>>n;
    for(int i=0;i<n;i++)cin>>S[i];
    mergesort(S,0,n);
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<S[i];
    }
    
    cout<<endl<<cnt<<endl;
    
}





Measured memory_bytes: 6984
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    int ans = inf;
    rep(i, 0, s.size()-2) {
      ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		bool l = 1;
		for (int j = 2; j*j <= x; j++) {
			if (!(x%j)) {
				l = 0;
			}
		}
		if (l) sum++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 3116
s=input()
n=len(s)
if n==2:
    if s[0]==s[1]:
        print(1,2)
        exit()
for i in range(n-2):
    a,b,c=s[i],s[i+1],s[i+2]
    if a==b or a==c or b==c:
        print(i+1,i+3)
        exit()
print(-1,-1)


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

#define PRINT(mpr) printf(#mpr "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int d; cin >> d;
    switch(d){
        case 22: cout << "Christmas Eve Eve Eve" << endl; break;
        case 23: cout << "Christmas Eve Eve" << endl; break;
        case 24: cout << "Christmas Eve" << endl; break;
        case 25: cout << "Christmas" << endl; break;
    }

}


Measured memory_bytes: 256
from itertools import permutations
import math

n = int(input())
li = [tuple(map(int,input().split())) for _ in range(n)]

# 2点間の距離
def length(x1,y1,x2,y2):
    return(math.sqrt(abs(x2-x1)**2+abs(y2-y1)**2))

point = 0

for i in permutations(li):
    for j in range(1,n):
        point += length(i[j-1][0],i[j-1][1],i[j][0],i[j][1])

print(point/math.factorial(n))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


int n, k;
char s[500];

int main()
{
	scanf("%d%d\n", &n, &k);
	scanf("%s", s);
	s[k - 1] = s[k - 1] - 'A' + 'a';
	
	printf("%s\n", s);
	
	return 0;
}



Measured memory_bytes: 128
H, W = map(int, input().split())
S = []
di = [-1, 0, 1, 0]
dj = [0, -1, 0, 1]
for _ in range(H):
  S.append(input())

ans = 0
for si in range(H):
  for sj in range(W):
    if S[si][sj] == "#":
      continue
    dist = [[-1 for _ in range(W)] for _ in range(H)]
    dist[si][sj] = 0
    queue = [[si, sj]]
    while len(queue) > 0:
      q = queue.pop(0)
      i = q[0]
      j = q[1]
      for dir in range(4):
        ni = i + di[dir]
        nj = j + dj[dir]
        if ni < 0 or ni >= H or nj < 0 or nj >= W:
          continue
        if S[ni][nj] == "#":
          continue
        if dist[ni][nj] == -1:
          dist[ni][nj] = dist[i][j] + 1
          queue.append([ni, nj])
    for i in range(H):
      for j in range(W):
        ans = max(ans, dist[i][j])

print(ans)

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

int main() {
    int H,W,N;
    cin>>H>>W>>N;
    int count=0;
    if(H>W){
    	while(count*H<N){
    		count++;
    	}
    }
    else{
    	while(count*W<N){
    		count++;
    }
    }
    cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
//************************************************************************
// File Name: F.cpp
// Author: Shili_Xu
// E-Mail: shili_xu@qq.com 
// Created Time: 2018年03月24日 星期六 22时32分59秒
//************************************************************************

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-8, PI = acos(-1);
const int MAXN = 105;

struct point {
	double x, y;
	int id;
	
	point() {}
	point(double _x, double _y, int _id = -1) : x(_x), y(_y), id(_id) {}
	bool operator<(const point &another) const;
};

struct ans {
	double val;
	int id;

	ans() {}
	bool operator<(const ans &another) const
	{
		return id < another.id;
	}
};

int tot, n;
point p[MAXN], s[MAXN], normal[MAXN];
ans an[MAXN];
bool visited[MAXN];

int sgn(double x)
{
	if (fabs(x) < EPS) return 0;
	return (x > 0 ? 1 : -1);
}

double det(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.y - b1.y) - (a2.y - a1.y) * (b2.x - b1.x));
}

double dot(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.x - b1.x) + (a2.y - a1.y) * (b2.y - b1.y));
}

double dist(const point &p1, const point &p2)
{
	return sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
}

bool point::operator<(const point &another) const
{
	if (sgn(det(p[0], *this, p[0], another)) == 0)
		return dist(p[0], *this) < dist(p[0], another);
	else
		return det(p[0], *this, p[0], another) > 0;
}

void graham()
{
	double min_y = p[0].y, min_x = p[0].x;
	int index = 0;
	for (int i = 1; i <= n - 1; i++) {
		if (p[i].y < min_y || (sgn(p[i].y - min_y) == 0 && p[i].x < min_x)) {
			min_y = p[i].y;
			min_x = p[i].x;
			index = i;
		}
	}
	swap(p[0], p[index]);
	sort(p + 1, p + n);
	s[0] = p[0]; s[1] = p[1];
	tot = 2;
	for (int i = 2; i <= n - 1; i++) {
		while (tot >= 2 && sgn(det(s[tot - 1], p[i], s[tot - 1], s[tot - 2]) < 0)) tot--;
		s[tot++] = p[i];
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf %lf", &p[i].x, &p[i].y);
		p[i].id = i;
	}
	graham();
	for (int i = 0; i < tot; i++) {
		if (i == 0) {
			normal[i].y = -(s[i].x - s[tot - 1].x);
			normal[i].x = s[i].y - s[tot - 1].y;
			normal[i].id = s[i].id;
		}
		else {
			normal[i].y = -(s[i].x - s[i - 1].x);
			normal[i].x = s[i].y - s[i - 1].y;
			normal[i].id = s[i].id;
		}
	}
	point zero(0, 0);
	for (int i = 0; i < tot; i++) {
		if (i == tot - 1) {
			an[i].val = acos(dot(zero, normal[i], zero, normal[0]) / dist(zero, normal[i]) / dist(zero, normal[0])) / PI / 2;
			an[i].id = normal[i].id;
		}
		else {
			an[i].val = acos(dot(zero, normal[i], zero, normal[i + 1]) / dist(zero, normal[i]) / dist(zero, normal[i + 1])) / PI / 2;
			an[i].id = normal[i].id;
		}
	}
	memset(visited, false, sizeof(visited));
	for (int i = 0; i < tot; i++) visited[s[i].id] = true;
	for (int i = 0; i < n; i++)
		if (!visited[i]) {
			an[tot].val = 0.0000000;
			an[tot++].id = i;
		}
	sort(an, an + n);
	for (int i = 0; i < n; i++) printf("%.8f\n", an[i].val);
	return 0;
}


Measured memory_bytes: 128
from collections import deque
a=deque()
n=int(input())
for i in range(n):
    x=list(map(int, input().split()))
    if x[0]==0:
        if x[1]==1:a.append(x[2])
        else:a.appendleft(x[2])
    if x[0]==1:print(a[x[1]])
    if x[0]==2:
        if x[1]==1:a.pop()
        else:a.popleft()


Measured memory_bytes: 21980
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str1=Console.ReadLine().Split(' ');
    int H=int.Parse(str1[0]);
    int W=int.Parse(str1[1]);
    string[] str2=Console.ReadLine().Split(' ');
      int h=int.Parse(str2[0]);
      int w=int.Parse(str2[1]);
      Console.WriteLine((H*W)-((h*W)+(H*w)-(h*w)));
    }
    
  }

}


Measured memory_bytes: 27456
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBackfront solver = new BBackfront();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBackfront {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.NextInt();
            int[] a = in.NextIntArray(n, -1);
            int[] maxSequenseTillThisElement = new int[n];
            for (int i = 0; i < n; i++) {
                if (a[i] == 0) {
                    maxSequenseTillThisElement[a[i]] = 1;
                } else
                    maxSequenseTillThisElement[a[i]] = maxSequenseTillThisElement[a[i] - 1] + 1;
            }
            out.println(n - ArraysExtention.GetMax(maxSequenseTillThisElement));
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(next());
        }

        public int[] NextIntArray(int n, int offset) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = NextInt() + offset;
            }
            return a;
        }

    }

    static class ArraysExtention {
        public static int GetMax(int[] ar) {
            int max = Integer.MIN_VALUE;
            for (int a : ar) {
                max = Math.max(max, a);
            }
            return max;
        }

    }
}



Measured memory_bytes: 45592
#include <stdio.h>

int main(void)
{
  int n,i,j,a;

  while(1){
    scanf("%d",&n);
    int data[11][11] = {0};
    if(n==0)break;
    a = 0;

    for(i=0; i<n; i++){
      for(j=0; j<n; j++){
	scanf("%d",&data[i][j]);
	data[i][n] += data[i][j];
	data[n][j] += data[i][j];
	a += data[i][j];
      }
    }
    data[n][n] = a;
    for(i=0; i<=n; i++){
      for(j=0; j<=n; j++){
	printf("%5d",data[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}

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

    string s; cin >> s;
    int dir = 0;

    map<int,bool> vis;
    int ans = 0;

    for (char c : s) {
        if (c == 'R') {
           dir = (dir + 1) % 4;
           vis[dir] = 1;
           if (dir == 0) {
               if (vis.size() == 4) {
                   ++ans;
               }
               vis.clear();
           }
        } else {
            dir = (dir + 3) % 4;
            if (dir == 0) {
                vis.clear();
            }
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
struct dev{
	ll v;
	bool b;
	void ch(dev d){v = min(v,d.v); b |= d.b;}
	dev mg(dev d){return {v + d.v, b && d.b};}
	bool ok(){return v < 0 || b;}
};
using vd = vector<dev>;
const ll INF = 1e16;
const int MX = 5005;
int n, a[MX], u, v;
vector<int> G[MX];
vd dfs(int t, int p){
	vd ret(1,{a[t], a[t] > 0});
	for(int nx: G[t]) if(nx != p){
		vd ch = dfs(nx,t);
		int sc = (int)ch.size(), sr = (int)ret.size();
		vd tmp(sc+sr,{INF,false});
		rep(i,sc) if(ch[i].ok()) rep(j,sr) tmp[i+j+1].ch(ret[j]);
		rep(i,sc) rep(j,sr) tmp[i+j].ch(ch[i].mg(ret[j]));
		ret = tmp;
	}
	return ret;
}
int main(){
	scanf("%d", &n);
	rep(i,n) scanf("%d", a+i);
	rep(i,n-1){
		scanf("%d%d", &u, &v);
		u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	vd res = dfs(0,0);
	rep(i,res.size()) if(res[i].ok()) return 0*printf("%d\n", i);
}

Measured memory_bytes: 1596
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int n,d;cin>>n>>d;
    int x,y;int cnt=0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d)
        cnt++;
    }
    cout<<cnt;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3640
// Mahesh Sharma
// Beauty is in the struggle!
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <memory.h>
#include <cassert>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ford(i, a, b, c)        for(int i=(a); i<(b); i+=(c))
#define fori(i, a, b)           ford(i,a,b,1)
#define rep(i, n)               fori(i,0,n)
#define ifor(i, a, b)           for(int i=(a); i>=(b); i--)
#define si(x)                   ((int)x.size())
#define SS                      ({int x;scanf("%d",&x);x;})
#define pb                      push_back
#define mp                      make_pair
#define all(a)                  a.begin(),a.end()
#define inf                     (int)1e9
#define linf                    (long long)1e18
#define V                       vector
#define S                       string
#define XX                      first
#define YY                      second
#define PVI(v)                  rep(i, si(v)) cout<<v[i]<<" "; puts("")
#define PPI(p)                  cout<<"("<<p.first<<", "<<p.second<<")\n"
#define PVPI(v)                 rep(i, si(v)) cout<<"("<<v[i].first<<", "<<v[i].second<<")"<<(i==si(v)-1?"":", ");puts("")
#define PA(arr1, arr2)          for(auto it = arr1; it != arr2; it++) cout<<*it<<" "; puts("");

typedef V<int> vi;
typedef V<S> vs;
typedef long long ll;
typedef pair<int,int> pii;
const int MOD7 = 1000000000+7;
const int MOD9 = 1000000000+9;
/* ################### Program Body starts here ################ */


int dp[10001][1000];
int main() {
    int H = SS, n = SS;
    V<pii> a(n);
    rep(i, n) {
        a[i].XX = SS;
        a[i].YY = SS;
    }
    
    
    rep(h, H+1) {
        ifor(i, n-1, 0) {
            if (h==0) dp[h][i] = 0;
            else dp[h][i] = min(i+1==n?inf:dp[h][i+1], a[i].YY + dp[max(0, h-a[i].XX)][i]);
        }
    }
    cout<<dp[H][0]<<"\n";
}


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

bool f(int x){
    int keta = 0;
    while(x){
        keta++;
        x /= 10;
    }
    return keta % 2 == 1;
}

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

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
char s;
  cin >> s;
  if(s=='A')cout << "T"<<endl;
  else if(s=='T')cout << "A"<<endl;
  else if(s=='G')cout << "C"<<endl;
  else if(s=='C')cout << "G"<<endl;
}

Measured memory_bytes: 256
s=str(input())
br1=0
s=list(s)
s2=s
br2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='0':
            br1+=1
    else:
        if s[i]=='1':
            br1+=1

for i in range(len(s)):
    if i%2==1:
        if s[i]=='0':
            br2+=1
    else:
        if s[i]=='1':
            br2+=1
print(min(br1,br2))

Measured memory_bytes: 49392
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a > 0 && c > 0){
    c -= b;
    if(c <= 0){
      cout << "Yes\n";
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No\n";
      return 0;
    }
  }
  if(a <= 0){
    cout << "No\n";
  }else{
    cout << "Yes\n";
  }
  return 0;
}

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

int A[505][505], dp[505][505];
vector< pair< pair<int, int>, pair<int, int> > > X;

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int H, W;
    cin >> H >> W;
    
    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            cin >> A[i][j];
    
    for(int i=H; i>=1; i--)
        for(int j=W; j>=1; j--)
        {
            if(A[i][j] % 2 == 0)
                continue;
            
            if(i > 1)
            {
                A[i-1][j]++, A[i][j]--;
                X.push_back({{i, j}, {i-1, j}});
                continue;
            }
            
            if(j == 1)
                continue;
            
            A[i][j-1]++, A[i][j]--;
            X.push_back({{i, j}, {i, j-1}});
        }
    
    cout << X.size() << "\n";
    
    for(auto x : X)
        cout << x.first.first << " " << x.first.second << " " << x.second.first << " " << x.second.second << "\n";
    
    return 0;
}


Measured memory_bytes: 5232
n = int(input())
s = input()
left_w = 0
right_e = s.count('E')
ans = left_w + right_e
for i in range(n):
    if s[i] == 'E':
        right_e -= 1
    ans = min(ans, left_w + right_e)
    if s[i] == 'W':
        left_w += 1
print(ans)

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

int main(void) {
    int a, b, c, ans = 0;
    bool penki[114] = {};
    cin >> a >> b >> c;
    penki[a] = true;
    penki[b] = true;
    penki[c] = true;
    for (int i = 1; i <= 100; i++) if (penki[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
typedef pair<ll, ll> P;
const ll INF=1LL<<60;

int a[330][330];
int main() {
  int n; cin>>n;
  ll sum=0;
	rep(i,n)rep(j,n){
    int x;
    cin>>x;
    a[i][j]=x;
  }
  rep(i,n){
    rep(j,n){
      bool hantei=true;
      rep(k,n){
        if(a[i][j]>a[i][k]+a[k][j]){
          cout<<-1<<endl;
          return 0;
        }else if(a[i][j]==a[i][k]+a[k][j]){
          if(i!=k&&j!=k)hantei=false;
        }
      }
      if(hantei==true&&i>j)sum+=a[i][j];
    }
  }
  cout<<sum<<endl;
  return 0;
}
  

Measured memory_bytes: 3972
N, M, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
xmax = max(X, max(xs))
ymin = min(Y, min(ys))
if xmax < ymin:
  print("No War")
else:
  print("War")


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template #


A, B = mi()
N = max(A, B)
if A == B:
    print(A + B)
else:
    print(2*N-1)

Measured memory_bytes: 3060
import java.util.*;

class Main {
    //
    static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0;i < 3;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = a[0] + a[1];
        System.out.println(ans);
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string str;
  int red = 0;
  int blue = 0;
  cin >> str;
  
  for (int i = 0; i < str.size(); i++){
    if ( str.at(i) == '0'){
      red++;
    } else {
      blue++;
    }
  }
  
  if (red > blue){
    cout << 2 * blue << endl;
  } else {
    cout << 2 * red << endl;
  }
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
vector<int> arr(3);
for(int i=0;i<3;i++){
cin>>arr[i];
}
sort(arr.begin(),arr.end());
if(arr[0]+arr[1]==arr[2])cout<<"Yes";
else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
int main() {
	string s, t;
	cin >> s >> t;
	map<char, char> mp, mp2;
	rep(i, 0, s.size()) {
		if (mp[s[i]] == 0) {
			mp[s[i]] = t[i];
		}
		if (mp2[t[i]] == 0) {
			mp2[t[i]] = s[i];
		}
		if (mp[s[i]] != t[i] || mp2[t[i]] != s[i]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 776
import fractions
N,M=map(int,input().split())
a=list(map(int,input().split()))
l=1
count=0
A=a[0]
ans=0
flag=1
while A%2==0:
    A=A//2
    count=count+1
for i in range(N):
    A=a[i]
    b=A//(2**count)
    if b==0 or b%2==0:
        flag=0
        break
    A=A//2
    l=l*A//fractions.gcd(l,A)
if flag==1:
    ans=M//l
    if ans%2==0:
        print(ans//2)
    else:
        print(ans//2+1)
else:
    print(0)

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

int ans, n, m, a, b, v[10];
bool pass[10][10];

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < m; i++){
    scanf("%d%d", &a, &b); a--; b--;
    pass[a][b] = pass[b][a] = true;
  }
  for(int i = 0; i < n; i++) v[i] = i;
  do{
    bool ok = true;
    for(int i = 1; i < n; i++) ok &= pass[v[i-1]][v[i]];
    ans += ok;
  }while(next_permutation(v+1, v+n));
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    s = "0 , 0 , 0";
    int c;
    c = 0;
    cin >> s;
    if (s.at(0) == '1')
        c++;
    if (s.at(1) == '1')
        c++;
    if (s.at(2) == '1')
        c++;
    cout << c << endl;
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int a, b;
	cin >> a >> b;
	if (b % a) {
		cout << b - a << "\n";
	}
	else {
		cout << b + a << "\n";
	}
}

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


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

x = k()
for i in range(-int(x**(1/4))+1,int(x**(1/4))+1):
    for j in range(-int(x**(1/4))+1,int(x**(1/4))+1):
        if i**5 - j**5==x:
            print("{} {}".format(i,j))
            sys.exit()


Measured memory_bytes: 10792
N = int(input())
h = list(map(int, input().split()))
dp = [0] * N
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: 13928
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,t[50];
	string s[50],x;

	cin>>n;
	rep(i,n) cin>>s[i]>>t[i];
	cin>>x;

	rep(i,n) if(s[i]==x) cout<<accumulate(t+i+1,t+n,0)<<'\n';

	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

vector<int> parent;
int root(int x) {
  if (parent[x] == x)
    return x;
  return parent[x] = root(parent[x]);
}
bool same(int x, int y) {
  return root(x) == root(y);
}
void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;
  parent[x] = y;
}
int main() {
  IN(N); IN(M);
  parent.resize(N);
  REP(i, N)
    parent[i] = i;

  REP(i, M) {
    IN(s); IN(t);
    unite(s, t);
  }
  IN(Q);
  REP(i, Q) {
    IN(s); IN(t);
    OUT((same(s, t) ? "yes" : "no"));
  }
  return 0;
}



Measured memory_bytes: 3816
//******* In the name of Allah *******//


#include<bits/stdc++.h>
using namespace std;

int main( )
{
    int a,b,ans;
    cin>>a>>b;
    if(a<=9 && b<=9)
    {
         ans = a*b;
         cout<<ans<<endl;
    }
    else
    {
         cout<<"-1"<<endl;
    }
    
    return 0;
}

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

int a[200005], b[200005];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = n; i >= 1; i--)
    for (int j = i * 2; j <= n; j += i)
      a[i] ^= a[j];
  int ttl = 0;
  for (int i = 1; i <= n; i++)
    if (a[i])
      ttl++;
  cout << ttl << endl;
  for (int i = 1; i <= n; i++)
    if (a[i])
      cout << i << " ";
  cout << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
		/*#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif*/
fast();
//ll  t;cin>>t;while(t--)
{
	ll n,s=0,t,A;
	cin>>n;
	cin>>t>>A;
	ll a[n];
	double b[n];
	for( int i=0;i<n;i++)
	      cin>>a[i];
	 for (int i = 0; i < n; i++)
	 {
          b[i]=t-a[i]*0.006;
	 	
	 }
	 double min=abs(b[0]-A);
	 int index=0;
	 for(int i=1;i<n;i++)
	 {
         double x=abs(A-b[i]);
         if(min>x)
         {
         	index=i;
         	min=x;
         }
	 }
	 

	cout << index+1<<endl;
	cerr<<"hello"<<endl;

}
return 0;
}

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

int main()
{
    auto K = 100;
    string S = "";

    {
        string num_str = "";
        getline( cin, num_str );
        K = stoi( num_str );
    }
    getline( cin, S );


    if( static_cast< int >( S.length() ) <= K )
    {
        cout << S << endl;
    }
    else
    {
        auto short_S = S.substr(0, K);
        cout << short_S << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3616
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    string s;
    cin >>n;
    long long ans = 0;
    unordered_map<string, long long> mp;
    while(n--){
        cin >>s;
        sort(s.begin(), s.end());
        ans += mp[s];
        mp[s]++;
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 10660
# n + 1 長の array を返す
def cumulative_sum(array)
  tmp = [0]
  previous = 0
  array.each { |num| tmp << previous += num }
  tmp
end

n, m, k = gets.split.map(&:to_i)
books_1 = gets.split.map(&:to_i)
cumulative_books_1 = cumulative_sum(books_1)
books_2 = gets.split.map(&:to_i)
cumulative_books_2 = cumulative_sum(books_2)
ans = [0]
(0..n).each do |first|
  rest = k - cumulative_books_1[first]
  break if rest < 0
  sec = cumulative_books_2.bsearch_index { |second| rest - second < 0 }
  sec = m + 1 if sec == nil
  sec -= 1
  ans << first + sec
end
puts ans.max


Measured memory_bytes: 45372
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main (String args[]) throws IOException{

		Scanner sc = new Scanner(System.in);

		int sec = sc.nextInt();

		// ?¨??????????
//		int hour = sec / 3600;
//		int minuts = (sec % 3600) / 60;
//		int seconds = sec % 60;
//		
//		System.out.println();

		System.out.println((sec / 3600) + ":" + ((sec % 3600) / 60) + ":" + (sec % 60) );
		sc.close();
	}
}

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

int main () {
  int n;
  cin >> n;
  
  vector<int> sides(n, 0);
  for (int i = 0; i < n; i++) cin >> sides.at(i);
  
  sort(sides.begin(), sides.end());
  reverse(sides.begin(), sides.end());
  
  int sum = 0;
  
  for (int i = 1; i < n; i++) sum += sides.at(i);
  
  if (sides.at(0) < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
newab=[ab[i][0]+ab[i][1] for i in range(n)]
newab.sort()
# print(newab)
ans=0
for i in range(n):
    if i%2==0:
        ans+=newab[-i-1]
# print(ans)
for i in range(n):
    ans-=ab[i][1]
print(ans)

Measured memory_bytes: 63836
n = int(input())
kz = [0]*100
for i in range(n):
    # n+1の約数
    t = i + 1
    while True:
        for j in range(2, 11):
            if t % j == 0:
                kz[j] += 1
                t = t // j
                break
        else:
            if t != 1:
                kz[t] += 1
            break
a = 0
for i in range(74):
    a += kz.count(i)
ans = 100 - a
a = 0
for i in range(4):
    a += kz.count(i)
b = 0
for i in range(4, 14):
    b += kz.count(i)
c = 100 - a - b
ans += (c * (c - 1)) + c * b
a = 0
for i in range(2):
    a += kz.count(i)
b = 0
for i in range(2, 24):
    b += kz.count(i)
c = 100 - a - b
ans += (c * (c - 1)) + c * b
a = 0
for i in range(2):
    a += kz.count(i)
b = 0
for i in range(2, 4):
    b += kz.count(i)
c = 100 - a - b
ans += (c * (c - 1) * (c - 2))//2 + (b * c * (c - 1))//2
print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define mod 1000000007
#define int long long
int dp[3001][3001][2];

int deq(int i, int j, vector<int> &a, int turn){
	if(i > j)return 0;
	if(dp[i][j][turn] != -1)return dp[i][j][turn];

	if(turn == 0){
		dp[i][j][turn] = max(a[i]+deq(i+1,j,a,1),a[j]+deq(i,j-1,a,1));
	}
	else{
		dp[i][j][turn] = min(deq(i+1,j,a,0),deq(i,j-1,a,0));
	}
	return dp[i][j][turn];
}

void solve() {
	int n;
	cin>>n;
	vector<int> a(n);
	int i;
	for(i=0;i<n;i++)cin>>a[i];
	int j,k;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			for(k=0;k<2;k++)dp[i][j][k] = -1;
		}
	}
	int x = deq(0,n-1,a,0);
	int sum = 0;
	for(i=0;i<n;i++)sum += a[i];
	int y = sum - x;
	
	cout<<x-y<<endl;
	return;
}

int32_t main() {
	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 144500
#include <stdio.h>
#include <algorithm>
using namespace std;

int N,E,T,X[100100];
long long D[100100],W[100100];

int main()
{
	scanf ("%d %d %d",&N,&E,&T);
	for (int i=1;i<=N;i++) scanf ("%d",&X[i]);
	W[0] = -2 * X[1];
	for (int i=1;i<=N;i++){
		int j = lower_bound(X,X+i,X[i]-T/2) - X;
		if (j){
			j--;
			D[i] = D[j] + T;
			if (j){
				j--;
				if (D[i] > W[j] + 2 * X[i])
					D[i] = W[j] + 2 * X[i];
			}
		}
		else D[i] = T;

		W[i] = D[i] - 2 * X[i+1];
		if (W[i] > W[i-1])
			W[i] = W[i-1];
	}

	printf ("%lld\n",D[N]+E);

	return 0;
}

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

int main() {
  int64_t N,M,V,P,Z=1,A=0;
  cin>>N>>M>>V>>P;
  vector<int64_t> p(N);
  for(int64_t i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  for(int64_t i=1;i<N;i++){
    if(p.at(i)==p.at(i-1)||i<P){
      Z++;
    }
    else{
      if(p.at(P-1)-p.at(i)<=M&&M*(N-(i-P+1))+A+(p.at(i)+M-p.at(P-1))*(i-P+1)>=M*V){
        Z++;
      }
      else{
        break;
      }
    }
    if(p.at(i)<p.at(P-1)){
      A+=p.at(P-1)-p.at(i);
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef pair< int , int > P;

int W, N, value[1000], weight[1000];
P dp[1001][1001];

P rec(int i,int j){ //i番目以降の品物からj以下となるように選ぶ
  if(dp[i][j] != P(-1,-1)) return dp[i][j];
  P res;
  if(i == N) res = P(0,j);
  else if(j < weight[i]) return res = rec(i+1,j);
  else{
    P tmp = rec(i+1,j-weight[i]);
    res = max(rec(i+1,j),P(tmp.first + value[i],tmp.second));
  }
  return dp[i][j] = res;
}

int main(){
  int cnt = 0; char op;
  while(cin >> W , W){
    fill_n(*dp,1001*1001,P(-1,-1));
    cin >> N;
    for(int i = 0 ; i < N ; i++ ) cin >> value[i] >> op >> weight[i];
    P p = rec(0,W);
    cout << "Case " << ++cnt << ":" << endl;
    cout << p.first << endl;
    cout << W - p.second << endl;
  }
}

Measured memory_bytes: 9104