akhauriyash/Code-Regression huggingface dataset:
#include <time.h>
struct tm t,T;
main(y,m,Y,M){
	for(;scanf("%d%d%d%d%d%d",&y,&m,&t.tm_mday,&Y,&M,&T.tm_mday),~Y;printf("%d\n",(mktime(&T)-mktime(&t))/86400))t.tm_year=y-1900,t.tm_mon=m-1,T.tm_year=Y-1900,T.tm_mon=M-1;
exit(0);}

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

#define ll long long
#define ar array
#define vi vector<int>
#define INF 1000000000

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;	
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int N;
	int A, B;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> A;
		cin >> B;
		cout << (A + B);
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string w; cin >> w;
  vector<int> cnts(26);
  for (int i = 0; i < w.size(); i++)
    cnts[w[i] - 'a']++;
  for (int i = 0; i < 26; i++) {
    if (cnts[i] % 2 == 1) {
      No();
      return;
    }
  }
  Yes();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using intl = int64_t;
using graph = vector<vector<int> >;
int main(){
    string s,t;
    cin >> s >> t;
    vector<string> a(s.size()-t.size()+1);
    for(int i=0;i<a.size();i++){
        for(int j=i;j<i+t.size();j++){
            a[i].push_back(s.at(j));
        }
    }

    int match=0;
    for(int i=0;i<a.size();i++){
        int tmp=0;
        for(int j=0;j<t.size();j++){
            if(a[i].at(j)==t.at(j)) tmp++; 
        }
        match = max(match,tmp);
    }

    cout << t.size()-match << endl;
}

Measured memory_bytes: 3996
n, m = map(int, raw_input().split())
g = [[] for i in xrange(n)]
for i in xrange(m):
    a, b, c = map(int, raw_input().split())
    g[a-1].append((b-1, c))
dist = [-10**18]*n


import sys
sys.setrecursionlimit(10**6)
used = [0]*n
valid = [0]*n
memo = [None]*n
def dfs(v):
    res = 0
    if memo[v] is not None:
        return memo[v]
    for t, c in g[v]:
        if not used[t]:
            if t == n-1:
                res = 1
            used[t] = 1
            res |= dfs(t)
            used[t] = 0
    valid[v] |= res
    memo[v] = valid[v]
    return res
valid[0] = valid[n-1] = 1
used[0] = 1
dfs(0)

dist[0] = 0
for t in xrange(2*n):
    update = 0
    for v in xrange(n):
        for t, c in g[v]:
            if valid[t] and dist[v] + c > dist[t]:
                dist[t] = dist[v] + c
                update = 1
if update == 1:
    print "inf"
else:
    print dist[n-1]


Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;


int main(void) {
	int k, t;
	int a[101];
	int maxi = 0;
	int total = 0;
	cin >> k >> t;
	FOR(i, 1, t) {
		cin >> a[i];
		maxi = max(maxi, a[i]);
	}
	FOR(i, 1, t) {
		total += a[i];
	}
	cout << max(0, maxi - 1 - total+maxi) << endl;
	return 0;
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n;
    cin >> n;
    lli a[n];
    lli a_orig[n];
    REP(i, 0, n) {
        cin >> a[i];
        a_orig[i] = a[i];
        a[i] *= 2;
    }

    // 畳み込んで計算していき、aを出す。
    lli i = 0;
    lli up = 2;
    bool is_minus = true;
    while (true) {
        lli num1 = a[i];
        if (i+(up/2) >= n-1) {
            a[i] = num1;
        }
        else {
            lli num2 = a[i+(up/2)];
            if (is_minus)
                a[i] = num1 - num2;
            else
                a[i] = num1 + num2;

        }

        i+= up;
        if (i >= n-1) {
            // 畳み込みが次のフェーズに行く
            i = 0;
            up *= 2;
            if (i + (up/2) >= n-1) {
                break;
            }
            if (is_minus)
                is_minus = false;
        }
    }
    lli a0;
    a0 = (a[0] + a[n-1]) / 2;
    cout << a0;
    lli cur = a0;
    REP(i, 0, n-1) {
        cout <<" " << a_orig[i]*2 - cur;
        cur = a_orig[i]*2 - cur;
    }
    cout << endl;
}


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

int main() {
    long n, x;
    cin >> n >> x;
    long prev, a;
    cin >> prev;
    long count = 0;
    for (int i = 1; i < n; i++) {
        cin >> a;
        if (x - prev < a) {
            count += a + prev - x;
            if (x <= prev) {
                prev = 0;
            } else {
                prev = x - prev;
            }
        } else {
            prev = a;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def list_gcd(arr):
    if len(arr) == 1:
        return arr[0]

    ans = gcd(arr[0], arr[1])
    for i in range(2, len(arr)):
        ans = gcd(ans, arr[i])
    return ans


N, X = map(int, input().split())
li = list(map(int, input().split()))
steps = []
for i in range(N):
    steps.append(abs(li[i] - X))

print(list_gcd(steps))


Measured memory_bytes: 63768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll s;
    cin >>s;
    map<ll,ll> m;
    ll now=s;
    ll i=1;

    while(1){
        i++;
        m[now]=1;
        if(now%2==0){
            now/=2;
        }else{
            now = 3*now + 1;
        }
        if(m[now]==1){
            cout<<i<<endl;
            return 0;
        }
    }
    



    return 0;
    

}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#pragma warning(disable:4996)
using namespace std;
const int maxn = 100 + 10;
const int maxv = 10000 + 10;
const int INF = 1 << 21;
int n;
int E;
typedef struct{
	int from, to, cost;
}Edge;

Edge e[maxv];
int d[maxn];
void bellman_ford(int s){
	fill(d, d + n, INF);
	d[s] = 0;
	while (true)	{
		bool bUpdate = false;
		for (int i = 0; i<E; i++)	{
			Edge es = e[i];
			if (d[es.from] != INF&&d[es.to]>d[es.from] + es.cost)		{
				d[es.to] = d[es.from] + es.cost;
				bUpdate = true;
			}
		}
		if (!bUpdate) break;
	}
	for (int i = 0; i<n; i++) printf("%d %d\n", i, d[i]);
}

int main(){
	scanf("%d", &n);
	int id, c;
	E = 0;
	for (int i = 0; i<n; i++){
		scanf("%d%d", &id, &c);
		while (c--){
			scanf("%d%d", &e[E].to, &e[E].cost);
			e[E].from = id;
			E++;
		}
	}
	bellman_ford(0);
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <set>
using namespace std;
int main(int argc, const char *argv[])
{
    set<int> st;
    int x;
    for (int i = 0; i < 3; i++)
    {
        cin >> x;
        st.insert(x);
    }
    if (st.size() == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    int n;
    int a[100], b[100];

    cin >> n;
    Rep(i, n) {
        cin >> a[i];
        if ( i ) a[i] = a[i] + a[i-1];
    }

    Rep(i, n) {
        cin >> b[i];
        if ( i ) b[i] = b[i] + b[i-1];
    }

    int ans = a[0]+b[n-1];
    Rep(i, n-1) {
        ans = max(ans, a[i]+b[n-1]-b[i-1]);
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i=1;i<=n;++i)
int main(){
	int N,p;
	cin>>N;
	int add[N+1];
	rep1(i,N)cin>>p,add[p]=i;
	rep1(i,N)cout<<i*N<<" ";
	cout<<endl;
	rep1(i,N)cout<<N*(N-i)+add[i]<<" ";
	cout<<endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n;
  cin >> n;
  int ans = 0;
  bool f = 0;
  FOR(i, 1, 10) {
    if (i == n) ans++;
    if (i >= n || f) {
      f = 1;
      break;
    }
    ans++;
  }

  FOR(i, 100, 1000) {
    if (i == n) ans++;
    if (i >= n || f) {
      f = 1;
      break;
    }
    ans++;
  }

  FOR(i, 10000, 100000) {
    if (i == n) ans++;
    if (i >= n || f) {
      f = 1;
      break;
    }
    ans++;
  }
  cout << ans << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import defaultdict

N = int(input())
a = list(map(int, input().split()))

cnt = 0
d = [0] * (N + 2)
for i in range(N):
    d[a[i]] = i


l = list(range(N + 2))
r = list(range(N + 2))

# print(a)
for i in range(N, 0, -1):
    di = d[i]
    cnt += i * (r[di] - di + 1) * (di - l[di] + 1)
    r[l[di] - 1] = r[di]
    l[r[di] + 1] = l[di]
    # print(i)
    # print(r)
    # print(l)
# print(r)
# print(l)
print(cnt)


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

long atack(long x){
  if(x==1) return 1;
  else{
    x=floor(x/2);
    return 1+2*atack(x);
  }
}

int main(){
  long h;cin>>h;
  cout <<atack(h) <<endl;
}

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

int main() {

    int n,y;
    cin >> n >> y;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n-i; j++){

            if( 10000*i + 5000*j + 1000*(n-i-j) == y ){
                cout << i << ' ' << j << ' ' << n-i-j << endl;
                return 0;
            }
        
        }
    }
  
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

static class Extensions {
   public static int ToInt(this string str) => int.Parse(str);
}

class Program {
   public static void Main(string[] args) {
      var n = ReadLine().ToInt();
      var h = ReadLine().Split(' ').Select(int.Parse).ToArray();

      var dp = new int[n];
      for (int i = 0; i < n; i++) dp[i] = int.MaxValue;

      dp[0] = 0;

      for (int i = 0; i < n - 2; i++) {
         var delta1 = dp[i] + Math.Abs(h[i + 1] - h[i]);
         var delta2 = dp[i] + Math.Abs(h[i + 2] - h[i]);
         
         if (dp[i + 1] > delta1) dp[i + 1] = delta1;
         if (dp[i + 2] > delta2) dp[i + 2] = delta2;
      }

      var delta = dp[n - 2] + Math.Abs(h[n - 2] - h[n - 1]);
      if (dp[n - 1] > delta) dp[n - 1] = delta;

      WriteLine(dp.Last());
   }
}


Measured memory_bytes: 18016
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int sum[440][440];
Int dp[440][440];
Int a[440];
Int n;
int main(){
    cin >> n;
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int l = 0;l < n;l++){
        sum[l][l+1] = a[l];
        for(int r = l+2;r <= n;r++){
            sum[l][r] = sum[l][r-1] + a[r-1];
        }
    }

    for(int width = 2;width <= n;width++){
        for(int l = 0;l+width <= n;l++){
            int r = l + width;
            dp[l][r] = LINF;
            for(int m = l + 1;m < r;m++){
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m][r] + sum[l][r]); 
            }
        }
    }
    cout << dp[0][n] << endl;
    return 0;
}

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

#define INF 1e+9
#define MAX_V 2000

struct edge {
    int to;
    int cost;
};

using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int X, Y;
    cin >> V >> X >> Y;
    for (int i=0; i<V-1; ++i) {
        edge e1 = {i+1, 1};
        G[i].push_back(e1);
        edge e2 = {i, 1};
        G[i+1].push_back(e2);
    }
    edge e3 = {X-1, 1};
    G[Y-1].push_back(e3);
    edge e4 = {Y-1, 1};
    G[X-1].push_back(e4);

    int saitan[V];
    for(int i = 0; i<V; ++i){
        saitan[i]=0;
    }

    for (int i=0; i<V; ++i) {
        dijkstra(i);
        for(int j=0; j<V; ++j){
            saitan[d[j]]++;
        }
    }
    for(int i=1; i<V; ++i){
        cout << saitan[i]/2 << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 632
#include	<cstdint>
#include	<iostream>
#include	<fstream>

typedef		std::uint_least32_t		ULI;		//10^9
typedef		std::int_least32_t		SLI;
typedef		std::uint_least64_t		ULLI;
typedef		std::int_least64_t		SLLI;

using namespace std;

int	Cnt = 0;

void BubbleSort(int A[], int N);

int main()
{
	int		N;
	int		A[100];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	BubbleSort(A, N);

	for (int i = 0; i < N; i++)
	{
		if (i != 0)	cout << " ";
		cout << A[i];
	}
	cout << "\n";
	cout << Cnt << "\n";

	return 0;
}

void BubbleSort(int A[], int N)
{
	bool		flag = true;

	while (flag)
	{
		flag = false;

		for (int i = N - 1; i > 0; i--)
		{
			if (A[i] < A[i - 1])
			{
				int		temp = A[i];
				A[i] = A[i - 1];
				A[i - 1] = temp;
				Cnt++;
				flag = true;
			}
		}
	}
}

Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	int A[N+1];
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	int cnt=0;
	for(int i=1;i<=N;i++){
		if(A[A[i]]==i){
			cnt++;
		}
	}
	cnt/=2;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

k = int(arr_data[0][0])

if k % 2==0:
    
    print((k // 2 ) ** 2 )
    
else:

    print((k // 2 ) * ((k // 2) + 1 ))
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

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

  bool is_ok = false;
  rep(i, S.size() - 1)
  {
    if (S[i] == 'A' && S[i + 1] == 'C')
      is_ok = true;
  }

  printYesNo(is_ok);
  return 0;
}

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

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


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

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double kaku1 = 30 * H;
    kaku1 += 0.5 * M;
    double kaku2 = 6 * M;
    double kaku3;

    if(kaku1 >= kaku2){
        kaku3 = kaku1 - kaku2;
    }else{
        kaku3 = kaku2 - kaku1;
    }
    
    if(kaku3 >= 180){
        kaku3 = 360 - kaku3;
    }

    const double PI=3.14159265358979323846264338327950288;
    
    double ans = sqrt(A * A + B * B - 2 * A * B * cos(kaku3 * PI / 180));
    cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

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

    long ans=0;
    for(int i=1;i<=n;i++){
        int x=i;
        int sum=0;
        while(x>0){
            sum+=x%10;
            x/=10;
        }
        if(a<=sum && sum<=b){
            ans+=i;
        }
    }

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



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

int dat[2002];
vector<int> graph[2002];
bool visit[2005];
int n;

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

vector<int> merge(vector<vector<int>> vvt, int head)
{
	vector<int> ret;

	if (head >= 0) ret.push_back(head);

	priority_queue<tuple<int, int, int>> pq;

	for (int i = 0; i < vvt.size(); i++)
	{
		pq.emplace(vvt[i][0], i, 0);
	}

	while (pq.empty() == false)
	{
		int val, idx, nxt;
		tie(val, idx, nxt) = pq.top();
		pq.pop();
		ret.push_back(val);

		if (nxt + 1 < vvt[idx].size())
		{
			pq.emplace(vvt[idx][nxt + 1], idx, nxt + 1);
		}
	}

	return ret;
}

vector<int> process(int t)
{
	vector<vector<int>> vvt;
	visit[t] = true;

	for (int nxt : graph[t])
	{
		if (visit[nxt]) continue;
		vvt.emplace_back(process(nxt));
	}

	return merge(move(vvt), t);
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &dat[i]);
	}

	sort(dat, dat + n);

	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (gcd(dat[i], dat[j]) > 1)
			{
				graph[i].push_back(j);
				graph[j].push_back(i);
			}
		}
	}

	for (int i = 0; i < n; i++) sort(graph[i].begin(), graph[i].end());

	vector<vector<int>> vvt;

	for (int i = 0; i < n; i++)
	{
		if (visit[i]) continue;
		vvt.emplace_back(process(i));
	}

	auto ret = merge(move(vvt), -1);

	for (int t : ret) printf("%d ", dat[t]);
	printf("\n");
}

Measured memory_bytes: 17792
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//数値の入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		int c = 0;
		//計算
		int a = N / K;
		int b = N % K;
		
		if(b == 0){
			c = b;
		}
		else{
			c = (a + 1) - a;
		}
		//出力
		System.out.println(c);
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

// k回2倍 -> bit演算を使うと便利
int main() {
    int a, b, c, n;
    cin >> a >> b >> c >> n;
    bool flag = false;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            for(int k = 0; k <= n; k++){
                int x = a * (1 << i);
                int y = b * (1 << j);
                int z = c * (1 << k);
                if(i + j + k <= n && x < y && y < z){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	int ans = 0;
	if (n % m == 0)ans = n / m;
	else ans = n / m + 1;
	cout << ans << endl;
	return 0;
}

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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll X, Y;
    cin >> X >> Y;

    if((Y - 2 * X >= 0)
    && ((Y - 2 * X) % 2 == 0)
    && (4 * X - Y >= 0)
    && ((4 * X - Y) % 2 == 0))
    {
        OUTX("Yes");
    }
    else
    {
        OUTX("No");
    }
    

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    long double a,b;
    cin>>a>>b;
    cout<<(ll)trunc(a*b);
}


Measured memory_bytes: 3732
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    S, P = get_data(n, [str, int])
    R = [(i+1, s, p) for i, (s, p) in enumerate(zip(S, P))]
    R.sort(key=lambda r: r[2], reverse=True)
    R.sort(key=lambda r: r[1])
    for i, s, p in R:
        print(i)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65516
/**
 * author: Dhakad_123
 * created : 05.05.2020
 **/

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

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

  string s;
  cin >> s;

  if(s == "ABC"){
	  cout << "ARC" <<"\n";
  }
  else{
    cout << "ABC" << "\n";
  }
  return 0;
}



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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  vector<int> v = {A,B,C};
  sort(v.begin(),v.end());
  int ma = v[2];
  int mid = v[1];
  int mi = v[0];

  int ans  = 0;
  ans += (ma-mid)/2;
  mid += (ma-mid)/2 * 2;
  //ma = mid　か ma = mid-1になる
  if(ma != mid){
    ans++;
    mid++;
    mi++;
  }
  //ma = midになる
  if((mid-mi)%2){
    ma++;
    mid++;
    ans++;
    //cout << ma << " " << mid << " " << mi << " " << ans << endl;
    ans += (mid-mi)/2;
    mi += (mid-mi)/2 * 2;
    
  }
  else{
    ans += (mid-mi)/2;
    mi += (mid-mi)/2 * 2;
  }
  cout << ans << endl;
 }


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

/**
 * Made by egor https://github.com/chermehdi/egor.
 * 
 * @author Azuz
 * 
 */
public class Main {

    void solve(Scanner in, PrintWriter out) {
      int a = in.nextInt();
      int b = in.nextInt();
      int c = in.nextInt();
      int d = in.nextInt();
        
      int turn = 0;
      while (a > 0 && c > 0) {
        if (turn % 2 == 0) {
          c -= b;
        } else {
          a -= d;
        }
        ++turn;
      }
      
      System.err.println(a + " " + c);
      out.println(a > 0 ? "Yes" : "No");

    }

    public static void main(String[] args) {
        try(Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }
}


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

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

    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;


int main(){
   ll n,m,x;cin >>n>>m>>x;
   vector<ll>c(n);
   vector<vector<ll>>a(n,vector<ll>(m));
    for (int i = 0; i < n; ++i) {
        cin >>c[i];
        for (int j = 0; j < m; ++j) {
            cin >>a[i][j];
        }
    }
    ll ans=INF;
    for (int i = 0; i < (1 << n); ++i) {
        vector<ll>skill(m,0);
        ll money=0;
        for (int j = 0; j < n; ++j) {
            if(i>>j&1){
               money+=c[j];
                for (int k = 0; k < m; ++k) {
                    skill[k]+=a[j][k];
                }
            }
        }
        bool flg=true;
        for (int q = 0; q < m; ++q) {
            if(skill[q]<x)flg=false;
        }
        if(flg){
            ans=min(ans,money);
        }
    }
    if(ans==INF)ans=-1;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
  int t;
  cin >> t;
  int n[10];
  int b[10]={0};
  int c[10]={0};
  int bcount=0,ccount=0,h=0;
  for(int i=0;i<t;i++){
    for(int j=0;j<10;j++) cin >> n[j];
    for(int j=0;j<10;j++){
      if(b[0]==0) b[bcount] = n[j];
      else if(b[bcount]>c[ccount]&&b[bcount]<n[j]){
    bcount++;
    b[bcount] = n[j];
      }
      else if(c[ccount]>b[bcount]&&c[ccount]<n[j]){
    if(c[ccount]!=0) ccount++;
    c[ccount] = n[j];
      }
      else if(b[bcount]>c[ccount]&&b[bcount]>n[j]&&c[ccount]<n[j]){
    if(c[ccount]!=0) ccount++;
    c[ccount] = n[j];
      }
      else if(c[ccount]>b[bcount]&&c[ccount]>n[j]&&b[bcount]<n[j]){
    bcount++;
    b[bcount] = n[j];
      }
      else if(b[bcount]>n[j]&&c[ccount]>n[j]){
    cout << "NO" << endl;
    h = 1;
    break;
      }
    }
    if(h==0) cout << "YES" << endl;
    for(int i=0;i<10;i++){
      b[i] = 0;
      c[i] = 0;
    }
      bcount = 0;
      ccount = 0;
      h = 0;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
     if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
ll ans;
int fa[N<<1],bj[N<<1];
inline int gf(int x){
	return fa[x]==x?x:fa[x]=gf(fa[x]);
}
pair<int,PI> a[N];
int main(){
	int n=read(),h=read(),w=read();
	For(i,1,n){
		a[i].se.fi=read(); a[i].se.se=read()+h;
		a[i].fi=read();
	}
	For(i,1,200000)fa[i]=i;
	sort(&a[1],&a[n+1]);
	Rep(i,n,1){
		int x=a[i].se.fi,y=a[i].se.se;
		x=gf(x); y=gf(y);
		if(x!=y&&(!bj[x]||!bj[y])){
			ans+=a[i].fi; fa[x]=y; bj[y]|=bj[x];
		}else if(!bj[x]){
			ans+=a[i].fi; bj[x]=1;
		}
	}
	cout<<ans<<endl;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  
  int h[n];
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  
  sort(h, h+n);
  
  int sigma = h[k-1] - h[0];
  for(int i = 0; i < n-k+1; i++){
    //cout << h[i] << endl;
    if(sigma > h[i+k-1]-h[i]){
      sigma = h[i+k-1]-h[i];
    }
  }  
  cout << sigma << endl;
}

Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)

int main()
{
    int A, P;
    cin >> A >> P;
    cout << (3 * A + P) / 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050
ll dp[50][1<<20];
vector<ll> change(int x){
    vector <ll> v;
    int count=0;
    while(x){
        count++;
        if(x%2){v.pb(count);count=0;}
        x/=2;
    }
    return v;
}
int change2(vector<ll> v){
    ll now=1;
    ll ans=0;
    for(auto e:v){
        rep(i,e)now*=2;
        ans+=now/2;
    }
    return ans;
}
bool judge[N];
ll pw[50];
main(){
    int n=in();
    int x[3];
    rep(i,3)x[i]=in();
    int sum=x[0]+x[1]+x[2];
    ll ans=0;
    pw[0]=1;
    rep(i,20)pw[i+1]=pw[i]*2;
    dp[0][0]=1;
    vec all;
    rep(i,1<<sum){
        if((i&(1<<(x[2]-1))&&(i&(1<<(x[2]+x[1]-1))&&(i&1<<(sum-1)))))judge[i]=1;
        else all.pb(i);
    }
    rep(i,n){
        for(auto k:all){
            if(dp[i][k]==0)continue;
            rep2(j,1,7){
                ll next=(k*pw[j]+pw[j-1])%pw[sum];
                if(!judge[next])
                dp[i+1][next]=(dp[i][k]+dp[i+1][next])%MOD;
            }
            dp[i+1][0]=(dp[i+1][0]+dp[i][k]*3)%MOD;
        }
    }
    ll p=1;
    rep(i,n){
        p=p*10ll%MOD;
    }
    rep(i,1<<sum){
        p=(p-dp[n][i]+MOD)%MOD;
    }
    cout<<p<<endl;
}

Measured memory_bytes: 150392
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  int x;
  x=(a[2]*10+a[1])+a[0];
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
def solve():
  ans = 0
  N = int(input())
  A = [list(map(int, input().split())) for _ in range(N)]
  d = deepcopy(A)
  D = deepcopy(A)
  #三重ループ
  for k in range(N):
    for i in range(N):
      if i==k:
        continue
      for j in range(N):
        if j==k:
          continue
        if d[i][k]+d[k][j]<=d[i][j]:
          d[i][j] = d[i][k]+d[k][j]
          D[i][j] = float('inf')
  for i in range(N): #ひとまず枝があるペアは枝の長さをセット
    for j in range(N):
      if D[i][j]<float('inf') and i>j:
        ans += A[i][j]
  #三重ループ
  for k in range(N):
    for i in range(N):
      for j in range(N):
        D[i][j] = min(D[i][j], D[i][k]+D[k][j])
  for i in range(N):
    for j in range(N):
      if D[i][j] != A[i][j]:
        return -1
  return ans
print(solve())

Measured memory_bytes: 73812
#include <iostream>  
#include <string.h> 
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1&&a!=b)
        cout << "Alice";
    else if (b == 1 && a != b)
        cout << "Bob";
    else if (a > b)
        cout << "Alice";
    else if (a < b)
        cout << "Bob";
    else
        cout << "Draw";
    return 0;
}
 


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

int main(void){
    int a=0;
    int b=0;
    int c=0;
    int num=0;

    cin >> a >> b >> c;

    num=b/a;
    if(num>=c)cout << c << endl;
    else cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
		   tree_order_statistics_node_update> oset;
*/

#define IO            ios::sync_with_stdio(false);cin.tie(0);
 
#define int           long long
#define pi            pair<int,int>
#define pii           pair<int,pi>
#define vi            vector<int>
#define vs            vector<string>
#define vb            vector<bool>
#define vii           vector<vector<int>>
#define vpi           vector<pi>
#define pb            push_back
#define mp            make_pair
#define eb            emplace_back
#define ff            first
#define ss            second
#define fo(i,val,n)   for(int i=val;i<n;i++)
#define rfo(i,val,j)  for(int i=val;i>=j;i--)
#define all(x)        x.begin(),x.end()
#define inf           0x3f3f3f3f3f3f3f3fLL
#define endl          '\n'
#define PI            acos(-1)

mt19937 rnd(time(0));

const int N=2e5+7;
//const int MOD=1e9+7;
const int MOD=998244353; 

int fastpow(int b,int p){
    //b %= MOD;
    //p %= (MOD - 1);
    int temp;
    if(p==0) return 1;
    if(p==1) return b;
    temp = fastpow(b , p/2);
    temp = temp * temp % MOD;
    if(p & 1){
        temp = temp * b % MOD;
    }
    return temp;
}

int32_t main(){
 	
	IO  

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

	int mn = min(b - 1, n);

	cout << ((a * mn) / b) - (a * (mn / b));

	return 0; 
}	
	
	


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x,n,ld=1e9+10,ans;
	cin>>x>>n;
	set<int> st;
	for(int i=0,a;i<n;++i){
		cin>>a;
		st.insert(a);
	}
	for(int i=x;i<=4*x;++i){
		if(!st.count(i) && abs(x-i) < ld){
			ld = abs(x-i);
			ans=i;
		}
	}
	for(int i=x;i>=(-4*x);--i){
		if(!st.count(i) && abs(x-i) <= ld){
			ld = abs(x-i);
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3676
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hList = readLine()!!.split(" ").map(String::toInt).toMutableList()
    for (i in n-2 downTo 0) {
        if(hList[i] > hList[i+1] + 1) {
            println("No")
            return
        } else if (hList[i] == hList[i+1] + 1) hList[i] -= 1
    }
    println("Yes")
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  double s=0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    s+=a[i];
  }
  int count=0;
  for(int i=0; i<n; i++){
    if(s/(4*m)<=a[i])
      count++;
  }
  if(count>=m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

char str[1100][34];
int  len[1100];
int n ;


string ans1 ="";

map<string,int> mp ;
void init_map(){
     mp.clear();
    for(int i=1;i<=n;i++){
        mp[str[i]] = 0 ;
    }
    for(int i=1;i<=n;i++){
       mp[str[i]]++;
    }
    int l =0;
    for( map<string,int>::iterator it = mp.begin();it!= mp.end();it++){
        if((it->second)>l){
	   ans1 = it->first;
	   l = it->second;
	}
    }            
}
int main(){
  int idx =1;
  while(~scanf("%s",str[idx])){
      len[idx] = strlen(str[idx]);
      idx ++;	
      
  }
   n = idx-1;
   init_map();
   cout << ans1<<" ";
    int l = 0;
    int maxidx  =0 ;
   for(int i=1;i<=n;i++){
      if(len[i]>l){
         maxidx = i;
	 l = len[i];
      }
   }
   cout << str[maxidx]<<endl;
 return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int m;
    cin >> m;
    vector<int> w(m);
    for(int i = 0; i < m; i++) cin >> w[i];
    vector<int> result;
    set_intersection(v.begin(), v.end(), w.begin(), w.end(), back_inserter(result));
    for(int i = 0; i < result.size(); i++) cout << result[i] << endl;
    return 0;
}




Measured memory_bytes: 4720
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().doIt();
	}

	protected void doIt() {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		Queue<Integer> queue = new PriorityQueue<>(Collections.reverseOrder());
		for (int i = 0; i < N; i++) {
			queue.add(scan.nextInt());
		}
		for (int i = 0; i < M; i++) {
			queue.add(queue.poll() / 2);
		}
		long ans = 0;
		while(!queue.isEmpty()) {
			ans += queue.poll();
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 59520
n = int(input())
if n == 1 :
    print(1)
else :
    l = [0] * (n + 1)
    l[0] = 2
    l[1] = 1
    for i in range(2, n+1) :
        l[i] = l[i-1] + l[i-2]
    print(l[n])

Measured memory_bytes: 3060
import itertools
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
l.sort()
ll=[i for i in range(1,n+1)]
x=[]
for i in range(1,n+1):
    z=list(itertools.combinations(l,i))
    zz=list(itertools.combinations(ll,i))
    for j in range(len(z)):
        x.append([sum(z[j]),(i-1)*10,list(zz[j])])
x.sort()
A=[];B=[];C=[]
for i in range(len(x)):
    A.append([x[i][1]+abs(a-x[i][0]),x[i][2]])
    B.append([x[i][1]+abs(b-x[i][0]),x[i][2]])
    C.append([x[i][1]+abs(c-x[i][0]),x[i][2]])
A.sort();B.sort();C.sort()
m=len(A)
ans=10**10
for i in range(m):
    for j in range(m):
        for k in range(m):
            if len(A[i][1]+B[j][1]+C[k][1])>=n+1:
                break
            elif len(A[i][1]+B[j][1]+C[k][1])==len((set(A[i][1]+B[j][1]+C[k][1]))):
                ans=min(ans,A[i][0]+B[j][0]+C[k][0])
print(ans)

Measured memory_bytes: 43356
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
ll cnt;
ll sum, x;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	cin >> x;
	sum = 100;
	while(sum < x){
		cnt++;
		sum += sum / 100;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

struct Point
{
	int x,y;
	vector<int> sameX,sameY;
	bool tag=false;
};

void dfs(set<int> &X,set<int> &Y,vector<Point> &pts,int now,int &cnt)
{
	cnt++;
	Point &p=pts[now];
	p.tag=true;
	X.insert(p.x);
	Y.insert(p.y);
	/*
	cout<<"\n"<<p.x<<" "<<p.y<<"\n";
	cout<<"x  "; for(auto i:p.sameX) cout<<i<<" "; cout<<"\n";
	cout<<"y  "; for(auto i:p.sameY) cout<<i<<" "; cout<<"\n";
	cout<<cnt<<"\n\n";
	*/
	for(auto &i:p.sameX)
	{
		if(pts[i].tag) continue;
		dfs(X,Y,pts,i,cnt);
	}
	for(auto &i:p.sameY)
	{
		if(pts[i].tag) continue;
		dfs(X,Y,pts,i,cnt);
	}
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	vector<Point> pts(n);
	map<int,int> mpX,mpY;
	For(i,0,n-1)
	{
		Point &p=pts[i];
		cin>>p.x>>p.y;
		if(mpX.count(p.x))
		{
			p.sameX.emplace_back(mpX[p.x]);
			pts[mpX[p.x]].sameX.emplace_back(i);
		}
		else mpX[p.x]=i;
		if(mpY.count(p.y))
		{
			p.sameY.emplace_back(mpY[p.y]);
			pts[mpY[p.y]].sameY.emplace_back(i);
		}
		else mpY[p.y]=i;
	}
	set<int> X,Y;
	int ans=0,cnt;
	For(id,0,n-1)
	{
		Point &i=pts[id];
		if(i.tag) continue;
		X.clear(); Y.clear(); cnt=0;
		dfs(X,Y,pts,id,cnt);
		ans+=sz(X)*sz(Y)-cnt;
		//cout<<sz(X)<<" "<<sz(Y)<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}















Measured memory_bytes: 32256
#include<stdio.h>
#include<stdlib.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

	unsigned short *A, *B;

	int n, i;
	scanf("%d", &n);

	A = (unsigned short*)malloc(sizeof(short) * n + 1);
	B = (unsigned short*)malloc(sizeof(short) * n + 1);

	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
	}

	int max = (1<<30)*-1;
	for (i = 1; i <= n; i++) max = MAX(max, A[i]);
	int C[max+1] = {0};

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	free(A);
	free(B);
	return 0;
}


Measured memory_bytes: 10224