akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int n, a, x = 1;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a == x)x++;
	}
	if (x == 1)printf("-1\n");
	else printf("%d\n", n - x + 1);
}

Measured memory_bytes: 128
//  Author : Amit Kumar 

#include <iostream>
#include <algorithm> 
#include <string> 
#include <sstream>
#include <fstream>
#include <iomanip> 
#include <chrono> 
#include <numeric> 
#include <utility>
#include <functional>

#include <bitset>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <deque>
#include <list>


#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdio>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace std::chrono;
//  using namespace placeholders;
using namespace __gnu_pbds;
template<typename TypeInfo>
using new_set = tree< 
/* ob.order_of_key(element) -> number of element strictly less than element
 * *ob.find_by_order(n) ->  nth element in increasing order
 */
         TypeInfo ,
         null_type ,
         less<TypeInfo> ,
         rb_tree_tag ,
         tree_order_statistics_node_update 
 > ;

void debug_out() { cerr << endl; }
 
template <typename HEAD, typename... TAIL>
void debug_out(HEAD H, TAIL... T) {
  cerr << " " << (H);
  debug_out(T...);
}
 
#ifdef HELL_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 0
#endif
 


const int MAXM = (int)1e5+100;
const int MAXN = (int)1e5+100;
const int MOD  = (int)1e9+7;




int main(void){
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    ios::sync_with_stdio(false); // FLUSH THE STREAM IF USING puts / printf / scanf/
    cin.tie(nullptr);            //
    cout.tie(nullptr);           //
#ifdef HELL_JUDGE
    auto INITIAL_TIME = high_resolution_clock::now();
#endif 
    int counter{};
    int n; cin >> n; 
    vector<bool>visited(1e6+100,false);
    vector<bool>possible(1e6+100,true);
    for(int i=0;i<n;++i){
        int x; 
        cin >> x; 
        if(visited[x]){
            possible[x] = false;
        }else{
            visited[x]=true;
        }
    }
    for(int i=1;i<=1e6+10;++i){
        if(visited[i]){
            for(int j=i+i;j<=1e6+10;j+=i){
                possible[j] = false;
            }
            counter+=possible[i];
        }
    }
    cout << counter << '\n'; 
#ifdef HELL_JUDGE
    auto FINAL_TIME = high_resolution_clock::now();
    cout << "Time : "
         << duration_cast<milliseconds>(FINAL_TIME-INITIAL_TIME).count() 
         << " ms" << '\n'; 
#endif 
    return 0;
}


Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  long N, K;
  long tmp;
  long ans=0;

  cin >> N;

  for(long i =1; i*i<N; i++){
    if(N%i == 0){
      if(i!=1){
        if(N/(i-1) == N%(i-1)){
          ans = ans+(i-1);
      }
      }
      if(i*i !=N){
        tmp = N/i;
        if(N/(tmp-1) == N%(tmp-1)){
          ans = ans+(tmp-1);
        }
      }
    }
    
  }
  
  
    cout << ans << endl;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int a, b;
	cin >> a >>b;
	if (a > 2 * b) cout << (a - 2 *b) << '\n';
	else cout << 0 << '\n'; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
	while (1) {
		int n, t[10005];
		long long int w;
		w = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < n; i++) {
			cin >> t[i];
		}
		sort(t, t + n);
		for (int i = 0; i < n; i++) {
			w += t[i] * (n - 1 - i);
		}
		cout << w << endl;
	}
	return 0;
}

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

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

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

int main(){
  int n,m;
  scanf("%d",&n);
  scanf("%d",&m);
  int i,j,k,a;
  int s[m];
  for(i=0;i<m;i++) {
    s[i] = 0;
  }
  for(i=0;i<n;i++) {
    scanf("%d",&k);
    for(j=0;j<k;j++) {
      scanf("%d",&a);
      s[a-1]++;
    }
  }
  int ans = 0;
  for(i=0;i<m;i++) {
    if(s[i] == n) {
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  int n, ans = 0, i;

  scanf("%d", &n);

  for ( i = 1; i <= n; i++) {
    if(i < 10) {
      ans++;
    }
    else if(i>99&&i<1000) {
      ans++;
    }
    else if (i>9999&&i<100000) {
      ans++;
    }
  }

  printf("%d\n", ans);
}


Measured memory_bytes: 128
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for i in range(n)]

ans = 10**4

for i in range(n):
    if ct[i][1]<=t:
        ans = min(ans, ct[i][0])

print('TLE' if ans == 10**4 else ans)

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

string hidari="qazwsxedcrfvtgb";
string migi="yhnujmifkolp";

int calc(char ch){
  int i;
  for(i=0;i < hidari.size();i++){
    if(ch==hidari[i]){
      return 0;
    }
  }
  return 1;
}

int main(){
  int i;
  string moji;
 
  while(1){
    int count=0;
    cin >> moji;
    if(moji=="#")break;
    int size=moji.size();
    for(i = 0; i+1 < size; i++){
      if( calc(moji[i]) != calc(moji[i+1]))count++;
    }
    
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def kaisa(x):
  a = 1
  for i in range(1,x + 1,1):
    a += a *i
  return a 
    
a_ = 1
b_ = 1

for i in range(1,n,1):
  a_ += sorted(a).index(a[0]) * kaisa(n-1-i)
  del a[0]
  b_ += sorted(b).index(b[0]) * kaisa(n-1-i)
  del b[0]
  
print(abs(a_ - b_))

Measured memory_bytes: 3064
from sys import exit

N, M = [int(x) for x in input().split()]
A = list([int(x) for x in input().split()])

vote = sum(A)

count = 0
for a in A:
    if a * 4 * M >= vote:
        count += 1
        if count == M:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 9180
modprime = 10**9+7
n, k = map(int, input().split())
big_total = 0
# fix the number of selected
for z in range(k, n+2):
  min_sum = (z-1)*z//2
  max_sum = n*(n+1)//2 - (n-z)*(n-z+1)//2
  # all intermediate sums are possible
  num_sums = max_sum - min_sum + 1
  big_total = (big_total + num_sums)%modprime
print(big_total)

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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back

int main() {
	string x; cin >> x;
	
	FOR(i, 0, 3) printf("%c", x[i]);
	
	puts("");
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 5e5 + 5;
int n, k, a[N], h[N];
int dp[N];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) scanf("%d", h + i);
	for (int i = 0; i <= n; ++i) dp[i] = 1e9;
	dp[1] = 0;
	for (int i = 2; i <= n; ++i) {
		for (int j = max(1, i - k); j < i; ++j)
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
	}
	cout << dp[n];
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
string s;
bool ch(string t){
  int res=0;
  if(t.find("iwi")==string::npos)return 0;
  for(int i=0;i<t.size()/2;i++){
    if(t[i]==')'&&t[t.size()-1-i]!='(')res++;
    if(t[i]=='('&&t[t.size()-1-i]!=')')res++;
    if(t[i]==']'&&t[t.size()-1-i]!='[')res++;
    if(t[i]=='['&&t[t.size()-1-i]!=']')res++;
    if(t[i]=='}'&&t[t.size()-1-i]!='{')res++;
    if(t[i]=='{'&&t[t.size()-1-i]!='}')res++;
    if(t[i]=='i'&&t[t.size()-1-i]!='i')res++;
    if(t[i]=='w'&&t[t.size()-1-i]!='w')res++;
  }
  if(res)return 0;
  else return 1;
}
int dfs(int d,string t){
  int res=0;
  if(d==s.size()){
    if(ch(t))res=t.size();
  }
  else{
    res=max(res,dfs(d+1,t));
    res=max(res,dfs(d+1,t+s[d]));
  }
  return res;
}
int main(){
  cin>>s;
  cout<<dfs(0,"")<<endl;
}

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

bool binSearch(int s[], int n, int t)
{
    int l = 0;
    int m = n / 2;
    int h = n;
    while (l != m && m != h) {
        if (s[m] == t) {
            return true;
        } else if (t < s[m]) {
            h = m;
            m = (l + h) /2;
        } else {
            l = m;
            m = (l + h) /2;
        }
    }

    if (s[m] == t) {
        return true;
    } else {
        return false;
    }
}

int main()
{
    int n;
    std::cin >> n;

    int s[n];
    for (std::size_t i = 0; i < n; ++i) {
        std::cin >> s[i];
    }

    int q, cnt = 0;
    std::cin >> q;

    int t;
    for (std::size_t i = 0; i < q; ++i) {
        std::cin >> t;
        if (binSearch(s, n, t)) {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 3472
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

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

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

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;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
ll n;
map<ll,ll> dp;

ll d(ll x)
{
	if (x==1) return 1;
	if (dp[x]) return dp[x];
	ll a=x/2,b=x-a;
	return dp[x]=1+d(a)+d(a);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n;
	cout<<d(n);
}





Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {

	int s = 0;

	for (int i = 0; i < 5; i++) {
		int t;
		scanf("%d", &t);
		s += max(40, t);
	}

	printf("%d\n", s / 5);

	return 0;
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vvi a;
vi dp;

int main(){
	cin>>n;
	a=vvi(n,vi(n));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
	int S=1<<n;
	dp=vi(S);
	dp[0]++;
	for(int i=1;i<S;i++){
		int t=0;
		for(int j=0;j<n;j++) if(i&1<<j) t++;
		for(int j=0;j<n;j++) if(i&1<<j&&a[t-1][j]) (dp[i]+=dp[i-(1<<j)])%=mod;
	}
	cout<<dp[S-1]<<endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T> constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll x[1005], y[1005], r[1005];
vector<pair<int, double>> g[1005];
double d[1005];
void solve() {
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    cin >> n;

    rep(i, n) cin >> x[i + 2] >> y[i + 2] >> r[i + 2];

    const auto len = [](double x, double y, double r) { return max(0., sqrt(x * x + y * y) - r); };
    rep(j, n + 2) rep(i, j) {
        auto cst = len((double)x[i] - x[j], (double)y[i] - y[j], (double)r[i] + r[j]);
        g[i].emplace_back(j, cst);
        g[j].emplace_back(i, cst);
    }

    fill(d, d + n + 2, dinf);
    queue<int> que;
    que.push(0);
    d[0] = 0.;
    while (!que.empty()) {
        auto p = que.front(); que.pop();

        rep(i, g[p].size()) {
            if (d[p] + g[p][i].second < d[g[p][i].first]) {
                d[g[p][i].first] = d[p] + g[p][i].second;
                que.push(g[p][i].first);
            }
        }
    }

    cout << d[1] << endn;

}

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

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;

  map<ll, ll> beki;
  beki[1] = 1;
  rep(i, 33) {
    if (i == 0 || i == 1) continue;
    ll ii = i * i;
    while (ii <= N) {
      beki[ii]++;
      ii *= i;
    }
  }

  repr(i, N) {
    if (beki[i] != 0) {
      COUT(i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define len(x) x.size()
#define all(x) x.begin(), x.end()

ll use(int &K, int &A, int score) {
	ll ans = 0;
	if (K < A) {
		ans = (ll)score * K;
		A -= K;
		K = 0;
	} else {
		ans = (ll)score * A;
		K -= A;
		A = 0;
	}
	return ans;
}

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

	int A, B, C, K;
	cin >> A >> B >> C >> K;

	ll score = 0;
	score += use(K, A, 1);
	score += use(K, B, 0);
	score += use(K, C, -1);
	cout << score << endl;
}


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

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 9;
using Graph = vector<vector<int>>;

string parse(string s, int l, int r) {
    if (l >= r) return "";
    // output(l, r);

    // if (s[l] == ']') return parse(s, l + 1, r);

    if (s[l] == '[') {
        int depth = 0;
        rep2(i, l, r) {
            if (s[i] == '[') depth++;
            if (s[i] == ']') depth--;
            if (!depth) {
                string t = parse(s, l + 1, i);
                reverse(all(t));
                return t + parse(s, i + 1, r);
            }
        }
        assert(false);
    }

    int t = 0;
    rep2(i, l, r) {
        if (s[i] == '+') {
            (t += 1) %= 26;
        }
        else if (s[i] == '-') {
            (t += 25) %= 26;
        }
        else {
            assert(isalpha(s[i]));
            return char((s[i] - 'A' + t) % 26 + 'A') + parse(s, i + 1, r);
        }
    }

    assert(false);
}

string replace(string s, vi v) {
    int j = 0;
    rep(i, s.size()) {
        if (s[i] == '?') {
            s[i] = 'A' + v[j++];
        }
    }
    return s;
}

string dfs(string s, int i, int q, vi v) {
    if (i == q) {
        auto t = replace(s, v);
        return parse(t, 0, t.size());
    }

    string ret(s.size(), '~');
    rep(j, 26) {
        v.emplace_back(j);
        chmin(ret, dfs(s, i + 1, q, v));
        v.pop_back();
    }
    return ret;
}

string solve(string s) {
    int q = 0;
    rep(i, s.size()) {
        if (s[i] == '?') {
            q++;
        }
    }

    return dfs(s, 0, q, vector<int>{});
}

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

    string s;
    while (cin >> s, s != ".") {
        cout << solve(s) << endl;
    }
}

Measured memory_bytes: 3244
n = int(input())
a = list(map(int, input().split()))
step = 0
for i in range(1, n):
    if a[i] < a[i-1]:
        humidai = a[i-1] - a[i]
        step += humidai
        a[i] = a[i] + humidai
print(step)

Measured memory_bytes: 105064
#include<stdio.h>
#include<ctype.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int IN(void)
{
  int x=0,f=1;char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-f;c=getchar();}
  while(isdigit(c))x=(x*10)+(c-48),c=getchar();
  return f*x;
}
int main(void)
{
  int N,M,A,B,count,H[100001]={0},low[100001]={0};
  N=IN(),M=IN();
  rep(i,N)H[i]=IN();
  rep(i,M){A=IN()-1,B=IN()-1;if(H[A]<=H[B])low[A]=1;if(H[A]>=H[B])low[B]=1;}
  count=0;
  rep(i,N)count+=!low[i];
  return printf("%d\n",count),0;
}

Measured memory_bytes: 2348
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b,d;
  cin>>a>>b;
  if(b==1||b==2*a-1)
    cout<<"No"<<endl;
  else{
    cout<<"Yes"<<endl;
    vector<int> c(2*a-1);
    d=2*a-1;
    fo(i,d)
      c[i]=d-i;
    if(b>a){
      swap(c[a-1],c[0]);
      swap(c[a],c[d-b]);
      swap(c[a-2],c[d-1]);
    }
    else if(b<a){
      rev(c);
      swap(c[a-1],c[0]);
      swap(c[a],c[b-1]);
      swap(c[a-2],c[d-1]);
    }
    fo(i,d)
      cout<<c[i]<<endl;
  }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << "No" << endl; exit(0);}

int main()
{
 cin.tie(0);
 ios::sync_with_stdio(false);
 int n;
 string s;
 cin >> n >> s;
 if (n % 2) END;
 string a = "", b = "";
 REP(i, n)
 {
  if (i < n/2) a += s[i];
  else b += s[i];
 }
 if (a == b) cout << "Yes" << endl;
 else cout << "No" << endl;

 return 0;
}

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

int main() {
	int W, H, x, y, r;
cin>> W>> H>> x>> y>> r;

if(0<=x-r&&x+r<=W&&0<=y-r&&y+r<=H){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}// your code goes here
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
//#define int long long
const int N = 500;
const int MAX_N = 210;


int main() {
  int n;
  while(cin >>n && n){
    int v[N][N];
    memset(v, 0, sizeof(v));
    P s[MAX_N];
    s[0].first = s[0].second = 250;
    v[250][250] = true;

    int my[] = {0, 1, 0, -1};
    int mx[] = {-1, 0, 1, 0};
    REP(i, n - 1){
      int num, type; cin >>num >>type;
      int ny = s[num].first + my[type];
      int nx = s[num].second + mx[type];
      s[i + 1] = P(ny, nx);
      v[ny][nx] = true;
    }
    int h = N, w = N;
    REP(i, N){
      bool f = false;
      REP(j, N) if(v[i][j]) f = true;
      if(f) break;
      --h;
    }
    for(int i = N - 1; i >= 0; --i){
      bool f = false;
      REP(j, N) if(v[i][j]) f = true;
      if(f) break;
      --h;
    }
    REP(i, N){
      bool f = false;
      REP(j, N) if(v[j][i]) f = true;
      if(f) break;
      --w;
    }
    for(int i = N - 1; i >= 0; --i){
      bool f = false;
      REP(j, N) if(v[j][i]) f = true;
      if(f) break;
      --w;
    }
    cout <<w <<" " <<h <<endl;
  }
  return 0;
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N=2e5+5;
pr a[N]; int d[N],ans[N]; bool vis[N],c[N];
vector< pr > G[N];
void dfs(int u){
    vis[u]=true;
    rep(i,0,G[u].size()-1){
        int v=G[u][i].fi;
        if (d[u]==d[v]){
            ans[G[u][i].se]=d[u];
            if (!vis[v]){ c[v]=!c[u]; dfs(v); }
        }
    }
}
bool complete(int u){
    rep(i,0,G[u].size()-1){
        int v=G[u][i].fi;
        if (d[v]<d[u]) ans[G[u][i].se]=1e9;
    }
}
int main(){
    int n,m; scanf("%d%d",&n,&m);
    rep(i,1,n){ scanf("%d",&d[i]); a[i]=mp(d[i],i); }
    rep(i,1,m){
        int u,v; scanf("%d%d",&u,&v);
        G[u].pb(mp(v,i)),G[v].pb(mp(u,i));
    }
    rep(i,1,n){
        bool t=false;
        rep(j,0,G[i].size()-1)
            if (d[G[i][j].fi]<=d[i]){ t=true; break; }
        if (!t){ cout<<-1<<endl; return 0; }
    }
    sort(a+1,a+1+n);
    rep(i,1,n){
        int u=a[i].se;
        if (vis[u]){ complete(u); continue; }
        bool t=false;
        rep(j,0,G[u].size()-1)
            if (d[u]==d[G[u][j].fi]){ t=true; break; }
        if (t){ dfs(u); complete(u); }
        else{
            rep(j,0,G[u].size()-1){
                int v=G[u][j].fi;
                if (d[v]<d[u]) ans[G[u][j].se]=c[v]?d[u]:d[u]-d[v];
            }
        }
    }
    rep(i,1,n) printf("%c",c[i]?'W':'B'); cout<<endl;
    rep(i,1,m) printf("%d\n",ans[i]);
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    forn(i, 0, n) cin >> a[i];
    vector<vector<int>> ans(h, vector<int> (w));
    int i = 0, j = 0, col = 0;
    while (col < n) {
        while (col < n && a[col]) {
            ans[i][j] = col;
            --a[col];
            if (a[col] == 0) ++col;
            if (i == 0 && j % 2) ++j;
            else if (i == h - 1 && j % 2 == 0) ++j;
            else if (j % 2) --i;
            else ++i;
        }
    }
    forn(I, 0, h) {
        forn(J, 0, w) cout << 1 + ans[I][J] << ' ';
        cout << '\n';
    }
}


Measured memory_bytes: 384
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    a,b,c,d = map(int, input().split())
    myturn = True
    while True:
        if a <= 0 or c <= 0:
            break
        if myturn:
            c -= b
        else:
            a -= d
        myturn = not myturn
    if c <= 0:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 10528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int h, w;
	cin >> h >> w;
	vs s(h);
	rep(i, 0, h) cin >> s[i];
	rep(i, 0, h) rep(j, 0, 2) cout << s[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int number[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
long long int dp[10][10001];
 
long long int factorial(int x)
{
    long long int ret = 1;
    for (int i = 1; i <= x; i++) ret *= i;
    return ret;
}
 
int main()
{
    do
    {
        int sum = 0;
        for (int i = 0; i < 10; i++)
        {
            sum += number[i] * (i + 1);
            dp[i][sum]++;
        }
    } while (next_permutation(number, number + 10));
 
    int n, s;
    while (cin >> n >> s)
    {
        cout << dp[n - 1][s] / factorial(10 - n) << endl;
    }
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,p,n) for(int i=p;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define Graph vector<vector<int>>

const int MOD = 1000000007;


int main() {

  int N,M ;  cin >> N >> M;

  Graph G(N+1);//頂点はn個。今回は数値にそのまま対応させるために+1した

 rep(i,M){//通路の入力
    int A,B;
    cin >> A >> B;
      G[A].push_back(B);
      G[B].push_back(A);
  }//入力終了

  vector<int> dist(N+1,-1);//全地点を未訪問で初期化
  
  dist[1]=0;//頂点1（スタート）の距離を0にする

  queue<int> que;//BFS用キュー

  que.push(1);

  while(!que.empty()){
    int v = que.front();
    que.pop();          //先頭頂点を取り出す
    
    for(int nv : G[v]){
      if(dist[nv]!=-1) continue;//探索済みならスルー

      //初めて候補に挙がった点は今いる地点を入力し、キューに入れる
      dist[nv]= v;
      que.push(nv);
    }

  }

  bool can=true;

  numrep(i,2,N){
    if(dist[i]==-1) can=false;
  }

  if(!can){
    cout << "No" << endl;
  }

  else{
    cout << "Yes" << endl;
    for(int i=2;i<=N;i++){
    cout << dist[i] <<endl ;
  }
  }

  return 0;
}

Measured memory_bytes: 10332
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  [k, s] <- (map read . words) <$> getLine
  print . length $ satisfiedNums k s

satisfiedNums :: Int -> Int -> [Int]
satisfiedNums k s = do
  x<-[0..k]
  y<-[0..k]
  let z = s - (x + y)
  guard (0 <= z && z <= k)
  return z


Measured memory_bytes: 764
#include <iostream>                                                                       
#include <cctype>                                                                         
#include <cstdio>                                                                         
#include <algorithm>                                                                      
                                                                                          
using namespace std;                                                                      
int main()                                                                                
{                                                                                         
  string s1, s2, s3;                                                                      
                                                                                          
  cin >> s1 >> s2 >> s3;                                                                  
                                                                                          
  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);                                 
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);                                 
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);                                 
                                                                                          
  cout << s1[0] << s2[0] << s3[0] << endl;                                                
}                                                                                         
  

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

int main(){
	string o, e;
	cin >> o >> e;
	e += "\n";
	rep(i, o.size()){
		cout << o[i] << e[i];;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <iostream>
#include <stack>
#include <cstdlib>
#include <string>
using namespace std;
int main(void)
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int a, b, x;
	string str;
	stack<int> s;
	while (cin >> str)
	{
		char ch = str[0];
		if (ch == '+')
		{
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a + b);
		}
		else if (ch == '-')
		{
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(b - a);
		}
		else if (ch == '*')
		{
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a * b);
		}
		else if (ch == '/')
		{
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a / b);
		}
		else
		{
			s.push(atoi(str.c_str()));
		}
	}
	cout << s.top() << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h,w;
    while(1){
        cin>>h>>w;
        if(h==0 && w==0){
            break;
        }
        for(int i=0;i<h;i++){
           for(int j=0;j<w;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        
        cout<<endl;
    }
}


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

int main() {
    int n, cnt = 0; cin >> n;
    ll x; cin >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i,n) {
        if (x >= a[i]) {
            if (i == n-1 && x == a[i]) cnt++;
            else if (i != n-1) {
                x -= a[i];
                cnt++;
            }
        }
        else break; 
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3552
from heapq import *
from bisect import *
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    hp = []
    for _ in range(n):
        a, b = map(int, input().split())
        heappush(hp, [a, 1, b])
    for _ in range(n):
        a, b = map(int, input().split())
        heappush(hp, [a, 0, b])
    yy = []
    ans = 0
    while hp:
        x, q, y = heappop(hp)
        if q:
            insort(yy, y)
        else:
            i = bisect_left(yy, y)
            if i > 0:
                del yy[i - 1]
                ans += 1
    print(ans)

main()


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

int main() {
  
  string S;
  cin >> S;
  int n = S.size();
  
  if(S.at(n-1)=='s'){
    cout << S <<"es"<<endl;
  }
  
  else{
    cout << S <<'s'<<endl;
  }
  
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a = max(a, c);
	b = min(b, d);
	int ans = max(0, b-a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> ii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lp(i,n)    for(int i=0;i<int(n);i++)
#define ff(i,a,b)  for(int i=a;i<=int(b);++i)
#define fr(i,a,b)  for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
string ys = "YES\n";
string no = "NO\n" ;
const double EPS = 1e-9;
const int inf = 1<<30;
const ll M  = 1e9+7 ;
//const int N = 100100;
//////////////////////    Hi    ^_^  hack me if you can :P

int n,k,t;

int main()
{
    speed;
    cin >> n >> t;
    cout << max(0,n - t);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<=b;i++){
		if(a*i%b==c){
			printf("YES\n");return 0;
		}
	}printf("NO\n");
}

Measured memory_bytes: 128
def ReadMap(n, m):
  Map = [0] * m
  for i in range(m):
    a = raw_input()
    b = list(a)
    if a.count('&')>0:
      j = a.index('&')
      PosCas = [j, i]
      b[j] = '.'
    Map[i] = b
  return Map, PosCas

def fill(SP, c1, c2):
  for x, y in SP:
    try:
      if Map[y][x]!=c1:continue
    except: continue
    if x in [0, n-1] or y in [0, m-1]:
      return 1
    Map[y][x] = c2
    SP += ([[x+1, y] , [x-1, y], [x, y+1], [x, y-1]])
    
  return 0

def PrintMap():
  for e in Map:
    print "".join(e)
  print
  return

while 1:
  n, m = map(int,raw_input().split())
  if n == m == 0: break
  Map, PosCas = ReadMap(n, m)
  c = 0
#  PrintMap()
  while 1:
    SP = [PosCas]
    if fill(SP, '.', '#'): break
#    PrintMap()
    c += 1
    if fill(SP, '#', '.'): break
#    PrintMap()
  print c

Measured memory_bytes: 12416
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n + 2)
	sum := 0
	for i := 1; i < n + 1; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr[i] = tmp
		sum += abs(arr[i] - arr[i - 1])
	}
	sum += abs(arr[n])
	for i := 1; i < n + 1; i++ {
		tmp := sum
		tmp -= abs(arr[i] - arr[i - 1]) + abs(arr[i] - arr[i + 1])
		tmp += abs(arr[i - 1] - arr[i + 1])
		fmt.Println(tmp)
	}
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstdio>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();
constexpr ll I_MAX = numeric_limits<int>::max();
constexpr ull UI_MAX = numeric_limits<unsigned int>::max();

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}



struct edge {
	int from;
	int to;
	int cost=1;
};


auto dijkstra(vector<vector<edge>> &g, int start = 0) {
	vector<int> d(g.size(), I_MAX);
	d[start] = 0;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int,int>>> nodes;//first dist, second edgenum
	nodes.push(pair<int, int>(0, start));


	while (!nodes.empty()) {
		pair<int, int> n = nodes.top();
		int s_node = n.second;
		nodes.pop();
		if (n.first > d[n.second])continue;
		rep(i, 0, g[s_node].size()) {
			int new_dist = d[s_node] + g[s_node][i].cost;
			int n_num = g[s_node][i].to;
			if (new_dist < d[n_num]) {
				nodes.push(make_pair(new_dist, n_num));
				d[n_num] = new_dist;
			}
		}
	}
	return d;
}

int main() {

	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	vector<int> s(k);
	pair<ll, ll> max(0,0);//first sum, second position
	rep(i, 0, n)
	{
		cin >> p[i];
		if (i < k) {
			max.first += p[i];
		}
	}
	ll presum = max.first;
	rep(i, 1, n - k +1) {
		presum += (-p[i - 1] + p[i+k-1]);
		if (presum > max.first) {
			max.first = presum;
			max.second = i;
		}

	}

	double ans = 0;

	rep(i, max.second, max.second+k) {
		ans += (p[i] + 1) / 2.0;
	}

	cout << fixed;
	cout << setprecision(8) << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

int main() {
  kyun;
  int a,n;
  cin >> a >> n;
  cout << (a+2*n)/(2*n+1);
  hinata;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long int N;
    scanf("%lld",&N);
    long long int a[N];
    for(int i=0;i<N;i++)scanf("%lld",&a[i]);
    int flag=0;
    long long int ans=0;
    while(flag==0){
        flag=1;
        for(int i=0;i<N;i++){
            long long int tmp=a[i]/N;
            if(tmp!=0){
                flag=0;
                a[i]-=tmp*N;
                ans+=tmp;
                for(int j=0;j<N;j++){
                    if(i!=j)a[j]+=tmp;
                }
            }
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
//kid_kb//

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;
 
int main()
{
    kb
    //                                            Let's Fight !!!!!!!
    ll t;
    t=1;
    // cin>>t;
    while(t--){
      int n;
      cin>>n;
      ll arr[n];
      rep(i,0,n)cin>>arr[i];
      ll ans=0;
      ll mini=arr[0];
      rep(i,1,n){
          if(arr[i]>=mini){
              mini=arr[i];
          }
          else{
              ans+=(mini-arr[i]);
          }
      }
      cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 5212
K,N=gets.split.map &:to_i;M=998244353;I=[1,1];*F=I;*R=I;2.upto(N+K){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M};a=[];1.upto((K+1)/2){|q|i=q*2+1;[x=0,i-K].max.upto([q,N].min){|t|x=(x+F[q]*R[t]*R[q-t]*F[N+K-i]*R[K-i+t]*R[N-t]*2**t)%M};a<<x};p *[*o=(1...K).map{|i|a[~-i/2]},a[-1],*o.reverse]

Measured memory_bytes: 2556