akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, s, a[MAXN];
int x, y, cur[MAXN], res[MAXN], ans[MAXN];
bool cnp(int s, int t) {
	if ((a[s] == x) == (a[t] == x)) return s < t;
	else return (a[s] == x) < (a[t] == x);
}
void work(int len) {
	bool valid = true, found = false;
	for (int i = 1; i <= len; i++)
		a[cur[i]]--;
	int Min = a[1], Max = a[1];
	for (int i = 2; i <= n; i++) {
		chkmin(Min, a[i]);
		chkmax(Max, a[i]);
	}
	if (Min * 2 >= Max) {
		found = true;
		for (int i = 1; i <= len; i++)
			res[i] = cur[i];
		sort(res + 1, res + len + 1);
	} else if (Min * 2 + 1 == Max) {
		x = Min, y = Max;
		int k1 = 0, k2 = 0, k = 0;
		static int res1[MAXN], res2[MAXN];
		for (int i = 1; i <= len; i++)
			if (a[cur[i]] == Min || a[cur[i]] == Max) res1[++k1] = cur[i];
			else res2[++k2] = cur[i];
		sort(res1 + 1, res1 + k1 + 1, cnp);
		sort(res2 + 1, res2 + k2 + 1);
		int x1 = 1, x2 = 1;
		for (int i = 1; i <= len; i++)
			if (x1 <= k1 && x2 <= k2) {
				if (res1[x1] < res2[x2]) res[i] = res1[x1++];
				else res[i] = res2[x2++];
			} else {
				if (x1 <= k1) res[i] = res1[x1++];
				else res[i] = res2[x2++];
			}
		found = true;
		for (int i = len + 1; i <= n; i++)
			if (a[cur[i]] == Min) found = false;
		found |= (x1 == 0) || (a[res1[1]] == Max);
	}
	for (int i = 1; i <= len; i++)
		a[cur[i]]++;
	if (!valid || !found) res[1] = 0;
}
bool cmp(int *a, int *b) {
	int pos = 1;
	while (a[pos] == b[pos]) pos++;
	return a[pos] < b[pos];
}
bool check() {
	int Min = a[1], Max = a[1];
	for (int i = 2; i <= n; i++) {
		chkmin(Min, a[i]);
		chkmax(Max, a[i]);
	}
	return Min * 2 >= Max;
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++) {
		read(a[i]);
		s += a[i];
	}
	if (!check()) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i <= n; i++)
		cur[i] = i;
	work(n);
	for (int i = 1; i <= n; i++) {
		m++, a[res[i]]--;
		cur[i] = res[i];
		ans[m] = res[i];
	}
	while (m != s) {
		static int inc[MAXN];
		memset(inc, 0, sizeof(inc));
		int len = 0; inc[1] = n + 1;
		for (int i = 1; i <= n; i++) {
			work(i);
			if (res[1] != 0 && cmp(res, inc)) {
				len = i;
				for (int j = 1; j <= i; j++)
					inc[j] = res[j];
			}
		}
		for (int i = 1; i + len <= n; i++)
			cur[i] = cur[i + len];
		for (int i = 1; i <= len; i++) {
			ans[++m] = inc[i];
			cur[n - len + i] = inc[i], a[inc[i]]--;
		}
	}
	for (int i = 1; i <= m; i++)
		printf("%d ", ans[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3784
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct Node{

  int key;
  struct Node *next,*prev;
}Node;

Node *nil;

Node* listSearch(int key){
   Node *x = nil->next;
  while(x->key != key){
    if(x==nil) break;
    x = x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}

void printList(){
  struct Node *cur = nil->next;
  int isf=1;
  while(1){
    if(cur==nil) break;
    if(isf==0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
    isf=0;
  }
  printf("\n");
}

void deleteNode(struct Node *t){
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  struct Node *t=nil->next;
  if(t==nil) return;
  deleteNode(t);
}

void deleteLast(){
 struct Node *x=nil->prev;
  if(x==nil)return;
  deleteNode(x);
}

void delete(int key){
  struct Node *x;
  x=listSearch(key);
  if(x==nil)return;
  deleteNode(x);
}


void insert(int key){
  struct Node *x;
  x=malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  x->prev=nil;
  nil->next=x;
  x->next->prev=x;
  x->next->prev=x;
}

main(){
  int key,i,n;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
	if(com[6]=='F') deleteFirst();
	else if(com[6]=='L') deleteLast();
      }
      else{
	delete(key); nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}

Measured memory_bytes: 31788
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_diffA = 0
sum_diffB = 0
for i, (ai, bi) in enumerate(zip(A,B)):
    if ai == bi:
        continue
    elif ai > bi:
        sum_diffB += (ai - bi)
    elif ai < bi:
        diffA = (bi - ai)
        sum_diffA += diffA // 2 + diffA % 2
        sum_diffB += diffA % 2
if sum_diffA >= sum_diffB:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 73932
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans;
  if (s == "A") {
    ans = "T";
  }
  else if (s == "T") {
    ans = "A";
  }
  else if (s == "C") {
    ans = "G";
  }
  else {
    ans = "C";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
using namespace::std;


long long n, bc, now, C, H, W, X, Y, ans, r, l, numcon, N, M;
string S,s,a[101],b[101],c[101];
bool h,k[101];
int main() {
	cin >> H>>W;
	Y = 0;
	X = 0;
	for (int i = 0; i <H;i++) {
		cin >> a[i];
	}

	for (int i = 0; i < H; i++) {
		h = false;
		for (int j = 0; j < W; j++) {
			if (a[i][j] == '#') {
				h = true;
			}
		}
		if (h == true) {
			b[Y] += a[i];
			Y++;
		}
	}

	for (int i = 0; i < W; i++) {
		k[i] = true;
	}

	for (int j = 0; j < W; j++) {
		for (int i = 0; i < Y; i++) {
			if (b[i][j] == '#'&&k[j]==true) {
				k[j] = false;
			}
			
			}
		}

	for (int i = 0; i < Y; i++) {
		for (int j = 0; j < W; j++) {
			if (k[j] == false) {
				cout << b[i][j];
			  }
			}
		cout<< endl;
		}

	return 0;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,m,mn,i;
    while(scanf("%lld %lld",&a,&b)!=EOF)
    {
        m=max(a,b);
      if(m==a)
      {
          mn=b;

      }
      else
        mn=a;
       //  printf("max= %lld min=%lld\n",m,mn);
        for(i=1;i<=mn;i++)
      {
          if((m*i)%mn==0)
          {
              printf("%lld\n",m*i);
              break;
          }
      }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int h,w,d; cin >> h >> w >> d;
  vector<vi> a(h,vi(w)); rep(i,h) rep(j,w) cin >> a[i][j];
  vector<pair<int,int>> num(h*w+1);
  rep(i,h) rep(j,w) num[a[i][j]] = {i,j};
  vi sum(h*w+1);
  rep(i,h*w+1){
    if(i+d <= h*w) sum[i] = abs(num[i+d].first-num[i].first)+abs(num[i+d].second-num[i].second);
  }
  for(int i = h*w; 0 <= i; i--){
    if(0 < i-d) sum[i-d] += sum[i];
  }
  int q; cin >> q;
  rep(i,q){
    int l,r; cin >> l >> r;
    cout << sum[l]-sum[r];
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 4760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN=2e5+5;
const int MOD=1000000000;
const LL INF=(2e5)*(1e9)+5;
LL a[MAXN];
LL sum[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        LL tot=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            sum[i]=sum[i-1]+a[i];
            tot+=a[i];
        }
        LL Min=INF;
        for(int i=1;i<n;i++)
        {
            if(Min>abs(2*sum[i]-tot))
                Min=abs(2*sum[i]-tot);
        }
        cout<<Min<<endl;
    }

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    ll x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    vector<ll> sc;
    vector<ll> sab;

    rep(i,x){ cin>>a[i]; }
    rep(i,y){ cin>>b[i]; }
    rep(i,z){cin>>c[i]; }

    sort(c.rbegin(),c.rend());

    vector<ll> ab;
    for(int long long i=0;i<y;i++){
        for(int long long j=0;j<x;j++){
            ab.push_back(a[j]+b[i]);
        }
    }

    sort(ab.rbegin(),ab.rend());
    ll absize=ab.size();
    ll u=min(k,absize);
    rep(i,u){
        sab.push_back(ab[i]);
    }
    sort(sab.rbegin(),sab.rend());

    vector<ll> ans;

    for(int long long i=0;i<c.size();i++) {
        for (int long long j = 0; j < sab.size(); j++) {
            ans.push_back(sab[j] + c[i]);
        }
    }

    sort(ans.rbegin(),ans.rend());

    rep(i,k){
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 43400
n,k = gets.split.map(&:to_i)

MAX_PAIR = (n - 1) * (n - 2) / 2 # スターグラフの場合
MAX_EDGE = n * (n - 1) / 2 # 完全グラフの辺の数
if MAX_PAIR < k
  puts -1
  exit
end

def each_edge(n)
  1.upto(n-1) do |i|
    (i+1).upto(n) do |j|
      yield i,j
    end
  end
end

cnt = MAX_EDGE - k
puts cnt
each_edge(n) do |i,j|
  puts [i,j].join(" ")
  cnt -= 1
  exit if cnt == 0
end



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

int main() {
	string S;
	cin >> S;
	sort(S.begin(), S.end());
	if ("abc" == S) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

const int N=1e5+10;

struct Edge{int to,next; }way[N<<1];
int n,k,a[N],ans,dis[N],num[N],tot;

void Build(int u,int v) { way[++tot]=(Edge){v,num[u]}; num[u]=tot; }

void Init()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
}

void Dfs(int x)
{
	dis[x]=1;
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to;
		Dfs(v);
		dis[x]=max(dis[v]+1,dis[x]);
	}
	if (dis[x]>=k && a[x]!=1) dis[x]=0,++ans;
}

void Solve()
{
	if (a[1]!=1) ans++,a[1]=1;
	
	for (int i=2;i<=n;++i) Build(a[i],i);
	
	dis[1]=0; Dfs(1);
	
	printf("%d\n",ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = d[n/2] - d[n/2-1];
    cout << ans << endl; 
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	auto S = fetch<string>();
	if(S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

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

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;
//cout << N.x << endl;


vector<vector<int>> G(200005);

mint dfs(int v){
    mint res = 1;
    for(int nv: G[v]){
        res *= dfs(nv);
    }
    return res + 1;
}

int main(){
    int N;
    cin >> N;
    vector<P> p(N);
    for(int i=0; i<N; i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(),p.end());
    set<P> se;
    for(int i=N-1; i>=0; i--){
        while(se.size() and se.begin()->first < p[i].first + p[i].second){
            G[i].emplace_back(se.begin()->second);
            se.erase(se.begin());
        }
        se.emplace(p[i].first,i);
    }

    mint ans = 1;
    for(auto s: se){
        ans *= dfs(s.second);
    }
    cout << ans.x << enld;
    return 0;
}

Measured memory_bytes: 21120
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;


int main() {
	double N, T, A;
	cin >> N >> T >> A;
	vector<double>H(N);
	int ans;
	double cand = pow(10, 9);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		if (cand > abs(A - (T - H[i] * 0.006))) {
			cand = abs(A - (T - H[i] * 0.006));
			ans = i + 1;
		}
	}
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"
#define ALL(x) (x).begin(),(x).end()
#define EXIST(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    int sum = 0;
    cin >> m;
    n = m;
    while (m > 0) {
        sum += m % 10;
        m /= 10;
    }
    DEBUG(sum);
    if (n % sum == 0) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
dir = [[1, 0], [0, 1], [-1, 0], [0, -1]]
def main():
  H, W = map(int, input().split())
  d = [[-1] *W for _ in range(H)]
  S = []
  for i in range(H):
    S.append(list(str(input())))
  ans =  -1
  que = [[0, 0]]
  d[0][0] = 1
  while len(que)>0:
    now = que.pop(0)
    for move in dir:
      nex = [now[0] + move[0], now[1] + move[1]]
      if 0 <= nex[0] < H and 0 <= nex[1] < W and S[nex[0]][nex[1]] == '.' and d[nex[0]][nex[1]] == -1:
        d[nex[0]][nex[1]] = d[now[0]][now[1]] + 1
        if nex[0] == H-1 and nex[1] == W-1:
          ans = d[H-1][W-1]
          break
        else:
          que.append(nex)
  if ans == -1:
    print(ans)
  else:
    num = 0
    for i in range(H):
      for j in range(W):
        if S[i][j] == '.':
          num += 1
    print(num - ans)
if __name__ == "__main__":
  main()
        

Measured memory_bytes: 3188
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
k = sum(a)
k = k/n
ans = n-1
kyo = 100000000000000000
for i in range(n-1,-1,-1):
  if kyo >= abs(a[i]-k):
    kyo = abs(a[i]-k)
    ans = i
print(ans)

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

int main()
{
    int n,k;
    int sum = 0;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());

    reverse(a.begin(),a.end());

    for(int i = 0; i < k; i++){
        sum += a.at(i);
    }
    cout << sum;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    static boolean[] f = new boolean[100001];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        List<Integer> l = new ArrayList<>();
        List<Integer> r = new ArrayList<>();
        for (int i = 0; i < q; i++) {
            int left = sc.nextInt();
            int right = sc.nextInt();
            l.add(left);
            r.add(right);
        }
        isPrime();

        int[] cnt = new int[100002];
        for (int i = 3; i <= 100000; i++) {
            if (!f[i] && !f[(i + 1) / 2]) {
                cnt[i] = cnt[i - 1] + 1;
            } else {
                cnt[i] = cnt[i - 1];
            }
        }

        for (int i = 0; i < q; i++) {
            int ans = cnt[r.get(i)] - cnt[l.get(i) - 1];
            System.out.println(ans);
        }
    }
    public static void isPrime() {
        for (int i = 2; i <= 100000; i++) {
            if (!f[i]) {
                for (int j = i + i; j <= 100000; j += i) {
                    f[j] = true;
                }
            }
        }
    }
}


Measured memory_bytes: 96360
#include <stdio.h>

int main(void)
{
    int n;

    scanf("%d", &n);
    while (n--){
        int y, m, d;
        int cnt = 0;

        scanf("%d %d %d", &y, &m, &d);
        while (d != 1){
            d++;
            cnt++;
            if (d > 20 || (d > 19 && y % 3 && m % 2 == 0)){
                d = 1;
                m++;
                if (m > 10){
                    m = 1;
                    y++;
                }
            }
        }
        while (m != 1){
            if (y % 3 && m % 2 == 0) cnt += 19;
            else cnt += 20;
            m++;
            if (m > 10){
                m = 1;
                y++;
            }
        }
        while (y != 1000){
            cnt += y % 3 ? 195 : 200;
            y++;
        }
        printf("%d\n", cnt);
    }

    return 0;
}

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

int main()
{
  int k;
  cin >> k;
  string s;
  cin >> s;
  string t ="";
  //cout << s.size() << endl;
  if(s.size() > k){
    rep(i,k){
      t += s[i];
    }
      t += "...";
  }else{
    t = s;
  }
  cout << t << endl;
      
  return 0;
}


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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n = 0, m = 0;
    cin >> n >> m;
    vector<int> v(n + 1, -1);
    int a = 0, b = 0;
    int found = 0;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        if(v[a] == -1) v[a] = b;
        else {
            if(v[a] != b) found = 1;
        }
    }

    if(v[1] == 0 && n != 1) found = 1;
    if(v[1] == -1) {
        if(n > 1)v[1] = 1;
        else v[1] = 0;
    }
    

    for(int j = 0; j < v.size(); j++) {
        if(v[j] == -1) {
            v[j] = 0;
        }
    }

    ll ans = 0;
    int count = 0;
    for(int j = v.size() - 1; j >= 1; j--) {
        ans += v[j] * pow(10, count); 
        count++;
    }

    if(found) cout << "-1" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,l;
        n = sc.nextInt();
        l = sc.nextInt();
        int sum = 0;
        int min = Integer.MAX_VALUE;
        int ans = 0;

        for(int i=1;i<=n;i++){
            sum += l+i-1;
        }
        for(int i=1;i<=n;i++){
            int tmp = 0;
            for(int j=1;j<=n;j++){
                if(i!=j) {
                    tmp += l + j - 1;
                }
            }
            if(Math.abs(min)>Math.abs(sum-tmp)){
                min = sum - tmp;
                ans = tmp;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 1000010
 
ll dp[M],n,h;
ll a[M],b[M];
ll f(ll h){
	if(h<=0)return 0;
	if(dp[h]!=-1)return dp[h];
	ll ans=inf;
	rep(i,0,n)ans=min(ans,b[i]+f(h-a[i]));
	return dp[h]=ans;
}
int main(){
	IOS;
	tihs;
	memset(dp,-1,sizeof(dp));
	cin>>h>>n;
	rep(i,0,n) cin>>a[i]>>b[i];
	cout<<f(h);
	
	return 0;
}

Measured memory_bytes: 11904
import java.util.*;
import java.util.Scanner;

public class Main {
    static int j = 0;
    static String con_str[];
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        int Y[] = new int[N];
        for(int i = 0;i < N;i++){
            X[i] = sc.nextInt();
            Y[i] = sc.nextInt();
        }
        String S = "01234567".substring(0,N);
        int con = 1;
        for(int i = 0;i < N;i++){
            con = con * (i + 1);
        }
        con_str = new String[con];
        permutation(S, "");
        
        double sum = 0;
        for(int i = 0;i < con;i++){
            for(int c = 0;c < N-1;c++){
                int x = X[Integer.parseInt(con_str[i].substring(c,c+1))] - X[Integer.parseInt(con_str[i].substring(c+1,c+2))];
                int y = Y[Integer.parseInt(con_str[i].substring(c,c+1))] - Y[Integer.parseInt(con_str[i].substring(c+1,c+2))];
                sum += Math.sqrt(x*x + y*y);
            }
        }
        
        System.out.println(sum / con);
    }
    
    public static void permutation(String q, String ans){
        if(q.length() <= 1) {
            con_str[j] = ans + q;
            j++;
        }
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
            }
        }
    }
}


Measured memory_bytes: 73552
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ApplePie | diff ApplePie.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ApplePie.cpp && ./a.out

/*
 
 5/26/2019
 
 5:00-
 
 */

int A,P;

void solve() {
  cout<<(3*A+P)/2<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>P;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char s[3];
		scanf("%s",s);
		
	if(s[0]==s[1] && s[1]==s[2] && s[0]==s[2])
	{
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{

    string a,b,c;
    cin >>a>>b;
    int t,m,n;
    cin>>m>>n;
    cin >>c;
    if(a.compare(c)==0){
        cout << m-1 << " " << n << endl;
    }else{
    cout << m << " " << n-1 << endl;
    }
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ans = 0
if 1 <= n && n <= 9
  ans = n
elsif 10 <= n && n <= 99
  ans = 9
elsif 100 <= n && n <= 999
  ans = 9 + (n - 99)
elsif 1000 <= n && n <= 9999
  ans = 909
elsif 10000 <= n && n <= 99999
  ans = 909 + (n - 9999)
else
  ans = 90909
end
puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

const ll mod = 1000000007;
ll a = 1e18;

int main() {
	ll n;
	cin >> n;
	if (n % 2 != 0) {
		cout << 0;
		return 0;
	}
	ll b = 5;
	ll ans(0);
	while (1) {
		ll cnt = n / b;
		cnt /= 2;
		ans += cnt;
		ll t = b;
		b *= 5;
		if (b > n)break;
		if (b / 5 != t)break;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3616
N = int(input())
H = list(map(int,input().split()))
ans = 1
for i in range(1,N):
    flg = True
    for j in range(i):
        if(H[i] >= H[j]):
            continue
        else:
            flg = False
            break
    if flg:
        ans += 1

print(ans)

Measured memory_bytes: 3060
import itertools
n, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = []
c = []
d= []
e= []
ans=0

for i in range(n):
    if a[i][0] == a[0][0]:
        b.append(a[i][1])
    elif a[i][0] == a[0][0]+1:
        c.append(a[i][1])
    elif a[i][0] == a[0][0]+2:
        d.append(a[i][1])
    else:
        e.append(a[i][1])

b.sort()
b.reverse()
c.sort()
c.reverse()
d.sort()
d.reverse()
e.sort()
e.reverse()

b = list(itertools.accumulate(b))
c = list(itertools.accumulate(c))
d = list(itertools.accumulate(d))
e = list(itertools.accumulate(e))
b.append(0)
c.append(0)
d.append(0)
e.append(0)


for i in range(len(b)):
    for j in range(len(c)):
        for k in range(len(d)):
            if a[0][0]*i+(a[0][0] +1)*j+(a[0][0] +2)*k>w:
                break
            else:
                x=(w-(a[0][0]*i+(a[0][0] +1)*j+(a[0][0] +2)*k))//(a[0][0]+3)
                ans=max(ans,b[i-1]+c[j-1]+d[k-1]+e[min(x-1,len(e)-1)])
print(ans)

Measured memory_bytes: 40304
n=int(input())
s={3,5,7,11,13}
l=[]
for i in range((n+1)//2):
    x=2*i+1
    count=0
    for j in s:
        if x%j==0:
            count+=1
    if count==3:
        l.append(x)
    elif x==27*5 or x==27*7:
        l.append(x)
print(len(l))

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr long long MOD = 998244353;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}


void solve() {
	ll x;
	cin >> x;
	ll ans = 0;
	ans += x / 500 * 1000;
	x -= x / 500 * 500;
	ans += x / 5 * 5;
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	char n[4];
	int a,b,c,d,i,j,k,l;
	
while(~scanf("%s",n))
{	b=0;
	for(j=0;j<3;j++)
	{
	if(n[j]==n[j+1])
	{
	printf("Bad\n");
	break;
		}	
		else
		{
			b+=1;
		}
	}
	if(b==3)
	printf("Good\n");
}
	
	
}

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


int main(){
    ll n , k , r , s , p,i,ans=0;
    string t,tp ;
    cin >> n >> k >> r >> s >> p >> t ;

    ll st= t.size() ;
    for(i=0;i<st;i++){
        if (t[i]=='s') tp.pb('r') ;
        else if (t[i]=='r') tp.pb('p') ;
        else tp.pb('s') ;
    }

    for(i=0;i<k;i++){
        if (tp[i]=='s') ans+=s ;
        else if (tp[i]=='r') ans+=r ;
        else ans+=p ;
    }

    for(i=k;i<n;i++){
        if (tp[i]==tp[i-k]) tp[i]='z' ;
        else {
            if (tp[i]=='s') ans+=s ;
            else if (tp[i]=='r') ans+=r ;
            else ans+=p ;
        }
    }

    cout << ans << endl ;

}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
//言語は「C++14(GCC 5.4.1)」
//AtCoder Beginner Contest 64-A

int main(void)
{
	int r, g, b, S;
	scanf("%d", &r);
	scanf("%d", &g);
	scanf("%d", &b);
	S = 100 * r + 10 * g + b;
	if (S % 4 == 0)
		printf("YES");
	else
		printf("NO");
	return 0;
}

Measured memory_bytes: 128
import sys

def main():
    input = sys.stdin.readline
    A, B, C = map(int, input().split())

    A, B = min(A, B), max(A, B)
    if A <= C <= B:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    print(main())


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'

string s;

bool check(char c){
    return c == 'A' || c == 'T' || c == 'G' || c == 'C';
}

signed main()
{
    cin >> s;
    int res = 0;

    REP(i, s.size()){
        if (!check(s[i])) continue;
        res = max(res, 1LL);
        FOR(j, i+1, s.size()){
            if (!check(s[j])) break;
            res = max(res, j - i + 1);
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 * 
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;
string cnt;
int convert(int N, int b)
{
     if (N == 0)
        return 0;
     int x = N % b;
     N /= b;
     if (x < 0)
        {
        	N+=1;
        } 
     convert(N, b);
      cnt+=( x < 0 ? x + (b * -1) : x);
     
           return  SZ(cnt);
}
int main()
{
    _SAD()
	int n,b;
	cin>>n>>b;
	stringstream ss;
	cout<<convert(n,b);
	//cout<<gu<<nl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var xy = Sarray();
            var x1 = xy[0];
            var y1 = xy[1];
            var x2 = xy[2];
            var y2 = xy[3];
            var inix = x2 - x1;
            var iniy = y2 - y1;
            
            var x3 = x2 - iniy;
            var y3 = y2 + inix;
            var x4 = x3 - inix;
            var y4 = y3 - iniy;


            WriteLine($"{x3} {y3} {x4} {y4}");
            //Out.Flush();
        }
    }
}

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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

int a[110];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

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

    sort(a, a + N);
    int al = 0, bl = 0;
    int t = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        (t % 2 == 0 ? al : bl) += a[i];
        t++;
    }
    cout << (al - bl) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18L+5
int main() 
{
    ll n,W;
    cin>>n>>W;
    ll weight[n],value[n];
    ll totalval=0;
    for(ll i=0;i<n;i++)
    {
        cin>>weight[i]>>value[i];
        totalval += value[i];
    }
    vector<ll> dp(totalval+1,inf); //dp[i] = minimum weight for value i
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll val = totalval - value[i];val>=0;val--)
        {
            dp[val+value[i]]=min(dp[val+value[i]],dp[val]+weight[i]);
        }
    }
    ll i,ans=0;
    for(i=0;i<=totalval;i++)
    {
        if(dp[i]<=W)
        {
            ans=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
def start_from(a, x):
  while a % x != 0:
    a += x - a % x
  return a

def ends_with(b, x):
    while b % x != 0:
        b -= b % x
    return b

def main():
  a, b, x = map(int, raw_input().split())
  start = start_from(a, x) / x
  end = ends_with(b, x) / x
  print(end-start+1)


main()

Measured memory_bytes: 2568
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long x){
    i64 v = 100;
    int i;
    for(i = 0; v < x; ++i){
        v += v / 100;
    }
    cout << i << endl;
}


signed main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    double h;
    vector<double> mh;
    while(cin>>h)
    {
        mh.push_back(h);
    }
    sort(mh.begin(),mh.end(),greater<double>());
    cout<<*mh.begin()-*(mh.end()-1)<<endl;
}

Measured memory_bytes: 1304
N=int(input())
abclist=[]
for a in 'abcdefghijklmnopqrstuvwxyz':
    abclist.append(a)
k=0
n=N
alist=[]
while n>0:
    amari=n%26
    if amari==0:
        n=n//26-1
    else:
        n=n//26
    alist.append(amari)
#print(alist)
name=''

for a in alist:
    name=abclist[a-1]+name
print(name)


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,c,k;cin >> n >> c >> k;
	vector<int> t(n);
	rep(i,n) cin >> t.at(i);
	sort(t.begin(),t.end());
	int ans=0,T=t[0],i=1,cnt=1;
	while(i<n){
		if(T+k>=t[i] && cnt<c) cnt++;
		else{
			ans++;
			T=t[i];
			cnt=1;
		}
		i++;
	}
	ans++;
	cout << ans << endl;
}

Measured memory_bytes: 640
n = int(input())
l = []
for i in input().split():
  t = []
  for j in i: t += [j]
  l += [t]

t = l[:]
f = 0
for i in range(n):
  for j in range(n-1, 0, -1):
    if t[j][1] < t[j-1][1]:
      t[j], t[j-1] = t[j-1], t[j]
    elif t[j][1] == t[j-1][1]:
      f += 1 if l.index(t[j-1]) > l.index(t[j]) else 0
print(*["{0}{1}".format(i[0], i[1]) for i in t])
print("Not stable" if f > 0 else "Stable")

x = l[:]
f = 0
for i in range(n):
  m = i
  for j in range(i, n):
    if x[j][1] < x[m][1]:
      m = j
    elif x[j][1] == x[m][1]:
      f += 1 if l.index(x[m]) > l.index(x[j]) else 0
  x[i], x[m] = x[m], x[i]
print(*["{0}{1}".format(i[0], i[1]) for i in x])
print("Not stable" if f > 0 else "Stable")


Measured memory_bytes: 5620
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }

    d[0] = 0;

    while(1){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v]>M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1) sum += M[i][p[i]];
    }

    return sum;

}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e;
            cin >> e;
            M[i][j] = (e==-1) ? INFTY : e;
        }
    }

    cout << prim() << endl;

    return 0;

}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
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; }

// 拡張ユークリッドの互除法
// ax + by = gcd(a, b) となる gcd(a, b) を返す。
// x, yの値はint型の変数を入れるとその関数に格納されている値が変更される。
ll exgcd(int a, int b, int& x, int& y){
    int d = a;
    if( b!= 0){
        d = exgcd(b, a%b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

int main(){
    int a, b, x, y;
    cin >> a >> b;
    exgcd(a, b, x, y);
    cout << x << " " << y << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdlib>
#include<cmath>

int main(){
  int i,j,count,N,c=0;
  double r;
  j=2;
  i=0;
  std::cin>>N;
  int a[N]={0};
  for(int l=0;l<N;l++){
    std::cin>>a[l];
  }
  for(i=0;i<N;i++){
    count=0;
    r=sqrt(a[i]);
    r=(int)r/1;
    for(int k=2;k<=r+1;k++){
      //std::cout<<r<<'\n';
      if(a[i]%k==0){
	count+=1;
      }
    }
    if(count<1 or a[i]==2){
      c++;
    }
    j++;
  }
  std::cout<<c<<'\n';
  return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double sum = 0;
		
		for(int i = 0; i < n; i++) {
			double x = sc.nextDouble();
			String u = sc.next();
			
			if(u.equals("BTC")) {
				x = 380000*x;
			}
			
			sum += x;
		}
		
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 24532