akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const int inf = 1e9 + 7;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(All(h));
    int res = inf;
    for (int i = 0; i + k <= n; i++)
    {
        res = min(h[i + k - 1] - h[i], res);
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
	int a,b,n;
	while(cin>>a>>b>>n){
		int ans=0;
		a%=b;
		for(int i=0;i<n;i++){
			ans+=a*10/b;
			a=a*10%b;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
  int A,B,C;
  scanf("%d%d%d",&A,&B,&C);
  if(A==B&&A!=C&&B!=C)
    printf("Yes\n");
  else if(A==C&&A!=B&&B!=C)
    printf("Yes\n");
  else if(B==C&&A!=B&&A!=C)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

//#define int ll

int n;
string s;
int d=0,c=0;

signed main(){
    cin>>n>>s;
    rep(i,0,n){
        if(s[i]=='(')c++;
        else c--;
        d=min(d,c);
    }
    rep(i,0,-d)cout<<"(";
    cout<<s;
    rep(i,0,c-d)cout<<")";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll h, w, a, b;
  in2(h, w);
  vector<vector<char>> c(h, vector<char> (w));
  vector<vector<ll>> d(h, vector<ll> (w, 0));
  rep(i, h){
    rep(j, w)
      in(c[i][j]);
  }
  rep(i, h){
    a = 0;
    while(a < w){
      while(c[i][a] == '#'){
        a++;
        if(a == w)
          break;
      }
      if(a == w)
        break;
      b = a;
      if(b != w - 1){
        while(c[i][b + 1] == '.'){
          b++;
          if(b == w - 1)
            break;
        }
      }
      rep2(j, a, b + 1)
        d[i][j] += b - a + 1;
      a = b + 1;
    }
  }
  rep(i, w){
    a = 0;
    while(a < h){
      while(c[a][i] == '#'){
        a++;
        if(a == h)
          break;
      }
      if(a == h)
        break;
      b = a;
      if(b != h - 1){
        while(c[b + 1][i] == '.'){
          b++;
          if(b == h - 1)
            break;
        }
      }
      rep2(j, a, b + 1)
        d[j][i] += b - a + 1;
      a = b + 1;
    }
  }
  a = 0;
  rep(i, h){
    rep(j, w)
      a = max(a, d[i][j]);
  }
  out(a - 1);
  memi;
}

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

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

  int abs_min = 999999;
  int abs_i = 0;

  for (int i = 1; i <= N; i++){
    if (abs(L + i - 1) < abs_min){
      abs_min = abs(L + i - 1);
      abs_i = i;
    }
  }

  int sum = 0;
  for (int i = 1; i <= N; i++){
    if (i != abs_i) sum += L + i - 1;
  }

  cout << sum << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    char[]n = N.toCharArray();
    
    int all = 0;
    for(int i=0; i<N.length(); i++) {
    	all += n[i]-48;
    }
    if(Integer.valueOf(N)%all==0) {   		
		System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
    }
}


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

using namespace std;

class Solution {
public:
	void solve() {
		int n, k;
		cin >> n >> k;
		vector<int> a(n, 0);
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = k; i < n; i++) {
			if (a[i - k] < a[i])
				cout << "Yes\n";
			else
				cout << "No\n";
		}
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 3984
N = int(input())
list_m = [input().split() for _ in range(N)]

money = 0
for i in range(N):
  if list_m[i][1] == 'JPY':
    money += float(list_m[i][0])
  else:
    money += float(list_m[i][0])*380000.0
print(money)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
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 T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vi a(n, INT_MAX);
    int m = sqrt(n);
    vi b((n+m-1)/m, -1);
    auto call = [&](int i) {
        for(int x = i/m*m; x != (i/m+1)*m and x != n; x++) {
            a[x] = b[i/m];
        }
        b[i/m] = -1;
    };
    auto get = [&](int i) {
        if(b[i/m] != -1) {
            call(i);
        }
        return a[i];
    };
    auto update = [&](int l, int r, int x) {
        if(l/m == r/m) {
            if(b[l/m] != -1) call(l);
            for(; l != r; l++) {
                a[l] = x;
            }
        }
        else {
            if(b[l/m] != -1) call(l);
            if(b[r/m] != -1) call(r);
            for(; l%m; a[l++] = x);
            for(; r%m; a[--r] = x);
            for(l /= m, r /= m; l != r; b[l++] = x);
        }
    };

    while(q--) {
        int t;
        cin >> t;
        if(t) {
            int i;
            cin >> i;
            cout << get(i) << '\n';
        } else {
            int l, r, x;
            cin >> l >> r >> x;
            update(l, r+1, x);
        }
    }
}


Measured memory_bytes: 3240
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define scani(i) scanf("%d", &(i))
#define scanc(c) scanf("%c", &(c))
#define scand(d) scanf("%lf", &(d))

#define printi(i) printf("%d", (i))
#define pr printf("\n")

#define NUM (100)

int main(int argc, char** argv){
    int n, d[NUM];
    scani(n);
    rep(i, n){
        scani(d[i]);
    }
    int sum = 0;

    rep(i, n){
        for(int j = i+1; j < n; j++){
            sum += d[i] * d[j];

        }
    }

    printi(sum);
    pr;

    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define nl "\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define trav(x) for(auto& i: x)

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

	int n;
	cin >> n;
	cout << n * n * n;
}

Measured memory_bytes: 256
# 左から1, 2, 3...と出現すればいい
n = int(input())
lis = list(map(int, input().split()))
tmp = 0
c = 0
for a in lis:
    if tmp + 1 == a:
        c += 1
        tmp += 1
if c == 0:
    print(-1)
else:
    print(n - c)



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

using namespace std;
typedef long long ll;

const int MAXN = 51, MAXK = 101;

int dp[MAXN][MAXN][MAXK];
int arr[MAXN];

int solve(int l, int r, int k) {
	if(k < 0) return -1;
	if(k == 0 || l > r) return 0;
	if(dp[l][r][k] != -1) return dp[l][r][k];
	
	int take_l = solve(l+1, r, k-1) + arr[l];
	int take_r = solve(l, r-1, k-1) + arr[r];
	int skip_l = solve(l+1, r, k-2);
	int skip_r = solve(l, r-1, k-2);
	
	dp[l][r][k] = max({take_l, take_r, skip_l, skip_r, 0});
	return dp[l][r][k];
}

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

	memset(dp, -1, sizeof(dp));
	for(int i=0; i < n; i++) cin >> arr[i];

	int maxVal = solve(0, n-1, k);
	cout << maxVal;

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int check(int t, vector<int> &v) {
    int ans = 0;
    for (int i : v) ans += (i - t) * (i - t);
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int &i:v) cin >> i;

    int ans = INT_MAX;
    for (int t = -100; t <= 100; t++) {
        int now = check(t, v);
        cmin(ans, now);
    }
    cout << ans << endl;

}


Measured memory_bytes: 3552
#include <iostream>

using namespace std;

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B||B==C||A==C){
    if(A==B&&B==C){
      cout<<"No";
    }else{
      cout<<"Yes";
    }
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    vc<pair<int, int>> a(n);
    For(i, n){
        Cin(int, x);
        a[i].first = x;
        a[i].second = i+1;
    }
    Sort(a);
    For(i, n) cout << a[i].second << " ";
    cout << endl;
}




Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

int main(int argc, char **argv) {
    i64 a;
    cin >> a;
    i64 ans = a + a*a + a*a*a;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
N, X = map(int, input().split())
lists = list(map(int, input().split()))

if X - sum(lists) == 0:
    print(len(lists))
    exit()

count = 0
for num in sorted(lists):
    X -= num
    if X >= 0:
        count += 1

if X < 0:
    print(count)
else:
    print(count - 1)

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;

int main() {
    Int n;
    cin >> n;
    vector<string> s(n);
    vector<Int> t(n);
    for (Int i = 0; i < n; i++) {
        cin >> s[i] >> t[i];
    }
    string x;
    cin >> x;
    bool check = false;
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        if (check) {
            res += t[i];
        }
        if (x == s[i]) {
            check = true;
        }
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 764
#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 <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit
int N, M, Q;
vector<int> a,b,c;
vector<ll> d;

ll dfs(int n, vector<int> A){
    if(n == N){
        ll ret = 0;
        REP(i, Q){
            if(A[b[i]] - A[a[i]] == c[i]){
                ret += d[i];
            }
        }
        return ret;
    }
    
    ll ret = 0;
    int st = 1;
    if(A.size()) st = A.back();
    for(int i = st; i <= M; ++i){
        vector<int> nA = A;
        nA.push_back(i);
        ll tmp = dfs(n + 1, nA);
        chmax(ret, tmp);
    }
    
    return ret;
}

void solve() {
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    REP(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    
    ll ans = dfs(0, vector<int>());
    cout << ans << endl;


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
int main(void)
{
	int n,b,f,r,v,i,j,k,m;
	int heya[4][3][10] = {0};
	scanf("%d",&n);
	for (i = 0; i < n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);
		heya[b-1][f-1][r-1] += v;
		heya[b-1][f-1][r-1] == 1;
	}
	for (m = 0; m < 4; m++)
	{
		for (j = 0; j < 3; j++)
		{
			for (k = 0; k < 10; k++)
			{
				if (heya[m][j][k] == 1)
				{
					printf(" %d", heya[m][j][k]);
				}
				else
				{
					printf(" %d", heya[m][j][k]);
				}
			}
			printf("\n");
		}
		if (m == 3)
			break;
		for (i = 0; i < 20; i++)
		{
			printf("#");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;


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

int n;
int s;
for(int i=1;i<=5;i++){
    cin>>n;
    if(n==0){
        s=i;
        break;
    }
}
cout<<s;


	return 0;
}





Measured memory_bytes: 3652
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int K = sc.nextInt();

        char target = S.charAt(K - 1);
        String result="";
        for (int i = 0; i < N; i++) {
            if (!(S.charAt(i) == target)) {
                result+="*";
            }else{
                result+=String.valueOf(target);
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
int main(void){
  int x,i,m=0;
  
  scanf("%d",&x);
  
  while(1){
    m = 0;
    for(i = 2; i < x; i ++)
      if(x % i == 0) {
        m = 1;
        break;
      }
    
    if(m == 0){
      printf("%d",x);
      break;
    }
    x ++;
  }
}

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {

	input = input.split(" ");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	
	if ( a > 8 || b > 8 ) {
		console.log(":(");
	} else {
		console.log("Yay!")
	}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    int ans=0,sum=0;
    int n,m;
    cin >> n>>m;


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << (n+m+1)/2 << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	int N, B[nmax_def];
	int ans = 0;
	cin >> N;
	rep(i, N - 1) {
		cin >> B[i];
	}
	ans += B[0];
	rep(i, N - 2) {
		ans += min(B[i], B[i + 1]);
	}
	ans += B[N - 2];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int i,j,h,w;
        scanf("%d%d",&h,&w);
        char c[h+1][w+1];
        for(i=0;i<h;i++)
                scanf("%s",c[i]);

        for(i=0;i<h;i++){
                for(j=0;j<w;j++)
                        printf("%c",c[i][j]);
                printf("\n");
                for(j=0;j<w;j++)
                        printf("%c",c[i][j]);
                printf("\n");
        }
        return 0;
}


Measured memory_bytes: 1664
using System;
using System.Linq;
using System.Collections.Generic;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A;
            int[] Town = new int[4];
            for (int i = 0; i < 3; i++)
            {
                A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)-1).ToArray();
                Town[A[0]]++;
                Town[A[1]]++;
            }
            bool y=true;
            for (int i = 0; i < 4; i++)
                y &= Town[i] < 3;
            Console.WriteLine(y ? "YES" : "NO");
            Console.ReadKey();
            
        }
    }
}

Measured memory_bytes: 13268
from enum import Enum
import sys
import math

# 0:上側 1:南 2:東 3:西 4:北 5:下側

class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.pattern = 'NNNNENNNENNNWNNNWNNNENNN'
        
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
        
    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]
        
        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0], self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2], self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2], self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5], self.work[0], self.work[4], self.work[3])

    def match(self, top, front):
        for i in range(6):
            self.work[i] = self.number[i]
        
        ret = 0
        
        for i in range(len(self.pattern)):
            self.roll(self.pattern[i])
            if top == self.number[0] and front == self.number[1]:
                ret = self.number[2]
                break
                
    def get_Right(self):
        return self.number[2]        
        
dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

top_fro = []
q = int(input())
for i in range(q):
    top_fro.append(list(map(int, input().split())))

for i in range(q):
    dice.match(top_fro[i][0], top_fro[i][1])
    print("%d"%(dice.get_Right()))

                


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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin>>n>>k;
	vector<ll> a(n+1), ans;
	map<int, bool> is;
	for(int i = 1; i <= n; i++)
	{
		cin>>a[i];
	}
	int f = 0, curr = a[1], next;
	ans.pb(1);
	is[1]=true;
	int ind;
	while(true)
	{
		if(is[curr]==false)
		{
			// curr = a[i];
			next = a[curr];
			ans.pb(curr);
			is[curr]=true;
			curr = next;
		}
		else
		{
			ind=curr;
			f=1;
			break;
		}
	}

	if(k < ans.size())
	{
		cout<<ans[k];
	}
	else
	{
		// cout<<"ind2 "<<ind<<endl;
		int ind2 = -1;
		for(int i = 0; i < ans.size(); i++)
		{
			if(ans[i]==curr)
			{
				ind2 = i;
				break;
			}
		}
		// cout<<ind2<<endl;
		vector<ll> tempe;
		for(int i = ind2; i < ans.size(); i++)
		{
			tempe.pb(ans[i]);
		}
		// for(auto i: tempe)
		// {
		// 	cout<<i<<"  ";
		// }
		// cout<<endl;




		// for(auto i: ans)
		// {
		// 	cout<<i<<" ";
		// }
		// cout<<endl;
		// int size = ans.size();
		// cout<<tempe.size()<<endl;
		cout<<tempe[(k-ind2+tempe.size())%(tempe.size())]<<endl;
		// cout<<ans[(k-ind2+1+ans.size())%(ans.size())]<<endl;
	}
	// for(int i = 0; i < ans.size(); i++)
	// {
	// 	cout<<ans[i]<<" ";
	// }
	// cout<<endl;
	// if 
	// {
		// cout<<ans[k%(ans.size())]<<endl;
	// }
	// else
	// {

	// }

}

Measured memory_bytes: 16456
#include <iostream>
#include <iomanip>

int main()
{
    unsigned long int ax, bx;
    int X, Y;


    std::cin >> ax >> bx;
    X = ax / bx;
    Y = ax % bx;

    std::cout << std::fixed << std::setprecision(10);
    std::cout << X << " " << Y <<
    " "  <<  (1.0 * ax )/(1.0 *  bx)<<"\n";

    return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10;
vector<int>adj[M];
int val[M],dp[M],zt[M],leaf[M],root;
void dfs(int v,int l)
{
	vector<int>tmp;
	if(adj[v].size()==1){
		leaf[v]=val[v];
		return;
	}
	for(int i=0;i<adj[v].size();i++)
	{
		int u=adj[v][i];
		if(u!=l)dfs(u,v);
		if(u==l)continue;
		zt[v]+=zt[u];
		leaf[v]+=leaf[u];
		tmp.pb(leaf[u]-zt[u]);
	}
	int res=leaf[v]-zt[v];
	if(val[v]>res)
	{
		cout<<"NO";
		exit(0);
	}
	dp[v]=res-val[v];
	if(v==root && dp[v]!=val[v])
	{
		cout<<"NO";
		exit(0);
	}
	zt[v]+=2*dp[v];
	int bad=0;
	for(int i=0;i<tmp.size();i++)
	{
		if(tmp[i]<=dp[v])continue;
		bad+=tmp[i]-dp[v];
	}
	if(bad>res-dp[v]*2)
	{
		cout<<"NO";
		exit(0);
	}
}
main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>val[i];
	for(int i=1;i<=n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	if(n==2)
	{
		if(val[1]==val[2])cout<<"YES";
		else cout<<"NO";
		return 0;
	}
	root=1;
	for(int i=1;i<=n;i++)
	{
		if(adj[i].size()!=1)root=i;
	}
	dfs(root,0);
	cout<<"YES";
}

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

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

using namespace std;

void makeRoute(vector<vector<int>> &routes, vector<int> vec, set<int> unvisited) {
	if (unvisited.empty())routes.push_back(vec);
	for (auto itr = unvisited.begin(); itr != unvisited.end(); ++itr) {
		set<int> s = unvisited;
		s.erase(*itr);
		vector<int> v = vec;
		v.push_back(*itr);
		makeRoute(routes, v, s);
	}
}

double calcDistances(double &ans, vector<vector<int>> routes, vector<pair<int, int>> cordinate, int factorial) {
	rep(i, routes.size()) {
		double distance = 0;
		rep(j, routes[i].size() - 1) {
			int town1 = routes[i][j];
			int town2 = routes[i][j + 1];
			int x1 = cordinate[town1-1].first;
			int x2 = cordinate[town2-1].first;
			int y1 = cordinate[town1-1].second;
			int y2 = cordinate[town2-1].second;
			distance += sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		}
		ans += distance / factorial;
	}
	return ans;
}

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> cordinate(N);

	rep(i, N) {
		int x, y;
		cin >> x >> y;
		cordinate[i] = make_pair(x, y);
	}

	vector<vector<int>> routes;
	set<int> unvisited;
	rep(i, N)unvisited.insert(i + 1);
	vector<int> vec;
	makeRoute(routes, vec, unvisited);
	/*rep(i, routes.size()) {
		rep(j, N)cout << routes[i][j];
		cout << endl;
	}*/

	int factorial = 1;
	rep(i, N)factorial *= (i + 1);

	double ans = 0;
	vector<int> visited;
	ans = calcDistances(ans, routes, cordinate, factorial);
	cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 5940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n;
	vector<char> s(0);
	vector<char> prev(0);
	vector<char> n2(0);
	bool ans = true;
	cin >> n;
	if (n % 2 != 0) {
		ans = false;
		cout << "No";
		return 0;
	}
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		s.push_back(c);
		if (i < n / 2) {
			prev.push_back(c);
		}
		else {
			n2.push_back(c);
		}
	}
	for (int i = 0; i < prev.size(); i++) {
		//cout << prev.at(i) << " " << n2.at(i) << endl;
		if (prev.at(i) != n2.at(i)) ans = false;
	}
	if (ans) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int Max(int x, int y) {
  return (x>y) ? x : y;
}

int main() {
  int a, b, max;
  scanf("%d%d", &a, &b);
  max = Max(a+b, a-b);
  max = Max(max, a*b);
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  while (true) {
    ll n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) break;

    vll cs(m);
    rep(i, m) cin >> cs[i];
    vll xs(n);
    rep(i, n) cin >> xs[i];

    auto dis = [](ll x, ll y) { return (x - y) * (x - y); };

    vvll dp(n + 1, vll(256, INF));
    dp[0][128] = 0;
    rep(i, n){
      rep(j, 256){
        rep(k, m) { ll nj = j + cs[k];
          chmin(nj, 255LL);
          chmax(nj, 0LL);
          ll cst = dis(nj, xs[i]);
          chmin(dp[i + 1][nj], dp[i][j] + cst);
        }  // k
      } // j
    } // i
    ll ans = INF;
    rep(j, 256) chmin(ans, dp[n][j]);
    cout << ans << endl;
  }  // while

  return 0;
}



Measured memory_bytes: 43812
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

  int all_E = 0;
  for (int i = 0; i < N; i++) {
      if (S[i] == 'E') all_E++;
  }
  int all_W = N-all_E;

  int tmp_E = 0;
  int min = N;
  for (int i = 0; i < N; i++) {
      int countable_W = (i-tmp_E);
      int countable_E = all_E-tmp_E;
      if (S[i] == 'E') countable_E--;
      if (min > countable_W + countable_E) min = countable_E+countable_W;
      if (S[i] == 'E') tmp_E++;
  }

  cout<<min<<endl;

  return 0;
}


Measured memory_bytes: 900
open Batteries
let n = read_int ()
let a = read_line () |> String.split_on_char ' ' |> List.map int_of_string
let q = read_int ()

let dp = Array.init 100010 @@ fun _ -> 0
let rec dp_loop lst result =
  match lst with
  | [] -> result
  | first :: rest -> dp.(first) <- dp.(first)+1; dp_loop rest (result+first)
let all = dp_loop a 0

let rec q_loop i now_all =
  if i >= q then () else (
    Scanf.sscanf (read_line()) "%d %d" (fun b c -> 
    let new_all = (now_all - (dp.(b)*b) - (dp.(c)*c) + ((dp.(b)+dp.(c))*c)) in
      Printf.printf "%d\n" new_all;
      (* Printf.printf "dp(b)*b: %d, dp(b): %d\n" (dp.(b)*b) (dp.(b));
      Printf.printf "dp(c)*c: %d, dp(c): %d\n" (dp.(c)*c) dp.(c); *)
      dp.(c) <- dp.(c) + dp.(b);
      dp.(b) <- 0;
      q_loop (i+1) new_all
    )
  )

let _ = q_loop 0 all

Measured memory_bytes: 17400
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int N,K,x,y,sum;
	cin >> N >> K;
    vector<int> vec(100);
    vector<int> F(N);
    for(int i=0;i<N;i++){
      F.at(i)=0;
    }
    for(int i=0; i<K;i++){
      cin >> x;
      for(int j=0;j<x;j++){
        cin >> y;
        F.at(y-1)++;
      }
    }
    for(int i=0;i<N;i++){
      if(F.at(i)==0){
        sum++;
      }
    }
    
      cout << sum << "\n";
  
}

Measured memory_bytes: 3656
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#define N 4400
#define L 4000
#define eps 1e-7
#define inf 1e9+7
#define db double
#define ll long long
#define ldb long double
using namespace std;
inline ll read()
{
	char ch=0;
	ll x=0,flag=1;
	while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*flag;
}
const ll mo=998244353;
char s[N];
ll a[N],b[N],f[N][N],dp[N][N];
int main()
{
	scanf("%s",s+1);
	ll n=strlen(s+1);
	for(ll i=1;i<=n;i++)
	{
		a[i]=a[i-1],b[i]=b[i-1];
		if(s[i]=='0')a[i]+=2;
		if(s[i]=='2')b[i]+=2;
		if(s[i]=='1')a[i]+=1,b[i]+=1;
	}
	for(ll i=0;i<=a[n];i++)
	for(ll j=0;j<=b[n];j++)
	if(i+j<2*n)
	{
		f[i][j]=-1;
		ll k=min(n,i+j+1);
		if(a[k]-i>0&&b[k]-j>0)f[i][j]=1;
		else
		{
			if(a[k]-i>0)f[i][j]=0;
			if(b[k]-j>0)f[i][j]=2;
		}
	}
	dp[0][0]=1;
	for(ll i=0;i<=a[n];i++)
	for(ll j=0;j<=b[n];j++)
	if(i+j!=0)
	{
		dp[i][j]=0;
		if(i&&(f[i-1][j]==0||f[i-1][j]==1))dp[i][j]=(dp[i][j]+dp[i-1][j])%mo;
		if(j&&(f[i][j-1]==1||f[i][j-1]==2))dp[i][j]=(dp[i][j]+dp[i][j-1])%mo;
	}
	printf("%lld",dp[a[n]][b[n]]);
	return 0;
}

Measured memory_bytes: 276992
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[10];
    for(int i = 0 ; i < 10 ; i++) cin >> a[i];
    sort(a, a + 10);
    for(int i = 0 ; i < 3 ; i++)
        cout << a[9 - i] << endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, k;
bool d[10];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> k;
    rep(i, 0, k) {
        int s; cin >> s;
        d[s] = true;
    }
    int cnt = 1;
    while (1) {
        int t = n;
        bool flag = true;
        while (t > 0) {
            int p = t % 10;
            if (d[p]) {
                // cout << t << " " << p << endl;
                n++;
                flag = false;
                break;
            }
            t /= 10;
        }
        if (flag) break;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int n, k, iAns, p;
	register int i, j;
	int arrChecker[12][6] = {
		{ 4, 2, 0, 9, 7 },
		{ 1, 10, 8, 6, 4 },
		{ 9, 7, 5, 3, 1 },
		{ 6, 4, 2, 0, 9 },
		{ 3, 1, 10, 8, 6 },
		{ 0, 9, 7, 5, 3 },
		{ 8, 6, 4, 2, 0 },
		{ 5, 3, 1, 10, 8 },
		{ 2, 0, 9, 7, 5 },
		{ 10, 8, 6, 4, 2 },
		{ 7, 5, 3, 1, 10 }
	};
	cin >> n >> k;
	n -= 2;
	p = n % 11;
	n /= 11;
	iAns = n * 5;
	for (i = 0; i<p; ++i)
		for (j = 0; j<5; ++j)
			if (arrChecker[i][j] == k)
				++iAns;
	cout << iAns << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
INF = 10 ** 8
import itertools

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ABC = []
for _ in range(M):
    ABC.append(tuple(map(int, input().split())))

G = [[INF] * N for _ in range(N)]
for i in range(N):
    G[i][i] = 0
for el in ABC:
    a, b, c = el
    G[a-1][b-1] = c
    G[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            #print(G)
            G[i][j] = min(G[i][k] + G[k][j], G[i][j])

#print(G)
p = itertools.permutations(r)
m = INF
for el in p:
    #print(el)
    dist = 0
    for i in range(R - 1):
        dist += G[el[i] - 1][el[i + 1] - 1]
    m = min(m, dist)
print(m)








Measured memory_bytes: 48856
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
unsigned long long int gcd(unsigned long long int a,unsigned long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
  
   
// Function to return LCM of two numbers  
 unsigned long long int lcm(unsigned long long int a,unsigned long long int b)  
 {  
    return (a*b)/gcd(a, b);  
 }  

int main()
{
 unsigned long long int A,B,C,D;
  cin>>A>>B>>C>>D;
  unsigned long long int p,q,r,y,x,ps,pe,qs,qe,ys,ye;
  y=lcm(C,D);
  pe=B/C;
  if(A%C==0){
      ps=A/C;
  }
  else
    ps=(A/C)+1;;
  qe=B/D;
  if(A%D==0){
      qs=A/D;
  }
  else
    qs=(A/D)+1;;
  ye=B/y;
  if(A%y==0){
      ys=A/y;
  }
  else
    ys=(A/y)+1;
    
p=pe-ps+1;
q=qe-qs+1;
r=ye-ys+1;

 cout<<(B-A+1)-(p+q-r);
//   cout<<x;
  
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn main() {
    input!{
        n: i64,
        k: i64
    }
    let m:i64 = 1_000_000_007;
    let mut ans:i64 = 1;
    for i in k..n+1 {
        ans += i*(n - i+1)%m + 1;
        ans%=m;
    }
    println!("{}", ans);
}

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


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

	vector<int> A(N);
	for(auto& e : A) {
		cin >> e;
	}

	vector<int> X(Q);
	for(auto& e : X) {
		cin >> e;
	}

	vector<ll> cumsum_all(N), cumsum_even(N), cumsum_odd(N);
	cumsum_all[0] = A[0];
	cumsum_even[0] = A[0];
	cumsum_odd[0] = 0;
	for(int i=1;i<N;i++) {
		cumsum_all[i] = cumsum_all[i - 1] + A[i];
		cumsum_even[i] = cumsum_even[i - 1] + (i % 2 == 0 ? A[i] : 0);
		cumsum_odd[i] = cumsum_odd[i - 1] + (i % 2 == 1 ? A[i] : 0);
	}

	for(int q=0;q<Q;q++) {
		int i = lower_bound(A.begin(), A.end(), X[q]) - A.begin();
		int l = 0, r = N;
		while(r - l > 1) {
			int mid = (l + r) / 2;
			assert(mid >= 1 && mid + 1 <= N);
			int aoki_r = N - mid - 1;
			int aoki_l = lower_bound(A.begin(), A.end(), X[q] - abs(X[q] - A[aoki_r])) - A.begin();
			if(aoki_r - aoki_l + 1 >= mid) {
				l = mid;
			}else {
				r = mid;
			}
		}
		int aoki_r = N - l - 1;
		int aoki_l = lower_bound(A.begin(), A.end(), X[q] - abs(X[q] - A[aoki_r])) - A.begin();
		int aoki_len = aoki_r - aoki_l + 1;
		assert(l <= aoki_len);
		ll ans = cumsum_all[N - 1] - cumsum_all[aoki_r];
		if(l < aoki_len) {
			ans += A[aoki_r];
			int j = aoki_r - 1 - (l + 1);
			if (j >= 0) {
				ans += j % 2 == 0 ? cumsum_even[j] : cumsum_odd[j];
			}
		}else {
			int j = aoki_r - l;
			if (j >= 0) {
				ans += j % 2 == 0 ? cumsum_even[j] : cumsum_odd[j];
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 4864
n = int(input())
nums = [list(map(int, input().split())) for _ in range(n)]

count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for num in nums:
    count[num[0] - 1][num[1] - 1][num[2] - 1] += num[3]

for k in range(4):
    for j in range(3):
        for i in range(10):
            print("", count[k][j][i], end="")
        print()
    if k != 3:
        print("#" * 20)



Measured memory_bytes: 5636
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    // #pragma GCC optimize("Ofast")
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double

    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int cnt;
    string s,st;
    
    void solve()
    {
        cin>>s>>st;
        n=s.size();
        fo(i,0,n)
        if(s[i]!=st[i])cnt++;
        cout<<cnt;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3764