akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> A(H,vector<char>(W));
  for (int i=0;i<H;i++) {
    for (int j=0;j<W;j++) {
      cin>>A.at(i).at(j);
    }
  }
  for (int i=0;i<H;i++) {
    for (int j=0;j<W;j++) {
      if(A.at(i).at(j)=='#')
        break;
      if(j==W-1) {
        for (int k=0;k<W;k++)
          A.at(i).at(k)='0';
      }
    }
  }
  for(int j=0;j<W;j++) {
    for (int i=0;i<H;i++) {
      if(A.at(i).at(j)=='#')
        break;
      if(i==H-1) {
        for (int k=0;k<H;k++)
          A.at(k).at(j)='0';
      }
    }
  }
  for (int i=0;i<H;i++) {
    bool b=true;
    for (int j=0;j<W;j++) {
      if(A.at(i).at(j)!='0') {
        cout<<A.at(i).at(j);
        b=false;
      }
      if((j==W-1)&&(b==false))
        cout<<endl;
    }
  }
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			String str = sc.next() + "X";
			for (int i = 0; i < N; ++i) {
				StringBuilder next = new StringBuilder();
				char c = str.charAt(0);
				int n = 1;
				for (int j = 1; j < str.length(); ++j) {
					if (c != str.charAt(j)) {
						next.append(n);
						next.append(c);
						c = str.charAt(j);
						n = 1;
					} else {
						++n;
					}
				}
				str = next + "X";
			}
			System.out.println(str.substring(0, str.length() - 1));
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int now = 0;
    int ans = 0;
    rep(i, n){
        if(a[i] == now+1){
            now++;
            ans++;
        }
    }
    cout << (ans==0 ? -1 : n-ans)<< endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long K, long long X){
    for (int i = X-K+1; i <= X+K-1; i++)
    {
        cout << i << endl;
    }
    
}

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


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

const long long inf = 1000000000000000013;
const int maxn = 200005;

int n;
int a[maxn];
long long ans = inf;
long long pref[maxn];

long long f (int pos, int i, int j) {
	if (!pos || pos >= i || j <= i || j == n)
		return inf;
	long long x1 = pref[pos], x2 = pref[i] - pref[pos], x3 = pref[j] - pref[i], x4 = pref[n] - pref[j];
	return max(max(x1, x2), max(x3, x4)) - min(min(x1, x2), min(x3, x4));
}

signed main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		pref[i] = pref[i - 1] + a[i];
	}
	for (int i = 2; i <= n - 2; ++i) {
		auto l = upper_bound(pref, pref + n + 1, pref[i] / 2) - pref;
		auto r = upper_bound(pref, pref + n + 1, pref[i] + (pref[n] - pref[i]) / 2) - pref;
		for (int pos = l - 1; pos <= l; ++pos) {
			for (int j = r - 1; j <= r; ++j)
				ans = min(ans, f(pos, i, j));
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin>>N;
    vl A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));
    reverse(all(A));
    vl E;
    rep(i,N-1){
        if(A[i]==A[i+1]){
            E.eb(A[i]);
            i++;
        }

        if (E.size() == 2) break;
    }

    if(E.size()<2){
        cout << 0 << endl;
    }else{
        cout << E[0] * E[1] << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <limits>
using namespace std;

int main()
{
int n,i=0; cin>>n;
double x= 800.0 * n;
while(n>=15) {n-=15; i++;}
double y=200.0*i;
cout<<x-y;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
//#include <numeric>
using namespace std;
using ll = long long;

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+8
#define PI acos(-1)
#define TAU PI * 2
#define EPS 0.00000001
const ll MOD = 1000000007;


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


    if(a <= b){
        if(b - (a + w) > 0){
            println(b - (a + w));
        }else{
            println(0);
        }
    }else{
        if(a - (b + w) > 0){
            println(a - (b + w));
        }else{
            println(0);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
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;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  bool flag = 1;
  set <string> s;
  stack <string> st;
  rep(i, n) {
    string str;
    cin >> str;
    if (!i) {
      s.insert(str);
      st.push(str);
    } else {
      if(s.count(str)) {
        flag = 0;
        break;
      }
      string tmp = st.top();
      if (str.at(0) != tmp.at(tmp.size()-1)) {
        flag = 0;
        break;
      }
      s.insert(str);
      st.push(str);
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

int main(void)
{
	int n;
	cin >> n;
	vector<int> vs(n);
	rep(i, n) cin >> vs[i];

	int a = 0;
	rep(i, n) {
		if (vs[i] == a + 1) {
			a++;
		}
	}
	if (a == 0) cout << -1 << endl;
	else cout << (n - a) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANF(x) scanf("%d",&x);

int main(){

    int A,B,C,D;

    SCANF(A);
    SCANF(B);
    SCANF(C);
    SCANF(D);

    printf("%d\n",min(A,B)+min(C,D));

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, num=0;
    cin >> a >> b;
    for (int i=a; i<=b; i++) {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3])
            num++;
    }
    cout << num << endl;
}

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

int main() {
  int n; cin >> n;
  bool ans = false;
  
  while(n>0){
    if(n%10==7){
      ans = true;
      break;
    }
    n /=10;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100
i64 dp[MAX_N + 1][MAX_N + 1][MAX_N * 3 + 1];

int main() {
    i64 N, wlim; cin >> N >> wlim;

    vector<i64> W(N), V(N);
    REP(i, N) cin >> W[i] >> V[i];

    REP(i, N) {
        for (i64 npacked = 0; npacked <= i; npacked++) {
            REP(j, 3 * N + 1) {
                i64 rem = W[i] - W[0];
                chmax(dp[i + 1][npacked][j], dp[i][npacked][j]);
                chmax(dp[i + 1][npacked + 1][j + rem], dp[i][npacked][j] + V[i]);
            }
        }
    }

    i64 maxv = 0;
    REP(npacked, N + 1) {
        REP(j, 3 * N + 1) {
            if (npacked * W[0] + j <= wlim)
                chmax(maxv, dp[N][npacked][j]);
        }
    }
    cout << maxv << endl;

    return 0;
}

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

signed main()
{
	int n,l,x=0,y,in;cin>>n>>l;
	int a[n];
	int index = 0;
	for(int i=0;i<n;i++)
		{
			y=(l+i+1)-1;
			a[i]=abs((l+i+1)-1);
			x=x+y;
		}
	for(int i = 0; i <n; i++)
    {
        
        if(a[i] < a[index])
            index = i;              
    }
 
  cout<<x-((l+index+1)-1);
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Text;

namespace ABC0613
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string ans="a";

            if(Char.IsUpper(str.ToCharArray()[0])==true)
            {
                ans = "A";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25784
n, m = map(int, input().split())
l = []
for i in range(n):
    a = list(map(int, input().split()))
    a.pop(0)
    l.append(a)
cnt1 = 0
for i in range(m):
    cnt2 = 0
    for j in range(n):
        if i + 1 in l[j]:
            cnt2 += 1
    if cnt2 == n:
        cnt1 += 1
print(cnt1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ull = unsigned long long;
 
#define NL '\n'
#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define _ctz(x) __builtin_ctz(x)
#define _clz(x) __builtin_clz(x)
#define _pop(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"1


#define mdx ((l+r)>>1)
#define ldx (idx<<1)
#define rdx ((idx<<1)|1)


const int N = 1e6+9;
int n, q, x, y, z, t, a[N], s[N];


void build(int idx, int l, int r){
	if(l == r) {s[idx] = a[l]; return; }
	build(ldx, l, mdx);
	build(rdx, mdx + 1, r);
	s[idx] = min(s[ldx], s[rdx]);
}

void update(int idx, int l, int r, int i, int v){
	if(i < l || i > r) return;
	if(i == l && i == r) {s[idx] = v; return;}
	update(ldx, l, mdx, i, v);
	update(rdx, mdx + 1, r, i, v);
	s[idx] = min(s[ldx], s[rdx]);	
}

int query(int idx, int l, int r, int i, int j){
	if(j < l || i > r) return INT_MAX;
	if(l >= i && r <= j) return s[idx];
	return min(query(ldx, l, mdx, i, j), query(rdx, mdx + 1, r, i, j));	
}

int main(){
	_fastIO();
	cin >> n >> q;
	mem(a, 0);
	mem(s, 0);
	for(int i = 1; i <= n; i++) a[i] = INT_MAX;
	build(1, 1, n);
	for(int ix = 0; ix < q; ix++) {
		cin >> t >> x >> y;
		if(t == 0) update(1, 1, n, x+1, y);
		else cout << query(1, 1, n, min(x,y)+1, max(x,y)+1) << NL; 
	}
}





Measured memory_bytes: 11000
#include<iostream>
using namespace std;
#define MX 10000001
int main()
{
  bool pr[MX]={0};
  int i,j;
  pr[0]=pr[1]=1;
  for(i=2;i*i<MX;i++)if(!pr[i])for(j=i+i;j<MX;j+=i)pr[j]=1;

  int m,a,b,p,q;
  bool f;
  while(cin>>m>>a>>b,m|a|b){
    f=false;
    for(i=m;i>3;i--){
      for(j=2;j*j<=i;j++){
	if(i%j!=0)continue;
	if(pr[j])continue;
	if(pr[i/j])continue;
	if((double)a/b>(double)j/(i/j))continue;
	p=j;
	q=i/j;
	f=true;
	break;
      }
      if(f)break;
    }
    cout<<p<<" "<<q<<endl;
  }
}

Measured memory_bytes: 10000
#include<stdio.h>
#include<string.h>
int main()
{
	char c[100005];
	gets(c);
	int s=0;
	for(int i=0;i<strlen(c);i++)
	{
		if(c[i]==c[i+1])
		{
		c[i+1]='1'-c[i+1]+'0';
		s++;
		}
	}
	printf("%d",s);
}


Measured memory_bytes: 256
import sys
from itertools import accumulate, combinations

read = sys.stdin.read

N, K, *a = map(int, read().split())

a = accumulate([0] + a)
seq = []
for i, j in combinations(a, 2):
    seq.append(j - i)

m = (10 ** 9 * 1000).bit_length()
answer = 0
bit = 1 << (m - 1)
for _ in range(m):
    tmp = bit + answer
    if len([i for i in seq if i & tmp == tmp]) >= K:
        answer = tmp
    bit >>= 1

print(answer)


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

using namespace std;

bool is_digit(char c) {
    return c >= '0' && c <= '9';
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    vector<long long> sa(n+1), sb(m+1);
    sa[0] = 0;
    for (int i = 0; i < n; i++) {
        sa[i+1] = a[i] + sa[i];
    }
    sb[0] = 0;
    for (int i = 0; i < m; i++) {
        sb[i+1] = b[i] + sb[i];
    }
    int res = 0;
    for (int i = 0; i <= n; i++) {
        if (sa[i] > k) break;
        int l = 0, r = m + 1;
        while (r - l > 1) {
            int mid = (r+l)/2;
            if (sa[i] + sb[mid] > k) {
                r = mid;
            } else {
                l = mid;
            }
        }
        res = max(res, i + l);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 8008
#include<bits/stdc++.h>
#define ll long long
using namespace std;
    ll val[100001];
    ll wt[100001];
int32_t main()
{
    ll n,W;
    cin>>n>>W;
    ll K[n+1][W+1];

    for(int i=0;i<n;i++)
    {
         cin>>wt[i];
        cin>>val[i];

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

       for (int w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }
   cout<<K[n][W];



}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

int W, a, b;
int main(){
    ios::sync_with_stdio(false);
    cin >> W >> a >> b;
    if(a>b)swap(a,b);
    cout<< max(0, b-a-W) <<endl;
    return 0;
}

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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    int a[n];
    int b[m];
    int i;
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(i = 0; i < m; i++) {
        cin >> b[i];
    }

    vector<int64_t> s_a(n+1);
    vector<int64_t> s_b(m+1);
    for(i = 0; i < n; i++) {
        s_a[i+1] = s_a[i] + a[i];
    }
    for(i = 0; i < m; i++) {
        s_b[i+1] = s_b[i] + b[i];
    }

    int ans = 0;
    for(i = 0; i < n+1; i++) {
        if (s_a[i] > k) {
            break;
        }

        int tmp = upper_bound(s_b.begin(), s_b.end(), k - s_a[i]) - s_b.begin();
        ans = max(ans, tmp + i - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8004
/**
 * @author: shashankchdhry
 * @made:   2020-04-04 20:16:38 
**/
#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    int n = s.length();

    int index1, index2;
    for (int i = 0; i < n; i++)
        if (s[i] == 'A')
        {
            index1 = i;
            break;
        }

    for (int i = n-1; i >= 0; i--)
        if (s[i] == 'Z')
        {
            index2 = i;
            break;
        }

    cout << index2 - index1 + 1 << "\n";

    return 0;
}

Measured memory_bytes: 720
n, x, m = (int(x) for x in input().split())
dic = {}
count = 1
dic[x]=0
ans = [x]
bool = True
while (count < n):
    x = pow(x, 2, m)
    if x not in dic:
        dic[x] = count
        ans.append(x)
    else:
        roop = ans[dic[x]:count]
        ans = sum(ans[:dic[x]])
        roop_count = (n-dic[x])//len(roop)
        roop_hasuu = (n-dic[x])%len(roop)
        ans+=roop_count*sum(roop)+sum(roop[:roop_hasuu])
        print(ans)
        bool = False
        count = pow(10, 13)
    count+=1
if bool:
    print(sum(ans))


Measured memory_bytes: 77652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s, x;
    cin >> s;
    ll tmp, ans = atoll(s.c_str());
    int len = s.size();
    for (int i = 1; i < (1 << (len - 1)); i++){
        x = s[0];
        tmp = atoll(x.c_str());
        for (int j = 0; j < len - 1; j++){
            x = s[j + 1];
            if (i & (1<<j)){
                ans += tmp;
                tmp = atoll(x.c_str());
            }else tmp = 1ll * tmp * 10 + atoll(x.c_str());
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)

inp = list(map(lambda x: int(x), input().split(" ")))
N = inp[0]
M = inp[1]

dp = [-1]*N

g = {}

def path(x):
    if dp[x-1]!=-1:
        return dp[x-1]
    if g[x] == []:
        return 0
    else:
        ret = 0
        for k in g[x]:
            if ret<path(k)+1:
                ret = path(k)+1
        dp[x-1] = ret
        return ret

for i in range(1,N+1):
    g[i] = []

for i in range(M):
    inp = list(map(lambda x: int(x), input().split(" ")))
    x = inp[0]
    y = inp[1]
    g[x].append(y)

ret = 0
for i in range(1,N+1):
    if ret<path(i):
        ret = path(i)

print(ret)

Measured memory_bytes: 145892
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

map <int, int> Mx;

char u[15];
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);

	int a1 = 0, a2 = 0;
	while (M--) {
		int t;
		scanf("%d %s", &t, u);
		if (Mx[t] == -1) continue;

		if (u[0] == 'A') {
			a1++;
			a2 += Mx[t];
			Mx[t] = -1;
		}
		else Mx[t]++;
	}
	return !printf("%d %d\n", a1, a2);
}

Measured memory_bytes: 4992
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int a[100010],b[100010];
signed main(void)
{
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i],b[a[i]]=i;
	for(int i=1;i<=n;++i)
		cout<<b[i]<<" ";
	cout<<endl;
	return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n[11];
	string s;
	while(cin >> s){
	for(int i=0;i<10;i++) n[i] = s[i]-'0';
		for(int i=9;i>0;i--){
			for(int j=0;j<i;j++){
			n[j] = (n[j] + n[j+1])%10;
			}
		}
		printf("%d\n",n[0]);
	}
}

Measured memory_bytes: 3212
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

def bfs(grid):
    h = len(grid)
    w = len(grid[0])
    
    dist = [[float('inf')]*w for _ in range(h)]
    
    que = deque([])
    que.append(((0,0), 1))
    dist[0][0] = 0
    
    drs = [-1,0,1,0]
    dcs = [0,-1,0,1]
    
    while que:
        (rcur, ccur), cost = que.popleft()
        if rcur == h-1 and ccur == w-1:
            return dist[h-1][w-1]
    
        for dr, dc in zip(drs, dcs):
            if not (0 <= rcur+dr < h and 0 <= ccur+dc < w):
                continue
            
            elif grid[rcur+dr][ccur+dc] == '#':
                continue
            
            elif dist[rcur+dr][ccur+dc] != float('inf'):
                continue
            
            dist[rcur+dr][ccur+dc] = cost + 1
            que.append(((rcur+dr, ccur+dc), cost+1))
            
    return -1
            

h,w = li()
grid = [lc() for _ in range(h)]

white = 0
for row in grid:
    for col in row:
        if col == '.':
            white += 1

route = bfs(grid)
print(-1 if route == -1 else white - route)

Measured memory_bytes: 3416
N, A, B = gets.split.map(&:to_i)
hp = Array.new(N) { gets.to_i }

l = 0
r = hp.max / B + 1
while l + 1 < r
  m = (l + r) / 2
  
  count = hp.map { |h| ((h - B * m).to_f / (A - B)).ceil }
            .select { |c| c > 0 }
            .inject(0, &:+)
  
  if count > m
    l = m
  else
    r = m
  end
end
puts r

Measured memory_bytes: 37500
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
bool palindrome(string s) {
    for(int i = 0; i < s.size() / 2; i++) {
        if(s[i] != s[s.size() - 1 - i]) {
            return false;
        }
    }
    return true;
}
int main(){
    string s;
    cin >> s;
    bool check = true;
    int n = s.size();
    string s1 = "", s2 = "";
    for(int i = 0; i < n / 2; i++) {
        s1 += s[i];
    }
    for(int i = (n / 2) + 1; i < n; i++) {
        s2 += s[i];
    }
    if( !palindrome(s1) || !palindrome(s2) || !palindrome(s)) {
        check = false;
    }
    if(check) {
        cout << "Yes";
    }
    else{
        cout <<"No";
    }
    return 0;
}

Measured memory_bytes: 256
def check_kingaku(maisu, kingaku):
    if(maisu*10000<kingaku):
        return "-1 -1 -1"
    for itr_1000 in range(maisu+1):
        for itr_5000 in range(maisu-itr_1000+1):
            itr_10000 = maisu - itr_1000 - itr_5000
            target = 1000*itr_1000 + 5000*itr_5000 + 10000*itr_10000
            if(target == kingaku):
                return str(itr_10000) + " " + str(itr_5000) + " " + str(itr_1000)
    return "-1 -1 -1"

maisu, kingaku = [int(x) for x in input().split()]
ret = check_kingaku(maisu, kingaku)
print(ret)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A;
  cin >> A;
  if(A.at(0) == '7') {
    cout << "Yes" << endl;
  }
  else if(A.at(1) == '7') {
    cout << "Yes" << endl;
  }
  else if(A.at(2) == '7') {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////
const int inf = 1e15;

int f(int b, int n) {
    return n < b ? n : f(b,n/b) + (n%b);
}

int32_t main() {
    int n,s; cin >> n >> s;
    if (n == s) quit(n+1);
    int mi = inf;
    for (int x = 1; x*x <= n-s; x++) {
        if ((n-s)%x != 0) continue;
        int b1 = x+1, b2 = (n-s)/x+1;
        if (f(b1,n) == s) chmin(mi,b1);
        if (f(b2,n) == s) chmin(mi,b2);
    }
    if (mi == inf) mi = -1;
    cout << mi << endl;
}


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

int main(){
	int K,S;
	cin>>K>>S;
	
	int X,Y,Z,ans=0;
	for(int i=0;i<=K;i++){
		for(int j=0;j<=K;j++){
			X=i;
			Y=j;
			Z=S-X-Y;
			if(0<=Z&&Z<=K){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
 string s;
 int x,y,sum=0;
 cin>>s;
x=s.find("A");
y=s.rfind("Z");
for(int i=x;i<=y;i++)
{
	sum++;
}
cout<<sum;
}

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

int main() {
    ll n;
    cin >> n;

    vector<ll> a(n-1), b(n, 0);
    for (int i=0; i<n-1; i++) {
        cin >> a.at(i);
        b.at(a.at(i)-1)++;
    }

    for (int i=0; i<n; i++) {
        cout << b.at(i) << endl;
    }
}

Measured memory_bytes: 6340
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

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

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int a[3];
  while(cin>>a[0]>>a[1]>>a[2],a[0]|a[1]|a[2]){
    sort(a,a+3);
    int m1 = a[0];
    int m2 = a[1];
    double t = sqrt( a[0]*a[0] + a[1]*a[1] );

    int n;
    cin>>n;
    REP(i,n){
      int s;
      cin>>s;
      if( s*2 <= t )
	cout << "NA" << endl;
      else
	cout << "OK" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define sz(s) ( (int)s.size() )
#define all(s) s.begin(), s.end()

using namespace std;

const int M = 1e5 + 5;

int n, m, p[M], sz[M], k, x;

vector <int> vec[M];

int get (int v)
{
    return v == p[v] ? v : p[v] = get(p[v]);
}
void unite (int a, int b)
{
    a = get(a);
    b = get(b);
    if (a != b)
    {
        if (sz[a] > sz[b]) swap(a, b);
        sz[b] += sz[a];
        p[a] = b;
    }
}

main ()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        p[i] = i;
        sz[i] = 1;
        scanf("%d", &k);
        for (int j = 0; j < k; j++)
        {
            scanf("%d", &x);
            vec[x].pb(i);
        }
    }
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j < sz(vec[i]); j++)
        {
            unite( vec[i][0], vec[i][j] );
        }
    }
    for (int i = 1; i <= n; i++)
        if(get(i) != get(1) )
        {
            puts("NO");
            return 0;
        }
    puts("YES");
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;


int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        ll h,w,k; cin >> h >> w >> k;
        vector<vector<char>> c(h, vector<char>(w));
        ll black = 0;
        rep(i,h)rep(j,w){
                cin >> c[i][j];
                if(c[i][j] == '#') black++;
        } 
        ll ans = 0;
        for(int hb = 0; hb < (1<<h); ++hb){
                for(int wb = 0; wb < (1<<w); ++wb){
                        ll now = 0;
                        rep(k,h)rep(l,w){
                                if( !((hb >> k) & 1) ){
                                        if( !((wb >> l) & 1) ){
                                                if(c[k][l] == '#') now++;
                                        }
                                }
                        }
                        if(now == k) ans++;
                }
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
 
const long long MX = 1e18;
int main() {
  long long n;
  cin >> n;
 
  long long ans = 1;
  bool ng = false;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || MX / ans < a) {
      ng = true;
    }
    ans *= a;
  }
 
  if (ng) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, b;

int main(){
	cin >> n >> a >> b;
	cout << max((b-a)*(n-2)+1, 0LL) << endl;
	return 0;
}

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

using u64 = std::uint64_t;

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

	if (n % 2 == 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	n /= 2;
	u64 ans = 0;
	while (n != 0)
		ans += (n /= 5);

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int N;
	cin >> N;
    vector<ll> A(N+1), S(N+1);
    rep (i, N) {
        ll x;
        cin >> x;
        A[i+1] = A[i] ^ x;
        S[i+1] = S[i] + x;
    }
    ll ans = 0;
    int l = 1;
    for (int r = 1; r <= N; r++) {
        while ((S[r]-S[l-1]) != (A[r]^A[l-1])) {
            l++;
        }
        ans += r-l+1;        
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>

using namespace std;
#define MAX_N 100000

void swap(int* x, int* y) {
  int tmp = *x;
  *x = *y;
  *y = tmp;
}

int partition(int A[], int p, int r) {
  int x = A[r];
  int i = p-1;
  for(int j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      swap(&A[i], &A[j]);
    }
  }
  swap(&A[i+1], &A[r]);
  return i+1;
}

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

  int q = partition(A, 0, n-1);
  for(int i=0; i<q; i++) {
    printf("%d", A[i]);
    if(i != q-1) {
      printf(" ");
    }
  }
  printf(" [%d] ", A[q]);

  for(int i=q+1; i<n; i++) {
    printf("%d", A[i]);
    if(i != n-1) {
      printf(" ");
    }
  }
  printf("\n");
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
  
        ll n,ans;
        cin>>n;
        ans=0;
        ll A[n];
        for(ll i=0;i<n;i++)
        {
            cin>>A[i];
        }
        ll min=A[0];
        for(ll j=0;j<n;j++)
        {
            if(A[j]<=min)
            {
                min=A[j];
                ans++;
            }
        }
       
        cout<<ans;
    
	return 0;
}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        int tmp;
        cin>>tmp;
        a[i] = --tmp;
    }
    int cnt=1;
    int now = a[0];
    for(;;){
        if(now==1){
            cout<<cnt;
            return 0;
        }
        if(cnt>=N){
            cout<<"-1";
            return 0;
        }
        cnt++;
        now = a[now];
    }

}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
//#pragma GCC optimize ("trapv")

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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
//#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) lli((x).size())
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;

typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
typedef long double C;

#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cout <<  *it  << " : " << a << endl;
    err(++it, args...);
}


int main(){
	fastio;
	lli x; cin>>x;
	lli wyn=1000*(x/500);
	x%=500;
	wyn+=5*(x/5);
	cout<<wyn<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main() {
    val n = readLine()!!.toInt()
    val list = mutableListOf<Work>()
    for (i in 0 until n) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        list.add(Work(a, b))
    }
    list.sortBy { it.b }

    var total = 0
    for (d in list) {
        total += d.a
        if (total > d.b) {
            print("No")
            return
        }
    }
    print("Yes")
}

data class Work(val a: Int, val b: Int)

Measured memory_bytes: 68576
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int x = 0; x <= 25; x++) {
    for (int y = 0; y <= 14; y++) {
      if (4 * x + 7 * y == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
cum = [0] * (n+1)
for i in range(n):
    cum[i+1] = (cum[i] + a[i]) % m
d = {}
for i in cum:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
ans = 0
for i, count in d.items():
    ans += count * (count - 1) // 2
print(ans)


Measured memory_bytes: 16272
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::sort(a.begin(), a.end());
    int ans = a[n - 1] - a[0];
    for (int i = 1; i < n - 1; i++) {
        ans += std::abs(a[i]);
    }
    std::cout << ans << std::endl;
    int cur = a[0];
    for (int i = n - 2; i > 0; i--) {
        if (a[i] < 0) break;
        std::cout << cur << " " << a[i] << std::endl;
        cur -= a[i];
    }
    std::cout << a[n - 1] << " " << cur << std::endl;
    cur = a[n - 1] - cur;
    for (int i = 1; i < n - 1; i++) {
        if (a[i] >= 0) break;
        std::cout << cur << " " << a[i] << std::endl;
        cur -= a[i];
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e6 + 5, MX = 1e9;
int cnt(int n){
    int ret = 0;
    while (n) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main(){
    int d = D(), n = D();
    if(!d)
        return printf("%d", n == 100 ? 101 : n), 0;
    else if(d == 1){
        if(n == 100)
            printf("%d", n * 100 + 100);
        else
            printf("%d", n * 100);
    }else
        if(n == 100)
            printf("%d", n * 10000 + 10000);
        else
            printf("%d", n * 10000);
    return 0;
}


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

int main() {
  int n;cin >> n;
  long long mod=1000000007;
  long long ans=1;
  for (int i=1;i<n+1;i++) {
    ans *= i;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - Digits Sum
	var N int
	fmt.Scanf("%d", &N)

	var ans int
	var min int = 100000000000
	var A, B int
	for i := 1; i < N; i++ {
		A = i
		B = N - i
		ans = 0
		for {
			if A/10 == 0 {
				ans += A % 10
				break
			} else {
				ans += A % 10
				A = A / 10
			}
		}
		for {
			if B/10 == 0 {
				ans += B % 10
				break
			} else {
				ans += B % 10
				B = B / 10
			}
		}

		if min > ans {
			min = ans
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 1832
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific

using namespace std;

template<typename T> void rar(size_t n, T* a);

int main(void) {
    size_t n;
    cin >> n;
    char *s, *t;
    s = new char[n];
    t = new char[n];
    rar(n, s); rar(n, t);
    size_t start = 0;//where t starts
    size_t search = 0;//current search pos in t
    for (size_t pos = 0; pos < n; ++pos)
    {
        if (s[pos] == t[search]) {//match
            ++search;
        } else if (s[pos] == t[0]) {//no match; new search match
            start = pos;
            search = 1;
        } else {//new search no match
            start = pos+1;
            search = 0;
        }
    }
    cout << start+n << endl;
    return 0;
}

template<typename T>
void rar(size_t n, T* a) {
    for (size_t i = 0; i < n; ++i) cin >> a[i];
    return;
}


Measured memory_bytes: 256
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! print_vec {
    ($vec:expr) => {
        for (i, &v) in $vec.iter().enumerate() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", v);
        }
        println!();
    };
}

fn main() {
    let k = scan!(usize);
    let mut vs: Vec<usize> = (0..50).map(|i| i + (k / 50)).rev().collect();
    for v in vs.iter_mut().take(k % 50) {
        *v += 1
    }

    println!("50");
    print_vec!(vs);
}


Measured memory_bytes: 4352