akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(X: int):
    prices = [100, 101, 102, 103, 104, 105]
    flag = [None]*(100000+1)
    flag[0] = True

    def rec(x):
        if flag[x] is not None:
            return flag[x]

        if x < 100:
            flag[x] = False
            return False

        fff = False
        for p in prices:
            fff = fff or rec(x-p)
            if fff == True:
                break
        flag[x] = fff
        return fff

    print(int(rec(X)))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4852
N, K = map(int, input().split())

sunukes = [0]*N

for i in range(K):
    d = int(input())
    lis = list(map(int, input().split()))

    for l in lis:
        sunukes[l-1] += 1

ans = 0
for s in sunukes:
    if s == 0:
        ans += 1

print(ans)


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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x & 1) cnt++;
    }
    if(cnt & 1) cout << "NO" << endl;
    else cout << "YES" << endl;
}





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

int main(void) {
 int N, M;
 cin >> N >> M;

 const int NMMAX = 50;
 int A[NMMAX], B[NMMAX];

 for (int i = 0; i < M; ++i) {
 cin >> A[i] >> B[i];
 }

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

 for (int i = 0; i < M; ++i) {
 road[A[i] - 1] += 1;
 road[B[i] - 1] += 1;
 }

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

 return 0;
}

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

using namespace std;

#define l long long 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // l n;
    // cin>>n;
    // cout<<(n+n*n+n*n*n);
    string s1,s2;
    cin>>s1>>s2;
    l ct = 0;
    for(l i =0;i<s1.length();i++){
        if(s1[i]!=s2[i]){
            ct++;
        }
    }
    cout<<ct;
}

Measured memory_bytes: 3820
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

void call(int n){
    if(n % 3 == 0){
        cout << space << n;
        return;
    }
    int x = n;
    while(x != 0){
        if(x % 10 == 3){
            cout << space << n;
            return;
        }
        x /= 10;
    }
}


int main() {
    int n;
    cin >> n;
    FE(i, 1, n){
        call(i);
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 string n;
  cin>>n;
  
  int cnt=0;
  int nd=15-n.size();
  
  for(int i=0;i<n.size();i++){
    if(n[i]=='o'){
      cnt++;}
  }
    
    if(cnt+nd<=7){
      cout<<"NO"<<endl;}
    else{
      cout<<"YES"<<endl;}
    
    
    
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  int sum = 0;
  int ma= 0;
  REP(i,0,n){
    int a;cin>>a;
    ma=max(ma,a);
    sum+=a;
  }
  cout<<sum-ma/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s;
  cin >> s;
  if('A' <= s[0] && s[0] <= 'Z'){
    print("A");
  }else{
    print("a");
  }
}


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

using namespace std;

vector<int> a[200000];
int vis[200000];

void dfs(int node)
{
	vis[node]=1;
	
	
int i,tt;

for(i=0;i<a[node].size();i++)
{
	
	tt=a[node][i];
	
	if(vis[tt]==0)
	{
		dfs(tt);
	}	
	
}
	
	
}
int main()
{
	int t;
	t=1;
	while(t--)
	{
	
	int n,m,i,j,k,q;
	
	
	memset(vis,0,sizeof(vis));
	cin>>n>>q;
	
	for(i=0;i<q;i++)
	{
		
int x,y;

cin>>x>>y;

           a[x].push_back(y);
		   a[y].push_back(x);		
	}
  
  k=0;
   for(i=1;i<=n;i++)
   {
   	
   	if(vis[i]==0)
   	{
   		k++;
   		dfs(i);
	   }
   }
	
	cout<<k-1<<endl;
	
	
	
	}



}


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

int main(void)
{
	int a, b, k;
	cin >> a >> b >> k;
	if (b-a < 2*k)
	{
		for (int i = a; i <= b; i++)
			cout << i << endl;
	}
	else
	{
		int x = a;
		for (int i = 0; i < k; i++)
		{
			cout << x << endl;
			x++;
		}
		x = b - k + 1;
		for (int i = 0; i < k; i++)
		{
			cout << x << endl;
			x++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc54C.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if((a == 0 || b == 0)){
  	cout << "IMPOSSIBLE" << endl;
  }
  else{
    if((a + b) % 2 == 0){
    	cout << (a + b) / 2 << endl;
    }
    else if(abs(a - b) % 2 == 0){      
    	cout << abs(a - b) / 2 << endl;
    }
    else{
	  	cout << "IMPOSSIBLE" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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


int i,j;

int main(void){
    
    int h,w;
    cin>>h>>w;
    string s[h];
    FOR(i,h)cin>>s[i];
    
    FOR(i,h+2){
        FOR(j,w+2){
            if(i==0||j==0)cout<<"#";
            else if(i==h+1||j==w+1)cout<<"#";
            else cout<<s[i-1][j-1];
        }
        cout<<endl;
    }
    
    
    
    return 0;
    
}


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

int main(void){
  int i, j, k = 3, a, n, s[10000], p[10000];

  p[0] = 1;  s[0] = 0;
  p[1] = 2;  s[1] = 2;
  p[2] = 3;  s[2] = 5;
  for(i = 5; i <= 104729; i += 2){
    a = 0;
    for(j = 2; p[j] <= sqrt((double)i); j++){
      if(i % p[j] == 0){
	a++;
	break;
      }
    }
    if(a == 0){
      p[k] = i;
      s[k] = s[k-1]+p[k];
      k++;
    }
  }

  scanf("%d", &n);
  while(n != 0){
    printf("%d\n", s[n]);
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 676
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <map>

class TaskC {
public:
	void solve(std::istream& in, std::ostream& out) {
		size_t n;
		in >> n;
		std::vector<int> numbers;
		numbers.reserve(n);
		for (int i = 0; i < n; ++i) {
			int number;
			in >> number;
			numbers.push_back(number);
		}


		for (auto number: numbers) {
			add_count(number);
			add_count(number + 1);
			add_count(number - 1);
		}

		int max_count = 0;
		for (const auto& item: counts_) {
			if (item.second > max_count) {
				max_count = item.second;
			}
		}

		out << max_count;
	}

private:
	void add_count(int number) {
		if (counts_.find(number) == counts_.end()) {
			counts_[number] = 1;
		} else {
			++counts_[number];
		}
	}

	std::map<int, int> counts_;
};


int main() {
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n;
    cin >> n;
    static int64_t a[100000], b[100000], sum = 0;
    for(int i=0;i<n;i++){ cin >> a[i]; b[i] = abs(a[i]); sum += b[i]; }
    
    int cnt = 0;
    for(int i=0;i<n;i++) if(a[i] < 0) cnt++;
    if(cnt % 2 == 0) cout << sum << endl;
    else cout << sum - 2 * *min_element(b, b+n) << endl;

    return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args)throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int d = Integer.parseInt(in.readLine());
    if(d==25)
      System.out.println("Christmas");
    else if(d==24)
      System.out.println("Christmas Eve");
    else if(d==23)
      System.out.println("Christmas Eve Eve");
    else
      System.out.println("Christmas Eve Eve Eve");
  }
}
     

Measured memory_bytes: 21076
#!/mnt/c/Users/moiki/bash/env/bin/python
H,W = map(int, input().split())
a = [ list(map(int, input().split())) for _ in range(H)]

diff = lambda a,b: abs(a[0]-b[0]) + abs(a[1]-b[1])

trainsition_list = []
for h in range(H):
    step = 1 if h%2==0 else -1
    for w in range(W)[::step]:
        trainsition_list.append( (h,w) )

ans_tuple = []
# ans_n = 0
n = 0
for pos,next_pos in zip(trainsition_list, trainsition_list[1:]):
    h,w = pos
    if a[h][w] % 2 == 1:
        nh,nw = next_pos
        a[nh][nw] += 1
        # print(h, w, nh, nw)
        ans_tuple.append( (h,w,nh,nw) )
        n += 1
print(n)
for atp in ans_tuple:
    print( *(map(lambda x: x+1, atp)))
    

# print(trainsition_list)
# exit(0)
        # if a[h][w] !=
        
    
    

# odd_pos = []
# for h in range(H):
#     for w in range(W):
#         if a[h][w] % 2 == 1:
#             odd_pos.append( (h+1,w+1) )
# 
# odd_pos = sorted(odd_pos, lambda x: x[0])
# odd_pos = sorted(odd_pos, lambda x: x[1])
# 
# N = 0
# for pair in zip( odd_pos[0::2], odd_pos[1::2]):
#     N += diff(pair[0], pair[1])
# 
# if N <= H*W:
#     print(N)
# else:
#     print(H*W)
# 
# cnt = 0
# for pair in zip( odd_pos[0::2], odd_pos[1::2]):
#     pos = pair[0]
#     target = pair[1]
#     while pos[0] != target[0] and cnt <= H*W:
#         cnt += 1
#         decrease = 1 if pos[0] > target[0] else -1
#         print(pos[0], pos[1], pos[0] - decrease, pos[1])
#         pos = (pos[0] - decrease, pos[1])
#     while pos[1] != target[1] and cnt <= H*W:
#         cnt += 1
#         decrease = 1 if pos[1] > target[1] else -1
#         print(pos[0], pos[1], pos[0], pos[1]-decrease)
#         pos = (pos[0] , pos[1] - decrease)
# 


Measured memory_bytes: 85916
#include <iostream>
#include<cstring>
using namespace std;
int main() {
   long long int n;
   long long int sum = 0;
   cin>>n;
   if(n==0)
    cout<<0;
   else if(n<5)
   {
       cout<<0;
   } 
   else
   {
       if(n>=500)
       {
           while(n>=500)
           {
                  n = n-500;
                sum = sum + 1000;
           }
       }
     if(n>=5)
       {
           while(n>=5)
           {
                  n = n-5;
                sum = sum + 5;
           }
       }
       cout<<sum;
   } 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

struct node {
	ll to, index;
};

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll h, w; cin >> h >> w;
	vector<string> a(h);
	REP(i, h) cin >> a[i];
	auto blue = a;
	auto red = a;
	REP(i, w - 1) red[h - 1][i] = '#';
	FOR(i, 1, w) blue[0][i] = '#';
	FOR(i, 1, h) red[i][0] = '#';
	REP(i, h - 1) blue[i][w - 1] = '#';
	FOR(i, 1, h-1) {
		FOR(j, 1, w - 1) (i % 2 == 0 ? red : blue)[i][j] = '#';
	}
	REP(i, h) {
		REP(j, w) cout << red[i][j];
		cout << "\n";
	}
	cout << "\n";

	REP(i, h) {
		REP(j, w) cout << blue[i][j];
		cout << "\n";
	}
}

Measured memory_bytes: 1536
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

type Bomb [][]int
func (B Bomb) Len() int { return len(B) }
func (B Bomb) Less(i, j int) bool { return B[i][0] < B[j][0] }
func (B Bomb) Swap(i, j int) { B[i], B[j] = B[j], B[i] }

func Solve() {
  var H, W, M, h, w int
  var ok bool
  NextInt(&H, &W, &M)
  X := make([][]int, H)
  for i := range X { X[i] = []int{0, i} }
  Y := make([][]int, W)
  for i := range Y { Y[i] = []int{0, i} }
  A := make([][]int, M)
  B := make([]map[int]struct{}, H)
  for i := range B { B[i] = make(map[int]struct{}) }
  for i := range A {
    NextInt(&h, &w)
    h--; w--
    X[h][0]++; Y[w][0]++
    A[i] = []int{h, w}
    B[h][w] = struct{}{}
  }
  E := 0
  for _, a := range A {
    h, w := a[0], a[1]
    e := X[h][0] + Y[w][0] - 1
    if _, ok = B[h][w]; !ok { e++ }
    E = MaxInt(e, E)
  }
  sort.Sort(sort.Reverse(Bomb(X)))
  sort.Sort(sort.Reverse(Bomb(Y)))
  for _, x := range X {
    for _, y := range Y {
      if _, ok = B[x[1]][y[1]]; ok { continue }
      E = MaxInt(x[0] + y[0], E)
      break
    }
  }
  Write(E)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

Measured memory_bytes: 102100
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  long int N;
  cin >> N;
  vector<long int> A(N, 0);
  vector<long int> B(N, 0);
  vector<long int> diff(N, 0);
  long int A_sum=0, B_sum=0;
  for(int i=0; i<N; ++i){
    cin >> A[i];
    A_sum += A[i];
  }
  for(int i=0; i<N; ++i){
    cin >> B[i];
    B_sum += B[i];
    diff[i] = A[i]-B[i];
  }

  if(A_sum < B_sum){
    printf("-1\n");
    return 0;
  }

  long int ans=0;
  long int posi_sum=0;
  long int nega_sum=0;

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

  for(int i=0; i<N; ++i){
    if(diff[i]<0){
      ans++;
      nega_sum-=diff[i];
    }else{
      break;
    }
  }

  for(int i=N-1; posi_sum<nega_sum; --i){
    if(i<0){
      printf("-1\n");
      return 0;
    }
    posi_sum+=diff[i];
    ans++;
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int a[26],b[26];

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

    int n=s.size();
    rep(i,n){
        a[s[i]-'a']++;
        b[t[i]-'a']++;
    }

    vector<int> cnts,cntt;
    rep(i,26){
        cnts.push_back(a[i]);
        cntt.push_back(b[i]);
    }
    sort(all(cnts));
    sort(all(cntt));

    bool ok=true;
    rep(i,26){
        if(cnts[i]!=cntt[i]) ok=false;
    }

    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define F(i,a,b) for(int i=a;i<=b;++i)
int n,f[10005];
int main()
{
	cin>>n;
	F(i,1,100) F(j,1,100) F(k,1,100)
	if(i*i+j*j+k*k+i*j+j*k+k*i<=n) ++f[i*i+j*j+k*k+i*j+j*k+k*i];
	F(i,1,n) printf("%d\n",f[i]);
	return 0;
}

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

long long mod=1000000007,dp[2002];


int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld",&n);

        if(n<=2)printf("0\n");
        else
        {

            long long idx,cap;

            for(cap=0;cap<=n;cap++)
            {
                for(idx=n;idx>=3;idx--)
                {
                    if(idx==n)
                    {
                        long long p=0,q=0;

                        if(cap-idx>=0){  p=dp[cap-idx];   }

                        if(cap==0){  q=1; }

                        dp[cap]=(p+q)%mod;
                    }
                    else
                    {

                        long long p=0,q=0;

                        if(cap-idx>=0){ p=dp[cap-idx];  }
                        q=dp[cap];

                        dp[cap]=(p+q)%mod;

                    }

                }
            }

            ans=dp[n];


            printf("%lld\n",ans);


        }







    return 0;
}





Measured memory_bytes: 3780
#include <iostream>
using namespace std;
int main(){
    long X,K,D; cin>>X>>K>>D;
    X=abs(X);
    if (X/D >= K)
        cout<<X-D*K<<endl;
    else
        cout<<abs(X%D-((X/D)%2==K%2?0:D))<<endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	System.out.println(br.readLine().equals("ABC") ? "ARC" : "ABC");
    }
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

const int N = 1000000;
const int mod = 1e9 + 7;

int fac[N + 1];

#define pow abcdef
int pow(int a, int b) {
  if (b == 0) return 1;
  int t = pow(a, b / 2);
  t = (t * t) % mod;
  if (b % 2) return (t * a) % mod;
  return t;
}

void Main() {
  fac[0] = 1;
  for (int i = 1; i <= N; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
  }
  int x, y;
  cin >> x >> y;
  int mx = 0, my = 0, a = 0, b = 0;
  while (mx <= x && my <= y) {
    if ((x - mx) % 2 == 0 && (x - mx) / 2 == y - my) {
      b = y - my;
      int ans = (fac[a + b] * pow(fac[a], mod - 2)) % mod;
      (ans *= pow(fac[b], mod - 2)) %= mod;
      cout << ans << '\n';
      return;
    }
    mx += 1;
    my += 2;
    a++;
  }
  cout << 0 << '\n';
}

signed main() {
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 11424
n,c = gets.chomp.split(" ").map(&:to_i)
a = n.times.map{gets.chomp.split(" ").map(&:to_i)}
b = a.map{|i,j|[c-i,j]}.reverse
ans = 0
for i in 1..n-1
  a[i][1] += a[i-1][1]
  b[i][1] += b[i-1][1]
end
rs,rd,ls,ld = 4.times.map{Array.new(n+1,0)}
for i in 0..n-1
  rs[i+1] = rs[i] < a[i][1]-a[i][0] ? a[i][1]-a[i][0] : rs[i]
  rd[i+1] = rd[i] < a[i][1]-2*a[i][0] ? a[i][1]-2*a[i][0] : rd[i]
  ls[i+1] = ls[i] < b[i][1]-b[i][0] ? b[i][1]-b[i][0] : ls[i]
  ld[i+1] = ld[i] < b[i][1]-2*b[i][0] ? b[i][1]-2*b[i][0] : ld[i]
end
for i in 0..n
  ans = [ans,rs[i]+ld[-i-1],ls[i]+rd[-i-1]].max
end
puts ans

Measured memory_bytes: 20860
#include<bits/stdc++.h>
#define mo 998244353
using namespace std;
long long fac[1000010],nifac[1000010];
long long C(int n,int m){return fac[n]*nifac[m]%mo*nifac[n-m]%mo;}
long long getmi(long long a,long long x)
{
	long long ans=1;
	while (x)
	{
		if (x&1) ans=ans*a%mo;
		a=a*a%mo;
		x>>=1;
	}
	return ans;
}
int main()
{
	fac[0]=1;for (int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mo;
	nifac[1000000]=getmi(fac[1000000],mo-2);
	for (int i=999999;i>=0;i--) nifac[i]=nifac[i+1]*(i+1)%mo;//cout<<fac[233]*nifac[233]%mo<<endl;
	int n,m;long long ans=0;scanf("%d%d",&n,&m);if (n>m) swap(n,m);
	for (int i=1;i<=n;i++) ans=(ans+C(2*i,i)*C(n+m-2*i,n-i))%mo;
	ans=(m+ans*nifac[2]%mo*getmi(C(n+m,n),mo-2))%mo;
	printf("%lld\n",ans);
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, arr[100001], dp[100001];
int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    memset(dp, INF, sizeof dp);
    dp[0] = 0;
    for (int i = 0; i < n-1; ++i) {
        dp[i+1] = min(dp[i+1], abs(arr[i+1]-arr[i])+dp[i]);
        if (i+2 < n) {
            dp[i+2] = min(dp[i+2], dp[i]+abs(arr[i+2]-arr[i]));
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
using pll=pair<ll,ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i,l,r) for(ll i = (l); i <= (ll)(r); i++)
#define rep3(i,l,r) for(ll i = (l); i >= (ll)(r); i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = 1001001001;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = acos(-1);
 
// union by size + path having
class UnionFind {
public:
   vector <ll> par; // 各元の親を表す配列
   vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)
 
   // Constructor
   UnionFind(ll sz_): par(sz_),siz(sz_, 1LL){
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
   }
   void init(ll sz_){
       par.resize(sz_);
       siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
       for (ll i=0; i<sz_; i++) par[i]=i; // 初期では親は自分自身
  }
 
   // Member Function
   // Find
   ll root(ll x){ // 根の検索
      while (par[x]!=x){
           x=par[x]=par[par[x]]; // x の親の親を x の親とする
       }
       return x;
  }
 
   // Union(Unite, Merge)
   bool unite(ll x, ll y){
       x=root(x);
       y=root(y);
       if (x==y) return false;
       // merge technique（データ構造をマージするテク．小を大にくっつける)
       if (siz[x]<siz[y]) swap(x, y);
       siz[x]+=siz[y];
       par[y]=x;
       return true;
  }
 
  bool same(ll x, ll y){ // 連結判定
       return root(x)==root(y);
  }
 
  ll size(ll x){ // 素集合のサイズ
      return siz[root(x)];
  }
};
 
ll modpow(ll x, ll n){
   x=x%mod;
   if(n==0) return 1;  //再帰の終了条件
 
   else if(n%2==1){
       return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
   }
   else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}
 
ll com(ll n, ll k){
   ll x=1;
   for(int i=n-k+1; i<=n; i++){
      x=x*i%mod;
   }
 
   ll y=1;
   for(int i=1; i<=k; i++){
       y=y*i%mod;
   }
   y=modpow(y, mod-2);
 
   return x*y%mod;
}
 
bool is_prime(const unsigned n){
   switch(n){
       case 0: // fall-through
       case 1: return false;
       case 2: // fall-through
       case 3: return true;
  } // n>3 が保証された
 
   if(n%2==0 || n%3==0) return false;
   // nは2と3のいずれの倍数でもないことが保証された
   // これよりnは(6の倍数)-1か(6の倍数)+1である
 
   // 6の倍数前後の数を使って試し割りをする
   for(unsigned i = 5; i*i<=n; i+=6) {
       if(n%i==0) return false; // (6の倍数)-1
       if(n%(i+2)==0) return false; // (6の倍数)+1
   }
 
   return true;
}
 
int digsum(int n){
   int res=0;
   while(n > 0) {
       res+=n%10; //ここをres++;に変えたら桁数を求める関数になる,res+=n%10;なら格桁の和
       n/=10;
   }
   return res;
}
vector<ll> divisor(ll n){
   vector<ll> ret;
   for(ll i=1; i*i<=n; i++){
       if(n%i==0){
           ret.push_back(i);
           if(i*i!=n) ret.push_back(n/i);
       }
   }
   sort(ret.begin(),ret.end());
   return ret;
}
 
int main(){

    ll n;
    cin >> n;
    vector<pll> a;
    rep(i,n){
        ll x;
        cin >> x;
        a.push_back(pll(x,i+1));
    }

    sort(a.begin(),a.end());
    for(auto x:a){
        cout << x.second << endl;
    }
 
}

Measured memory_bytes: 2544
#include<bits/stdc++.h>
#define ll  long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 1000005
#define mod 1000000007
#define pi 3.14159265358979323846

using namespace std;

int p[N];

void sieve()
{
    //memset(p,1,sizeof p);
    for(int i=2; i<N; i++){
        for(int j=i; j<N; j+=i)p[j]++;
    }
}


int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    sieve();
    int n;
    cin>>n;
    int ans = 0;
    for(int i=2; i<n; i++)ans+=p[i]+1;
    cout<<ans+1<<endl;
}


Measured memory_bytes: 7552
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;


int ans[510][510];

bool go(int nRow, int nCol, int h, int w) {
  ll sum = 0;
  int x = 600;
  REP(i, nRow) REP(j, nCol) {
    if(i % h == h-1 && j % w == w-1) {
      ans[i][j] = -(h*w-1)*x - 1;
    } else {
      ans[i][j] = x;
    }
    sum += ans[i][j];
  }
  return sum > 0;
}

int main(void) {
  int nRow, nCol, h, w;
  scanf("%d%d%d%d", &nRow, &nCol, &h, &w);
  bool possible = go(nRow, nCol, h, w);
  if(!possible) {
    puts("No");
  } else {
    puts("Yes");
    REP(i, nRow) {
      REP(j, nCol) {
        printf("%d%c", ans[i][j], j == nCol-1 ? '\n' : ' ');
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, l, q;
int x[N];
int dp[N][21];
ll sum[N];
int main() {
  cin>>n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x[i]);
  }
  memset(sum, 0, sizeof(sum));
  for (int i = 2; i <= n; ++i) {
    sum[i] = sum[i-1]+x[i]-x[i-1];
  }
  memset(dp, -1, sizeof(dp));
  scanf("%d", &l);
  for (int i = 1; i < n; ++i) {
    int y = i;
    int z = n;
    while(y<z) {
      int mid=(y+z+1)/2;
      if (sum[mid]-sum[i]>l) {
        z = mid-1;
      } else {
        y = mid;
      }
    }
    dp[i][0] = y;
  }
//  cout<<dp[5][0]<<" "<<dp[7][0]<<endl;
  for (int j = 1; j <= 20; ++j) {
    for (int i = 1; i <= n; ++i) {
      if (dp[i][j-1] >= 0 && dp[dp[i][j-1]][j-1] >= 0) {
        dp[i][j] = dp[dp[i][j-1]][j-1];
      }
    }
  }
//  cout<<"x="<<dp[5][3]<<endl;
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    int res=0;
    int cur=a;
    for (int j = 20; j >= 0; --j) {
      if (dp[cur][j] >= 0 && dp[cur][j] <= b) {
     //   if (a==5 && b==8) cout<<"j="<<cur<<" "<<j<<" "<<dp[cur][j]<<endl;
        res += 1<<j;
        cur = dp[cur][j];
      }
    }
    if (cur < b) res++;
    cout<<res<<endl;
  }
  return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

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

  VAR(int, N, M);

  vector<int> vec[100010];
  rep(i, N) {
    VAR(int, a, b);
    if (a <= M) vec[a-1].emplace_back(b);
  }

  priority_queue<int> que;
  i64 res = 0;
  rep(i, M) {
    for (auto e : vec[i]) {
      que.emplace(e);
    }
    if (!que.empty()) {
      res += que.top();
      que.pop();
    }
  }

  OUTL(res);

  return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, pll> mpll;

const ll MX = 200;

int main() {FIN
	
	ll x, i, j;
	vll pws(MX + 1);
	mpll xs;
	for (i = 0; i <= MX; i++) {
		pws[i] = pow(i, 5);
		for (j = 0; j <= i; j++) {
			xs[pws[i] - pws[j]] = pll(i, j);
			xs[pws[i] + pws[j]] = pll(i, -j);
		}
	}
	
	cin >> x;
	cout << xs[x].first << " " << xs[x].second << "\n";
	
	return 0;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(int argc, char *argv[]) { _
    string s, f;
    ll j = 0, qtd = 0;

    cin >> s;
    f.append("CODEFESTIVAL2016");
    for (auto i : s) {
        if (i != f[j]) {
            qtd++;
        }
        j++;
    }
    cout << qtd;
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	int N, K, ans = 0, i;
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) {
		int t;
		scanf("%d", &t);
		ans += 2 * min(t, K - t);
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
var main = function(input) {
var Ar = input.split(' ').map(x=>parseInt(x));
var N=Ar[0];
var M=Ar[1];
var K=Ar[2];
var Ans ='No';
for (var i = 0; i <= N; i++) {
        for (var j = 0; j <= M; j++) {
            if (j * (N - i) + i * (M - j) == K) {
                Ans = 'Yes'
                console.log(Ans);
                return 0;
            }
        }
    }
console.log(Ans);
    return 0; 
}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7500
import sys
import itertools
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template

def retmax(a, b):
    if a > b:
        return a
    else:
        return b

def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]

    dp = np.zeros([3, n+1])

    for i, a_l in enumerate(a):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[k, i+1] = max(dp[k, i+1], dp[j, i] + a_l[k])

    print(int(np.max(dp[:, n], axis=0)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 42788
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    ll a,b,k;

    cin >> a >> b >> k;

    if(a < k){

        k = k - a;
        a = 0;

        b = max(b - k, (ll)0);

        cout << a << " " << b << endl;

    }else{
        a = a - k;

        cout << a << " " << b << endl;
    }



    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;


int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll>H;
	vector<ll>check;
	vector<ll>A,B;
	ll count=0;
	ll c;
	for (int i = 0; i < N; i++) {
		cin >> c;
		H.push_back(c);
		check.push_back(1);
		

	}
	for (int i = 0; i < M; i++) {
		cin >> c;
		A.push_back(c);
		cin >> c;
		B.push_back(c);
	}
	for (int i = 0; i < M; i++) {
		if (H[A[i]-1]==H[B[i]-1]) {
			check[A[i] - 1] = 0;
			check[B[i] - 1] = 0;
		}
		else {
			H[A[i] - 1] > H[B[i] - 1] ? check[B[i] - 1] = 0 : check[A[i] - 1] = 0;
		}


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

		count += check[i];

	}
	cout << count;

}

Measured memory_bytes: 7156
n = int(input())
s = input()

# 条件①はrgbの組み合わせが"R","G","B"がそれぞれ選ばれる場合のみを想定
# それぞれの出現回数をかけ合わせることで全組み合わせを網羅できる。
r = s.count("R")
g = s.count("G")
b = s.count("B")
rgb = r*g*b

# 条件②：j-i ≠ k-j を別の見方をすると k = 2*j-i になる。
# rgbの全通りの組み合わせから上記の組み合わせになる回数を引く
# ただし、条件①に該当する組み合わせについてはすでに引かれている為、スキップする。
for i in range(n-2):
  for j in range(i+1, n-1):
    k = 2*j-i 
    if k >= n or s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
      continue
    rgb -= 1
print(rgb)

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

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

	lli cnt = 1;
	lli sum = a[0];
	REP(i,1,n){
		if(sum*2>=a[i])
		{
			cnt++;
		}
		else{
			cnt=1;
		}
		sum += a[i];
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  10005

ll dp[N][100][2];
ll n,d;
vi v;
ll tim=0;
ll dps(ll ind,ll mod,ll flg)
{
    // tim++;
    // cout<<tim++<<endl;
    // cout<<ind<<" "<<mod<<" "<<flg<<endl;
    if(ind==n)
    {
        if(mod==0)
        return 1;
        return 0;
    }
    if(dp[ind][mod][flg]!=-1)
        return dp[ind][mod][flg];
    dp[ind][mod][flg]=1;
    // cout<<"Pass"<<endl;
    ll x=0;
    if(flg==1)
    rep(i,0,10)
    {
        if(i<v[ind])
        {
            x=(x+dps(ind+1,(mod+i)%d,0))%hell;
        }
        else if(i==v[ind])
        {
            x=(x+dps(ind+1,(mod+i)%d,1))%hell;       
        }
    }
    else
    rep(i,0,10)
    {
        x=(x+dps(ind+1,(mod+i)%d,0))%hell;  
    }   
    return dp[ind][mod][flg]=x;
}
void solve()
{
    string s;
    cin>>s;
    n=sz(s);
    cin>>d;
    for(auto u:s)
        v.pb(u-'0');
    // cout<<n<<endl;
    memset(dp,-1,sizeof(dp));
    cout<<(dps(0,0,1)-1+hell)%hell<<endl;
    // rep(i,0,n+1)
    // {
    //     rep(j,0,d)
    //     {
    //         cout<<dp[i][j][0]<<" ";
    //     }
    //     cout<<endl;
    // }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

using ll = long long;

int main(){
  string S;
  cin >> S;
  int K;cin >> K;

  int not_1_digit=0;
  for(int i=0;i<S.size();i++){
    if(S[i]!='1'){
      not_1_digit=i;
      break;
    }
  }

  string ans;
  if(not_1_digit>=K)ans = "1";
  else ans = S[not_1_digit];
  cout << ans << endl;
}

/*
5000兆日経ったら左から大概の文字は1文字目で構成されそうだが…(1除く)

指定されるK番目の文字がK<1E18で5000兆は1e15
数字が2以上だった場合その桁数は最低でも2^(10^15)以上なので何も問題なかったです

ということで頭から文字を見ていって桁数と1じゃない値とのあれこれやると良さげ
*/

Measured memory_bytes: 3580
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, A, B;
	cin >> H >> A >> B;
	int res = 0;
	FOR(i, A, B+1) res += (H % i == 0 ? 1 : 0);
	cout << res << endl;
}



Measured memory_bytes: 3176
d, g = $stdin.readline.chomp.split.map(&:to_i)
prob = Array.new(d) { $stdin.readline.chomp.split.map(&:to_i) }
res = []

(1 << d).times do |bit|
  s = 0
  cnt = 0
  d.times do |i|
    if (bit >> i) & 1 != 0
      s += prob[i][0] * 100 * (i + 1) + prob[i][1]
      cnt += prob[i][0]
    end
  end

  j = ((~ bit) & ((1 << d) - 1)).bit_length - 1
  if j >= 0 && s < g
    ac = [(g - s + 100 * (j + 1) - 1) / (100 * (j + 1)), prob[j][0] - 1].min
    cnt += ac
    s += 100 * (j + 1) * ac
  end
  res << cnt if s >= g
end
puts res.min

Measured memory_bytes: 14376