akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <string>
using namespace std;
const int INF = 1 << 29;

int sub(const string &ma, const string &mi) {
    assert(ma.size() == mi.size());
    int N = ma.size();
    for(int i=0; i<N; i++) {
        if(i < N - 2 and ma[i] != mi[i]) return INF;
    }

    int k = max(0, N - 2);
    int X = stoi(ma.substr(k)), Y = stoi(mi.substr(k));
    // fprintf(stderr, "ma = %s, mi = %s, X = %d, Y = %d\n",
    //        ma.c_str(), mi.c_str(), X, Y);
    return X - Y;
}

int solve1(const string &s, int d) {
    string ma(1, '0' - 1), mi(1, '9' + 1);
    int N = s.size();
    for(int i=0; i<N; i+=d) {
        string t = s.substr(i, d);
        ma = max(ma, t);
        mi = min(mi, t);
    }
    return sub(ma, mi);
}

int dp[100010][100];
int solve2(const string &s) {
    int N = s.size();
    fill(dp[0], dp[N+1], -INF);
    if(N > 1) dp[1][stoi(s.substr(0, 1))] = stoi(s.substr(0, 1));
    if(N > 2) dp[2][stoi(s.substr(0, 2))] = stoi(s.substr(0, 2));
    for(int i=1; i<N; i++) {
        for(int d=1; d<=2; d++) {
            if(i + d > N) continue;
            int v = stoi(s.substr(i, d));
            for(int j=0; j<100; j++) {
                // j (max), dp[i][j] (min), v
                int nj = max(j, v);
                int nk = min(dp[i][j], v);
                dp[i+d][nj] = max(dp[i+d][nj], nk);
            }
        }
    }

    int res = INF;
    for(int i=0; i<100; i++) {
        res = min(res, i - dp[N][i]);
    }
    return res;
}

int main() {
    string s; cin >> s;

    int N = s.size();
    vector<int> divs;
    for(int i=1; i*i<=N; i++) {
        if(N % i == 0) {
            divs.emplace_back(i);
            if(N / i != N) divs.emplace_back(N / i);
        }
    }

    int ans = 10;
    for(auto d : divs) ans = min(ans, solve1(s, d));
    // cerr << "# " << ans << endl;
    ans = min(ans, solve2(s));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 42404
def div(N):
    ans = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans


N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 2 == 1:
        di = []
        di = div(i)
        if len(di) == 8:
            ans += 1
print(ans)


Measured memory_bytes: 3060
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    int sum = 0, arr[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
        sum += arr[i];
    }
    int fl = floor((double)sum / (double)n);
    int cl = ceil((double)sum / (double)n);

    int suma = 0, sumb = 0;
    //printf("%d %d\n",fl,cl);
    for (int i = 0; i < n; i++)
    {
        suma += (arr[i] - fl) * (arr[i] - fl);
        sumb += (arr[i] - cl) * (arr[i] - cl);
    }

    printf("%d\n", min(suma, sumb));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> Uvw;
vector<vector<pair<int, int>>> Ver;
vector<int> Dista;
void dfs(int index, int base_dist) {
  if (Dista.at(index - 1) > -1) {
    return;
  }
  Dista.at(index - 1) = base_dist;
  for (pair<int, int> p : Ver.at(index - 1)) {
    // cout << p.first << " p " << p.second << endl;
    dfs(p.first, base_dist % 2 + p.second % 2);
  }
}

int main() {
  int N;
  cin >> N;
  Ver.resize(N);
  Dista.resize(N);
  fill(Dista.begin(), Dista.end(), -1);
  for (int n_i = 0; n_i < N - 1; n_i++) {
    vector<int> inp(3);
    cin >> inp.at(0) >> inp.at(1) >> inp.at(2);
    Ver.at(inp.at(0) - 1).emplace_back(inp.at(1), inp.at(2));
    Ver.at(inp.at(1) - 1).emplace_back(inp.at(0), inp.at(2));
    Uvw.emplace_back(inp);
  }

  // for (int n_i = 0; n_i < N - 1; n_i++) {
  //   for (int u_i = 0; u_i < 3; u_i++) {
  //     cout << Uvw.at(n_i).at(u_i) << " ";
  //   }
  //   cout << endl;
  // }
  // for (int v_i = 0; v_i < N; v_i++) {
  //   for (pair<int, int> p : Ver.at(v_i)) {
  //     cout << p.first << " p " << endl;
  //   }
  // }
  dfs(1, 0);
  for (int dist : Dista) {
    cout << dist % 2 << endl;
  }
}


Measured memory_bytes: 12464
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b){
  long long int *A = (long long int *)a;
  long long int *B = (long long int *)b;
  if(*A>*B) return 1;
  if(*A<*B) return -1;
  return 0;
}
int main(void){
  int n,i,mid;
  long long int ans=0;
  scanf("%d",&n);
  long long int a[n],b[n];
  for(i=0;i<n;i++) scanf("%lld",&a[i]);
  for(i=0;i<n;i++) b[i]=a[i]-i;
  qsort(b,n,sizeof(long long int),cmp);
  mid=b[n/2];
  for(i=0;i<n;i++){
    ans+=abs(b[i]-mid);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M; cin >> N >> M;
    map<int, ll> ma;

    ll accum = 0LL;
    for(int i=0; i<N; i++){
        ll a; cin >> a;
        accum += a;
        accum %= M;
        ma[accum]++;
    }
    ma[0]++;

    ll ans = 0;
    for(auto itr = ma.begin(); itr != ma.end(); itr++){
        ans += (itr->second)*(itr->second-1)/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <map>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	multimap<int, P> memo;
	for(int i = 1; i < 151; ++i)
	{
		for(int j = i + 1; j < 151; ++j)
		{
			memo.insert(map<int, P>::value_type(i * i + j * j, P(i, j)));
		}
	}
	int h, w;
	while(cin >> h >> w, h || w)
	{
		int diagonal = h * h + w * w;
		multimap<int, P>::iterator it = memo.begin();
		while(it != memo.end())
		{
			if(it->first == diagonal)
			{
				while(it->second.first != h && it->second.second != w)
				{
					++it;
				}
				++it;
				cout << it->second.first << " " << it->second.second << endl;
				break;
			}
			++it;
		}
	}
}

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

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

int main() {

  int N = 0;
  int X = 0;
  int Y = 0;

  cin >> N >> X >> Y;

  int ans[N - 1];

  for (int i = 0; i < N; i++) {
    ans[i] = 0;
  }

  int diff = Y - X - 1;

  for (int i = 1; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      int dis = j - i;
      if (i <= X && j >= Y) {
        dis = j - i - diff;
      } else if(i <= X && j > X && j < Y) {
        if (((X - i) + 1 + (Y - j)) < dis) {
          dis = (X - i) + 1 + (Y - j);
        }
      } else if(i > X && i < Y && j > X && j < Y) {
        if (((i - X) + 1 + (Y - j)) < dis) {
          dis = (i - X) + 1 + (Y - j);
        }
      } else if(i > X && i < Y && j >= Y) {
        if (((i - X) + 1 + (j - Y) < dis)) {
          dis = (i - X) + 1 + (j - Y);
        }
      }
      ans[dis - 1] = ans[dis - 1] + 1;
    }
  }

  for (int i = 0; i < N - 1; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
int main(){
  
	int a,b,c;
	b=1;
	for(a=1;a<=9&&b<=9;b++){
		c=a*b;
		cout<<a<<"x"<<b<<"="<<c<<endl;
		if(b==9){
			a++;
			b=0;
		}	
	}
	
	
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define MX 500000
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n; char s[MX+5];
lnt pw[MX+5], h[MX+5];
map <lnt, int> c; lnt cur, ans;
lnt p = 233, q = 7204522363551799129;
int main() {
	read(n), scanf("%s", s+1), cur = 1;
	for (int i = 1; i <= n; c[h[i++]]++) {
		if (s[i] ==	'+') h[i] = h[i-1]+cur;
		if (s[i] == '-') h[i] = h[i-1]-cur;
		if (s[i] == '>') cur *= p, h[i] = h[i-1];
		if (s[i] == '<') cur *= q, h[i] = h[i-1];
	}
	cur = 1;
	for (int i = 1; i <= n; c[h[i++]]--) {
		ans += c[h[n]*cur+h[i-1]];
		if (s[i] == '>') cur *= p;
		if (s[i] == '<') cur *= q;
	}
	return printf("%lld\n", ans), 0;
}


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

using namespace std;

int main() {
  int N;
  long long x;
  vector <long long> v;

  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    v.push_back(num);
  }
  sort(v.begin(), v.end());

  // cout << "---------" << endl;
  int rest = x;
  int num = 0;
  for (auto it = v.begin(); it != v.end(); it++){
    // cout << "rest:" << rest << "a_i:" << *it << endl;
    if (rest >= *it) {
      rest -= *it;
      num++;
    }
    // cout << *it << endl;
  }
  // あまったら一人犠牲になってもらう
  // cout << "num:" << num << "x:" << x << endl;
  if (rest > 0 && num == N) {
    // cout << "heru" << endl;
    num--;
  }
  cout << num << endl;
}


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

typedef long long int ll;
#define size 100002
ll n,k;
ll a[size],dp[size];

ll func(ll i)
{
	if(dp[i]!=-1)
		return dp[i];
	ll ma = 1e18;
	for(ll j=1;j<=k;j++)
		ma = min(ma , func(i-j) + abs(a[i]-a[i-j]));
	dp[i]=ma;
	return dp[i];
}

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> k;
	ll i,j;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		dp[i]=-1;
	}
	dp[1]=0;
	for(i=2;i<=k;i++)
	{
		ll ma=1e18;
		for(j=1;j<=k;j++)
		{
			if(i-j>=1)
				ma = min(ma , dp[i-j] + abs(a[i]-a[i-j]));
		}
		dp[i]=ma;
	}
	ll ans = func(n);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 6528
A, B = map(int, input().split())
answer = []

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
     
A_div = divisor(A)
B_div = divisor(B) 
common_div = list(set(A_div) & set(B_div))
common_div.sort()

for i in common_div:
  tmp = [1 for j in answer[1:] if i % j == 0]
  if len(tmp) == 0:
    answer.append(i)
    
print(len(answer))

Measured memory_bytes: 5220
import Control.Monad
import Data.List

main = do
  li <- getLine
  let [n,m] = map read $ words li
  scs <- forM [1..m] (\_ -> do
    li <- getLine
    let [s,c] = map read $ words li
    return (s,c)
    )
  let ans = compute n scs
  print ans

compute :: Int -> [(Int,Int)] -> Int
compute n scs = inner n
  where
    [c1,c2,c3] = [ nub $ findAll i scs | i <- [1..3] ]
    dig d c = if null c then d else head c
    d1 = dig 1 c1
    d2 = dig 0 c2
    d3 = dig 0 c3
    inner _ | bad c1 || bad c2 || bad c3 = -1
    inner 1 = dig 0 c1
    inner _ | d1 == 0 = -1
    inner 2 = d1 * 10 + d2
    inner 3 = d1 * 100 + d2 * 10 + d3

findAll x kvs = [ v | (k,v) <- kvs, x == k ]

bad []  = False
bad [_] = False
bad  _  = True


Measured memory_bytes: 508
def main():
    n = int(input())
    b_list = list(map(int, input().split()))
    ans = b_list[0] + b_list[n - 2]

    for i in range(1, n - 1):
        ans += min(b_list[i - 1], b_list[i])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61992
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <string>

int N, M;
std::vector<int> A;
long long ans;

int main() {
  std::cin >> N >> M;
  A.assign(M, 0);
  for (int i = 0; i < M; ++i) {
    std::cin >> A[i];
    ans -= A[i];
  }
  ans += N;
  if (ans >= 0) {
    std::cout << ans << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0 || a[i] % 5 == 0) continue;
			else {
				puts("DENIED");
				return 0;
			}
		}
	}
	puts("APPROVED");
	return 0;
}

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

typedef long long ll;
ll map[100000];
using namespace std;

int main(){
	int N;
	scanf("%d",&N);	
	for(int i = 0; i < N; i++) scanf("%lld",map+i);	
	sort(map,map+N);
	int i = 0;
	int ans = 0;
	while(i < N){
		int j = i;
		while(map[j] == map[i] && j < N) j++;
		ans += (j-i)%2;
		i = j;
	}
	printf("%d\n",ans);
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;


class UnionFindTree{
private:
  // indexの数の親ノード(ある集合の親を見つけたいときはここを直接参照せず、findを使う)
  vector<int> par;
  // indexを根とする木のランク
  vector<int> rank;
  // 集合のサイズ
  vector<int> cnts;
  // 木の最大値
  int treeSize;
public:
  UnionFindTree(int initTreeSize = 1000){
    // 引数で与えられた値を最大格納数とするUnionFindTreeの作成
    treeSize = initTreeSize;
    init(initTreeSize);
  }
  void init(int sz){
    par.clear(),rank.clear(),cnts.clear();
    treeSize=sz;
    for(int i = 0; i < sz; i++){
      par.push_back(i);
      rank.push_back(0);
      cnts.push_back(1);
    }
  }
  // 与えられた数が格納されている木のルートを探索
  int find(int x){  
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
  }
  // 和集合をとる。ただしここでは各集合の親の付け替えは起こらない
  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      par[x] = y;
      cnts[y]+=cnts[x];
    }
    else{
      par[y] = x;
      cnts[x]+=cnts[y];
      if(rank[y] == rank[x])rank[x]++;
    }
  }
  // xの属する集合のサイズ
  int getCnt(int x){
    return cnts[find(x)];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
    
};


int N;
int X[100010];
int Y[100010];
UnionFindTree uft(100010);

int main(){
    
    cin >> N;
    map<int, vector<int> > xs;
    map<int, vector<int> > ys;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> Y[i];
        xs[X[i]].push_back(i);
        ys[Y[i]].push_back(i);
    }


    for(auto &ary : {xs, ys}){
        for(auto &p : ary){
            auto &v = p.second;
            for(int i = 1; i < (int)v.size(); i++){
                uft.unite(v[0], v[i]);
            }
        }
    }
    
    // 同じ値に属するもの同士で分類
    map<int, vector<int> > cls;
    for(int i = 0; i < N; i++){
        cls[uft.find(i)].push_back(i);
    }

    ll ans = 0;
    for(auto p : cls){
        set<int> xs, ys;
        auto &v = p.second;
        for(int idx : v){
            xs.insert(X[idx]);
            ys.insert(Y[idx]);
        }
        ans += (ll)xs.size() * ys.size() - (int)v.size();
    }
    cout << ans << endl;
    
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=0;i<10;++i){
			for(int j=0;j<10;++j){
				for(int k=0;k<10;++k){
					for(int l=0;l<10;++l){
						if(i+j+k+l==n)++ans;
					}
				}
			}
		}
		cout<<ans<<"\n"s;
	}
}


Measured memory_bytes: 3132
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int64 a, b, c, k;
    cin >> a >> b >> c >> k;

    int64 ans = min(a, k);
    k -= a;
    k -= b;
    if (k > 0) ans -= min(c, k);

    print(ans);

    return 0;
}



Measured memory_bytes: 3636
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  for (char c = 'a'; c <= 'z'; c++) {
    if (c == s[0]) {
      Cout("a");
      return 0;
    }
  }
  Cout("A");

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,k,c=1;
    cin>>n>>k;
    while (n/k>0) {
        c++;
        n /= k;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int,input().split()))
    
    high = 0
    ans = 0
    for i in range(N):
        if A[i] < high:
            ans += (high - A[i])
        else:
            high = A[i]
            
    print(ans)
    
if __name__ == '__main__':
    main()

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

vector<int> res;

void Prime_factorize(int n){
  for(int i = 2 ; i*i <= n ; i++){
    while(n%i==0){
      res.push_back(i);
      n /= i;
    }
  }
  if(n != 1) res.push_back(n);
}

int main(){
  int n;
 
  cin >> n;
  cout << n << ':';

  Prime_factorize(n);

  for(int i = 0 ; i < res.size() ; i++){
    cout << " " << res[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;

int main() {
    int N;
    cin>>N;
    if(N==1)
    {
        cout<<0;
        return 0;
    }
    int h[N];
    
    for(int i=0;i<N;i++)
    {
        cin>>h[i];
    }
    
    int val[N];
    val[0]=0;
    val[1]=abs(h[1]-h[0]);
    for(int i=2;i<N;i++)
    {
        val[i]=min(abs(h[i]-h[i-1])+val[i-1],val[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<val[N-1];
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int answer = 0;
    if(n==1){
      answer = 2;
    }else if(n%2==0){
      answer = n;
    }else{
      answer = n*2;
    }
    System.out.println(answer);
  }
  

  
}

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


int main() {
	long long int n, m;
	cin >> n >> m;

	long long int ans;
	if (n > m / 2) {
		ans = m / 2;
	}
	else {
		ans = n + (m - n * 2) / 4;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
int n,m,k;
char a[10][10];
int main() {
    ios::sync_with_stdio(false);cin.tie(0);
  	cin>>n>>m>>k;
  	int sum=0;
  	for(int i=0;i<n;++i){
  		for(int j=0;j<m;++j){
  			cin>>a[i][j];
  			if(a[i][j]=='#') sum++;
  		}
  	}

  	int cnt=0;
  	int ans=0;
  	 for(int i=0;i<(1<<n);++i){
  	 	for(int j=0;j<(1<<m);++j){
  	 		cnt=0;
  	 		for(int r=0;r<n;++r){
  	 			for(int c=0;c<m;++c){
  	 				if( ((i&(1<<r)) || (j&(1<<c)))&& a[r][c]=='#') cnt++;
  	 			} 
  	 		}
  	 		if(cnt==sum-k) ans++;
  	 	}
  	 }

  	 cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3556
def gcd(n,m):
    if(n%m==0): return m
    else: return gcd(m,n%m)
a,b,c,d = map(int,input().split())
a-=1
x = b-b//c-b//d+b//(c*d//gcd(c,d))
y = a-a//c-a//d+a//(c*d//gcd(c,d))
print(x-y)


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

#define ll long long
#define Y printf("YES\n")
#define N printf("NO\n")
#define pb push_back
#define tp make_tuple
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
#define pi acos(-1)

using namespace std;

int main(){

     ll n,m,i,j,k,l,r,x,y,z,t;

     string s;

     cin>>s;

     char ch;

     n=s.size()-1;

     ch=s[n];

     if(ch=='s')cout<<s<<"es"<<endl;
     else cout<<s<<"s"<<endl;
}



Measured memory_bytes: 3628
#include<cstdio>
#include<iostream>
using namespace std;
char a[300010];
int l[300010],r[300010],n;
int main()
{
	scanf("%d",&n);scanf("%s",a+1);
	for (int i=1;i<=n;i++) {l[i]=l[i-1];if (a[i]=='W') l[i]++;}
	for (int i=n;i>=1;i--) {r[i]=r[i+1];if (a[i]=='E') r[i]++;}
	int ans=1e9;
	for (int i=1;i<=n;i++) ans=min(ans,l[i-1]+r[i+1]);
	printf("%d",ans);
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define maxn 200010
const int maxm=1<<26;
#define INF 0x3f3f3f3f
int dp[maxm];
char s[maxn];
int idx(char x)
{
	int ans=x-'a';
	return 1<<ans;
}
int main()
{
	memset(dp,INF,sizeof(dp));
	cin>>s;
	int n=strlen(s);
	dp[0]=0;
	int now=idx(s[0]);
	dp[now]=1;
	for (int i=1;i<n;i++)
	{
		now^=idx(s[i]);
		for (int j=0;j<=25;j++)
		{
			if (now^(1<<j)!=now) dp[now]=min(dp[now],dp[now^(1<<j)]+1);
		}
	}
	if (now==0) dp[now]=1;
	printf("%d\n",dp[now]);
	return 0;
}

Measured memory_bytes: 262656
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
#define FW freopen("data2.txt", "w", stdout);
//读入输出外挂，只适用于整数，使用时流同步打开，C语言不准关流
// getchar()<<cin(关流)<<scanf()<<cin
template <class T>
inline bool Read(T& ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}
//输出只能用于整数
template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}

void slove(int quetion_num)
{
    double a, b, c;
    cin >> a >> b >> c;
    if (a / c > b)
        cout << "No";
    else
        cout << "Yes";
}
int main()
{
    int num = 1;
    // cin >> num;
    for (int i = 1; i <= num; ++i) {
        slove(num);
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <stdbool.h>

int digit_sum(int n){
    int res=0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

int main(){
    int n;
    scanf("%d",&n);
    if(n%digit_sum(n)==0) printf("Yes\n");
    else printf("No\n");
}

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

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m],c[n][n],d[n][n];
    int INF=1e9;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        d[i][j]=INF;
        if(i==j) d[i][j]=0;
    }
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        cin>>c[a[i]][b[i]];
        c[b[i]][a[i]]=c[a[i]][b[i]];
        d[a[i]][b[i]]=c[a[i]][b[i]];
        d[b[i]][a[i]]=c[a[i]][b[i]];
    }



    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }


    int ans=0;
    bool used=false;



    for(int k=0;k<m;k++)
    {   
        used=false;
        for(int i=0;i<n;i++){
            if(d[i][b[k]]==d[i][a[k]]+c[a[k]][b[k]]) used=true;
        }

        if(!used) ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static int[][] graph;
	static int time;
	static int[] d, f;
	static boolean[] visited;
	
	static void visit(int node) {
		if(!visited[node]) {
			visited[node] = true;
			d[node] = time++;
			for(int i = 1; i < d.length; i++) {
				if(graph[node][i] == 1) {
					visit(i);
				}
			}
			f[node] = time++;
		}
	}
	
	public final static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			time = 1;
			graph = new int[n+1][n+1];
			d = new int[n+1];
			f = new int[n+1];
			visited = new boolean[n+1];
			for(int i = 0; i < n; i++) {
				int s = sc.nextInt();
				int k = sc.nextInt();
				for(int j = 0; j < k; j++) {
					graph[s][sc.nextInt()] = 1;
				}
			}
			for(int i = 1; i <= n; i++) {
				visit(i);
			}
			for(int i = 1; i <= n; i++) {
				System.out.println(i + " " + d[i] + " " + f[i]);
			}
		}
	}
}


Measured memory_bytes: 28140
from math import factorial,sqrt,ceil #,gcd

N,M = map(int,input().split())
MOD = 10**9 + 7

if abs(N-M)>=2:
    print(0)
    exit()

if N==M:
    ans = factorial(N) % MOD
    ans = ans * factorial(M) % MOD
    ans = ans * 2 % MOD  
    print(ans)
    exit()
elif N>M:
    ans = factorial(N) % MOD * factorial(M) % MOD
    print(ans)
    exit()
elif M>N:
    ans = factorial(M) % MOD * factorial(N) % MOD
    print(ans)
    exit()

Measured memory_bytes: 4088
def dfs(i)
  $visited[i] = true
  $d[i] = $cnt
  $cnt += 1
  $adj[i].each do |v|
    unless $visited[v]
      dfs(v)
    end
  end
  $f[i] = $cnt
  $cnt += 1
end
n = gets.to_i
$adj = []
$adj << Array.new(n){ |i| i+1 }
$d = Array.new(n+1,0)
$f = Array.new(n+1,0)
n.times { $adj << gets.split.map(&:to_i)[2..-1] }

$visited = Array.new(n+1)
$cnt = 0
dfs(0)

(1..n).each do |i|
  print i, " ", $d[i], " ", $f[i]
  puts
end

Measured memory_bytes: 8864
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>

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

using namespace std;

int main () {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    rep (i, n) {
        int h;
        cin >> h;
        if (h >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
    int n;
    int a = 0;
    int b = 0;
    int temp;
    vector<int> v;

    cin >> n;

    for(int i = 0; i < n; i++){
      cin >> temp;
      v.push_back(temp);
    }

    sort(v.begin(), v.end(), greater<int>());

    for (int i = 0; i < n; i++){
      if (i % 2 == 0) {
        a += v[i];
      }else{
        b += v[i];
      }
    }

    cout << a-b << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect_right

    a, b, q = map(int, input().split())
    s = [-float('inf')] + [int(input()) for _ in range(a)] + [float('inf')]
    t = [-float('inf')] + [int(input()) for _ in range(b)] + [float('inf')]

    # See:
    # https://img.atcoder.jp/abc119/editorial.pdf
    for _ in range(q):
        x = int(input())
        s_right = bisect_right(s, x)
        s_left = s_right - 1
        t_right = bisect_right(t, x)
        t_left = t_right - 1
        ans = float('inf')

        for si in [s[s_left], s[s_right]]:
            for ti in [t[t_left], t[t_right]]:
                ans = min(ans, abs(si - x) + abs(si - ti), abs(ti - x) + abs(si - ti))

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14200
#include <bits/stdc++.h>
using namespace std;
#define EPS                 0.00000001
#define LL_MAX              1e18
#define LL_MIN              -1e18
#define MAX                 0x3f3f3f3f
#define MIN                 -0x3f3f3f3f
#define MOD                 1000000007
#define DEBUG(x)            cout << '>' << #x << ':' << x << endl;
#define REP(i,n)            for(int i=0;i<(n);i++)
#define FOR(i,a,b)          for(int i=(a);i<=(b);i++)
#define FORD(i,a,b)         for(int i=(a);i>=(b);i--)
#define n1                  '\n'

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> pt;
typedef vector<pt> pol;

ll power(ll b, int e) {
    ll res = 1;
    for ( ; e>0; e/=2) {
        if (e&1) res = res*b % MOD;
        b = b*b % MOD;
    }
    return res;
}

inline void IOS() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll knapsack(vector<ll> w, vector<ll> v, int N, ll W) {
    ll K[N+1][W+1];
    FOR(i, 0, N) {
        FOR(j, 0, W) {
            if (i==0 || j==0) K[i][j] = 0;
            else if (w[i-1] <= j) {
                K[i][j] = max(v[i-1] + K[i-1][j-w[i-1]], K[i-1][j]);
            } else {
                K[i][j] = K[i-1][j];
            }
        }   
    }
    
    return K[N][W];
}

int main()
{
    IOS();
    int n, w;
    cin >> n >> w;
    vector<ll> ws(n);
    vector<ll> vs(n);
    REP(i, n) {
        cin >> ws[i];
        cin >> vs[i];
    }
    cout << knapsack(ws, vs, n, w) << n1;
    
    return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    ll ans=0,n,k, mod=1e9+7;
    cin>>n>>k;
    for(ll i=k;i<=1+n;i++) {
        ll mn,mx;
        mn = i*(i-1)/2;
        mx = n*i - mn;
        ans =(ans +  mx - mn + 1)%mod;
    }
    cout<<ans;
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 3592
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    let mut b = a.clone();
    b.sort_by_key(|x| -x);
    for i in a {
        println!("{}", if i == b[0] { b[1] } else { b[0] });
    }
}


Measured memory_bytes: 9724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e5+1000;
ll n,k,a[maxn],dif[maxn];
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n;i++) dif[i]=a[i]-a[i-1];
    ll mo=1000,num=0;
    for(int i=i;i<n;i++){
        if(dif[i]>0){
            num=floor(mo/a[i-1]);
            mo-=floor(mo/a[i-1])*a[i-1];
            mo+=num*a[i];
        }
    }
    cout<<mo<<endl;
    return 0;
}


Measured memory_bytes: 3636
h,w = map(int,input().split())
field = []
xx = [-1, -1, -1, 0, 0, 1, 1, 1]
yy = [-1, 0, 1, -1, 1, -1, 0, 1]
for i in range(h):
    field.append(input())

for i in range(h):
    line = ''
    for j in range(w):
        if field[i][j] == '#':
            line += '#'
        else:
            temp = 0
            for x,y in zip(xx,yy):
                if i+x < 0 or i+x > h-1:
                    continue
                elif j+y < 0 or j+y > w-1:
                    continue
                elif field[i+x][j+y] == '#':           
                    temp += 1
            line += str(temp)
                
    print(line)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] x = in.nextIntArray(n);
            int[] y = in.nextIntArray(m);

            long MOD = 1000000007;

            long xSum = 0;
            for (int i = 0; i < n - 1; i++) {
                long cnt = (long) (i + 1) * (n - 1 - i) % MOD;
                long sum = (x[i + 1] - x[i]) * cnt % MOD;
                xSum = (xSum + sum) % MOD;
            }

            long ySum = 0;
            for (int i = 0; i < m - 1; i++) {
                long cnt = (long) (i + 1) * (m - 1 - i) % MOD;
                long sum = (y[i + 1] - y[i]) * cnt % MOD;
                ySum = (ySum + sum) % MOD;
            }

            long ans = xSum * ySum % MOD;
            out.println(ans);
        }

    }

    static class InputReader {
        private BufferedReader in;
        private StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 45888
def f(a):
    if a < 10: return 1
    return f(a//10) + 1
n = int(input())
a = 0
ans = f(n)
while a * a <= n:
    a += 1
    if n % a > 0: continue;
    b = n // a
    ans = max(f(a), f(b))
    
print(ans)

Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <tuple>
#include <ctime>
#include <list>
#include <map>
#include <set>

#define REP(i,n) for(int i=0;i<(n);i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define SIZE(x) (int)(x).size()

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back

using namespace std;

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

const int MAXN = 1e5 + 10;

char s[MAXN];

int main() {
    int N, A, B;
    while (cin >> N >> A >> B) {
        scanf("%s", s);
        int a = 0, b = 0;
        REP(i, N) {
            if (s[i] == 'c') {
                puts("No");
            } else {
                if (a + b < A + B) {
                    if (s[i] == 'a') {
                        ++a;
                        puts("Yes");
                    } else if (b < B) {
                        ++b;
                        puts("Yes");
                    } else {
                        puts("No");
                    }
                } else {
                    puts("No");
                }

            }
        }
    }
    return 0;
}


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

int main() {

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

    bool flg = false;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK";
            return 0;
        }
    }

    cout << "NG";

}

Measured memory_bytes: 3628
N,M = map(int, raw_input().split())
EDGES = {}
d = [[float('inf') for j in range(N)] for i in range(N)]
for i in range(M):
  a,b,c = map(int, raw_input().split())
  a -= 1
  b -= 1
  EDGES[(min(a,b),max(a,b))] = c
  d[a][b] = c
  d[b][a] = c

for k in range(N):
  for i in range(N):
    for j in range(N):
      if(d[i][j] > d[i][k] + d[k][j]):
        d[i][j] = d[i][k] + d[k][j]

unused = 0
for e,v in EDGES.items():
  if v != d[e[0]][e[1]]:
    unused += 1
print unused

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	if (n == m) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int64_t> vec(N); 
  for (int i=0; i<N ; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  
  int64_t n = 1;
  int64_t r = 1000000000000000000LL;
  for (int i=0; i<N ; i++) {
    if (vec.at(i) == 0) {
      n = n*vec.at(i);
    }
    else if (n < r / (vec.at(i)) + 1) {
      n = n*vec.at(i);
    }
    else {
      n = -1;
      break;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 4028
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int a[n],d,c,ans=0;fill(a,a+n,0);
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>c;
      a[c-1]++;
    }
  }
  for(int i=0;i<n;i++){
    if(a[i]==0){ans++;}
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define sp putchar(' ')
#define en putchar('\n')
#define MOD(x) ((((x)%Mod)+Mod)%Mod)
#define int64_t int
const int MAXN = 1000005 ;
using namespace std ;

int n , m ;
int64_t a ;
bool isP[MAXN] ;
vector<int> primes ;
void getP() {
    memset(isP, true, sizeof(isP)) ;
    isP[0] = isP[1] = false ;
    primes.clear() ;
    for(int i = 2; i < MAXN; ++ i) {
        if(!isP[i]) continue ;
        primes.push_back(i) ;
        for(int j = 2;1LL*j*i < MAXN; ++ j) {
            isP[j * i] = false ;
        }
    }
}

int factor[20][2] ;
int factCnt ;

int getFactor(int x)
{
    factCnt = 0 ;
    for(int i = 0;primes[i] < x; ++ i) {
        if (isP[x]) break ;
        if (x % primes[i] == 0) {
            for (factor[factCnt][1] = 0;x % primes[i] == 0;x /= primes[i]) {
                ++ factor[factCnt][1] ;
            }
            factor[factCnt ++ ][0] = primes[i] ;
        }
    }
    if (x != 1) {
        factor[factCnt][1] = 1 ;
        factor[factCnt ++ ][0] = x ;
    }
    return factCnt ;
}

unordered_set<int64_t> s ;
int main()
{
    getP() ;
//    getFactor(24) ;

    ios::sync_with_stdio(false) ;
    while(cin >> n) {
        s.clear() ;
        int64_t gcds ;
        bool isOk = true ;
        for(int i = 1;i <= n; ++i) {
            cin >> a ;
            getFactor(a) ;
//            cout << "factors of "<< a<<":" << endl ;
//            for(int i = 0;i < factCnt; ++i) {
//                cout << factor[i][0] << "," << factor[i][1] << endl ;
//            }
            gcds = (i == 1)?a:__gcd(gcds, a) ;
            for(int j = 0;j < factCnt; ++j)  {
                if(s.count(factor[j][0])) {
                    isOk = false ;
                    break ;
                }
                s.insert(factor[j][0]) ;
            }
        }
        if(isOk) {
            cout << "pairwise coprime" << endl ;
        } else if(gcds == 1) {
            cout << "setwise coprime" << endl ;
        } else {
            cout << "not coprime" << endl ;
        }
    }
}


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

int main()
{
	int n;
	while( cin >> n ){
		int ans = -1000000000;
		int memo[ 101 ][ 101 ] = {0};
		for( int i = 1; i <= n; ++i ){
			for( int j = 1; j <= n; ++j ){
				cin >> memo[ i ][ j ];
			}
		}
		for( int i = 1; i <= n; ++i ){
			for( int j = 1; j <= n; ++j ){
				memo[ i ][ j ] += memo[ i ][ j - 1 ];
			}
		}
		for( int i = 1; i <= n; ++i ){
			for( int j = 1; j <= n; ++j ){
				memo[ i ][ j ] += memo[ i - 1 ][ j ];
			}
		}
		for( int by = 1; by <= n; ++by ){
			for( int ey = by; ey <= n; ++ey ){
				for( int bx = 1; bx <= n; ++bx ){
					for( int ex = bx; ex <= n; ++ex ){
						int a = memo[ ey ][ ex ];
						int b = memo[ by - 1 ][ ex ];
						int c = memo[ ey ][ bx - 1 ];
						int d = memo[ by - 1 ][ bx - 1 ];
						ans = max( ans, a - b - c + d );
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n,b[100000],c[100000],d[100000],a=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
	cin>>c[i];
  }
  for(int i=0;i<n;i++){
	d[i] = b[i] - c[i];
    if(d[i]>0){
      a += d[i];
    }
  }
  cout<<a<<"\n";
  return(0);
}

Measured memory_bytes: 256
open System

let read() = Console.ReadLine()

let N = read() |> int
let A = read().Split()
        |> Array.map(int)
        
A
|> Array.sortDescending
|> Array.indexed
|> Array.fold (fun acc x -> 
        if fst x % 2 = 0 then acc + (snd x)
        else                  acc - (snd x)
        ) 0
|> printfn "%i"        
                


Measured memory_bytes: 14160
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Jan 16 16:34:18 2019
//
package main

import "fmt"

const mod = 1e9 + 7

var dp = map[int]int{}

func fact(n int) int {
	if v, ok := dp[n]; ok {
		return v
	}
	dp[n] = (n * fact(n-1)) % mod
	return dp[n]
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	dp[0] = 1
	if N == M {
		fmt.Println((2 * (fact(N) * fact(M)) % mod) % mod)
	} else if N-1 == M || N == M-1 {
		fmt.Println((fact(N) * fact(M)) % mod)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 19072
#include<iostream>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    long long a,sum=0;
    cin>>a;
    for(int i=1;i<=a;i++)
    {
        if((i%3!=0) && (i%5!=0))
            sum+=i;
    }
    cout<<sum;

}




Measured memory_bytes: 3192