akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    deque<char> s;
    string c1;
    Int q;
    cin >> c1 >> q;
    for (auto z : c1) {
        s.push_back(z);
    }

    bool rev = false;
    for (Int i = 0; i < q; i++) {
        int t;
        cin >> t;

        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;

            if (!rev) {
                if (f == 1) {
                    s.push_front(c);
                } else {
                    s.push_back(c);
                }
            } else {
                if (f == 1) {
                    s.push_back(c);
                } else {
                    s.push_front(c);
                }
            }
        }
    }

    if (rev) {
        reverse(s.begin(), s.end());
    }
    for (auto z : s) {
        cout << z;
    }
    cout << endl;

    return 0;
}


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

typedef long long ll;

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    ll a,c,b;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
m_list = []
for _ in range(n):
    m_list.append(int(input()))

# print(f"{n} {x}")
# print(m_list)

nokori = x - sum(m_list)
# print(nokori)
sarani = nokori // min(m_list)
# print(sarani)
print(len(m_list) + sarani)

Measured memory_bytes: 9096
//ALDS1_11D
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

static const int MAX=100000;
static const int NIL=-1;
int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r,int c){
 stack<int> S;
 S.push(r);
 color[r]=c;
 while(!S.empty()){
  int u=S.top(); S.pop();
  for(int i=0;i<G[u].size();i++){
   int v=G[u][i];
   if(color[v]==NIL){
    color[v]=c;
    S.push(v);
   }
  }
 }
}

void assignColor(){
 int id=1;
 for(int i=0;i<n;i++) color[i]=NIL;
 for(int u=0;u<n;u++){
  if(color[u]==NIL) dfs(u,id++);
 }
}

int main(){
 int s,t,m,q;
 cin>>n>>m;
 for(int i=0;i<m;i++){
  cin>>s>>t;
  G[s].push_back(t);
  G[t].push_back(s);
 }
 assignColor();
 cin>>q;
 for(int i=0;i<q;i++){
  cin>>s>>t;
  if(color[s]==color[t]){
   cout<<"yes"<<endl;
  }else{
   cout<<"no"<<endl;
  }
 }
 return 0;
}

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

template <typename T>
void max_heapify(std::vector<T> &A, std::size_t pos, std::size_t heapsize) {
    while(pos < heapsize / 2) {
        std::size_t l = (pos << 1) + 1;
        std::size_t r = (pos << 1) + 2;
        std::size_t largest = pos;
        if(l < heapsize && A[largest] < A[l]) largest = l;
        if(r < heapsize && A[largest] < A[r]) largest = r;
        
        if(largest == pos) break;
        std::swap(A[pos], A[largest]);
        pos = largest;
    }
}

template <typename T>
void build_max_heap(std::vector<T> &A) {
    for(int pos = A.size() / 2 - 1; pos >= 0; --pos) {
        max_heapify<T>(A, pos, A.size());
    }
}

template <typename T>
void heapsort(std::vector<T> &A) {
    build_max_heap<T>(A);
    for(int pos = A.size() - 1; pos > 0; --pos) {
        std::swap(A[0], A[pos]);
        max_heapify<T>(A, 0, pos);
    }
}

int main() {
    int H; cin >> H;
    vector<int> A(H);
    for(int i=0; i<H; ++i) cin >> A[i];
    build_max_heap<int>(A);
    for(int i=0; i<H; ++i) cout << ' ' << A[i];
    cout << endl;
}


Measured memory_bytes: 4540
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int H, W, c[10][10], b[200][200];

int main() {
    cin >> H >> W;
    for (int j = 0; j < 10; ++j) for (int k = 0; k < 10; ++k) cin >> c[j][k];
    for (int j = 0; j < H; ++j) for (int k = 0; k < W; ++k) cin >> b[j][k];

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

    int ans = 0;
    for (int j = 0 ; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if (b[j][k] == -1) continue;
            ans += c[b[j][k]][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <utility>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    long long int n,T,sum=0;
    cin>>n>>T;
    vector<long long int>t(n);
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<n-1;i++){
        if(t[i]+T<t[i+1]){
            sum+=T;
        }else{
            sum+=-t[i]+t[i+1];
        }
    }
    cout<<sum+T;
}

Measured memory_bytes: 1792
import sys

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

S = s()

prev = S[0]
for i in range(1, len(S)):
    if prev == S[i]:
        print('Bad')
        sys.exit()
    prev = S[i]

print('Good')


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int H, W, h, w;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> H >> W >> h >> w;

  if ((H % h) == 0 && (W % w) == 0) {
    cout << "No" << endl;
    return 0;
  } 

  cout << "Yes" << endl;
  bool rev = false;
  if ((H % h) == 0) {
    swap(W, H);
    swap(w, h);
    rev = true;
  }
  assert(H % h > 0);

  int c1 = 1 + 300000;
  int c2 = -h + (1 - h) * 300000;


  if (rev) {
    for(int j  = 0; j < W; ++j) {
      for(int i = 0; i < H; ++i) {
        if ((i % h) == h - 1) {
          cout << c2 << ' ';
        } else {
          cout << c1 << ' ';
        }
      }

      cout << '\n';
    }

    return 0;
  }

  // else
  for(int i = 0; i < H; ++i) {
    if ((i % h) == h - 1) {
      for(int j = 0; j < W; ++j) {
        cout << c2 << ' ';
      }
    } else {
      for(int j = 0; j < W; ++j) {
        cout << c1 << ' ';
      }
    }

    cout << '\n';
  }
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>

using namespace std;

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

  vector<string> v;

  for(int i = 0; i < N;i++){
    string s;
    cin >> s;
    v.push_back(s);
  }

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

  for(int i = 0; i < v.size(); ++i)
    cout << v[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
def insert_string_to_base(target_string, insert_point, insert_string):
    return target_string[:insert_point] + insert_string + target_string[insert_point:]

input1=input()
input2=input()
input3=input()

N=int(input1)

P=""
for i in range((len(input2)+1)//2):
    P+=input2[2*i]
Q=""
for i in range((len(input3)+1)//2):
    Q+=input3[2*i]



def permutate(n):
    ans=[]
    if n==1:
        ans=["1"]
    else:
        temp=permutate(n-1)

        for t in temp:
            for i in range(len(t)+1):
                tm=insert_string_to_base(t,i,"{}".format(n))
                ans.append(tm)

    return ans

arr=permutate(N)

ARR=sorted(arr)

print(abs(ARR.index(P)-ARR.index(Q)))



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

int main() {
	int X,Y;
	cin >> X >> Y;
	for (int i = 0; i <= X; i++) {
		if (i * 2 + (X - i) * 4 == Y) {
			cout << "Yes" << endl;
			return(0);
		}
	}
	cout << "No" << endl;
	return(0);
}


Measured memory_bytes: 3636
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N, M, Q = map(int, readline().split())
q_kumi = []
for _ in range(Q):
    q_kumi.append(list(map(int, readline().split())))

import itertools
AL = itertools.combinations_with_replacement(range(1, M+1), N)

ans = 0
for A in AL:
    tmp_ans = 0
    for kumi in q_kumi:
        if A[kumi[1]-1] - A[kumi[0]-1] == kumi[2]:
            tmp_ans += kumi[3]
    ans = max(ans, tmp_ans)


print(ans)

Measured memory_bytes: 9268
#include <stdio.h>
int main()
{
	int a,b,c, i;
	int count=0 ;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a; i <= b; i++)
        {
		if(c%i == 0)
            count++;
	}
	printf("%d\n", count);
	return 0;
}



Measured memory_bytes: 2104
n = int(input())
R = []
for _ in range(n):
    R.append(int(input()))

minv = R[0]
maxv = -10**9
for j in range(1,n):
    maxv = max(maxv, R[j]-minv)
    minv = min(minv, R[j])
print(maxv)


Measured memory_bytes: 13592
n = gets.to_i
names = Hash.new(0)
n.times { names[gets[0]] += 1 }
ans = 0
names.keys.select { |k| ['M', 'A', 'R', 'C', 'H'].include?(k) }.combination(3).each do |s|
  break if s.size < 3

  ans += s.map { |k| names[k] }.inject(:*)
end
puts ans

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(std::string S) {
  for(auto &c : S) c = 'x';
  cout << S << endl;;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, ans;
    ans = -1;
    cin >> a >> b;
    for (int i = 1; i <= 1009; i++)
    {
        int tmp1 = (int)i * 0.08;
        int tmp2 = (int)i * 0.1;
        if (tmp1 == a && tmp2 == b)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

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

int convBin(int n)
{
    int t = 1;
    for(int i = 1; i < n; ++i)
    {
        t *= 2;
    }
    return t;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> switches(n);
    vector<int> lights(m);
    for(int i = 0; i < m; ++i)
    {
        int cn;
        cin >> cn;
        int key = 0;
        for(int i = 0; i < cn; ++i)
        {
            int t;
            cin >> t;
            key |= convBin(t);
        }
        switches[i] = key;
    }

    for(int i = 0; i < m; ++i)
    {
        int t;
        cin >> t;
        lights[i] = t;
    }

    int maxN = 1;
    for(int i = 0; i < n; ++i)
    {
        maxN *= 2;
    }
    int ans = 0;
    for(int i = 0; i < maxN; ++i)
    {
        bool all = true;
        for(int j = 0; j < m; ++j)
        {
            int key = switches[j];
            int t = i & key;
            int cnt = 0;
            //cout << "i : " << i << " key: " << key << " t: " << t << endl;
            for(int k = t; k > 0; k/=2)
            {
                if(k%2==1)
                {
                    ++cnt;
                }
            }
            if(cnt%2!=lights[j])
            {
                all = false;
                break;
            }
        }
        if(all)
        {
            //cout << "ans : " << i << endl;
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<string> startStr = {"SS", "SW", "WS", "WW"};
    for (string start : startStr) {
        vector<char> save = {start[0], start[1]};
        for (int i = 1; i < N - 1; i++) {
            if (save[i] == 'S') {
                if (S[i] == 'o') {
                    save.push_back(save[i - 1]);
                } else {
                    save.push_back(save[i - 1] == 'S' ? 'W' : 'S');
                }
            } else {
                if (S[i] == 'x') {
                    save.push_back(save[i - 1]);
                } else {
                    save.push_back(save[i - 1] == 'S' ? 'W' : 'S');
                }
            }
        }
        bool check = true;
        for (int i = 0; i < N; i++) {
            int left = (i - 1 + N) % N;
            int right = (i + 1 + N) % N;
            if (save[i] == 'S') {
                if (S[i] == 'o') {
                    if (save[left] != save[right]) check = false;
                } else {
                    if (save[left] == save[right]) check = false;
                }
            } else {
                if (S[i] == 'x') {
                    if (save[left] != save[right]) check = false;
                } else {
                    if (save[left] == save[right]) check = false;
                }
            }
        }
        if (check) {
            for (int i = 0; i < N; i++) cout << save[i];
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    modint pow(modint m) {
        modint ans = 1, base = a;
        while (m.a != 0) {
            if (m.a & 1) {
                ans *= base;
            }
            base *= base;
            m.a /= 2;
        }
        return ans;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    using m = modint<mod>;
    auto ans = m(10).pow(n) - m(9).pow(n) * 2 + m(8).pow(n);
    cout << ans.a << endl;
    return 0;
}



Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class315
    {
        static void Main()
        {
            var nmx = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = nmx[0], M = nmx[1], X = nmx[2];
            Tuple<int, int[]>[] T = new Tuple<int, int[]>[N];
            for(int i = 0; i < N; i++)
            {
                var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int c = r[0];
                int[] a = new int[M];
                Array.Copy(r, 1, a, 0,M);
                T[i] = Tuple.Create(c, a);
            }
            int ans = int.MaxValue;
            for(int i = 0; i < (1 << N); i++)
            {
                int[] K = new int[M];
                int money = 0;
                for(int j = 0; j < N; j++)
                {
                    if ((i & (1 << j)) > 0)
                    {
                        for(int k = 0; k < M; k++)
                        {
                            K[k] += T[j].Item2[k];
                        }
                        money += T[j].Item1;
                    }
                }
                if (K.All(x => x >= X)) ans = Math.Min(ans, money);
            }
            Console.WriteLine(ans == int.MaxValue ? -1:ans);
        }
    }
}


Measured memory_bytes: 28740
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, m = load_list()
S = []
for _ in range(m):
    s = load_list()
    del s[0]
    S.append(s)
p = load_list()

def s2bit(s):
    bit = 0
    for e in s:
        bit |= 2**(e-1)
    return bit

cnt = 0
for bit in range(0, 2**n):
    flag = True
    for i in range(m):
        if not bin(s2bit(S[i]) & bit).count("1") % 2 == p[i]:
            flag = False
            break
    if flag:
        cnt += 1


print(cnt)

Measured memory_bytes: 40176
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>n>>k;
    map<int,int> mp;
    for(i=0;i<k;i++)
    {
        cin>>temp;
        
        for(j=0;j<temp;j++)
        {
            cin>>x;
            mp[x]++;
        }
    }
    
    cout<<n-mp.size()<<endl;
    
    
}

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

using namespace std;
//frog problem
inline int abs(int a){ return a>0?a:-a;}
inline long long min(long long a,long long b){ return a>b?b:a; }
long long cost_paid(vector<int> &height_array,int N,vector<int> &cost_array,int K){
    //base case
    cost_array[1] = abs(height_array[0]-height_array[1]);
    //intialize till kth element
    for(int i=2;i<N && i<=K;i++){
        cost_array[i] = abs(height_array[0]-height_array[i]);
        for(int j=1;j<i;j++){
            cost_array[i] = min(cost_array[i],cost_array[i-j]+abs(height_array[i]-height_array[i-j]));    
        }
    }
    for(int i=K+1;i<N;i++){
        cost_array[i] = abs(height_array[i-K]-height_array[i]) + cost_array[i-K];
        for(int j=1;j<K;j++)
            cost_array[i] = min(cost_array[i],cost_array[i-j]+abs(height_array[i]-height_array[i-j]));
    }
    return cost_array[N-1];
}


int main(){
    int N=0,K=0;cin>>N>>K;
    vector<int> height_array(N),cost_array(N);
    for(int i=0;i<N;i++)
        scanf("%d",&height_array[i]);

    printf("%d\n",cost_paid(height_array,N,cost_array,K));

    return 0;
}

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

using namespace std;



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

	int n, a, b;
	cin >> n >> a >> b;

	cout << min(n * a, b);

	//system("pause");

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define true 1
#define false 0

int judge(int);

int main() {
  int i,n,a,flag=0;
  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    scanf("%d",&a);
    if(judge(a) == true) 
      flag++; 
  }
  printf("%d\n",flag);
  

  return 0;

}

int judge(int x)
{
  int i;
  if(x == 2) return true;
  
  if(x < 2 || x % 2 == 0) return false;
  
  for(i = 3;i <= sqrt(x) ; i+=2) {
    if(x % i == 0) return false;
  }
  
  return true;
}



Measured memory_bytes: 2128
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static long solver()
        {
            var HW = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var H = HW[0]; var W = HW[1];

            if (H == 1 || W == 1) return 1;

            var odd = (W + 1) / 2;
            var even = W / 2;

            var result = (odd * ((H + 1) / 2)) + (even * (H / 2));
            return result;
        }
    }
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N;
    scanf("%d",&N);
    int p[N];
    for(int i = 0;i < N;i++){
        scanf("%d",&p[i]);
    }
    
    int max = 0;
    int memo;
    for(int i = 0;i < N;i++){
        if(max < p[i]){
            max = p[i];
            memo = i;
        }
    }

    p[memo] /= 2;

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

    printf("%d\n",Sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n, l; cin >> n >> l;
    int sum = 0;
    rep(i, n){
        sum += l + i;
    }
    if(l + n - 1 <= 0){
        cout << sum - (l + n - 1) << endl; 
    }else if(0 <= l){
        cout << sum - l << endl;
    }else{
        cout << sum << endl;
    }
}

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

import math

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

ans=0
for i in range(n-1):
    for j in range(i+1,n):
        diff=0
        for k in range(d):
            diff+=(x[i][k]-x[j][k])**2
        if math.sqrt(diff).is_integer():
            ans+=1
print(ans)


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

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

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

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

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

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

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

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

fn main() {
    input!{
        a: usize,
        b: usize
    }
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}


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

int main(){
	long long n, a, b;
	cin >> n >> a >> b;
	if(abs(a-b)%2==0) {cout << abs(a-b)/2; return 0;}
	else{
		long long first,second;
		if((a-1)+(b-1) < (n-a) + (n-b)){
			first = min(a-1,b-1);
			second = max(a-1,b-1);
			}
		else{
			first = min(n-a,n-b);
			second = max(n-a,n-b);
		}
		long long result = 0;
		result += first;
		//cout << first << second;
		if (second - first == 1) {cout << result +1;return 0;}
		else cout << result + 1+(second-1-first)/2;
	}
 }


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int x,y,z;
int main(){
	scanf("%d/%d/%d",&x,&y,&z);
	if(x<=2019&&y<=4&&z<=30)puts("Heisei");
	else puts("TBD");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>S;

    for(int i=0;S[i];i++){
        cur = S[i]-'0';
        sum += cur;
        if(sum>=9)sum-=9;
    }

    if(!sum)cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


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

long long gcd( long long m, long long n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

long long lcm( long long m, long long n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main() {
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long sum = 0;

  sum += b-a+1;
  sum -= b/c - (a-1)/c;
  sum -= b/d - (a-1)/d;
  sum += b/lcm(c,d) - (a-1)/lcm(c,d);
  // cout << b/gcd(c,d) << endl;
  // cout << (a-1)/gcd(c,d) << endl;  


  cout << sum << endl;

}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A[100];
  int i, j, N, flag = 1,count = 0;

  scanf("%d",&N);

  for(i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }

  while(flag){
    flag = 0;
    for(j = N-1; j > 0; j--){
      if(A[j] < A[j-1]){
	i = A[j];
	A[j] = A[j-1];
	A[j-1] = i;
	flag = 1;
	count++;
      }
    }
  }

  for(i = 0; i < N-1; i++){
    printf("%d ",A[i]);
  }

  printf("%d\n%d\n",A[i],count);
  
  return 0;
}



Measured memory_bytes: 2124
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    val n = readInt
    val b = new ArrayBuffer[Int]
    val g = for(i<-0 until n) yield {
      readLine.trim.split(" ").map(_.toInt)
    }

    var v = 0
    var total = 0
    b += v

    while(b.length < g.length) {
      var min = Int.MaxValue
      v = 0
      for(e <- b) {
        val list = for(i<-0 until g(e).length if !b.contains(i) && g(e)(i) != -1) yield (g(e)(i),i)
        if(list.length > 0) {
          val listMin = list.min
          if(listMin._1<min) {
            min = listMin._1
            v = listMin._2
          }
        }
      }
      total += min
      b += v
    }
    println(total)
  }
}

Measured memory_bytes: 59640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_100().doIt();
	}
	class Test_100{
		void doIt() {
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			if(C <= B && C >= A)System.out.println("Yes");
			else System.out.println("No");
		}
	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d = 1001, e;
	cin >> a >> b;
	for (int h = 1; h <= a; h++) {
		cin >> c >> e;
		if (e <= b) {
			d = min(c, d);
		}
	}
	if (d == 1001) {
		cout << "TLE" << "\n";
	}
	else {
		cout << d << "\n";
	}
	cin >> e;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{

    string s;

   cin>>s;

   long long int  x=0 ,res=0;

   for(int i=0;i<s.length();i++)

     {
         x=x+s[i]-48;
     }

    while(x>0)
    {
        res =x%10+res;
        x=x/10;
    }
    if(res%9==0)
    cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3652
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapify(a)
for _ in range(m):
  l = heappop(a)
  heappush(a, -((-l)//2))

print(-sum(a))

Measured memory_bytes: 14380
def solve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    A = sorted(A, reverse=True)
    width, height = 0, 0
    cnt = 0
    last_val = -1
    for i, A_i in enumerate(A):
        if last_val == A_i:
            if width == 0:
                width = max(A_i, width)
                last_val = 0
            elif height == 0:
                height = max(A_i, height)
        else:
            cnt = 0
            last_val = A_i
        if width * height > 0:
            print(width * height)
            return
        
    print(0)
    return


solve()


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  string s; cin>>s;
  string t=s.substr(5,2);
  int b=stoi(t); 
  if(b<5) cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
}


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

int main()
{
    int a,b,ans;
    cin>>a>>b;
    ans=1;
    while(ans<=1000)
    {
        int x=(ans*8)/100;
        int y=(ans*10)/100;
        if(x==a && y==b)
            break;
        ans++;
    }
    if(ans<=1000)
        cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}


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

long long dp[100][100000];

long long maxvalue(long long cur,long long B,long long w[],long long v[],long long n)
{
    if(cur==n){
        return 0;
    }
    if(B<=0){
        return 0;
    }
    if(dp[cur][B]!=-1){
        return dp[cur][B];
    }
    long long a=0;
    if(B>=w[cur]){
        a=v[cur]+maxvalue(cur+1,B-w[cur],w,v,n);
    }
    long long b=maxvalue(cur+1,B,w,v,n);
    dp[cur][B] = max(a,b);
    return dp[cur][B];
}

int main()
{
    long long n,W;
    cin>>n>>W;
    long long w[n],v[n];
    for(long long i=0; i<n; i++)
    {
        cin>>w[i]>>v[i];
    }
    for(long long i=0;i<n;i++){
        fill(dp[i],dp[i]+W+1,-1);
    }

    cout << maxvalue(0,W,w,v,n);
}



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

int main() {
	int a, b;
	char op;

	while (cin >> a >> op >> b && op != '?') {

		int ans = 0;

		if (op == '+') {
			ans = a + b;
		}
		if (op == '-') {
			ans = a - b;
		}
		if (op == '*') {
			ans = a * b;
		}
		if (op == '/') {
			ans = a / b;
		}

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

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    int H,W;
    cin >> H >> W;
    vector<char> vec(W);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> vec[j];
        }
        for(int j=0;j<W;j++){
            cout << vec[j];
        }
        cout << endl;
        for(int j=0;j<W;j++){
            cout << vec[j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

const int inf=1e9+10;
const int maxn=55;

ll dp[1<<21];
int xx[maxn],n,m;
vector <pair<int,int> > g[maxn];

bool dfs(int x,int fa,int ed,int id){
	if(x==ed) return true; 
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i].fst;
		if(to!=fa) if(dfs(to,x,ed,id)){
			xx[g[x][i].snd]|=1<<id;
			return true;
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int u,v; 
		scanf("%d%d",&u,&v);
		u--; v--;
		g[u].pb(mp(v,i));
		g[v].pb(mp(u,i));
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--; v--;
		dfs(u,-1,v,i);
	}
	dp[0]=1ll;
	for(int i=0;i<n-1;i++) 
		for(int mask=(1<<m)-1;mask>=0;mask--)
			dp[mask|xx[i]]+=dp[mask];
	printf("%lld\n",dp[(1<<m)-1]);
	return 0;
}


Measured memory_bytes: 10496
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;


int main() {
	int N;
	cin >> N;
	cout << N / 2+N%2 << endl;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){	
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int N, M, C;
	cin >> N >> M >> C;
	int *B = new int[M];
	REP(i, M) cin >> B[i];
	int cnt=0, tmp=0, a;
	REP(i, N){
		tmp=C;
		REP(j, M){
			cin >> a;
			tmp += a*B[j];
		}
		if(tmp > 0) cnt++;
	}
	cout << cnt << '\n';

	delete[] B;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{
  int N,K;
  cin>>N>>K;
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    ANS += 2*min(A,abs(K-A));
  }
  cout<<ANS<<endl;
  
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
a = list(map(float, input().split()))

a.sort()
b = [0.5,0.5]
for i in range(n-2):
    b = list(map(lambda x: x*0.5, b)) + [0.5,]

print(sum(np.array(a)*np.array(b)))


Measured memory_bytes: 12484
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2005;
int n,x,i,j,a[N],mn[N][N];
long long w,ans;
int main()
{
	scanf("%d%d",&n,&x);
	for(i=1;i<=n;++i)
		scanf("%d",a+i);
	for(i=1;i<=n;++i)
	{
		mn[i][i]=a[i];
		for(j=i+1;j<=n;++j)
			mn[i][j]=min(mn[i][j-1],a[j]);
	}
	ans=1ll<<60;
	for(i=0;i<n;++i)
	{
		w=0;
		for(j=1;j<=n;++j)
			w+=min((j-i-1>=0?mn[j-i][j]:mn[1][j]),(i-j>=0?mn[n-(i-j)][n]:1<<30));
		ans=min(ans,w+1ll*i*x);
	}
	printf("%lld",ans);
	return 0;
}


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

using namespace std;
int main()
{
 
   long long int n;
  long long a,b;
  scanf("%lld%lld%lld",&n,&a,&b);
  
   long long int ans1,ans=n/(a+b);
   if(n%(a+b)>a)
       ans1=ans*a +a;
       
   else
     ans1=ans*a + n%(a+b);

  printf("%lld",ans1);

}
   

Measured memory_bytes: 256
//abc090_d.cpp
//Sun Mar 11 20:55:05 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

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

	long ans = 0;

	if (k == 0){
		cout << n*n << endl;
	}else{

	for (int b=k+1;b<=n;b++){
		ans = ans + (b-k)*(n/b);
		int kei = n/b;
		int x = b*kei+k;
		while (x <=n){
			ans++;
			x++;
		}
//		cout << b << " " << ans << endl;
	}

	cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int A, B, C, D;

	cin >> A >> B >> C >> D;
	while (1) {
		C -= B;
		if (C <= 0) {
			cout << "Yes";
			break;
		}
		A -= D;
		if (A <= 0) {
			cout << "No";
			break;
		}

	}

}

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

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int diffx = x2 - x1;
    int diffy = y2 - y1;
    int x3=x2 - diffy;
    int x4=x1 - diffy;
    int y3= y2 + diffx;
    int y4 =y1 + diffx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int d = sc.nextInt();  
      	int[] c = new int[26];
      	int[][] s = new int[d][26];
      	for(int i=0;i<26;i++){
          c[i] = sc.nextInt();
        }
      	for(int i=0;i<d;i++){
          for(int j=0;j<26;j++){
            s[i][j] = sc.nextInt();
          }
        }
      	for(int i=0;i<d;i++){
          int n = s[i][0];
          int pos = 0;
          for(int j=1;j<26;j++){
            if( s[i][j] > n ){
              n = s[i][j];
              pos = j;
            }
          }
          System.out.println(pos+1);
        }
    }
}

Measured memory_bytes: 38076
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
using ll = long long;
using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int lcm(int x,int y){
    return x/gcd(x,y)*y;
}
int main(){
    ll r,g,b,n;
    cin >> r >> g >> b >> n;
    ll c=0;
    for(int i=0;i<=3000;i++){
        ll sum=n;
        sum -= i*r;
        if(sum<0){
            break;
        }
        if(sum==0){
            c++;
          //  cout<<i<<" "<<" "<<endl;
            break;
        }
        for(int j=0;j<=3000;j++){
            ll sum1 = sum;
            sum1 -= j*g;
            if(sum1<0){
                break;
            }
            if(sum1==0){
                c++;
             //   cout<<i<<" "<<j<<" "<<0<<endl;
                break;
            }
            if(sum1%b==0){
                c++;
              //  cout<<i<<" "<<j<<" "<<sum1/b<<endl;
                continue;
            }
        }
    }
    cout << c <<endl;
}

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

using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int H, W, N;
int a[10000];
int ans[100][100];

void solve() {
    cin >> H >> W >> N;
    rep(i,N) cin >> a[i];
    int k = 0;
    rep(i,H) rep(j,W) {
        if (i % 2 == 0) {
            ans[i][j] = k+1;
        } else {
            ans[i][W-j-1] = k+1;
        }
        a[k]--;
        if (!a[k]) k++;
    }
    rep(i,H) {
        rep(j,W) cout << ans[i][j] << " ";
        cout << endl;
    }
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<double, vector<double>, less<double>> a;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push(x);
	}
	for (int i = 0; i < m; i++) {
		double y = a.top();
		a.pop();
		y /= 2;
		a.push(y);
	}
	long long ans = 0;
	while (a.size() > 0) {
		double z = a.top();
		ans += z / 1;
		a.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;
;

int n,m;
vector<int> d[10];



bool reached(vector<int> v)
{
    bool ans = true;
    for (int i = 0;i < n-1;i++){
        if(binary_search(d[v[i]].begin(),d[v[i]].end(),v[i+1])){
            ;
        }
        else {
            ans = false;
            break;
        }
    }
    return ans;
}

int main()
{
    int a,b;
    int ans = 0;
    
    cin >> n >> m;
    for (int i = 0;i < m;i++){
        cin >> a >> b;
        a--;
        b--;
        d[a].push_back(b);
        d[b].push_back(a);
    }
    
    for (int i = 0;i < n;i++){
        sort(d[i].begin(),d[i].end());
    }
    vector<int> v;
    for (int i = 0;i < n;i++){
        v.push_back(i);
    }
    
    do {
        if(reached(v)){
            ans++;
        }
    } while (next_permutation(v.begin()+1,v.end()));
    
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
ans = 0
A = list(map(int,input().split()))
backet = [0]*n

for a in A:
  if a > n:ans += 1
  else:backet[a-1] += 1

for i,b in enumerate(backet):
  if b >= i+1:
    ans += b-i-1
  else:
    ans += b
print(ans)


Measured memory_bytes: 14268