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

using namespace std;

#define endl "\n"
typedef long long int lli;

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);


lli memo[100001];
lli dp(int pos, vector<int> &v){
	if(pos == v.size()-1)
		return 0;

	if(memo[pos] != -1)
		return memo[pos];

	lli ans = dp(pos+1,v)+abs(v[pos+1]-v[pos]);
	if(pos+2 < v.size())
		ans = min(ans, dp(pos+2,v)+abs(v[pos+2]-v[pos]));

	return memo[pos] = ans;
}

int main(){
	int n; cin >> n;
	vector<int> v(n);
	for(auto &x:v) cin >> x;

	memset(memo, -1, sizeof(memo));
	cout << dp(0, v) << endl;

	return 0;
}


Measured memory_bytes: 7680
n = int(input())
ai = [int(i) for i in input().split()]

ai.sort()

tmp = ai[0]
num = 0

for i in range(1,n):
    if 2*tmp >= ai[i]:
        num += 1
    else:
        num = 0
    tmp += ai[i]
        
print(num+1)

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v = vector<int>(n);
    for (int i = 0; i < n; i++ ) {
        cin >> v[i];
    }
    int t = 0;
    vector<int> c = vector<int>(n);
    for (int i = 0; i < n; i++ ) {
        cin >> c[i];
        if (v[i] > c[i]) {
            t += v[i] - c[i];
        }
    }
    cout << t << endl;

    return 0;
}

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

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	double res{0};

	for (ll n = 1; n < N+1; ++n)
	{
		ll score{n};
		ll times{0};
		while (score < K) {score *= 2; ++times;}
		res += (1.0/N) * pow(0.5, times);
		
	}
	std::cout << fixed << setprecision(10) << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int ans[370] = {}; 
	int L[30] = {}; 
	for(int i = 1; i < D; i+= 2){
		int E[700] = {}; 
		for(int j = 1; j <= 676; j++){
			int p = (j - 1) % 26 + 1; // i日目
			int q = (j - 1) / 26 + 1; // i+1日目
			int M[30] = {}; 
			for(int k = 1; k <= 26; k++){
				M[k] = L[k]; 
			}
			E[j] += S[i][p] + C[p] * (i - M[p]) * min(D-i, 5); 
			M[p] = i; 
			E[j] += S[i+1][q] + C[q] * (i + 1 - M[q]) * min(D-i, 5);
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 676; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = (a-1) % 26 + 1; ans[i+1] = (a-1) / 26 + 1; 
		L[(a-1) % 26 + 1] = i; L[(a-1) / 26 + 1] = i + 1; 
	}
	for(int i = D; i <= D; i++){
		int E[30] = {}; 
		for(int j = 1; j <= 26; j++){
			E[j] = S[i][j] + C[j] * (i - L[j]); 
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 26; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = a; L[a] = i; 
	}
	for(int i = 1; i <= D; i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl a(n);
    set<ll> se;
    vl v(n+1,0);
    rep(i,n){
        cin >> a[i];
        if(v[a[i]-1] > 0){
            v[a[i]] = v[a[i]-1];
        }else{
            v[a[i]] = a[i];
        }
    }
    ll mx = 0;
    REP(i,1,n+1){
        mx = max(mx,i-v[i]);
    }
    mx++;
    cout << n-mx << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

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

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> x(N), y(N);
  for(int i = 0;i < N;i++) {
    cin >> x[i] >> y[i];
  }
  for(int i = 0;i < N;i++) {
    map<pair<i64, i64>, i64> mp; 
    i64 ans = 0;
    for(int j = 0;j < N;j++) {
      if(i == j) continue;
      i64 dx = x[i] - x[j];
      i64 dy = y[i] - y[j];
      if(dx == 0) {
        ans = max(ans, ++mp[pair<i64,i64>(0, 1)]);
      }
      else if(dy == 0) {
        ans = max(ans, ++mp[pair<i64,i64>(1, 0)]);
      }
      else {
        i64 g = gcd(abs(dx), abs(dy));
        dx /= g;
        dy /= g;
        if(dx < 0) dx *= -1, dy *= -1;
        ans = max(ans, ++mp[pair<i64,i64>(dx, dy)]);
      }
    }
    if(ans + 1 >= K) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}



Measured memory_bytes: 3256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    int A[210][210];
    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H) rep(j, W) if (A[i][j] != -1) ans += c[A[i][j]][1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
f=lambda:[*map(int,input().split())]
r=range
h,w=f()
g=[f() for _ in r(h)]
a=[]
for x in r(h):
  for y in r(w):
    if g[x][y]%2 and (x+1)*(y+1)<h*w:
      if (t:=y+1)<w: s=x
      elif (s:=x+1)<h: t=y
      g[x][y]-=1; g[s][t]+=1; a+=[(x+1,y+1,s+1,t+1)]
print(len(a))
for l in a: print(*l)

Measured memory_bytes: 30504
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s >> s;
	cout << 'A' << s[0] << 'C' << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);

            long x = a * b;


            if(a < b)
            {
                long temp = a;
                a = b;
                b = temp;
            }


            long r = a % b;
            while(r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
                
            Console.WriteLine(x / b);
                
        }
    }

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
    int n,i,j=1,c=0;
    cin>>n;
    for(i=10;i<=1000000;i*=10)
    {
        if(n/i==0 && j%2!=0)
        {
            c+=n+1-(i/10);
            break;
        }
        else if(j%2!=0)
            c+=9*i/10;
        else if(i>n)
            break;
        j++;

    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
	//this is a sample overloading function for sorting stl
	bool operator()(pii const &a, pii const &b)
	{
		if(a.F==b.F)
			return (a.S<b.S);
		return (a.F<b.F);
	}
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k,x,y;
        cin>>n>>k>>x>>y;
        cout<<(min(k,n)*x)+(max(0LL,n-k)*y)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
using System;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        if (n == 1) Console.WriteLine("Hello World");
        else {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine(a+b);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main() {
    int a,b,c;
    while (1) {
       
        cin >> a >> b >> c;
        int d;
        d = a+b;
        if (a == (-1) && b == (-1) && c ==(-1)) break;
        if (a == -1 || b == -1){
            cout << "F" ;
        }
        else if (d >= 80){
            cout << "A" ;
        }
        else if (d<80 && d>=65){
            cout << "B" ;
        }
        else if (d<65 && d>=50){
            cout << "C" ;
        }
        else if(d<50 && d>=30){
            if (c >= 50){
                cout << "C";
            }
            else  {
                cout << "D" ;
            }
        }
        else {
            cout << "F" ;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define update(a,b) (a)+=(b),(a)=(a)<mo?(a):(a)-mo

const int maxn=2010;
const int mo=924844033;

int n,K,Ans,fac[maxn],dp[maxn][2],tmp[maxn][2];

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int o,i,j;
	scanf("%d%d",&n,&K);
	fac[0]=1;
	for (i=1;i<=n;i++)
		fac[i]=(LL)fac[i-1]*i%mo;

	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for (o=1;o<=2*K;o++)
	{
		for (i=o;i<=n;i+=2*K)
		{
			memset(tmp,0,sizeof(tmp));
			for (j=0;j<n;j++)
			{
				update(tmp[j][0],dp[j][0]);
				update(tmp[j][0],dp[j][1]);
				if (i>K) update(tmp[j+1][0],dp[j][0]);
				if (i+K<=n)
				{
					update(tmp[j+1][1],dp[j][0]);
					update(tmp[j+1][1],dp[j][1]);
				}
			}
			memcpy(dp,tmp,sizeof(tmp));
		}
		for (i=0;i<=n;i++)
			update(dp[i][0],dp[i][1]),dp[i][1]=0;
	}

	Ans=0;
	for (i=0;i<=n;i++)
	{
		int val=(LL)dp[i][0]*fac[n-i]%mo;
		update(Ans,(i&1)?mo-val:val);
	}
	printf("%d\n",Ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;

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

	int ts = 0, hs = 0;
	for (int i = 0; i < n; i++) {
		string t, h;
		cin >> t >> h;
		if (t == h) {
			ts++, hs++;
		}
		else if (t < h) {
			hs += 3;
		}
		else {
			ts += 3;
		}
	}
	cout << ts << " " << hs << endl;

	return 0;
}



Measured memory_bytes: 3172
h,w = map(int,input().split())
n = int(input())
l = list(map(int,input().split()))
ans = [[0]*w for i in range(h)]
x,y = 0,0
z = 1
num = 1
for i in range(n):
    count = 0
    while count < l[i]:
        ans[x][y] = i+1
        count += 1
        if z == 1:
            if y == w-1:
                x += 1
                z = 2
                
            else:
                y += 1
        elif z == -1:
            if y == 0:
                x += 1
                z = 2
            else:
                y -= 1
        elif z == 2:
            if w != 1:
                if y == 0:
                    y += 1
                    z = 1
                else:
                    y -= 1
                    z = -1
            else:
                x += 1
        
for i in ans:
    print(*i)
                



Measured memory_bytes: 3920
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n, k := getInt(), getInt()
	ans := 0
	for n > 0 {
		ans++
		n /= k
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define eps 0.000001;
using namespace std;
typedef long long ll;
const int inf = 0xfff;
const int maxn = 100005;
ll gcd(ll a, ll b)
{
	return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
struct node{
    int x, y, d;
    node() { x = y = d = 0; };
};
int main()
{
    ios::sync_with_stdio(false);
    int n;
    ll dis;
    cin >> n >> dis;
    int cnt=0;
    ll x, y;
    ll ans;
    ll dis2 = dis * dis;
    for (int i = 1; i <= n;i++)
    {
        cin >> x >> y;
        ans = x * x  + y * y ;
        if(dis2>=ans)
            cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int N;  cin>>N;
  vector<ll> v(3*N);
  rep(i,0,3*N) cin>>v[i];
  sort(all(v));
  ll ans = 0;
  ll cnt=0;
  for(ll i=3*N-2 ; i>=0 ; i-=2){
    if(cnt==N) break;
    ans += v[i];
    cnt++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5596
n=int(input())
s=input()
ans=0
for i in range(10):
    if str(i) in s[:-2]:
        s1=s.index(str(i))

        for j in range(10):
            if str(j) in s[s1+1:-1]:
                s2=s[s1+1:].index(str(j))+s1+1

                for k in range(10):
                    if str(k) in s[s2+1:]:
                        ans+=1

print(ans)


Measured memory_bytes: 9116
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    lint n, a;
    cin>>n>>a;
    Yes(n%500<=a);
}

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

int countOfDigits(unsigned long long n){
    int count = 0;
    while(n > 0){
        n /= 10;
        count++;
    }
    return count;
}

int f(unsigned long long int a, unsigned long long int b){
    int sampleA = countOfDigits(a);
    int sampleB = countOfDigits(b);
    return max(sampleA, sampleB);
}


int main(){
    unsigned long long N; cin >> N;
    unsigned long long b;
    int ans = 1000;
    for (unsigned long long a = 1; a <=sqrt(N); a++)
    {
        if(N % a != 0) continue;
        b = N / a;
        int tmp = f(a, b);
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    unsigned long long int a;
    unsigned long long int b;
    unsigned long long int n;
    unsigned long long int m;

    scanf("%llu %llu %llu", &n, &a, &b);

    if (a + b != 0)
    {
        if (n % (a + b) >= a)
        {
            printf("%llu\n", n / (a + b) * a + a);
            return (0);
        }
        else if (n % (a + b) < a)
        {
            printf("%llu\n", n / (a + b) * a + n % (a + b));
            return (0);
        }
    }
    else if (a + b == 0)
    {
        printf("%d\n", 0);
    }
    return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
void print (int);
 
int main() {
	int x;
	cin >> x;
	int a,b,c;
	a = x /100;
	b = (x % 100) /10;
	c = x % 10;
	print(a);
	print(b);
	print(c);
	cout << endl;

	return 0;
}

void print(int a) {
	if (a == 1) cout << 9;
	else cout << 1;
}


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

int main(){
    int N;
    scanf("%d\n",&N);
    int ans = 0;
    
    for( int i= 0; i < N; i++){
        int x;
        scanf("%d\n",&x);
        
        bool flag = true;
        for( int j = 2; j*j <= x; j++){
            if( x%j == 0){
                flag = false;
                break;
            }
        }
        if( flag ) ans++;
    }
    
    printf("%d\n",ans);
}


Measured memory_bytes: 3204
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    a, b = sc.intarr()
    print(lcm(a, b))


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(x, y):
    return (x * y) // gcd(x, y)


def natural_num(n):
    for j in range(2, int(math.sqrt(n))+1):
        if n % j == 0:
            return 0
    return 1


main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); 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; }
const ll INF = 1LL << 60;
int main(){
    string s; cin >> s;
    int ans;
    if(s=="SUN") ans = 7;
    if(s=="MON") ans = 6;
    if(s=="TUE") ans = 5;
    if(s=="WED") ans = 4;
    if(s=="THU") ans = 3;
    if(s=="FRI") ans = 2;
    if(s=="SAT") ans = 1;
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N;
    cin >> N;
    vec x(N), y(N);
    REP(i,0,N) cin >> x[i] >> y[i];

    double sum = 0;
    REP(i,0,N-1) {
        REP(j,i+1,N) {
            ll dx = x[i] - x[j];
            ll dy = y[i] - y[j];
            sum += sqrt(dx*dx+dy*dy);
        }
    }
    cout << setprecision(12) << sum / N * 2 << endl;



    return 0;
}

/*



*/

Measured memory_bytes: 384
A,B,C,D = [int(i) for i in input()]
op = ["+","-"]
for i in op:
    if i == "+":
        AopB = A + B
    else:
        AopB = A - B
    for j in op:
        if j == "+":
            AopBopC = AopB + C
        else:
            AopBopC = AopB - C
        for k in op:
            if k == "+":
                AopBopCopD = AopBopC + D
            else:
                AopBopCopD = AopBopC -D
            if AopBopCopD == 7:
                print(str(A)+i+str(B)+j+str(C)+k+str(D)+"=7")
                exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL n, m, d;
    cin >> n >> m >> d;

    if( d == 0 ) {
        printf( "%.12lf\n", 1.0 / n  *( m - 1 ) );

    } else {
        printf( "%.12lf\n", ( 2.0 * ( n - d ) ) / ( n * n ) * ( m - 1 ) );

    }
    return 0;
}



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

int main() {
  int N;
  string s;
  cin >> s;
  N = s.size();
  vector<bool> a(26,false);
  char c;
  int nn;
  
  for (int i=0; i<N; i++) {
    c = s[i];
    nn = c - 'a';
    a[nn] = true;
  }
  
  for (int i=0; i<26; i++) {
    if (!a[i]) {
      c = 'a' + i;
      cout << c << endl;
      break;
    }
    if (i==25) {
      cout << "None" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 764
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();

    let mut iter = s.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap(). parse().unwrap();

    if n % k == 0 {println!("0");}
    else {println!("1");}
}

Measured memory_bytes: 4352
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const int MAX = 200000 + 5;


int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pii>> g(n);
	for (int i = 0; i < m; i++) {
		int l, r, c;
		cin >> l >> r >> c;

		l--;
		r--;
		g[l].emplace_back(make_pair(r, c));
	}

	for (int i = 1; i < n; i++) {
		g[i].emplace_back(make_pair(i - 1, 0));
	}

	vector<ll> d(n, INF);
	vector<bool> isChecked(n);
	d[0] = 0;
	priority_queue<pii, vector<pii>, greater<pii>> pq;
	pq.push(make_pair(0, 0));
	while (!pq.empty()) {
		int v = pq.top().second;
		pq.pop();
		//cout << v << endl;
		if (isChecked[v]) {
			continue;
		}

		for (pii e : g[v]) {
			int u = e.first;
			int c = e.second;

			if (d[u] > d[v] + c) {
				d[u] = d[v] + c;
				pq.push(make_pair(d[u], u));
			}
		}
		isChecked[v] = true;
	}

	ll ans = d[n - 1];
	if (ans == INF) {
		ans = -1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10444
#include <bits/stdc++.h>
#define ll long long
#define N (1<<17)

using namespace std;

int n, w, h[2][N];
ll d[N], ans;

int main(){

	cin >> n >> w;

	for(int i=0; i<n; i++) cin >> h[0][i] >> h[1][i];

	for(int i=0; i<n; i++){
		for(int j=w; j>=h[0][i]; j--) d[j] = max(d[j], d[j-h[0][i]]+h[1][i]);
	}

	for(int i=0; i<=w; i++) ans = max(ans, d[i]);

	cout << ans << endl;

}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b));
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            ReadInt(out n, out m);
            var gates = Enumerable.Repeat(0, m).Select(_ =>
            {
                int l, r;
                ReadInt(out l, out r);
                return new { L = l, R = r };
            }).ToArray();

            int maxL = gates.Max(g => g.L), minR = gates.Min(g => g.R);
            int ans = minR >= maxL ? minR - maxL + 1 : 0;
            Console.WriteLine(ans);
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 24248
#include <stdio.h>
#include <math.h>
int main(){ 
  int N,M;
  int A[10000];
  int i;
  int ans[10000];
  scanf("%d %d",&N,&M);
  for(i=0;i<M;i++){
    scanf("%d",&A[i]);
  }
  ans[0]=N-A[0];
  for(i=1;i<M;i++){
    ans[i]=ans[i-1]-A[i];
  }
  if(ans[M-1]>=0){
    printf("%d",ans[M-1]);
  }
  else if(ans[M-1]<0){
    printf("-1");
  }
}	



Measured memory_bytes: 1808
using System;

namespace ABC150
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();

			string word = "ABC";
			int counter = 0;
			int index = s.IndexOf(word);
			int next;

			if(index >= 0)
			{
				counter++;

				while (true)
				{
					next = index + word.Length;

					if (next < s.Length)
					{
						index = s.IndexOf(word, next);

						if(index < next)
						{
							break;
						}

						counter++;
					}
					else
					{
						break;
					}
				}
			}

			Console.WriteLine(counter);
		}
	}
}


Measured memory_bytes: 13404
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict

sys.setrecursionlimit(10**7)
X = int(input())


def is_prime(n): 
    i = 2
    while i * i <=n:
        if n % i == 0:
            return False
        i += 1
    return True

for x in range(X, 10**6):
    if is_prime(x):
        print(x)
        break


Measured memory_bytes: 3316
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const C = parseInt(arg[0].split(" ")[1]);
    const K = parseInt(arg[0].split(" ")[2]);
    
    const T = arg.slice(1, N + 1).map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    let peopleNowRiding = [];
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        peopleNowRiding.push(T[i]);

        for(let j=i+1; j<=i+C; j++) {
            if(peopleNowRiding.length < C && T[j] - T[i] <= K) {
                peopleNowRiding.push(T[j]);
            } else {                
                i = j - 1;
                answer++;
                
                peopleNowRiding = [];
                break;
            }
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main()
{
	int n;
	cin >> n;
	while (n--) {
		int r;
		vector<int> v;
		while (cin >> r, r) {
			v.push_back(r);
		}
		int ma = -1, it = 0;
		int e[100] = {}, t[100] = {}, par[100] = {};
		vector<int> res[100];
		for (auto ri : v) {
			if (ri > 0) {
				int to = ma + 1;
				par[to] = it;
				if (to) {
					res[it].push_back(to);
					res[to].push_back(it);
					t[it]++;
				}
				t[to] = 1;
				e[to] = ri;
				it = to;
			}
			else {
				int to = it;
				for (int i = 0; i < abs(ri); i++) {
					to = par[to];
				}
				t[it]++;
				t[to]++;
				res[it].push_back(to);
				res[to].push_back(it);
			}
			ma = max(ma, it);
			while (it && e[it] == t[it]) {
				it = par[it];
			}
		}
		int sz = 0;
		while (e[sz]) sz++;
		for (int i = 0; i < sz; i++) {
			sort(res[i].begin(), res[i].end());
			cout << i + 1 << ' ';
			for (int j = 0; j < e[i]; j++) {
				cout << res[i][j] + 1 << " \n"[j + 1 == e[i]];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h> 
    using namespace std;
    typedef long long ll;
    const int N=2e5+5;

    int n,m;
    
    int f[N];
    int find(int x)
    {
        if(f[x]==x)
            return x;
        else
            return f[x]=find(f[x]);
    }
    
    int h[N];
    int ans;
    int main()
    {
        ios::sync_with_stdio(false);
        cin>>n>>m;
        for(int i=1;i<=n;i++)
            f[i]=i;
        for(int i=0;i<m;i++)
        {
            int x,y;
            cin>>x>>y;
            int tx=find(x);
            int ty=find(y);
            if(tx!=ty)
                f[tx]=ty;
        }
        for(int i=1;i<=n;i++)
        {
            h[find(i)]++;
            ans=max(ans,h[find(i)]);
        }
        cout<<ans<<endl;
        
    }

Measured memory_bytes: 10636
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
const double PI	 = 3.141592;
const int	 MOD = 1e9 + 7;
using namespace std;

void solve() {
	int n;
	int a[3][3];
	bool appear[3][3];
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	vector<int> b(n);
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}

	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			appear[i][j] = false;
			for (int k = 0; k < n; ++k) {
				if (a[i][j] == b[k]) appear[i][j] = true;
			}
		}
	}

	string ans("No");
	for (int i = 0; i < 3; ++i) {
		if (appear[i][0] && appear[i][1] && appear[i][2]) ans = "Yes";
	}
	for (int j = 0; j < 3; ++j) {
		if (appear[0][j] && appear[1][j] && appear[2][j]) ans = "Yes";
	}
	if (appear[0][0] && appear[1][1] && appear[2][2]) ans = "Yes";
	if (appear[0][2] && appear[1][1] && appear[2][0]) ans = "Yes";

	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

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

using namespace std;
int main()
{
  long long N, M, X, C[15], A[15][15], MONEY = 0, MIN_MONEY = -1;
  bool err = false;
  cin >> N >> M >> X;

  for (int j = 0; j < N; j++)
  {
    cin >> C[j];
    for (int k = 0; k < M; k++)
    {
      cin >> A[j][k];
    }
  }

  for (int j = 0; j < (1 << N); j++)
  {
    long long SCORE[15] = {0};
    err = false;
    MONEY = 0;
    for (int k = 0; k < N; k++)
    {
      if (j & (1 << k))
      {
        MONEY += C[k];
        for (int l = 0; l < M; l++)
        {
          SCORE[l] += A[k][l];
        }
      }
    }
    for (int l = 0; l < M; l++)
    {
      if (SCORE[l] < X)
      {
        err = true;
        break;
      }
    }
    if (!err && (MIN_MONEY < 0 || MIN_MONEY > MONEY))
    {
      MIN_MONEY = MONEY;
    }
  }

  if (MIN_MONEY < 0)
  {
    cout << "-1" << endl;
  }
  else
  {
    cout << MIN_MONEY << endl;
  }
}


Measured memory_bytes: 3536
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
struct Query 
{ 
    int l, r, idx; 
}; 
  

bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 	
} 
  

void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  

int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 

    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  

    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  

    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 

        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 

        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
int N,M,l,r;
int main() 
{ 
	cin >> N >> M;
    int arr[N];
    for(int i = 0;i<N;++i)
    	cin >> arr[i];
    Query queries[M]; 
    for(int i = 0;i<M;++i){
		cin >> l >> r;
		queries[i].l = l-1;
		queries[i].r = r-1;
		queries[i].idx = i;	
	}
    sort(queries, queries+M, cmp); 
    answeringQueries(arr, N, queries, M); 
    return 0; 
} 


Measured memory_bytes: 19428
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque

N = int(input())
edge = [[] for _ in range(N)]

for i in range(N-1):
    u,v,w = map(int, input().split())
    u, v, w = u - 1, v - 1, w % 2
    edge[u].append((v,w))
    edge[v].append((u,w))

ans = [-1] * N
queue = deque([0])

#頂点1を0色に塗る
ans[0] = 0

while queue:
    a = queue.popleft()
    for ve in edge[a]:
        if ans[ve[0]] == -1:
            if ve[1] == 0:
                ans[ve[0]] = ans[a]
            else:
                ans[ve[0]] = (ans[a]+1) % 2
            queue.append(ve[0])

for a in ans:
    print(a)

Measured memory_bytes: 93540
N,M,K=map(int,input().split())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))

sum_alist=[0]
for a in alist:
  sum_alist.append(sum_alist[-1]+a)
sum_blist=[0]
for b in blist:
  sum_blist.append(sum_blist[-1]+b)
  
index_b=M
answer=0
for i in range(N+1):
  sum_a=sum_alist[i]
  if sum_a>K:
    break
    
  while sum_a+sum_blist[index_b]>K:
    index_b-=1
    
  #print(i,index_b)
  answer=max(answer,i+index_b)
  
print(answer)

Measured memory_bytes: 134128
// 公式Youtubeより
// INFが大きすぎるとdp[j]+Bが負になってしまうので注意が必要
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> dp(h+1, INF);
    dp[0] = 0;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        rep(j,h) {
        int nj = min(j+a,h);
        dp[nj] = min(dp[nj], dp[j]+b);
        }
    }
    cout << dp[h] << endl;
    return 0;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

ll S(ll n) {
    string s = to_string(n);
    ll res = 0;
    REP(i, s.length()) { res += s[i] - '0'; }
    return res;
}
double snuke(ll n) { return (double)((double)n / (double)S(n)); }

ll fact(ll n) {
    ll res = 1;
    REP(i, n) { res *= 10; }
    return res;
}

ll K;
vector< pair<ll, double> > cand;
vector<ll> ans;

signed main()
{
    cin >> K;

    ll nines[16] = {};
    for(ll i = 1; i < 16; ++i) {
        nines[i] = nines[i-1] + fact(i-1) * 9;
    }

    // 強そうなやつを列挙
    for(ll i = 1; i < 10; ++i) { cand.push_back({i, 1}); }
    for(ll i = 0; i < 1000; ++i) {
        for(ll j = 1; j < 16; ++j) {
            ll tmp = i * fact(j) + nines[j];
            cand.push_back(make_pair(tmp, snuke(tmp)));
        }
    }
    SORT(cand);
    cand.erase(unique(cand.begin(), cand.end()), cand.end());

    // 最強ではなかったやつを消していく
    REP(i, cand.size()) {
        bool isStrong = true;
        for(ll j = i + 1; j < cand.size(); ++j) {
            if(cand[i].second > cand[j].second) {
                isStrong = false;
                break;
            }
        }
        if(isStrong) { ans.push_back(cand[i].first); }
    }

    // 答えの表示
    REP(i, K) {
        printf("%lld\n", ans[i]);
    }

    return 0;
}


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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second

#if 1
i64 calc(const vector<int>& A) {

  int N = A.size();

  // 偶数indexにはそこまでの偶数indexの数値の合計、
  // 奇数indexには（以下略）を入れる
  vector<i64> sums;
  sums.reserve(N);
  sums.push_back(A[0]);
  sums.push_back(A[1]);
  FOR(i, 2, N) {
    sums.push_back(A[i] + sums[i - 2]);
  }

  i64 result = INT64_MIN;
  int hn = N / 2;

  // 1個足したあとは必ず1回休み、を繰り返すが
  // フリーの休み回数がNが偶数のとき1、奇数のとき2あると考える
  // A. "足す"の位置を休みにすること
  // B. 休みになった"足す"は、1つ奥にずれる。それ以降もずれる

  if (N % 2 == 0) {
    // 偶数個

    // 休み1回目
    FOR(i, 0, hn + 1) {

      // この休み位置における合計
      i64 sum = 0;

      if (i > 0) {
        // ～ i +偶数index
        sum += sums[(i - 1) * 2];

        // i ～ -奇数index
        sum -= sums[i * 2 - 1];
      }

      // i ～ +奇数index
      sum += sums[N - 1];

      if (sum > result) result = sum;
    }
  }
  else {
    // 奇数個

    // 休み1回目
    /*
    FOR(i, 0, hn + 1) {
      // 休み2回目 (i == j もありうる)
      FOR(j, i, hn + 1) {

        // この休み回数での合計を計算
        i64 sum = 0;

        if (i > 0) {
          // ～ i +偶数index
          sum += sums[(i - 1) * 2];

          // i ～ j -奇数index
          sum -= sums[i * 2 - 1];
        }
        if (j > 0) {
          // i ～ j +奇数index
          sum += sums[j * 2 - 1];
        }

        // j ～ -偶数index
        sum -= sums[j * 2];

        // j ～ +偶数index
        sum += sums[N - 1];

        //cout << sum << " ";
        if (sum > result) {
          result = sum;
        }
      }
    }
    */

    // 休み位置に対しての、sumの変動をあらかじめ計算
    vector<i64> ic(hn + 1);
    FOR(i, 1, hn + 1) {
      ic[i] = sums[(i - 1) * 2] - sums[i * 2 - 1];
    }
    deque<pair<int, i64>> jc(hn + 1);  // 2回目の休み位置は、indexつきの配列にする
    F0R(j, hn + 1) {
      i64 c = 0;
      if (j > 0) c += sums[j * 2 - 1];
      c -= sums[j * 2];
      jc[j] = { j, c };
    }

    sort(jc.begin(), jc.end(), [](const pair<int, i64>& a, const pair<int, i64>& b) {
      return a.second > b.second;
    });

    F0R(i, hn + 1) {
      i64 sum = ic[i];
      // この1回目の休み位置に対する、最良な2回目の休み位置を求める
      while (jc.begin()->first < i) {
        jc.pop_front();
      }
      sum += jc.begin()->second;

      if (sum > result) result = sum;
    }

    result += sums[N - 1];
  }

  return result;
}

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

  int N;
  cin >> N;

#if 1

  // Solve
  vector<int> A(N);
  F0R(i, N) {
    cin >> A[i];
  }

  cout << calc(A);

#else

  // Generate test data
  vector<int> A(N);
  F0R(i, N) {
    //cout << (i + 1) << ' ';
    A[i] = -1000000000;
  }

  cout << calc(A);
#endif
}
#endif


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

using namespace std;

int main() {
    long long N;
    cin >> N;

    long long ans = 0;
    if (N % 2 == 1) {
        ans = 0;
    } else {
        N /= 2;
        while (N >= 5) {
            ans += N / 5;
            N /= 5;
        }
    }

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


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

//----------------------------------------



int main(void)
{


	int n;
	cin >> n;
	int l;
	cin >> l;


	int mini = 1000000000;
	int no = 0;

	for (int i = 1; i <= n; i++)
	{
		int aji = l + i - 1;

		if (abs(aji) < abs(mini))
		{
			mini = aji;
			no = i;
		}
	}

	int ans = 0;

	for (int i = 1; i <= n; i++)
	{
		if(i!=no) ans += l + i - 1;
	}


	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"os"
	"fmt"
	"bufio"
	"strings"
	"strconv"
)

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	ab    := strings.Split(sc.Text(), " ")
	a, _  := strconv.Atoi(ab[0])
	b, _  := strconv.Atoi(ab[1])
	
	if a <= b {
		fmt.Println(a)
	} else {
		fmt.Println(a - 1)
	}

}

Measured memory_bytes: 640