akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    int a_coin,total;
    scanf("%d\n%d",&total,&a_coin);
    int x=total/500;
    int b=x*500;
    if(b==total){
        printf("Yes\n");
    }
    else{
       int c=total-b;
        if(a_coin>=c){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
        return 0;
    }
}


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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  int x, y;
  Read(x), Read(y);
  printf("%d\n", x % y ? x : -1);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

    vt<std::string> S;
    std::string p,q;
    p += s[0];
    S.push_back(p);
    int tmp = 0;
    for (int i = 1; i < s.size(); ++i) {
      q += s[i];
      if(S[tmp] != q) {
        S.push_back(q);
        q.clear();
        ++tmp;
      }
    }

  std::cout << S.size() << '\n';
  return 0;
}


Measured memory_bytes: 10996
#include <iostream>

using namespace std;


void changeBinary( int target ){
	int i;
	char str[20] = {'0'};

	i = 0;
	while( target != 0 ){
		str[i] = target % 2 + '0';
		target /= 2;
		i++;
	}
	if( i == 0 ) cout << "00000000.0000";
	else{
		for( int j = 0;j < 12 - i;j++ ) cout << '0';
		for( int j = 0;j < i;j++ ){
			if( i - j == 4 ) cout << '.';
			cout << str[( i - 1) - j ];
		}
	}
	cout << endl;


}
int main(void)
{
	double n;

	while( cin >> n && n >= 0 ){
		n *= 16.0;

		if( n - (int)n || n >= ( 1 << 12 ) ){
			cout << "NA" << endl;
		} else {
			changeBinary( n );
		}

	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>

int main() {
	int arr[200003], n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	std::sort(arr, arr + n, std::greater<int>());
	long long ans = 0;
	for (int i = 1; i < n; i++) {
		ans += arr[i / 2];
	}
	printf("%lld", ans);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }

    cout << (H * W + 1) / 2 << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    args = input().split(' ')
    s = input()
    k = int(args[1])
    n = int(args[0])
    if k == 1:
        print(s[k - 1].lower() + s[k:])
    elif k == n:
        print(s[0:k-1] + s[k - 1].lower())
    else:
        print(s[0:k-1] + s[k - 1].lower() + s[k:])


Measured memory_bytes: 3060
def main():
    INF = 10**18
    N,K = map(int,input().split())
    x = list(map(int,input().split()))
    ans = INF
    for i in range(K-1,N):
        ans = min(ans,abs(x[i]-x[i-K+1])+min(abs(0-x[i]),abs(0-x[i-K+1])))
    print(ans)

if __name__ == '__main__':
    main()

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

void print(int a,bool f){
  cout << setw(5) << right << a;
  if(f)cout << endl;
}

int main(){
  int n;
  int a[10][10];
  int row[10],col;

  while(cin >> n,n){
    for(int i=0;i<n;i++){
      row[i] = 0;
      for(int j=0;j<n;j++)cin >> a[i][j];
    }

    for(int i=0;i<n;i++){
      col = 0;
      for(int j=0;j<n;j++){
	row[j] += a[i][j];
	col += a[i][j];
	print(a[i][j],0);
      }
      print(col,1);
    }

    col = 0;
    for(int i=0;i<n;i++){
      col += row[i];
      print(row[i],0);
    }
    print(col,1);
  }
}
      

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> a(M);
  REP(i, M) cin >> a[i];
  
  vector<int> b(N + 1,0);
  REP(i,M){
    b.at(a.at(i)) = 1;
  }
  int cnt = 0;
  REP(i,X){
    if(b.at(i) == 1){
      cnt++;
    }
  }

  cout << min(cnt,M-cnt) << endl;
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A,B;
    cin >> N >> A >> B;
    if(abs(B-A)&1) cout << "Borys" << bn;
    else cout << "Alice" << bn;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
LL k,a,b;
int main()
{
	k=read(),a=read(),b=read();
	if(a+2>=b||a+1>k)printf("%lld",k+1);
	else printf("%lld",b+(k-1-a)/2*(b-a)+(k-1-a)%2);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

const int M = 1000005;

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

  vector<int> cnt(M);
  for (int x : a)
  {
    if (cnt[x] != 0)
    {
      cnt[x] = 2;
      continue;
    }
    for (int j = x; j < M; j += x)
    {
      cnt[j]++;
    }
  }

  int ans = 0;
  for (int x : a)
  {
    if (cnt[x] == 1)
    {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 8032
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll q,h,s,d;
    cin >> q >> h >> s >> d;
    q *= 4;
    h *= 2;
    ll n;
    cin >> n;
    s = min({q,h,s});
    ll ans;
    if(s*2<=d){
        ans = n*s;
    }else if(n%2==1){
        ans = d*(n/2) + s;
    }else{
        ans = d*(n/2);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np 
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m = I[:2]
a, b, c = I[2:].reshape(m, 3).T
a -= 1; b -= 1
graph = np.zeros((n, n))
graph[a, b] = c

def main():
    dist = floyd_warshall(csgraph=csr_matrix(graph), directed=False)
    bl =  (dist[:, a] == dist[:, b] + c) | (dist[:, b] == dist[:, a] + c)
    res = np.any(bl, axis=0)
    ans = m - np.count_nonzero(res)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 26748
n, m = gets.rstrip.split(" ").map { |c| c.to_i}
a = gets.rstrip.split(" ").map {|c| c.to_i }

total = 0
a.each { |ai| total += ai }

cnt = 0
a.each do |ai|
    if ai >= total.to_f/(4*m) then
        cnt += 1
    end
end

if cnt >= m then
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B);
    rep(i, A) { cin >> s[i]; }
    s.push_back(INF), s.push_back(-INF), sort(all(s));

    rep(i, B) { cin >> t[i]; }
    t.push_back(INF), t.push_back(-INF), sort(all(t));

    rep(i, Q) {
        ll x;
        cin >> x;
        ll res = INF;
        ll first1, first2;
        first1 = lower_bound(all(s), x) - s.begin() - 1;
        first2 = upper_bound(all(s), x) - s.begin();
        rep(i, 2) {
            ll second1 = lower_bound(all(t), s[first1]) - t.begin() - 1;
            ll second2 = upper_bound(all(t), s[first1]) - t.begin();
            res =
                min(res, min(abs(x - s[first1]) + abs(s[first1] - t[second1]),
                             abs(x - s[first1]) + abs(s[first1] - t[second2])));
        }

        rep(i, 2) {
            ll second1 = lower_bound(all(t), s[first2]) - t.begin() - 1;
            ll second2 = upper_bound(all(t), s[first2]) - t.begin();
            res =
                min(res, min(abs(x - s[first2]) + abs(s[first2] - t[second1]),
                             abs(x - s[first2]) + abs(s[first2] - t[second2])));
        }

        first1 = lower_bound(all(t), x) - t.begin() - 1;
        first2 = upper_bound(all(t), x) - t.begin();

        rep(i, 2) {
            ll second1 = lower_bound(all(s), t[first1]) - s.begin() - 1;
            ll second2 = upper_bound(all(s), t[first1]) - s.begin();
            res =
                min(res, min(abs(x - t[first1]) + abs(t[first1] - s[second1]),
                             abs(x - t[first1]) + abs(t[first1] - s[second2])));
        }

        rep(i, 2) {
            ll second1 = lower_bound(all(s), t[first2]) - s.begin() - 1;
            ll second2 = upper_bound(all(s), t[first2]) - s.begin();
            res =
                min(res, min(abs(x - t[first2]) + abs(t[first2] - s[second1]),
                             abs(x - t[first2]) + abs(t[first2] - s[second2])));
        }

        cout << res << endl;
    }
}

Measured memory_bytes: 4576
import sys
input = sys.stdin.readline

N = int(input().strip())
x_ = 0
y_ = 0
t_ = 0

def f(t, x, y):
    t -= (abs(x) + abs(y))
    if t < 0 or t % 2 == 1:
        return False
    else:
        return True

ans = 'No'
for n in range(N):
    t, x, y = [int(x) for x in input().strip().split()]
    t, t_, x, x_, y, y_ = t - t_, t, x - x_, x, y - y_, y
    if not f(t, x, y):
        break

else:
    ans = 'Yes'

print(ans)

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if ((i - b + 0.1) * (j - a + 0.1) > 0) {
        cout << 0;
      } else {
        cout << 1;
      }
    }
    cout << '\n';
  }
  return 0;
}

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

struct union_find{
	int N;
	vector<int> parent;
	vector<int> siz;

	union_find(int N) : parent(N), siz(N, 1){
		for (int i = 0; i < N; i++) parent[i] = i;
	}

	int root(int x){
		if(parent[x] == x) return x;
		else return parent[x] = root(parent[x]);
	}

	void merge(int x, int y){
		x = root(x), y = root(y);
		if(x == y) return;
		if(siz[x] < siz[y]) swap(x, y);
		parent[y] = x;
		siz[x] += siz[y];
		siz[y] = 0;
	}

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

	int size(int x){
		return siz[root(x)];
	}
};

void dfs(vector<map<int, int>> &g, int v, set<int> &visited){
	if(visited.count(v) == 0){
		visited.insert(v);
		for(auto &&to : g[v]){
			if(to.second > 0){
				dfs(g, to.first, visited);
			}
		}
	}
}

int main(){
	int B = 200;
	int N, Q, i, j, k;
	scanf("%d%d", &N, &Q);
	vector<int> ins(Q), u(Q), v(Q);
	for(i = 0; i < Q; i++){
		scanf("%d%d%d", &ins[i], &u[i], &v[i]);
	}
	set<pair<int, int>> edges;
	for(i = 0; i * B < Q; i++){
		vector<int> will_use(N, 0);
		for(j = 0; j < B && i * B + j < Q; j++){
			k = i * B + j;
			will_use[u[k]] = 1;
			will_use[v[k]] = 1;
		}
		union_find uf(N);
		int ru, rv;
		for(auto &&e : edges){
			if(will_use[e.first] == 0 || will_use[e.second] == 0){
				uf.merge(e.first, e.second);
			}
		}
		vector<map<int, int>> g(N, map<int, int>());
		for(auto &&e : edges){
			if(will_use[e.first] == 1 && will_use[e.second] == 1){
				ru = uf.root(e.first);
				rv = uf.root(e.second);
				g[ru][rv]++;
				g[rv][ru]++;
			}
		}
		for(j = 0; j < B && i * B + j < Q; j++){
			k = i * B + j;
			ru = uf.root(u[k]);
			rv = uf.root(v[k]);
			if(ins[k] == 1){
				g[ru][rv]++;
				g[rv][ru]++;
			}
			else if(ins[k] == 2){
				g[ru][rv]--;
				g[rv][ru]--;
			}
			else{
				set<int> visited;
				dfs(g, ru, visited);
				if(visited.count(rv) == 1){
					printf("YES\n");
				}
				else{
					printf("NO\n");
				}
			}
		}
		for(j = 0; j < B && i * B + j < Q; j++){
			k = i * B + j;
			if(ins[k] == 1){
				edges.insert(pair<int, int>(u[k], v[k]));
			}
			else if(ins[k] == 2){
				edges.erase(pair<int, int>(u[k], v[k]));
			}
		}
	}
	return 0;
}


Measured memory_bytes: 6884
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      int i = 0;
      int a,b,c,k;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
     //   System.out.println(atai[i]);
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      a = num[0];
      b = num[1];
      c = num[2];
      k = num[3];
        maxCal(a,b,c,k);
        scan.close();
    }
  
  public static void maxCal(int A , int B, int C, int K){   
    int S,T;
    if(A >= K){
       System.out.println(K);
      return;
    }else if((A+B) >= K){
       System.out.println(A);
      return;
    }else{
       S = K-(A+B);
       T = A - S;
       System.out.println(T);
      return;
    }
  }
}

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

class FenwickTree {
private:
  vector<int> bit;
public:
  FenwickTree(int n) {
    bit.resize(n + 1);
  }
  void add(int idx, int val) {
    ++idx;
    while (idx < bit.size()) {
      bit[idx] += val;
      idx += idx & -idx;
    }
  }
  int sum(int idx) {
    ++idx;
    int res = 0;
    while (idx > 0) {
      res += bit[idx];
      idx -= idx & -idx;
    }
    return res;
  }
  int sum(int l, int r) {
    return sum(r) - sum(l - 1);
  }
};

const int MAX = 1e5 + 10;
int R, C, N;
vector<pair<int, int>> v;
map<int, int> cmp;

inline int calc(int x, int y) {
  if (x == 0) return y;
  else if (y == C) return C + x;
  else if (x == R) return C + R + C - y;
  else if (y == 0) return C + R + C + R - x;
  else return -1;
}

int main() {
  scanf("%d%d%d", &R, &C, &N);
  set<int> se;
  for (int i = 0; i < N; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    int buf1 = calc(x1, y1);
    int buf2 = calc(x2, y2);
    if (buf1 != -1 && buf2 != -1) {
      if (buf1 > buf2) {
        swap(buf1, buf2);
      }
      se.insert(buf1);
      se.insert(buf2);
      se.insert(buf2 + 1);
      v.emplace_back(make_pair(buf1, buf2));
    }
  }
  int cnt = 0;
  for (auto e : se) {
    cmp[e] = cnt++;
  }
  FenwickTree bit(cnt);
  for (auto p : v) {
    bit.add(cmp[p.first], 1);
    bit.add(cmp[p.second + 1], -1);
  }
  for (auto p : v) {
    if (bit.sum(cmp[p.first]) != bit.sum(cmp[p.second])) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 30324
#[allow(unused_macros)]
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 ) * } };
}
#[allow(unused_macros)]
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 ) * } };
}
#[allow(unused_macros)]
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,
        ss: [u64; n]
    }

    let sum = ss .iter().fold(0, |acc, &x| acc + x);
    let mut s = ss;
    s.sort();
    if sum % 10 != 0 {
        println!("{}", sum);
    } else {
        let mut j = None;
        for i in 0..n {
            if s[i] % 10 != 0 {
                j = Some(i);
                break;
            }
        }
        if let Some(src) = j {
            println!("{}", sum - s[src]);
        } else {
            println!("0");
        }
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var ans = 0;
            for (int n = 1; n <= N; n+=2)
            {
                var s = 0;
                for (int i = 1; i <= n; i++)
                {
                    if (n % i == 0) s++;
                }

                if (s == 8) ans++;
            }
            Println(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

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

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int main() {
  std::string a,b;
	cin >> a >> b;
  int len = a.length() - b.length();
  if (len > 0) {
    cout << "GREATER" << endl;
    return 0;
  } else if (len < 0) {
    cout << "LESS" << endl;
    return 0;
  } else {
    rep(i,a.length()) {
      if(a[i] > b[i]) {
        cout << "GREATER" << endl;
        return 0;
      }
      if (a[i] < b[i]){
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    cout << N * 800 - (N / 15) * 200 << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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(){
	string str;
	int n;
	cin >> str >> n;
	REP(i,n){
		string op,p;
		int a,b;
		cin >> op;
        if (op == "print") {
            cin >> a >> b;
            cout << str.substr(a, b-a+1) << endl;
        }
        if (op == "reverse") {
            cin >> a >> b;
            reverse(str.begin()+a,str.begin()+b+1);
        }
        if (op == "replace") {
            cin >> a >> b >> p;
            str.replace(str.begin()+a, str.begin()+b+1, p);
        }
	}
}

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

int n,h[100005],c[100005],k;

int main()
{
    cin>>n>>k;
    for (int i = 0;i<n;i++)
        cin>>h[i];
    for (int i = 1;i<=k;i++)
        c[i] = abs(h[0] - h[i]);

    for (int i = k+1;i<=n;i++)
    {
        long long m = 1e10;
        for (int j = 1;j<=k;j++)
        {
            if ((c[i-j] + abs(h[i] - h[i-j])) <= m)
                m = c[i-j] + abs(h[i] - h[i-j]);
            c[i] = m;
        }
    }
    cout<<c[n-1];
}


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

typedef pair<int,int> pii;
int table[16][1024] = {0};

int main() {
	int m;
	while(cin >> m, m) {
		vector<pii> v;

		for(int i = 0; i < 16; i++)
			for(int j = 0; j < 1024; j++)
				table[i][j] = 0;

		for(int i = 0; i < m; i++) {
			int a, b;
			cin >> a >> b;
			v.push_back(pii(a, b));
			//cout << a << " " << b << endl;
		}

		for(int i = 0; i <= v[0].second; i++)
			table[0][v[0].first * i] = 1;

		for(int i = 1; i < v.size(); i++) {
			for(int j = 0; j < 1024; j++) {
				for(int k = 0; k <= v[i].second; k++) {
					if(j - v[i].first * k >= 0) {
						table[i][j] += table[i - 1][j - v[i].first * k];
					}
				}
			}
		}

		int g;
		cin >> g;
		for(int i = 0; i < g; i++) {
			int n;
			cin >> n;
			cout << table[m - 1][n] << endl;
		}
	}
}

Measured memory_bytes: 1256
import sys

#O(ElogV)
import heapq
def dijkstra_heap(s, n, edges):
    # 始点sから各頂点への最短距離
    dist = [float("inf")] * n
    used = [True] * n # True:未確定
    dist[s] = 0
    used[s] = False
    used_edges = set()
    edgelist = []
    for (d, e) in edges[s]:
        # 利用した辺を管理するため、sも入れていることに注意
        heapq.heappush(edgelist, (d, e, s))
    while edgelist:
        d, e, s = heapq.heappop(edgelist)
        if dist[e] >= d:
            if s < e:
                used_edges.add((s, e))
            else:
                used_edges.add((e, s))

        # まだ使われてない頂点の中から最小の距離のものを探す
        if not used[e]:
            continue
        dist[e] = d
        used[e] = False

        """
        if s < e:
            used_edges.add((s, e))
        else:
            used_edges.add((e, s))
        """
        for (nd, ne) in edges[e]:
            if used[ne]:
                heapq.heappush(edgelist, (nd + dist[e], ne, e))
    return dist, used_edges

N, M = map(int, sys.stdin.readline().strip().split())

edges = [[] for _ in range(N)]
all_edges = set()
for _ in range(M):
    a, b, c = map(int, sys.stdin.readline().strip().split())
    edges[a-1].append((c, b-1))
    edges[b-1].append((c, a-1))
    if a < b:
        all_edges.add((a-1, b-1))
    else:
        all_edges.add((b-1, a-1))

for i in range(N):
    min_d, used_edges = dijkstra_heap(i, N, edges)
    # 利用した辺を取り除く
    all_edges -= used_edges

print(len(all_edges))

Measured memory_bytes: 55900
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;
 
#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 
 
const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
vector<vll> adj;
vll tin;
void dfs1(ll idx, ll parent, ll t) {
  tin[idx] = t;
  for(auto it: adj[idx]) {
    if(it == parent) continue;
    dfs1(it, idx, t+1);
  }
}
ll ans = 0;
void dfs(ll idx, ll parent, ll t) {
  // if(t <= tin[idx]) ans = max(ans, t%2 ? t : t-1);
  if(t <= tin[idx]) ans = max(ans, tin[idx]-1);
  // if(tin[idx] == 5) cout << idx << endl;
  for(auto it: adj[idx]) {
    if(it == parent) continue;
    dfs(it, idx, t+1);
  }
}
 
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, u, v;
  cin >> n >> u >> v;
  adj.resize(n+1), tin.resize(n+1, 0);
  for(ll i = 0; i < n-1; i++) {
    ll x, y;
    cin >> x >> y;
    adj[x].pb(y);
    adj[y].pb(x);
  }
  dfs1(v, -1, 0);
  dfs(u, -1, 0);
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n), c(n);
    
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }

    vector<vector<ll> > sum(n);
    vector<vector<ll> > ss(n);
    vector<vector<ll> > lg(n,vector<ll>(n,0));

    ll ans = -1000000001;

    for(int i = 0; i < n; i++){
        int pos = i;
        ll cnt = 0;
        ll p_ans = -1000000001;
        ss[i].push_back(0);
        sum[i].push_back(0);
        while(true){
            pos = p[pos];
            if(lg[i][pos] == 1) break;
            ss[i].push_back(c[pos]+ss[i][cnt]);
            cnt++;
            p_ans = max(p_ans, ss[i][cnt]);
            sum[i].push_back(p_ans);
            if(cnt == k) break;
            lg[i][pos] = 1;
        }
        if(k > cnt && ss[i][cnt] > 0){
            ll calc = (k/cnt) * ss[i][cnt];
            if(k%cnt == 0){
                if(sum[i][cnt] > ss[i][cnt]){
                    calc -= ss[i][cnt];
                    calc += sum[i][cnt];
                }
            } else {
                calc += sum[i][k%cnt];
            }
            p_ans = max(p_ans, calc);
        }
        ans = max(ans, p_ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 629988
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;
constexpr ll MOD = 1000000007;

#define rep(i, N) for(ll i=0; i<(N); ++i)

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


ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

template<typename T> inline string toString(const T &a) {
  ostringstream oss; oss << a; return oss.str();
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N) cin >> S[i];
  
  unordered_map<string, int> mp;
  rep(i, N) {
    if(mp.find(S[i]) == mp.end()) {
      mp.insert(make_pair(S[i], 1));
    } else {
      ++(*(mp.find(S[i]))).second;
    }
  }
  
  int mv = 0;
  for(auto m : mp) {
    mv = max(mv, m.second);
  }
  
  vector<string> mvs;
  for(auto m : mp) {
    if(m.second == mv) {
      mvs.push_back(m.first);
    }
  }
  
  sort(mvs.begin(), mvs.end());
  
  for(auto mv : mvs) {
    cout << mv << endl;
  }
}


Measured memory_bytes: 29892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c, cnt=0;
    cin >> a >> b >> c;
    if(c>b) swap(b,c);
    if(b>a) swap(a,b);
    if(c>b) swap(b,c);
    cnt=a-b;
    if((b-c)%2==0) cnt+=(b-c)/2;
    else cnt+=((b-c)/2+2);
    cout << cnt;
}


Measured memory_bytes: 256
function main(s) {
	a = s.split("\n")[0].split(" ").map(x => Number(x));
	s = s.split("\n")[1];
	if (s.length != a[0]+a[1]+1) {console.log("No"); return;};
	if (s[a[0]] != "-") {console.log("No"); return;};
	for (var i = 0; i < s.length; i++) {
		if (i != a[0] && s[i] === "-") {console.log("No"); return;};
	}
	console.log("Yes");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#include<stdio.h> 
int main(void)
{
 int a[10001],n,i,min,max;
 long sum = 0;
 scanf("%d",&n);
 for(i = 0;i < n;i++){ 
scanf("%d",&a[i]);
 if(i == 0){
 min = a[i]; 
 max = a[i];
 } 
else{
 if(min>a[i]){
 min = a[i];
 } 
else if(max<a[i])
{ max = a[i]; }
 } 
sum += (long)a[i];
 } 
printf("%d %d %ld\n",min,max,sum);
 return 0;
 } 





Measured memory_bytes: 2048
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int [] array = new int[n];
		for(int i = 0; i < n; i++) {
			array[i] = stdIn.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			if(array[i] == 1) {
				break;
			}
			if(i == n-1) {
				System.out.println(-1);
				System.exit(0);
			}
		}
		
		int cnt = 1;
		int ans = 0;
		for(int i = 0; i < n; i++) {
			if(array[i] != cnt) {
				ans++;
			}else {
				cnt++;
			}
			
		}
		
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 80780
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
coin_sum = 0
for d in range(a+1):
    for e in range(b+1):
        for f in range(c+1):
            coin_sum = 500*d+100*e+50*f
            if(coin_sum == x):
                count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A;
  A = N;
  int B;
  int C;
  int D;
  int E;
  int F;
  int G;
  int H;
  int I;  
  
  B = A / 100000000;
  A = A - B * 100000000;
  C = A / 10000000;
  A = A - C * 10000000;
  D = A / 1000000;
  A = A - D * 1000000;
  E = A / 100000;  
  A = A - E * 100000;
  F = A / 10000;
  A = A - F * 10000;
  G = A / 1000;
  A = A - G * 1000;
  H = A / 100;
  A = A - H * 100;
  I = A / 10;
  A = A - I * 10;
  if ( N % ( A + B + C + D + E + F + G + H + I ) == 0 ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n = list(input())

a = n[0:2]

b = n[2:]
a = int("".join(a))
b = int("".join(b))

if 1 <= a and a <= 12:
	if 1 <= b and b <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= b and b <= 12:
		print("YYMM")
	else:
		print("NA")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  vector<int> v(5);
  REP(i,5) {
    cin >> v[i];
  }
  int k;
  cin >> k;

  bool flg = true;
  REP(i,4) {
    FOR(j,i+1,5) {
      if (abs(v[i] - v[j]) > k) flg = false;
    }
  }

  if(flg) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

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

// 
int main() {
    int a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << i + 1;
            return 0;
        }
    }
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{

    int i_inputBingoNum[9];
    int i_repeatNum;
    char c_bingoCheckFlag = 0;
    int i_checkNumFlag[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};

    for (int index = 0; index < 9; index++)
    {
        scanf("%d", &i_inputBingoNum[index]);
    }

    scanf("%d", &i_repeatNum);

    int i_inputJudgeNum[i_repeatNum];

    for (int index = 0; index < i_repeatNum; index++)
    {
        scanf("%d", &i_inputJudgeNum[index]);
    }

    for (int index = 0; index < i_repeatNum; index++)
    {
        for (int index2 = 0; index2 < 9; index2++)
        {
            if (i_inputJudgeNum[index] == i_inputBingoNum[index2])
            {
                i_checkNumFlag[index2] = 1;
            }
        }
    }

    if ((i_checkNumFlag[0] == 1 && i_checkNumFlag[1] == 1 && i_checkNumFlag[2] == 1) ||
        (i_checkNumFlag[0] == 1 && i_checkNumFlag[3] == 1 && i_checkNumFlag[6] == 1) ||
        (i_checkNumFlag[0] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[8] == 1) ||
        (i_checkNumFlag[1] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[7] == 1) ||
        (i_checkNumFlag[2] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[6] == 1) ||
        (i_checkNumFlag[2] == 1 && i_checkNumFlag[5] == 1 && i_checkNumFlag[8] == 1) ||
        (i_checkNumFlag[3] == 1 && i_checkNumFlag[4] == 1 && i_checkNumFlag[5] == 1) ||
        (i_checkNumFlag[6] == 1 && i_checkNumFlag[7] == 1 && i_checkNumFlag[8] == 1))
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

}

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

using namespace std;

typedef long long ll;
int main()
{
  int n,k;

  cin >> n >> k;

  int ans=0;

  int maxk = n-k+1;
  ans = maxk-1;
  if(k==1){
    ans = 0;
  } 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n, a, b;
    cin >> n;
    if(n == 1) puts("Hello World");
    else {
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int calc(pii a, pii b)
{
	if (a.first > b.first) swap(a, b);
	int sx = a.first, sy = a.second;
	int gx = b.first, gy = b.second;
	int x = abs(gx - sx), y = abs(gy - sy);
	int res = 0;
	if (sy < gy)
	{
		res = max(x, y);
	}
	else
	{
		res = x + y;
	}
	return res;
}

int main()
{
	cin.sync_with_stdio(false);
	int w, h, n;
	cin >> w >> h >> n;
	vector<pii> v;
	REP(i, n)
	{
		int a, b; cin >> a >> b;
		v.emplace_back(a, b);
	}
	int ans = 0;
	REP(i, n - 1) ans += calc(v[i], v[i + 1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3156
main = do
  (h:w:_) <- return . (map read) . words =<< getLine
  print $ minimum [h * f (mod h 3),w * f (mod w 3), g w h, g h w]

  where
    f 0 = 0
    f n = 1

    g w h = minimum [mm [h*x, hf*(w-x), (h-hf)*(w-x)] |x<-[1..w-1]]
      where
        hf = div h 2

    mm xs = maximum xs - minimum xs


Measured memory_bytes: 892
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

const int mod = 998244353;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this); return res/=a;}
};
mint mod_pow(long long p,long long q){mint res = p;return res.pow(q);}

struct Combination{
    const int MAX = 500050;
    vector<mint> fact;
    Combination(){
        fact.resize(MAX);
        for(int i = 0;i < MAX;i++){
            if(i == 0)fact[i] = (mint)1;
            else fact[i] = fact[i-1]*(mint)i;
        }
    }
    mint comb(int n,int r){
        if(n<0||r<0||n<r)return 0;
        else return fact[n]*fact[r].inv()*fact[n-r].inv();
    }
};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    ll N,A,B,K;cin >> N >> A >> B >> K;
    mint ans = 0;
    Combination C;
    for(ll a = 0;a <= N;a++){
        if((K - a*A) % B == 0){
            ll b = (K - a*A) / B;
            ans += C.comb(N,a) * C.comb(N,b);
        }
    }
    cout << ans.x << '\n';
    return 0;
}
/*
 * ちょっと待って！
 * そのコード本当に提出して大丈夫？
 * たくさんのコーナーケースがあるよ！
 * 君の注意力は大したことないよ！
 * WAを出すと君は冷静さを失うよ！
 * */


Measured memory_bytes: 4224
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        System.out.println(solve(in));
        
      }
      
      public static String solve(Scanner in) {
       Long X = in.nextLong();
       int points = 0;

        while (X >= 500) {
          X -= 500;
          points += 1000;
        }

        while (X >= 5) {
          X-= 5;
          points += 5;
        }
        return String.valueOf(points);
      }
      
    
}

Measured memory_bytes: 41168
#include<bits/stdc++.h>
#define bye return 0
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    char c;
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int a, b, d;
     a = n-k;
     b = n-a;
     int yen1=0, yen2=0;
    for(int i=1; i<=n; i++){
       if(i<=b){
       	yen1 += x;
       }else{
       	yen2 += y;
       }


    }

    cout << yen1+yen2 << "\n";

  
   bye;

}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int MAXN=1E5+10;
const int MAXK=16;
const int P=1E9+7;

template<typename T1,typename T2>
	void Inc(T1 &a,T2 b){a+=b;if(a>=P) a-=P;}

template<typename T1,typename T2>
	void Dec(T1 &a,T2 b){a-=b;if(a<0) a+=P;}

template<typename T1,typename T2>
	T1 Add(T1 a,T2 b){a+=b;return a>=P?a-P:a;}

template<typename T1,typename T2>
	T1 Sub(T1 a,T2 b){a-=b;return a<0?a+P:a;}

ll ksm(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,(a*=a)%=P)
		if(b&1)
			(ret*=a)%=P;
	return ret;
}

int n,m,a[MAXK+2],f[2][1<<MAXK];
ll fac[MAXN],ifac[MAXN];

ll C(int n,int m)
{
	if(n<0||m<0||n<m)
		return 0;
	return fac[n]*ifac[n-m]%P*ifac[m]%P;
}

int main()
{
	scanf("%d%d",&n,&m);
	int lim=1<<n;
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	fac[0]=ifac[0]=1;
	for(int i=1;i<=lim;i++)
		fac[i]=fac[i-1]*i%P;
	ifac[lim]=ksm(fac[lim],P-2);
	for(int i=lim-1;i;i--)
		ifac[i]=ifac[i+1]*(i+1)%P;
	int lst=0;
	f[lst][0]=1;
	for(int i=m;i;i--)
	{
		memcpy(f[!lst],f[lst],sizeof f[!lst]);
		for(int s=0;s<1<<n;s++)
			if(f[lst][s])
				for(int j=0;j<n;j++)
					if(!((s>>j)&1))
						Inc(f[!lst][s|(1<<j)],f[lst][s]*C(lim-s-a[i],(1<<j)-1)%P*fac[1<<j]%P);
		lst^=1;
	}
	ll Ans=0;
	for(int s=0;s<1<<n;s++)
	{
		if(__builtin_popcount(s)&1)
			Dec(Ans,f[lst][s]*fac[lim-s-1]%P);
		else
			Inc(Ans,f[lst][s]*fac[lim-s-1]%P);
	}
	Ans=Ans*(1ll<<n)%P;
	printf("%lld\n",Ans);
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
ans = 1
ok = 1

is0 = 0
for i in range(0, n):
    if a[i] == 0:
        is0 = 1

if is0 == 1:
    print(0)
else:
    for i in range(0, n):
        if ok:
            ans = ans * a[i]

        if ans > 1000000000000000000:
            ok = 0

    if ok:
        print(ans)
    else:
        print(-1)


Measured memory_bytes: 21472
using System;

namespace AtCoder.ABC106.C
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力値の検証は割愛
            var S = Console.ReadLine();
            var K = long.Parse(Console.ReadLine());

            var mrInfinity = new MrInfinity();

            var answer = mrInfinity.Answer(S, K);

            Console.WriteLine(answer);
        }
    }

    public class MrInfinity
    {
        public string Answer(string S, long K)
        {
            for (var i = 0; i < K; i++)
            {
                var s = S[i].ToString();

                if (s != "1")
                {
                    return s;
                }
            }
            return "1";
        }
    }
}


Measured memory_bytes: 13140
def main():

    S = input()
    T = input()

    min_cnt = float('inf')
    for i in range(len(S)):
        U = S[i:i+len(T)]
        if len(U) == len(T):
            cnt = 0
            for i in range(len(T)):
                if U[i] != T[i]:
                    cnt += 1
            min_cnt = min(min_cnt, cnt)
    return min_cnt

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 67524
n = int(input())
a_lst = list(map(int, input().split()))

x = a_lst[0]
y = sum(a_lst[1:])
diff = abs(y - x)
for a in a_lst[1:-1]:
  x += a
  y -= a
  diff = min(diff, abs(y - x))
print(diff)

Measured memory_bytes: 30740
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>

using namespace std;

int main(){
	vector<int> a(100,0);
	a={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
	
	int n;
	cin >> n;
	cout << a[n-1] << endl;
	
	return 0;
}


Measured memory_bytes: 256