akhauriyash/Code-Regression huggingface dataset:
X = gets.to_i
K = gets.to_i
rs = [0] + gets.split.map(&:to_i) + [10**10]

sat_ub = [X]
sat_lb = [0]
val_lb = [0]
(1..K).each do |k|
    rd = rs[k] - rs[k-1]
    if k % 2 == 1   # パーツA減少
        if val_lb[k-1] - rd < 0
            val_lb[k] = 0
            sat_lb[k] = sat_lb[k-1] + (rd - val_lb[k-1])
        else
            val_lb[k] = val_lb[k-1] - rd
            sat_lb[k] = sat_lb[k-1]
        end
        sat_ub[k] = sat_ub[k-1]
        sat_lb[k] = sat_ub[k] if sat_lb[k] > sat_ub[k]
    else
        val_ub = val_lb[k-1] + sat_ub[k-1] - sat_lb[k-1]
        if val_ub + rd > X
            sat_ub[k] = sat_ub[k-1] - (val_ub + rd - X)
        else
            sat_ub[k] = sat_ub[k-1]
        end
        val_lb[k] = val_lb[k-1] + rd
        val_lb[k] = X if val_lb[k] > X
        sat_lb[k] = sat_lb[k-1]
        sat_ub[k] = sat_lb[k] if sat_ub[k] < sat_lb[k]
    end
end

Q = gets.to_i
Q.times do
    t, a = gets.split.map(&:to_i)
    ng, ok = K+1, 0
    while ng - ok > 1
        mid = (ng+ok)/2
        if rs[mid] < t
            ok = mid
        else
            ng = mid
        end
    end
    i = ok
    if a <= sat_lb[i]
        start = val_lb[i]
    elsif a <= sat_ub[i]
        start = val_lb[i] + a - sat_lb[i]
    else
        start = val_lb[i] + sat_ub[i] - sat_lb[i]
    end
    if i % 2 == 0 # パーツA減少
        result = start - (t - rs[i])
        result = 0 if result < 0
    else
        result = start + (t - rs[i])
        result = X if result > X
    end
    puts result
end



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

using namespace std;

int h, v;
vector<vector<char>> mappa;
vector<vector<long long>> memo;

long long paths(int i, int j) {
    if(i >= h || j >= v)
        return 0;

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

    if(i == h - 1 && j == v - 1) 
        return 1;
    else if(mappa[i][j] == '#')
        return 0;
    long long result = (paths(i + 1, j) % 1000000007) + (paths(i, j + 1) % 1000000007);
    memo[i][j] = result;
    return result;
}

int main() {
    cin >> h >> v;

    mappa = vector<vector<char>>( h, vector<char>( v));
    memo = vector<vector<long long>>(h, vector<long long>(v, -1));

    for(int i = 0; i < h; i++) 
        for(int j = 0; j < v; j++)
            cin >> mappa[i][j];

    long long result = paths(0,0) % 1000000007;

    cout << result << endl;

    return 0;
}



Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#define mmax 100000
#define nmax 300000
using std::cin;
using std::cout;
struct souv
{
    int l, r;
};
bool shorter(souv a, souv b)
{
    return a.r - a.l < b.r - b.l;
}
int n, m, bit[mmax+1], ans[nmax+1];
souv qr[nmax+1];
void upd(int p, int v)
{
    for(; p; p &= p - 1)
      bit[p] += v;
}
int get(int x)
{
    int sum = 0;
    for(; x <= m; x += x & (-x))
      sum += bit[x];
    return sum;
}
int main()
{
    cin >> n >> m;
    for(int q = 1; q <= n; ++q){
      cin >> qr[q].l >> qr[q].r;
      --qr[q].l;
    }
    std::sort(qr + 1, qr + n + 1, shorter);
    for(int i = 1, j = 1; i <= m; ++i){
      for(; j <= n && qr[j].r - qr[j].l < i; ++j){
        upd(qr[j].r, 1);
        upd(qr[j].l, -1);
      }
      ans[i] = n - j + 1;
      for(int k = i; k <= m; k += i)
        ans[i] += get(k);
    }
    for(int i = 1; i <= m; ++i)
      cout << ans[i] << ' ';
    return 0;
}


Measured memory_bytes: 4096
import math

ans = 0
K = int(input())
for i in range(1, K+1):
  for j in range(1, i):
    for k in range(1, j):
      ans += math.gcd(i, math.gcd(j, k)) * 6
    ans += math.gcd(i, j) * 3
  for k in range(1, i):
    ans += math.gcd(i, k) * 3
  ans += i
print(ans)

Measured memory_bytes: 9200
module Main where

import Data.Bool (bool)
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS


main :: IO ()
main = do
  [k,s] <- readIntList . head <$> plainInputs
  print $ sum $ tiles k s

tiles :: Int -> Int -> [Int]
tiles k s = do
  x <- [0..lim s]
  y <- [0..lim (s-x)]
  pure $ bool 0 1 $ inbound (s-x-y)
  where
    inbound a = 0 <= a && a <= k
    lim a = min a k


-- utils
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readIntList :: BS.ByteString -> [Int]
readIntList = unfoldr (BS.readInt . BS.dropWhile isSpace)

plainInputs :: IO [BS.ByteString]
plainInputs = BS.lines <$> BS.getContents


Measured memory_bytes: 892
n, k = gets.split.map(&:to_i)
h = Hash.new { 0 }

n.times do
  a, b = gets.split.map(&:to_i)
  h[a] += b
end

h.sort.each do |key, v|
  k -= v
  if k <= 0
    puts key
    exit
  end
end


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

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

        vector<string> vec(N);
        for (int i = 0; i < N; i++) {
            cin >> vec.at(i);
        }

        sort(vec.begin(), vec.end());

        string tmp = vec.at(0);
        int count = 1;
        for (int i = 1; i < N; i++) {
            if(tmp != vec.at(i))    count++;
            tmp = vec.at(i);
        }

        cout << count << endl;
    }

Measured memory_bytes: 9496
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
char str[7][5];
long long OP=1000000000LL;
long long TP=2000000000LL;
long long TC=3000000000LL;
long long ST=4000000000LL;
long long FL=5000000000LL;
long long FH=6000000000LL;
long long FC=7000000000LL;
long long SF=8000000000LL;
long long RF=9000000000LL;
int v[5];
long long yk(vector<int>c){
	std::sort(c.begin(),c.end());
	bool flash=false;
	bool royal=false;
	if(c[0]%4==c[1]%4&&c[0]%4==c[2]%4&&c[0]%4==c[3]%4&&c[0]%4==c[4]%4)flash=true;
	for(int i=0;i<5;i++)c[i]/=4;
	if(c[0]==0&&c[1]==9&&c[2]==10&&c[3]==11&&c[4]==12)royal=true;
	for(int i=0;i<5;i++)v[i]=0;
	long long sc=0;
	int rem=5;
	while(rem){
		sc*=14;
		int sh=0;
		int val=-1;
		int best=0;
		int bval=0;
		for(int i=0;i<5;i++){
			if(v[i])continue;
			if(c[i]==val){
				sh++;
			}else {
				val=c[i];sh=1;
			}
			if(best<sh||(best==sh&&(c[i]==0||bval<c[i]))){
				best=sh;
				bval=c[i];
				if(bval==0)bval=13;
			}
		}
		sc+=bval;
		for(int i=0;i<5;i++){
			if(!v[i]&&bval%13==c[i]){
				v[i]=1;rem--;
			}
		}
	}
	bool stra=true;
	for(int i=1;i<5;i++)if(c[i]!=c[i-1]+1)stra=false;
	if(royal&&flash)return RF;
	if(flash&&stra)return SF+c[4];
	if(c[0]==c[3]||c[1]==c[4])return FC+sc;
	if((c[0]==c[2]&&c[3]==c[4])||(c[0]==c[1]&&c[2]==c[4]))return FH+sc;
	if(flash)return FL+sc;
	if(royal){
		return ST+114514;
	}
	if(stra)return ST+c[4];
	if(c[0]==c[2]||c[1]==c[3]||c[2]==c[4])return TC+sc;
	if((c[0]==c[1]&&c[2]==c[3])||(c[0]==c[1]&&c[3]==c[4])||(c[1]==c[2]&&c[3]==c[4]))return TP+sc;
	if(c[0]==c[1]||c[1]==c[2]||c[2]==c[3]||c[3]==c[4])return OP+sc;
	return sc;
}
bool used[55];
int p[7];
int perm[8];
int main(){
	while(1){
		scanf("%s",str[0]);
		if(str[0][0]=='#')break;
		for(int i=1;i<7;i++)scanf("%s",str[i]);
		for(int i=0;i<55;i++)used[i]=false;
		for(int i=0;i<7;i++){
			int tmp=0;
			if(str[i][1]=='T')tmp=9;
			if(str[i][1]=='J')tmp=10;
			if(str[i][1]=='Q')tmp=11;
			if(str[i][1]=='K')tmp=12;
			if('2'<=str[i][1]&&str[i][1]<='9')tmp=str[i][1]-'1';
			tmp*=4;
			if(str[i][0]=='S')tmp+=3;
			if(str[i][0]=='H')tmp+=2;
			if(str[i][0]=='D')tmp++;
			p[i]=tmp;
			used[p[i]]=1;
		}
		int win=0;
		int tot=0;
		for(int i=0;i<52;i++)for(int j=0;j<52;j++){
			if(used[i]||used[j]||i==j)continue;
			perm[0]=perm[1]=0;
			for(int k=2;k<7;k++)perm[k]=1;
			long long A=0;
			long long B=0;
			do{
				vector<int>t;
				for(int k=0;k<7;k++)if(perm[k]){
					if(k<2)t.push_back(p[k]);
					else if(k<5)t.push_back(p[k+2]);
					else if(k==6)t.push_back(i);
					else t.push_back(j);
				}
				long long Y=yk(t);
		//		printf("%lld\n",Y);
				A=max(A,Y);
			}while(next_permutation(perm,perm+7));
			do{
				vector<int>t;
				for(int k=0;k<7;k++)if(perm[k]){
					if(k<2)t.push_back(p[k+2]);
					else if(k<5)t.push_back(p[k+2]);
					else if(k==6)t.push_back(i);
					else t.push_back(j);
				}
				long long Y=yk(t);
		//		printf("%lld\n",Y);
				B=max(B,Y);
			}while(next_permutation(perm,perm+7));
			if(A>B)win++;
			tot++;
		}
		printf("%.12f\n",(double)win/tot);
	}
}

Measured memory_bytes: 1068
// AOJ 2909 Nim without Zero
// 2018.4.5 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()  // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int main() {

	int N, a, b = 1, ans = 0;

	N = in();
	while (N--) {
		a = in();
		ans ^= a, b &= !(a & 1);
	}
	puts((ans == 1 || (ans == 0 && b))? "Bob": "Alice");
	return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
int b[200004],d[200004]={0};
ll c(ll a)
{
	if(a<2) return 0;
	return a*(a-1)/2;
}
int main()
{
	int n,i;
	ll s=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		d[b[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		s+=c(d[i]);
	}
	for(i=1;i<=n;i++)
	{
		printf("%lld\n",s-c(d[b[i]])+c(d[b[i]]-1));
	}
	return 0;
}

Measured memory_bytes: 3712
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

struct Line {
	int a, b, cost, time, company;
}lines[500];

struct Passpotr {
	int cost, company;
}pass[1 << 8];

ll pass_cost[1 << 8];

typedef long long W;

const W INF = 1LL << 50;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;

void dijkstra(int s, const Graph G, vector<W>& d) {
	priority_queue< P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(P(0, s));
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int toV(int n, int h) {
	return 25 * n + h;
}

Graph G(25 * 100);
vector<W> d(25 * 100);

int main() {
	int n, m, k, h, s, g, p;
	while(scanf("%d %d %d %d", &n, &m, &h, &k), n) {
		for(int i = 0; i < m; i++) {
			scanf("%d %d %d %d %d", &lines[i].a, &lines[i].b, &lines[i].cost, &lines[i].time, &lines[i].company);
			lines[i].a--, lines[i].b--, lines[i].company--;
		}
		scanf("%d %d %d", &s, &g, &p);
		s--, g--;

		for(int i = 0; i < p; i++) {
			int l;
			scanf("%d %d", &l, &pass[i].cost);
			pass[i].company = 0;
			for(int j = 0; j < l; j++) {
				int cp;
				scanf("%d", &cp);
				cp--;
				pass[i].company |= 1 << cp;
			}
		}

		for(int i = 0; i < 1 << k; i++) {
			pass_cost[i] = INF;
		}
		pass_cost[0] = 0;
		for(int i = 0; i < p; i++) {
			for(int j = 0; j < 1 << k; j++) {
				pass_cost[j | pass[i].company] = min(pass_cost[j | pass[i].company], pass_cost[j] + pass[i].cost);
			}
		}

		ll ans = INF;
		for(int free = 0; free < 1 << k; free++) {
			if(pass_cost[free] == INF) continue;


			for(int i = 0; i < n; i++) {
				for(int j = 0; j < 25; j++) {
					G[toV(i, j)].clear();
				}
			}

			for(int i = 0; i < m; i++) {
				Line l = lines[i];
				int c = l.cost;
				if(free & (1 << l.company)) c = 0;

				for(int j = 0; j < h; j++) {
					if(j + l.time > h) continue;
					G[toV(l.a, j)].push_back(edge{ toV(l.b, j + l.time), c });
					G[toV(l.b, j)].push_back(edge{ toV(l.a, j + l.time), c });
				}
			}

			dijkstra(toV(s, 0), G, d);
			for(int i = 0; i <= h; i++) {
				ans = min(ans, pass_cost[free] + d[toV(g, i)]);
			}
		}

		printf("%lld\n", ((ans == INF) ? -1 : ans));
	}
}

Measured memory_bytes: 2900
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<double> sum(N + 1);
    rep(i, N) {
        cin >> A[i];
        sum[i + 1] = A[i] + sum[i];
    }

    ll ans = INF;
    repd(i, 1, N - 2) {
        double l = sum[i + 1], r = sum[N] - sum[i + 1];
        int indexl = upper_bound(all(sum), l / 2.0) - sum.begin();
        ll l1 = INF, l2 = INF;
        if (indexl - 1 > 0) {
            l1 = abs(sum[indexl - 1] - (sum[i + 1] - sum[indexl - 1]));
        }
        if (indexl <= i) {
            l2 = abs(sum[indexl] - (sum[i + 1] - sum[indexl]));
        }
        int indexr = upper_bound(all(sum), l + (r / 2.0)) - sum.begin();
        ll r1 = INF, r2 = INF;
        if (indexr - 1 > i + 1) {
            r1 = abs((sum[indexr - 1] - sum[i + 1]) - (sum[N] - sum[indexr - 1]));
        }
        if (indexr <= N) {
            r2 = abs((sum[indexr] - sum[i + 1]) - (sum[N] - sum[indexr]));
        }
        vector<ll> res(4);
        if (l1 < l2) {
            res[0] = sum[indexl - 1];
            res[1] = sum[i + 1] - sum[indexl - 1];
        }
        else {
            res[0] = sum[indexl];
            res[1] = sum[i + 1] - sum[indexl];
        }
        if (r1 < r2) {
            res[2] = sum[indexr - 1] - sum[i + 1];
            res[3] = sum[N] - sum[indexr - 1];
        }
        else {
            res[2] = sum[indexr] - sum[i + 1];
            res[3] = sum[N] - sum[indexr];
        }
        sort(all(res));
        chmin(ans, res[3] - res[0]);
    }

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

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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

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



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
    string s;
    cin>>s;

   cout<<string(s.size(),'x')<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N, K;
struct Point {
  ll x, y;
};
vector<Point> points;

int main () {
  cin >> N >> K;
  points.resize(N);

  rep(i,N) cin >> points[i].x >> points[i].y;

  ll ans = 4e18+1;
  rep(i,N) for(int j = i; j < N; j++) for(int k = j; k < N; k++) for(int l = k; l < N; l++){
        ll xmin = min({points[i].x, points[j].x, points[k].x, points[l].x});
        ll xmax = max({points[i].x, points[j].x, points[k].x, points[l].x});
        ll ymin = min({points[i].y, points[j].y, points[k].y, points[l].y});
        ll ymax = max({points[i].y, points[j].y, points[k].y, points[l].y});
        int c = 0;
        for(auto &p: points) {
          if(p.x < xmin || p.x > xmax) continue;
          if(p.y < ymin || p.y > ymax) continue;
          c++;
        }
        if(c < K) continue;
        ans = min(ans, (xmax - xmin) * (ymax - ymin));
      }

  cout << ans << endl;

  return 0;
}


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

int a,b;
char op;

int main(){
    while(1){
        cin >> a >> op >> b;
        if(op == '+')
            cout << a + b << endl;
        else if(op == '-')
            cout << a - b << endl;
        else if(op == '*')
            cout << a * b << endl;
        else if(op == '/')
            cout << a / b << endl;
        else
            break;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define endl '\n'
#define ll long long
#define INF 1000000000
#define fast ios::sync_with_stdio(0);cin.tie(0);
int  fu[10200];
void build(){
 int n;
      for(int f=1;f<=100;f++)
      {
        for(int s=1;s<=100;s++)
     	 {
        	for(int t=1;t<=100;t++)
     	 	{
                  n=f*f+s*s+t*t+f*s+s*t+t*f;
              //cout<<f<<" "<<s<<" "<<t<<" "<<n<<endl;
        		if(n<=10000)
                {
      				fu[n]+=1;
                }
              else
                break;
     	 	}
     	 }
      }
  }
void solve(){
int n;
  cin>>n;
  for(int i=1;i<=n;i++) cout<<fu[i]<<endl;
}
int main()
{
  	build();
	solve();
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int tc, i, boss = 9;
    scanf("%d", &tc);
    int sum[tc];
    for(i = 0;i < tc;i++){
        scanf("%d", &sum[i]);
        if(sum[i] % 2 == 0){
            if((sum[i] % 3 == 0 || sum[i] % 5 == 0) && boss != 3){
                boss = 6;
            }
            else{
                boss = 3;
            }
        }
    }
    if(boss == 6 || boss == 9){
        printf("APPROVED\n");
    }
    else if(boss == 3){
        printf("DENIED\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define repP(i, a, b) for(int i = a; i < b; i++)
#define repM(i, a, b) for(int i = a - 1; i >= b; i--)

using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0, i = 0, j = 0;
  int num = 0, count = 0, ans = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  //char s1[200000], s2[200000], s3[200000];
  //string s1, s2, s3;
  
  cin >> a;
  for(i = 0; i < a; i++){
    cin >> a1[i];
  }
   
 for(i = 0; i < a; i++){
   for(j = i + 1; j < a; j++){
     b = a1[i] * a1[j];
     c += b;
    }
  }
  cout << c << endl;
}
  


Measured memory_bytes: 256
am,k= list(map(int,input().split()))
arr = list(map(int,input().split()))
if am == 1:
    print(0)
else:
    dp = [0]
    for i in range(1,am):
        m = 9999999999999
        for g in range(max(i-k,0),i):
            m = min(dp[g] + abs(arr[g]-arr[i]),m)
        dp.append(m)
    print(dp[-1])

Measured memory_bytes: 90236
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        w: usize,
        wv: [(usize, usize); n],
    }
    let mut dp = vec![vec![0; w + 1]; n + 1];

    for i in 0..n {
        for sum_w in 0..w+1 {
            let (w_, v_) = wv[i];
            if (sum_w >= w_) {
                dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w_] + v_)
            } else {
                dp[i+1][sum_w] = dp[i][sum_w]
            }
        }
    }

    println!("{}", dp[n][w]);
}


Measured memory_bytes: 106748
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C&lang=jp*/

#include <iostream>
#include <cmath>

#define MAX 1000000

#define hash(key,p)   ((key)%(p))
#define hash_a(key)   hash(key,MAX)
#define hash_b(key)   (hash(key,MAX-1)+1)
#define myhash(key, n) hash_a(hash_a(key)+(n)*hash_b(key))

using namespace std;

string s[MAX];

int getKey(string value){
    int key = 0;
    for(int i=0;i<value.length();i++){
        switch (value[i]) {
            case 'A':
                key += pow(5,i)*1;
                break;
            case 'C':
                key += pow(5,i)*2;
                break;
            case 'G':
                key += pow(5,i)*3;
                break;
            case 'T':
                key += pow(5,i)*4;
                break;
        }
    }
    return key;
}

bool insert(string value){
    int key = getKey(value);
    for (int j = 0; j<MAX; j++) {
        int h= myhash(key,j);
        if(s[h]==""){
            s[h]=value;
            return true;
        }else if(s[h]==value){
            return false;
        }
    }
}

bool search(string value){
    int key = getKey(value);
    for (int j = 0; true; j++) {
        int h= myhash(key,j);
        if(j>MAX+1 || s[h]==""){
            return false;
        }else if(s[h]==value){
            return true;
        }
    }
}

int main(){
    int n;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for (int i = 0; i < n; i++) {
        string ins;
        string value;
        cin >> ins >> value;
        if(ins=="insert"){
            insert(value);
        }else if(search(value)){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 21996
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

signed main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;

    vi res(N, 0);
    rep(i, N-1) {
        for(int j=i+1; j<N; j++) {
            int dis = j-i;
            dis = min(dis, abs(X-i)+1+abs(Y-j));
            res[dis]++;
        }
    }

    FOR(i, 1, N) cout << res[i] << endl;
 
    return 0;
}

Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 08, 2020 2:24 PM
 *    Problem Name  : C - Fennec vs Monster
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc153/tasks/abc153_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    ll n,k;
    cin >> n >> k;

    ll arr[n+1];
    for(ll i=0; i<n; i++) {
        cin >> arr[i];
    }
    sort(arr,arr+n);

    n = n-k;
    if(n <= 0) cout << "0" << endl;
    else {
        ll sum =0;
        for(ll i=0; i<n; i++) {
            sum += arr[i];
        }
        cout << sum << endl;
    }

    return 0 ;
}


Measured memory_bytes: 5168
from collections import deque

n, m = map(int, input().split())
e = [list(map(int, input().split())) for _ in range(m)]

res = 0
for i in range(m):
    edge = [[] for _ in range(n)]
    for j in range(m):
        if i == j:
            continue
        a, b = e[j]
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    
    flag = False
    for j in range(n):
        d = deque([j])
        visited = [False] * n
        visit_cnt = 0
        while d:
            node = d.popleft()
            visited[node] = True
            visit_cnt += 1
            for next_node in edge[node]:
                if not visited[next_node]:
                    d.append(next_node)
        if visit_cnt < n:
            flag = True
            break
    
    if flag:
        res += 1

print(res)

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

int dfs(int const &curr, vector<vector<int> > const &edges, map<int,bool> visited)
{
    int visits=0;
    for(auto &i: visited)
    {
        visits+=i.second;
    }
    //cout<<curr<<" "<<visits<<" "<<edges.size()<<endl;
    if(visits==edges.size())
    return 1;

    int ret=0;

    for(auto &i: edges[curr])
    {
        if(!visited[i])
        {
            visited[i]=true;
            ret+=dfs(i, edges, visited);
            visited[i]=false;
        }
    }
    
    return ret;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N,M;
    cin>>N>>M;
    vector<vector<int> > edges(N); 
    int x,y;
    for(int i=0 ; i<M ; ++i)
    {
        cin>>x>>y;
        --x;
        --y;
        edges[y].push_back(x);
        edges[x].push_back(y);
    }
    map<int, bool> visited;
    visited[0]=true;
    cout<<dfs(0, edges, visited)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  string s,t;
  cin>>s>>t;
  int ans=0;
  for (int i = 0; i < s.size(); ++i)
  {
    if(t[i]!=s[i]) ans++;
  }
  cout<<ans;
}

Measured memory_bytes: 3844
#include <stdio.h>
#define N 100005
#define Q -1
typedef struct{
  int p;
  int l;
  int r;
}Tree;
Tree tree[N];
int Deep[N];
void print(int x);
void de(int x, int p);

int main()
{
  int i,j,n,d,v,c,l,r;
  int deep,node,parent,depth;
  scanf ("%d",&n);

  for (i=0;i<n;i++){
    tree[i].p=Q;
    tree[i].l=Q;
    tree[i].r=Q;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	tree[v].l=c;

      }else{
	  tree[l].r=c;
      }
	l=c;
	tree[c].p=v;
    }
  }
	
    for(i=0;i<n;i++){
      if(tree[i].p==Q)
	r=i;
    }

    de(r,0);

    for(i=0;i<n;i++)
      print(i);
    return 0;
  }

  void print(int x){
    int i,c,node,parent,depth;
    printf("node %d: parent = %d, depth = %d, ",x,tree[x].p,Deep[x]);
  
    if(tree[x].p ==Q)
      printf("root, ");
    else if(tree[x].l ==Q)
      printf("leaf, ");
    else
      printf("internal node, ");

    printf("[");

    for(i=0,c=tree[x].l;c!=Q;i++,c=tree[c].r){
      if(i)
	printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }

 void de(int x, int p){
    Deep[x]=p;
    if (tree[x].r!=Q)//*同じ深さ設定*//
      de(tree[x].r,p);
    if (tree[x].l!=Q)//*左に+1*//
      de(tree[x].l,p+1);
  }
    
	
    




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

int main(){
    int n;
    cin>>n;
    int w[n];
    int sum = 0;
    for (int i=0;i<n;i++) {
        cin>>w[i];
        sum += w[i];
        }
    
    int abs_min = sum + 1;
    for (int i=0;i<n;i++){
        int lsum = 0;
        for (int j=0; j<=i; j++){
            lsum += w[j];
        }
        int rl_abs_min = abs((sum - lsum) - lsum);
        if (abs_min > rl_abs_min){
            abs_min = rl_abs_min;
        }
    }
    cout<<abs_min<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int floor[4][3][10]={{{}}},n,b,f,r,v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> b >> f >> r >> v;
        floor[b-1][f-1][r-1] += v;
    }
    for(int i =0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " " << floor[i][j][k];
            }
        cout << endl;
        }
    if(i!=3)
    cout << "####################" << endl;
    }
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		sc.nextLine();
		int[][] t = new int[N][3];
		for (int i=0;i<N;i++){
			t[i][0] = sc.nextInt();
			t[i][1] = sc.nextInt();
			t[i][2] = sc.nextInt();
		}
		int xHead = 0;
		int xTail = W;
		int yHead = 0;
		int yTail = H;
		int area = 0;
		for (int i=0;i<N;i++){
			if (t[i][2]==1){
				if (t[i][0]>=xHead){
					xHead = t[i][0];
				}
			}
			else if (t[i][2]==2){
				if (t[i][0]<=xTail){
					xTail = t[i][0];
					
				}				
			}
			else if (t[i][2]==3){
				if (t[i][1]>=yHead){
					yHead = t[i][1];
				}				
			}
			else if (t[i][2]==4){
				if (t[i][1]<=yTail){
					yTail = t[i][1];
				}					
			}
		}
		
		
		if ((xTail-xHead)<0||(yTail-yHead)<0){
			area=0;
		}
		else{
			area = (xTail-xHead)*(yTail-yHead);
		}
		

		System.out.println(area);
		
	}

}


Measured memory_bytes: 10316
n, k = map(int, input().split())
mod = 10 ** 9 + 7
ans = [None] * (n - k + 2)
ans[0] = ((n - k + 1 + n) * k // 2) - ((0 + k - 1) * k // 2) + 1

for i in range(1, n - k+2):
    ans[i] = (ans[i-1] + n - 2 * (k + i - 1)) % mod

print(sum(ans) % mod)


Measured memory_bytes: 16632
N,M=map(int,input().split())
grid=[[0 for i in range(M)] for j in range(N)]
moji=""
for i in range(N):
    moji=input()
    for j in range(len(moji)):
        grid[i][j]=moji[j:j+1]
    

X=0
Y=0
while(X<N or Y<M): # or Y<=M
    delflug=True
    if (X<N):
        for i in range(M):
            if grid[X][i]=="#":
                delflug=False
                break
        if delflug==True:
            del grid[X]
            N-=1
            X-=1
            
        X+=1    
    else:
        for i in range(N):
            if grid[i][Y]=="#":
                delflug=False
                break
        if delflug==True:
            for i in range(N):
                del grid[i][Y]
                
            M-=1
            Y-=1
            
        Y+=1    
for i in range(N):
    s="".join(grid[i])
    print(s)

Measured memory_bytes: 3188
N = int(input())

# dict = {i:0 for i in range(N)}
dict = {}
for i in range(N+1):
    if i % 2 == 1:
        dict[i] = 0
        for j in range(1, N+1):
            if i % j == 0:
                dict[i] += 1
            else:
                continue
    else:
        continue
# print(dict)
count = 0
for i in dict.values():
    if i == 8:
        count += 1
    else:
        continue

print(count)

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

#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

// one-based numbering
struct UnionFind {
    vector<int> data;
    // i: (data[i] < 0) -> group size, (data[i] > 0) -> parent;
    UnionFind(int n) {
        data.resize(n+1, -1);
    }
    int find(int x) {
        if(data[x] < 0) return x;
        else return data[x] = find(data[x]);
    }
    int size(int x) {
        return -data[find(x)];
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    GetInv(); GetFactorial();
    int n, x, y; cin >> n >> x >> y;
    vector<vector<pair<int, int>>> e(n);
    vector<int> col(n);
    for (int i = 0; i < n; i++) {
        int c, w; cin >> c >> w;
        col[i] = c;
        e[--c].emplace_back(w, i+1);
    }
    int inf = (int) 1e9 + 10;
    vector<pair<int, int>> pref(n+1, {inf, 0});
    UnionFind uf(n);
    for (int i = 0; i < n; i++) {
        sort(e[i].begin(), e[i].end());
        for (auto &p: e[i]) {
            if (p.first + e[i].front().first <= x) {
                uf.unite(p.second, e[i].front().second);
            }
        }
        pref[i+1] = pref[i];
        if (!e[i].empty()) pref[i+1] = min(pref[i+1], e[i].front());
    }
    pair<int, int> mini = {inf, 0};
    for (int i = n-1; i >= 0; i--) {
        for (auto &p: e[i]) {
            if (pref[i].first + p.first <= y) {
                uf.unite(pref[i].second, p.second);
            }
            if (mini.first + p.first <= y) {
                uf.unite(mini.second, p.second);
            }
        }
        if (!e[i].empty()) mini = min(mini, e[i].front());
    }
    vector<map<int, int>> mv(n+1);
    for (int i = 1; i <= n; i++) {
        int x = uf.find(i);
        mv[x][col[i-1]]++;
    } 
    long long ans = 1;
    for (auto &m: mv) {
        int sum = 0;
        for (auto &iter: m) {
            ans = ans * inv_factorial[iter.second] % mod;
            sum += iter.second;
        }
        if (sum != 0) ans = ans * factorial[sum] % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 35968
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    if(N < K){
        cout << 1 << endl;
    }else if(N%K==0)
    cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);


int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    map<char, string> m;
    cin >> m['a'] >> m['b'] >> m['c'];
    reverse(all(m['a']));
    reverse(all(m['b']));
    reverse(all(m['c']));
    char cur = 'a';
    while(1)
    {
        if(m[cur].size() == 0)
        {
            cout << char(cur - 'a' + 'A');
            return 0;
        }
        char c = m[cur].back();
        m[cur].pop_back();
        cur = c;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)

inf = 1<<60

def solve():
    N, M = map(int, sys.stdin.readline().split())
    edges = [None] * M
    Adj = [[] for i in range(N)]

    for i in range(M):
        ai, bi, ci = map(int, sys.stdin.readline().split())
        edges[i] = (ai - 1, bi - 1, -ci)
        Adj[bi - 1].append(ai - 1)

    reachable = [False] * N
    reachable[N - 1] = True
    dfs(N, Adj, reachable, N - 1)

    edges = [(ai, bi, ci) for (ai, bi, ci) in edges if reachable[ai] and reachable[bi]]

    ans = BellmanFord(N, M, edges)

    if ans is None:
        print('inf')
    else:
        print(-ans)

    pass

def dfs(N, Adj, visited, u):
    for v in Adj[u]:
        if not visited[v]:
            visited[v] = True
            dfs(N, Adj, visited, v)

def BellmanFord(N, M, edges):
    d = [inf] * N
    d[0] = 0

    for i in range(N - 1):
        for (ai, bi, ci) in edges:
            if d[ai] != inf and d[ai] + ci < d[bi]:
                d[bi] = d[ai] + ci

    for (ai, bi, ci) in edges:
        if d[ai] != inf and d[ai] + ci < d[bi]:
            return None

    return d[N - 1]

if __name__ == '__main__':
    solve()

Measured memory_bytes: 4212
using System;
using System.Linq;

namespace ABC139_A {
    class Program {
        static string S { get; }
        static string T { get; }
        static Program() {
            S = Console.ReadLine();
            T = Console.ReadLine();
        }

        static void Main(string[] args) {
            Console.WriteLine(
                S.ToCharArray()
                .Zip(T.ToCharArray(), (f, g) => new { SElem = f, TElem = g })
                .Count(f => f.SElem == f.TElem)
            );
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
  int x, y, z, k;
  ll t;

  cin >> x >> y >> z >> k;

  vector<ll> a, b, c;

  for (int i = 0; i < x; i++) {
    cin >> t; a.push_back(t);
  }
  for (int i = 0; i < y; i++) {
    cin >> t; b.push_back(t);
  }
  for (int i = 0; i < z; i++) {
    cin >> t; c.push_back(t);
  }

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

  sort(bc.begin(), bc.end(), greater<ll>());

  vector<ll> cand;

  int s = min(x*y, 3333);
  for (int i = 0; i < z; i++) {
    for (int j = 0; j < s; j++) {
      t = c[i] + bc[j];
      cand.push_back(t);
    }
  }
  sort(cand.begin(), cand.end(), greater<ll>());

  for (int i = 0; i < k; i++) {
    cout << cand[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 43256
#include <iostream>

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

	int q, r;
	bool flag = false;
	q = n;
	while(q != 0){
		r = q % 10;
		q = q / 10;
		if(r == 7)flag=true;
	}

	if(flag){
		std::cout << "Yes" << std::endl;
	}
	else{
		std::cout << "No" << std::endl;
	}

	return 0;
}


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

int main() {
    int k, x;
    cin>>k >>x;
    rep(i,k){
        cout<<x-k+1+i<<" ";
    }
    for(int i=1;i<k;i++){
        cout<<x+i<<" ";
    }
    cout<<endl;
}

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

int main () {
	int a, b, c, x, d=0;
    cin >> a >> b >>c;
	for (x = a; x <= b; x++){
    	if (c % x == 0 ){
			d++;
    	}
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 3104
n, k, s = tuple(map(int, input().split()))
a = []
if s >= 10**5:
    for i in range(k):
        a.append(s)
    for i in range(n-k):
        a.append(1)
else:
    for i in range(k):
        a.append(s)
    for i in range(n-k):
        a.append(10**9)
print(*a)

Measured memory_bytes: 6808
//setの利用
#include<iostream>
#include<set>
using namespace std;
int main(){
    int n;
    int d[110];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    set<int> values;//insertするときに重複削除される　valuesが変数名
    for(int i=0;i<n;i++){
        values.insert(d[i]);//重複なしでd[i]が挿入される
    }
    cout<<values.size()<<endl;//setのサイズが答え
}

Measured memory_bytes: 256
L,R = map(int,input().split())

ilist = list()
a=2*10**9
for i in range(R+1)[L:L+2020]:
  imod = i % 2019
  if imod in ilist:
    continue
  ilist.append(imod)
  for j in range(R+1)[i+1:i+1+2020]:
    jmod = j % 2019
    m = (imod * jmod) % 2019
    a = min(a,m)

print(a)

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

int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    while (a > 0 && a % 2 == 0) {
      ++ans;
      a >>= 1;
    }
  }
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  double m;
  cin >> n >> m;
  int a[105];
  for(int i = 0; i < n; i++){
  	cin >> a[i];
  }
  
  double sum = 0;
  for(int i = 0; i < n; i++){
  	sum += a[i];
  }
  
  sort(a, a + n, greater<int>());
  
  for(int i = 0; i < m; i++){
  	if(a[i] < sum / (4 * m)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX],color[MAX];
    
    for(int i=0; i<n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    //color[0] = GRAY;
    while (1) {
        minv = INFTY;
        int u = -1;
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u==-1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v]!=BLACK && M[u][v]!=INFTY){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u]+M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(int i=0; i<n; i++){
        //cout << i << " " << (d[i]==INFTY ? -1 : d[i]) << endl;
        cout << i << " " << d[i] << endl;
    }
}

int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = INFTY;
        }
    }
    
    int k,c,u,v;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k; j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    
    dijkstra();
}

Measured memory_bytes: 3132
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let mut m = m;
    let mut result = 0;
    if n > m / 2 {
        result += m / 2;
    } else {
        result += n;
        m -= 2 * n;
        result += m / 4;
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}

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

string s;
cin >> s;
if (s == "SUN") cout << 7 << endl;
if (s == "MON") cout << 6 << endl;
if (s == "TUE") cout << 5 << endl;
if (s == "WED") cout << 4 << endl;
if (s == "THU") cout << 3 << endl;
if (s == "FRI") cout << 2 << endl;
if (s == "SAT") cout << 1 << endl;








//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
void test1()
{
   string s,t;
   cin>>s>>t;
   int ans=0;
   for(int i=0;i<s.size();i++)
   {
       if(s[i]!=t[i])
        ans++;
   }
   cout<<ans;
}
int main()
{
   // cout << "Hello world!" << endl;
   test1();
    return 0;
}


Measured memory_bytes: 3916
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n;
    cin>>n;
    int i;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll num=1;
    ll ans=0;
    rep(i,n){
        if(a[i]==num){
            num++;
        }else{
            ans++;
        }
    }
    if(num==1){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1792
import sys;
lines = sys.stdin.readlines();

#配列の宣言
alfabet = {};

#値の格納
alfabet['A'] = 1;
alfabet['B'] = 2;
alfabet['C'] = 3;
alfabet['D'] = 4;
alfabet['E'] = 5;
alfabet['F'] = 6;

for i, line in enumerate(lines):
    #値を受け取り格納
    first,second = line.split();

if(alfabet[first]<alfabet[second]):
    print ("<");
elif(alfabet[first]>alfabet[second]):
    print (">");
else:
    print("=");


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, K, D[10];

bool valid(int n){
	string s = to_string(n);
	for(int i = 0; i < s.length(); i++)
		if(D[s[i] - '0']) return false;
	return true;
}

int main(void){
	//IO("test.in", "test.out");
	cin >> N >> K;
	for(int i = 0; i < K; i++){
		int j;
		cin >> j;
		D[j] = 1;
	}
	for(int i = N; i <= 99999; i++)
		if(valid(i)){
			printf("%d\n", i);
			break;
		}
}

Measured memory_bytes: 256