akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>

typedef long long LL;

const int MAXN = 2e5;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL ans = INF;
int n, m, A, B, bug, test;
int w[MAXN | 1];

inline int read() {
	register int x = 0;
	register char ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}

namespace segmentTree {
	struct Node {
		LL minv, addv;
		Node *ch[2];
		Node() : minv(0), addv(0) {
			ch[0] = ch[1] = NULL;
		}
	} *root[2];
	inline void pushdown(Node *o, int l, int r, int de) {
		if (o -> addv) {
			o -> ch[0] -> minv += o -> addv;
			o -> ch[1] -> minv += o -> addv;
			o -> ch[0] -> addv += o -> addv;
			o -> ch[1] -> addv += o -> addv;
			o -> addv = 0;
		}
	}
	inline void pushup(Node *o) {
		o -> minv = std::min(o -> ch[0] -> minv , o -> ch[1] -> minv);
	}
	void build(Node *&o, int l, int r) {
		o = new Node;
		if (l == r) {
			o -> minv = INF;
			return;
		}
		int mid = (l + r) >> 1;
		build(o -> ch[0], l, mid);
		build(o -> ch[1], mid + 1, r);
		pushup(o);
	}
	void update(Node *o, int l, int r, int ql, int qr, int v) {
		if (ql <= l && r <= qr) {
			o -> minv += v;
			o -> addv += v;
			return;
		}
		int mid = (l + r) >> 1;
		pushdown(o, l, r, 1);
		if (ql <= mid) update(o -> ch[0], l, mid, ql, qr, v);
		if (mid < qr) update(o -> ch[1], mid + 1, r, ql, qr, v);
		pushup(o);
	}
	void modify(Node *o, int l, int r, int pos, LL v) {
		if (l == r) {
			o -> minv = v;
			return;
		}
		int mid = (l + r) >> 1;
		pushdown(o, l, r, 2);
		if (pos <= mid) modify(o -> ch[0], l, mid, pos, v);
		else modify(o -> ch[1], mid + 1, r, pos, v);
		pushup(o);
	}
	LL query(Node *o, int l, int r, int ql, int qr) {
		if (ql <= l && r <= qr) return o -> minv;
		int mid = (l + r) >> 1;
		LL res = 0x3f3f3f3f3f3f3f3f;
		pushdown(o, l, r, 3);
		if (ql <= mid) res = query(o -> ch[0], l, mid, ql, qr);
		if (mid < qr) res = std::min(res, query(o -> ch[1], mid + 1, r, ql, qr));
		return res;
	}
}

using namespace segmentTree;

int main() {
	n = read();
	m = read();
	A = read();
	B = read();
	for (int i = 1; i <= m; ++i) w[i] = read();
	build(root[0], 1, n);
	build(root[1], 1, n);
	modify(root[0], 1, n, A, std::abs(w[1] - B) - A);
	modify(root[1], 1, n, A, std::abs(w[1] - B) + A);
	modify(root[0], 1, n, B, std::abs(w[1] - A) - B);
	modify(root[1], 1, n, B, std::abs(w[1] - A) + B);
	for (int i = 2; i <= m; ++i) {
		int foo = std::abs(w[i] - w[i - 1]);
		LL res = query(root[0], 1, n, 1, w[i]) + w[i];
		if (w[i] != n) res = std::min(res, query(root[1], 1, n, w[i] + 1, n) - w[i]);
		modify(root[0], 1, n, w[i - 1], res - w[i - 1]);
		modify(root[1], 1, n, w[i - 1], res + w[i - 1]);
		update(root[0], 1, n, 1, n, foo);	
		update(root[1], 1, n, 1, n, foo);
		update(root[0], 1, n, w[i - 1], w[i - 1], -foo);
		update(root[1], 1, n, w[i - 1], w[i - 1], -foo);
	}
	for (int i = 1; i <= n; ++i) ans = std::min(ans, query(root[0], 1, n, i, i) + i);
	printf("%lld\n", ans);
	return 0;
}


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

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

	if (b == "A")      b = "T";
	else if (b == "T") b = "A";
	else if (b == "C") b = "G";
	else               b = "C";
	
	cout << b << endl;

	return 0;
}

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

using namespace std;

const int MAX_N = 8580;

int X, Y;
bool dp[2][MAX_N << 1];
char S[MAX_N];
vector<int> vecs[2];

int main()
{
    scanf("%s%d%d", S + 1, &X, &Y);
    int opt = 0, acc = 0;
    bool flag = true;
    for (int i = 1; S[i]; i++)
        if (S[i] == 'F')
            acc++;
        else if (flag)
            X -= acc, flag = false, opt ^= 1, acc = 0;
        else
            vecs[opt].push_back(acc), opt ^= 1, acc = 0;
    if (acc > 0)
        vecs[opt].push_back(acc);
    if (flag)
    {
        puts((acc == X) ? "Yes" : "No");
        return 0;
    }
    bool ans = true;
    int cb = 0;
    dp[0][MAX_N] = true;
    for (int x : vecs[0])
    {
        cb ^= 1, memset(dp[cb], 0, sizeof(dp[cb]));
        for (int i = 2 * MAX_N - 1; i >= 0; i--)
        {
            if (i - x >= 0)
                dp[cb][i] |= dp[!cb][i - x];
            if (i + x < 2 * MAX_N)
                dp[cb][i] |= dp[!cb][i + x];
        }
    }
    ans &= dp[cb][X + MAX_N];
    memset(dp, 0, sizeof(dp));
    cb = 0, dp[0][MAX_N] = true;
    for (int x : vecs[1])
    {
        cb ^= 1, memset(dp[cb], 0, sizeof(dp[cb]));
        for (int i = 2 * MAX_N - 1; i >= 0; i--)
        {
            if (i - x >= 0)
                dp[cb][i] |= dp[!cb][i - x];
            if (i + x < 2 * MAX_N)
                dp[cb][i] |= dp[!cb][i + x];
        }
    }
    ans &= dp[cb][Y + MAX_N];
    puts(ans ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3844
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long ll;                                // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll, int>> factorize(ll n)
{ // a,bの公約数 = GCD(a, b)の約数
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++)
  { // √nまで探せばよい
    if (n % i)
      continue;
    res.emplace_back(i, 0); // 割り切れたら
    while (n % i == 0)
    {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1)
    res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
  return res;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) { return (a + b - 1) / b; }

const ll INF = LONG_MAX;
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}

int main()
{
#ifdef LOCAL
  // 以降 cin の入力元が 'xxx.txt' になる
  std::ifstream in("code_b.txt");
  std::cin.rdbuf(in.rdbuf());
#endif

  ll a;
  cin >> a;
  string b;
  cin >>b;

  ll bb = 0;

  bool is_dot = false;
  int cnt_dot = 0;
  for (char& c : b) {
    
    if (c =='.') {
      is_dot = true;
    }
    else {
      if(is_dot)cnt_dot++;
      bb *= 10;
      bb += c - '0';

      
    }
  }

  
  //cout << dec << a * bb / (pow(10,cnt_dot));
  int div = 1;
  rep (i, cnt_dot) div*=10;
  ll ans = a * bb / div;
  //9989900100000009

  printf("%lld", ans );

  return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));  // 2次元配列初期化
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */


Measured memory_bytes: 3716
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
// using namespace atcoder;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int k; cin >> k;
    string ans = "ACL";
    k--;
    rep(i, k) ans += "ACL";
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <cstdio>

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


    if (a < b) printf("a < b\n", a, b);
    else if (a == b) printf("a == b\n", a, b);
    else if (a > b) printf("a > b\n", a, b);

    return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    while (1) {
        cin >> n;
        if (n == 0) return 0;
        i64 sum = 0;
        vi as;
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            as.push_back(a);
            sum += a;
        }
        int cnt = 0;
        for (int a: as) {
            if (a <= sum / n) cnt++;
        }
        cout << cnt << endl;
    }
}


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


void solve(long long N){

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;cin >> N;
    long long ans = 0;
    for (int i = 1;i <= N; i++){
        if((10 <= i and i <= 99) or (1000 <= i and i <= 9999) or i == 100000) continue;
        else ans ++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

struct Sector {
  int file_id;
  int first;
  int last;
  Sector(int _f,int _s,int _l) : file_id(_f), first(_s), last(_l) {}
  int size() {return last - first + 1;}
};

class FileSystem {
private:
  vector<Sector> sectors;
public:
  FileSystem(){
    sectors.clear();
    sectors.push_back(Sector(-1,0,1000000007));
  }
  void write_sectors(int file_id,int required_sectors){
    for(vector<Sector>::iterator it = sectors.begin();
	it != sectors.end();
	it++){
      if(it->file_id == -1){
	it->file_id = file_id;
	if(required_sectors < it->size()){
	  int l = it->last;
	  it->last = it->first + required_sectors - 1;
	  int f = it->last + 1;
	  it++;
	  sectors.insert(it,1,Sector(-1,f,l));
	  break;
	}
	else {
	  required_sectors -= it->size();
	}
      }
    }
  }

  void delete_sectors(int file_id){
    for(vector<Sector>::iterator it = sectors.begin();
	it != sectors.end();
	it++){
      if(it->file_id == file_id){
	it->file_id = -1;
      }
    }
  }

  int refer_file_id(int sector_id){
    for(vector<Sector>::iterator it = sectors.begin();
	it != sectors.end();
	it++){
      if(it->first <= sector_id
	 && sector_id <= it->last){
	return it->file_id;
      }
    }
    return -1;
  }
};

int main(){
  int total_commands;
  while(~scanf("%d",&total_commands)){
    FileSystem fs;
    for(int command_idx = 0; command_idx < total_commands; command_idx++){
      char operation[2];
      scanf("%s",operation);
      if(operation[0] == 'W'){
	int file_id,required_sectors;
	scanf("%d %d",&file_id,&required_sectors);
	fs.write_sectors(file_id,required_sectors);
      }
      else if(operation[0] == 'D'){
	int file_id;
	scanf("%d",&file_id);
	fs.delete_sectors(file_id);
      }
      else if(operation[0] == 'R'){
	int sector_id;
	scanf("%d",&sector_id);
	cout << fs.refer_file_id(sector_id) << endl;
      }
    }
    if(total_commands !=0) cout << "\n";
  }
}

Measured memory_bytes: 1344
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[1000001],minn=2147483645;

bool cmp(int a,int b){
	return a>b;
}

int Min(int a,int b){
    return a<b?a:b; 
} 

int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int j=1;j<=n-k+1;j++){
		minn=Min(minn,a[j]-a[j+k-1]);
	}
	cout<<minn<<endl;
    
}


Measured memory_bytes: 640
#include"stdio.h"
using namespace std;
char a[5],b[5];
int i;
int main(){
	scanf("%s",a);
	scanf("%s",b);
	for(i=0;i<3;i++)
	if(a[i]!=b[3-i-1]){printf("NO\n");return 0;}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(m)]

A.sort(key=lambda a:a[1])
ans = 0
i = 0

while i < m:
    b = A[i][1]
    ans += 1
    i += 1
    while i < m:
        if A[i][0] >= b:
            break
        i += 1

print(ans)

Measured memory_bytes: 22916
N=int(input())
V=list(map(int, input().split()))
C=list(map(int, input().split()))
ans=0
for i in range(2**N):
  X=0
  for j in range(N):
    if (i>>j)&1:
      X+=(V[j]-C[j])
  ans=max(ans,X)
print(ans)

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

const int INF = 1 << 28;

int main () {
    int n; cin >> n;
    string S, T;
    cin >> S >> T;

    vector<int> s(256), t(256);
    for (int i = 0; i < n; i++) {
        s[S[i]]++;
        t[T[i]]++;
    }

    sort(s.begin(), s.end(), greater<int>());
    sort(t.begin(), t.end(), greater<int>());

    int res = 0;
    for (int i = 0; i < t.size() && i < s.size(); i++) {
        res += abs(t[i] - s[i]);
    }

    cout << res / 2 << endl;

    return 0;
}

Measured memory_bytes: 1524
#include <iostream>
#include <stdio.h>
using namespace std;

const int M=55;
int p[M];
int n;

bool check()
{
	for(int i=1;i<n;i++)
		if(p[i-1]>p[i]) return false;
	return true;
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&p[i]);
	int f=check();
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			swap(p[i],p[j]);
			f|=check();
			swap(p[i],p[j]);
		}
	printf("%s\n",f?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

ll max(ll a,ll b){
    if(a > b) return a;
    return b;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = 0;
    ll tmp = 1;
    ll a_f,b_f;
    a--;
    while(tmp <= b){
        a_f = (a)/(2*tmp)*tmp + max(0,(a%(2*tmp))-tmp+1);
        b_f = (b)/(2*tmp)*tmp + max(0,(b%(2*tmp))-tmp+1);
        if(((b_f-a_f)%2)==1){
            ans += tmp;
        }
        tmp *= 2;
    }

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

Measured memory_bytes: 384
from collections import Counter
S=raw_input()
T=raw_input()

start=[ -1 for i in range(26) ]
goal=[ -1 for i in range(26) ]

L=len(S)


for i in range(L):
	a=ord(S[i])-ord("a")
	b=ord(T[i])-ord("a")

	if start[a]!=-1 or goal[b]!=-1:
		if start[a]!=b or goal[b]!=a:
			print "No"
			quit()
	else:
		start[a]=b
		goal[b]=a

#print "start::: ",start
#print "goal::: ",goal

print "Yes"

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

int main() {
  int h, w;
  cin >> h >> w;
  vector <string> arr(h);
  rep(i, h) cin >> arr[i];

  rep(i, h) {
    string res_string;
    rep(j, w) {
      if (arr[i][j] == '#') {
        res_string += '#';
        continue;
      }
      int res = 0;
      for (int dx = -1; dx <= 1; ++dx) {
        for (int dy = -1; dy <= 1; ++dy) {
          int nx = j + dx;
          int ny = i + dy;
          if (nx < 0 || nx >=  w || ny < 0 || ny >= h) {
            continue;
          }
          if (arr[ny][nx] == '#') {
            ++res;
          }
        }
      }
      res_string += to_string(res);
    }
    cout << res_string << endl;
  }
}


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

int main() {
    ll s;
    cin >> s;
    ll v = 1e9;
    ll x = (v - s % v) % v;
    ll y = (s + x) / v;
    cout << "0 0 1000000000 1 " << x << " " << y << endl;
    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 a,b,c;
    vector<int> vec(3);
    rep(i,3){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int ans = 0;
    ans += vec.at(1) - vec.at(0);
    ans += vec.at(2) - vec.at(1);
    cout << ans << endl;
}

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

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

  int ans = 0;
  ans = x / 500 * 1000;
  ans += x % 500 / 5 * 5;

  cout << ans << endl;
}


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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int a[501][501] = {0};
int b[501][501] = {0};


signed main(){
    
    int H,W;
    cin >> H >> W;

    REP(i,H){
        REP(j,W){
            cin >> a[i][j];
            b[i][j] = a[i][j];
        }
    }

    int cnt  = 0;

    REP(i,H){
        REP(j,W-1){
            if(b[i][j]%2 == 1){
                b[i][j+1]++;
                //cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
                cnt++;
            }
        }
    }
    REP(i,H-1){
        if(b[i][W-1]%2 == 1){
            b[i+1][W-1]++;
            //cout << i+1 << " " << W << " " << i+2 << " " << W << endl;
            cnt++;
        }
    }
    cout << cnt  << endl;

    REP(i,H){
        REP(j,W-1){
            if(a[i][j]%2 == 1){
                a[i][j+1]++;
                cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
               
            }
        }
    }
    REP(i,H-1){
        if(a[i][W-1]%2 == 1){
            a[i+1][W-1]++;
            cout << i+1 << " " << W << " " << i+2 << " " << W << endl;
   
        }
    }
    
    
    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 6016
#include<stdio.h>
int main()
{
    int x,y,z;
    int i;
    scanf("%d%d%d",&x,&y,&z);
    for(i=1;i;i++)
    {
        if(x==y*i+2*z+(i-1)*z)
        {
            printf("%d\n",i);
            break;
        }

        else if(x<y*i+2*z+(i-1)*z)
        {
            printf("%d\n",i-1);
            break;
        }

    }
    return 0;
}

Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
const double pi=acos(-1.0);
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FDR(i,a,n) for(int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=200005;
//Code begin....

int main ()
{
    int a, b, c, d, n;
    LL ans=0;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&n);
    int mi2=min(8*a,min(4*b,min(2*c,d)));
    int mi1=min(4*a,min(2*b,c));
    ans=(LL)n/2*mi2+(n%2)*mi1;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    S = [0] * (n + 1)
    for i in range(n):
        S[i + 1] = S[i] + A[i]

    dp = [[None] * (n + 1) for _ in range(n + 1)]
    for l in range(n):
        dp[l][l + 1] = 0

    for width in range(2, n + 1):
        for l in range(n - width + 1):
            r = l + width
            res = INF
            for m in range(l + 1, r):
                res = min(res, dp[l][m] + dp[m][r] + S[r] - S[l])
            dp[l][r] = res

    print(dp[0][n])
resolve()

Measured memory_bytes: 42608
m=int(input())

kou = 1

if m%2==0 or m%5==0:
    print(-1)
    
else:

    s=7%m
    k=7
    
    while 1:
        if s==0:
            print(kou)
            break
        
        
        k*=10
        k%=m
        s+=k
        s%=m
        
        kou+= 1
        

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

int main(){
	string s;
  	cin >> s;
  	bool ok;
  	int n = s.size();
  	int now;
  	if(n<26) {
    	for(int i = 0; i<26;i++) {
          	ok = true;
          	for(int j = 0; j < n;j++) {
              	if(s[j] == i+'a') {
                	ok = false;
                  	break;
                }
            }
          	if(ok) {
              	cout << s << (char)(i+'a')<<endl;
               	return 0;
            }
        }
    } else {
		if(s == "zyxwvutsrqponmlkjihgfedcba")
          	cout << -1 << endl;
      	else {
          	now = s[25];
        	for(int i = 24; i >=0;i--) {
              if((int)s[i] < now) {
                	int j,mini='z';
                	for(j = i+1;j<26;j++)
                      	if(s[j] > s[i] && mini > s[j])
                          	mini = s[j];
                   	cout << s.substr(0,i) << (char)(mini)<<endl;
                   	return 0;
                 	
                 } else {
                   	now = s[i];
                 }
              
            }
        }
	}
}


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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# Union-Find木
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        # 1-indexedのままでOK、その場合は[0]は未使用
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)
        # あるノードを根とする集合に属するノード数
        self.size = [1] * (n+1)

    # 根の検索(グループ番号と言えなくもない)
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

N,M=MAP()

uf=UnionFind(N)
# 橋が0の時の不便さ
sm=N*(N-1)//2
ans=[0]*(M)
ans[M-1]=sm
edges=[]
for i in range(M):
    a,b=MAP()
    edges.append((a,b))

# 逆から、1本ずつ橋をつないでいく
for i in range(M-1, 0, -1):
    a,b=edges[i]
    # 同じグループに属してなければ、不便さに変化がある
    if not uf.same(a, b):
        # 今回橋が繋がる分、aのグループに属する島数*bのグループに属する島数の不便さを減らす
        sm-=uf.size[uf.find(a)]*uf.size[uf.find(b)]
        uf.union(a, b)
    ans[i-1]=sm

[print(ans[i]) for i in range(M)]


Measured memory_bytes: 27192
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <regex>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

char buf[100];

bool isOK(void) {
  regex re("^A[a-z]+C[a-z]+$");
  return regex_match(buf, re);
}

int main(void) {
  cin >> buf;
  puts(isOK() ? "AC" : "WA");
  return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

const mod = 1000000007

func pow(m int64, n int) int64 {
	if n == 0 {
		return 1
	}
	r := pow(m*m%mod, n/2)
	if n%2 == 1 {
		return r * m % mod
	}
	return r
}

func main() {
	var m int64
	var n int
	fmt.Scan(&m, &n)
	fmt.Println(pow(m, n))
}



Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int gcd( int n, int m ) {
	if ( m == 0 ) {
		return n;
	}
	return gcd( m, n % m );
}

bool solve( string &str ) {
	if ( str[0] == 't' ) {
		str = str.substr( 4 );
		return false;
	}
	str = str.substr( 5 );
	return true;
}


int main() {
	string str;
	while ( cin >> str && str != "#" ) {
		int ans1, ans2 = 1;
		int now = 1;
		int north = 0, west = 0;
		reverse( str.begin(), str.end() );
		if ( solve( str ) ) {
			ans1 = 0;
		}
		else {
			ans1 = 90;
		}
		while ( str.size() ) {
			ans1 *= 2;
			ans2 *= 2;
			if ( solve( str ) ) {
				ans1 -= 90;
			}
			else {
				ans1 += 90;
			}
		}
		int d = gcd( ans1, ans2 );
		printf( "%d", ans1 / d );
		if ( ans2 != d ) {
			printf( "/%d", ans2 / d );
		}
		printf( "\n" );
	}
	return 0;
}

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

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

    map<int , string> dict{
        {22, "Christmas Eve Eve Eve"},
        {23, "Christmas Eve Eve"},
        {24, "Christmas Eve"},
        {25, "Christmas"}};

    cout << dict[D] << endl;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main(void){
    int a,b,max;
    scanf("%d%d",&a,&b);
    max=a*b>a-b?a*b:a-b;
    max=max>a+b?max:a+b;
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

signed main(){
	IOS;
	ll n, L;
	cin >> n >> L;
	vec<ll> a(n);
	REP(i,n)cin >> a[i];
	ll x = 0;
	REP(i,n - 1){
		if(a[i] + a[i + 1] >= L){
			x = i + 1;
			break;
		}
	}
	if(x == 0){
		dump("Impossible");
		return 0;
	}
	dump("Possible");
	for(int i = 1;i < x;i++){
		dump(i);
	}
	for(int i = n - 1;i >= x;i--){
		dump(i);
	}
}

Measured memory_bytes: 1664
n, m = map(int, input().split())

min_value = 1
max_value = n

for _ in range(m):
  l, r = map(int, input().split())
  if l >= min_value:
    min_value = l
  if r <= max_value:
    max_value = r

Answer = max(max_value - min_value +1,0)

print(Answer)

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

int main(){
    int n;
    cin>>n;
    string s[3];
    for(int i=0;i<3;i++) cin>>s[i];
    int res=0;
    for(int i=0;i<n;i++){
        map<char,int> cnt;
        int m=0;
        for(int j=0;j<3;j++){
            m=max(++cnt[s[j][i]],m);
        }
        res+=3-m;
    }
    cout<<res<<endl;
    


    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val S = readInputLine().toCharArray()
    
    var ans = 1
    
    for (i in 1 until N) {
        if (S[i - 1] != S[i]) {
            ans++
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#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 SQR(a)          ((a)*(a))
#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())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n , k;

    cin >> n >> k;

    set<ll>s;


    for(int i=0; i<k; i++)
    {

        ll a;

        cin >> a;

        for(int j=0; j<a; j++)
        {

            ll num;

            cin >> num;

            s.insert(num);
        }
    }

    cout << n-s.size() << endl;





    return 0;
}



Measured memory_bytes: 3656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn div_num(n: u64) -> u64 {
    if n % 2 == 0 {
        1 + div_num(n/2)
    } else {
        0
    }
}

fn main() {
    input! {
        n: u64
    }
    let mx = (1..n+1).fold((0,1), |(a,n), i| {
        let b = div_num(i);
        if a < b { (b, i) } else { (a, n) }
    });
    println!("{}", mx.1);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int count=0;
        if(i%2==0)continue;
        for(int j=1;j<=i;j++){
            if(i%j==0)count++;
        }
        //cout<<i<<" "<<count<<endl;
        if(count==8)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def aising2019_b():
    n = int(input())
    a, b = map(int, input().split())
    p = list(map(int, input().split()))
    first = second = third = 0
    for v in p:
        if v <= a:
            first += 1
        elif v <= b:
            second += 1
        else:
            third += 1
    print(min([first, second, third]))


aising2019_b()

Measured memory_bytes: 3064
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    a_time = [0]
    b_time = [0]
    for i in range(1, len(a) + 1):
        a_time.append(a_time[i - 1] + a[i - 1])
    for i in range(1, len(b) + 1):
        b_time.append(b_time[i - 1] + b[i - 1])

    a_max = 0
    b_max = 0
    for i in range(len(a_time)):
        if a_time[i] > k:
            break
        else:
            a_max = i
    for i in range(len(b_time)):
        if b_time[i] > k:
            break
        else:
            b_max = i

    for i in range(len(b_time)):
        if a_time[a_max] + b_time[i] <= k:
            ans = max(ans, a_max + i)
        else:
            if a_max > 0:
                a_max -= 1
    for i in range(len(a_time)):
        if b_time[b_max] + a_time[i] <= k:
            ans = max(ans, b_max + i)
        else:
            if b_max > 0:
                b_max -= 1

    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string S;
	cin >> S;
	map<char, int> alpha;
	alpha['A'] = 1; alpha['B'] = 2; alpha['C'] = 3; alpha['D'] = 4; alpha['E'] = 5;
	alpha['F'] = 6; alpha['G'] = 7; alpha['H'] = 8; alpha['I'] = 9; alpha['J'] = 10;
	alpha['K'] = 11; alpha['L'] = 12; alpha['M'] = 13; alpha['N'] = 14; alpha['O'] = 15;
	alpha['P'] = 16; alpha['Q'] = 17; alpha['R'] = 18; alpha['S'] = 19; alpha['T'] = 20;
	alpha['U'] = 21; alpha['V'] = 22; alpha['W'] = 23; alpha['X'] = 24; alpha['Y'] = 25;
	alpha['Z'] = 26;
	map<int, char> alpha2;
	alpha2[1] = 'A'; alpha2[2] = 'B'; alpha2[3] = 'C'; alpha2[4] = 'D';
	alpha2[5] = 'E'; alpha2[6] = 'F'; alpha2[7] = 'G'; alpha2[8] = 'H';
	alpha2[9] = 'I'; alpha2[10] = 'J'; alpha2[11] = 'K'; alpha2[12] = 'L';
	alpha2[13] = 'M'; alpha2[14] = 'N'; alpha2[15] = 'O'; alpha2[16] = 'P';
	alpha2[17] = 'Q'; alpha2[18] = 'R'; alpha2[19] = 'S'; alpha2[20] = 'T';
	alpha2[21] = 'U'; alpha2[22] = 'V'; alpha2[23] = 'W'; alpha2[24] = 'X';
	alpha2[25] = 'Y'; alpha2[26] = 'Z';
	rep(i, S.size()) {
		if (alpha[S[i]] + n <= 26) {
			S[i] = alpha2[alpha[S[i]] + n];
		}
		else {
			S[i] = alpha2[alpha[S[i]] + n - 26];
		}
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<pair<int,int>,ll> P;
const ll MOD = 1e9+7;

struct segtree {
    int N;
		ll dat[2*400000];
    segtree() {}
    segtree(int n) {
        N = 1;
        while(N < n) N *= 2;
        for(int i = 0; i < 2*N-1; i++)
            dat[i] = 1e14-1;
    }
    // update k th element
    void update(int k, ll a) {
        k += N-1; // leaf
        dat[k] = min(a,dat[k]);
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return 1e14-1;
        if(a <= l && r <= b) return dat[k];
        int m = (l + r) / 2;
        return min(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
		ll get(int i)
		{
			return dat[i+N-1];
		}
};


// bool operator<(P &lhs,P &rhs)
// {
// 	if(lhs.first.first==rhs.first.first)
// 		return lhs.second<rhs.second;
// 	else
// 		return lhs.first<rhs.first;
// }
P p[100000];
int main()
{
	int n,m;
	ll ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r;ll c;
		cin>>l>>r>>c;
		l--;r--;
		p[i]=P(make_pair(l,r),c);
	}
	sort(p,p+m);
	segtree t=segtree(n);
	t.update(0,0);
	for(int i=0;i<m;i++)
	{
		//cerr<<p[i].first.first<<endl;
		ll s=t.query(p[i].first.first,p[i].first.second+1);
		if(s==1e14-1)
			continue;
		t.update(p[i].first.second,s+p[i].second);
	}
	ans=t.get(n-1);
	if(ans==1e14-1)
		ans=-1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t[100010];
int main(){
	int n,l;	cin>>n>>l;
	int a[n];
	for(int i=0;i<n;i++)	cin>>a[i];
	t[0]=l-a[0];
	for(int i=1;i<n;i++){
		if(a[i-1]>a[i])	t[i]=t[i-1]+(l-a[i]);
		else 	t[i]=l-a[i];
	}
	for(int i=n-2;i>=0;i--){
		if(a[i]<a[i+1])	t[i]=max(t[i],t[i+1]+(l-a[i]));
	}
	ll ans=0;
	for(int i=0;i<n;i++)	ans=max(ans,t[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2328
x,n = map(int,input().split())
if n == 0:
    p = []
a = 0
b = 0
if n != 0:
    p = list(map(int,input().split()))
#print(p)
i = 0
while True:
    if x-i in p:
        i += 1
    else:
        a = x-i
        break
i = 0
while True:
    if x+i in p:
        i += 1
    else:
        b = x+i
        break
if abs(x-a)>abs(x-b):
    print(b)
if abs(x-a)<=abs(x-b):
    print(a)

Measured memory_bytes: 9212
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    int N = int.Parse(Console.ReadLine());
    // Console.WriteLine(N);
    var a1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    var a2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Console.WriteLine(a1.Zip(a2, (x, y) => x - y).Where(x => x >= 0).Sum());
  }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int arr[n];
    int i;
    int j;
    int count = 0;
    int check = 0;
    for(i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    for(i=n-1;i>=0;i--)
    {
        check = 0;
        for(j=i-1;j>=0;j--)
        {
            if(arr[j]>arr[i])
            {
                check = 1;
                break;
            }
        }
        if(check==0)
        {
            count++;
        }
    }
    cout << count;
}

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

using namespace std;
using i64 = int64_t;
i64 MOD = 1e9 + 7;

i64 solve(){
    
    i64 n;
    cin >> n;
    if(!n)
        return MOD;
    vector<i64> a(n + 1);
    for(auto& x : a)
        cin >> x;
    
    for(int j = 0; j <= n; ++j){
        vector<int> b;
        for(int i = 0; i <= n; ++i)
            if(i != j)
                b.emplace_back(a[i]);
    
        int d = b[1] - b[0];
        bool fl = true;
        for(int i = 0; i < n - 1; ++i)
            if(b[i + 1] - b[i] != d)
                fl = false;
        if(fl){
            cout << a[j] << endl;
            return 1;
        }
    }
    
    return true;
}

signed main(){
    while(solve() != MOD);
}


Measured memory_bytes: 3144
//#pragma comment(linker, "/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

ll n, k;
void solve()
{
	slla(n), slla(k);
	ll ans = 0;
	repp(x, k + 1, n)
	{
		ll f = n / x;
		ll num = x - k;
		ans += num*f;
		ll sur = n%x + 1;
		ans += max(sur - k, 0LL);
	}
	if (!k)ans = n*n;
	cout << ans << endl;
}

int main()
{

	solve();
    // system("pause");
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:33554432")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cmath>
#include <cstring>
#include <bitset>

using namespace std;
void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
using ld = long double;


void precalc() {}

void solve() {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); ++ i)
        cout << "x";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(20);
    precalc();
    solve();

}

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

int BubbleSort(vector<int>a, int n){
    int sw=0; bool flg=true;
    for(int i=0;flg;++i){
      flg=false;
      for(int j=n-1;j>i;--j){
        if(a[j-1]>a[j]){
          swap(a[j-1], a[j]);
          flg=true; ++sw;
        }
      }
    }
    for(int i=0;i<n;++i){
        if(i!=n-1) cout << a[i] <<" ";
        else cout << a[i];
    }
    cout << endl;
    return sw;
}

int main() {
    int N; cin >> N; vector<int> A(N);
    for(int i=0;i<N;++i) cin >> A[i];
    int sw = BubbleSort(A, N);
    
    cout << sw << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;

int main() {
	ll n, x;
	cin >> n >> x;
	
	ll ans = 0;
	if (n == x * 2) {
		ans = 3 * x;
	} else {
		bool f; //true: 上に上がる false:左に進む
		
		ll a = x, b = n - x; //a < b
		
		if (a < b) f = true;
		else {
			f = false;
			swap(a, b);
		}
		ans = a + b;
		while (true) {
			if (b == a) ans += a;
			else ans += (b / a) * 2 * a;
			
			if (b % a == 0) break;
			
			f = !f;
			ll tmp = a;
			a = b % a;
			b = tmp;
		}
		if (b != a) ans -= a;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int ans=0,cnt=0;
    rep(i,s.size()){
        if(s[i]=='R')cnt++;
        else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main()
{
    int N;
    int A;
    int B;
    int P[100];
    int i;
    int count;

    scanf("%d", &N);
    scanf("%d %d", &A, &B);
    for(i = 0; i < N; i++) {
        scanf("%d", &P[i]);
    }
    qsort(P, N, sizeof(P[0]), compare_int);

    count = 0;
    while(1) {
        for(i = 0; i < N; i++) {
            if(P[i] <= A && P[i] != -1) {
                P[i] = -1;
                break;
            }
        }
        if(i >= N) {
            break;
        }

        for(i = 0; i < N; i++) {
            if(P[i] >= (A+1) && P[i] <= B) {
                P[i] = -1;
                break;
            }
        }
        if(i >= N) {
            break;
        }

        for(i = 0; i < N; i++) {
            if(P[i] >= (B+1)) {
                P[i] = -1;
                count += 1;
                break;
            }
        }
        if(i >= N) {
            break;
        }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N=5005;
int n,p[N],a,b,dp[N][N];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++) dp[i][j]=1e18;
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(p[i+1]>j)
            {
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]+a);
                dp[i+1][p[i+1]]=min(dp[i+1][p[i+1]],dp[i][j]);
            }
            else dp[i+1][j]=min(dp[i+1][j],dp[i][j]+b);
        }
    }
    int res=1e18;
    for(int i=0;i<=n;i++) res=min(res,dp[n][i]);
    cout<<res;
}




Measured memory_bytes: 195840