akhauriyash/Code-Regression huggingface dataset:
int compare_int(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int n, m, x[100000], ans, sum, i;
int main(){
  scanf("%d%d", &n, &m);
  if(n>=m){
    puts("0");
    return 0;
  }
  for(i=0; i<m; i++){
    scanf("%d", x+i);
  }
  qsort(x, m, sizeof(int), compare_int);
  sum=x[0]-x[m-1];
  for(i=0; i<m-1; i++){
    x[i]=x[i]-x[i+1];
  }
  qsort(x, m-1, sizeof(int), compare_int);
  for(i=0; i<n-1; i++){
    ans+=x[i];
  }
  printf("%d\n", sum-ans);
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    LL res = 1;
    for(int i = 0; i < N; ++i) {
        LL a;
        cin >> a;
        res = LCM(res, a);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3628
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()

    if len(S) == 3:
        print(S[::-1])
    else:
        print(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61828
#include<stdio.h>

#define max(a,b) ((a>b)?a:b)

int main(void){
    int a[100000]={1},n,s=0,x,y,i,ans=0;
    scanf("%d",&n);
    scanf("%d",&x);
    for(i=1; i<n; i++){
        scanf("%d",&y);
        if(x==y){
            s++;
            a[s]=1;
        }else{
            a[s]++;
        }
        x = y;
    }
    for(i=0; i<=s; i++){
        ans = max(ans,a[i]);
    }
    for(i=0; i<s; i++){
        n = a[i]+a[i+1];
        ans = max(ans,n);
    }
    for(i=1; i<s; i++){
        n = a[i-1]+a[i]+a[i+1];
        ans = max(ans,n);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1428
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>
#include <tuple>
#include <numeric>

template <typename Tp, Tp inf = std::numeric_limits<Tp>::max()>
class li_chao_tree {
public:
  using value_type = Tp;
  using size_type = size_t;

private:
  using line_type = std::pair<value_type, value_type>;
  std::vector<value_type> M_x;
  size_type M_n;
  std::vector<line_type> M_l;

  static const value_type S_inf = inf;

  value_type M_f(size_type i, value_type x) const {
    x *= M_l[i].first;
    x += M_l[i].second;
    return x;
  }

  void M_descend(size_type i, value_type a, value_type b) {
    size_type l = i;
    size_type r = i+1;
    while (l < M_n) {
      l <<= 1;
      r <<= 1;
    }

    while (r-l > 1) {
      size_type m = (l+r) >> 1;
      value_type xl = M_x[l-M_n];
      value_type xm = M_x[m-M_n];
      value_type xr = M_x[r-1-M_n];
      value_type yl0 = M_f(i, xl);
      value_type ym0 = M_f(i, xm);
      value_type yr0 = M_f(i, xr);
      value_type yl1 = a * xl + b;
      value_type ym1 = a * xm + b;
      value_type yr1 = a * xr + b;

      if (yl0 < yl1 && yr0 < yr1) return;
      if (yl1 < yl0 && yr1 < yr0) {
        M_l[i] = {a, b};
        return;
      }

      if (ym1 < ym0) {
        std::swap(M_l[i].first, a);
        std::swap(M_l[i].second, b);
      }
      if ((yl0 < yl1 && yr1 < yr0) ^ (ym1 < ym0)) {
        l = m;
        i = (i << 1 | 1);
      } else {
        r = m;
        i = (i << 1 | 0);
      }
    }
  }

public:
  li_chao_tree() = default;
  li_chao_tree(li_chao_tree const&) = default;
  li_chao_tree(li_chao_tree&&) = default;

  template <typename InputIt>
  li_chao_tree(InputIt first, InputIt last):
    M_x(first, last), M_n(M_x.size()),
    M_l(M_n*2, std::make_pair(value_type(0), S_inf))
  {}  // assuming std::is_sorted(first, last);

  li_chao_tree& operator =(li_chao_tree const&) = default;
  li_chao_tree& operator =(li_chao_tree&&) = default;

  void push(value_type const& a, value_type const& b) {
    push(a, b, 0, M_n);
  }

  void push(value_type const& a, value_type const& b, size_type l, size_type r) {
    l += M_n;
    r += M_n;
    while (l < r) {
      if (l & 1) M_descend(l++, a, b);
      if (r & 1) M_descend(--r, a, b);
      l >>= 1;
      r >>= 1;
    }
  }

  value_type get(size_type i) const {
    value_type x = M_x[i];
    value_type res = S_inf;
    i += M_n;
    while (i > 0) {
      res = std::min(res, M_f(i, x));
      i >>= 1;
    }
    return res;
  }
};

template <typename Tp, Tp x>
Tp const li_chao_tree<Tp, x>::S_inf;

int main() {
  size_t n;
  intmax_t c;
  scanf("%zu %jd", &n, &c);

  std::vector<intmax_t> h(n);
  for (auto& hi: h) scanf("%jd", &hi);

  intmax_t inf = 1e18;
  std::vector<intmax_t> dp(n, inf);
  li_chao_tree<intmax_t> lct(h.begin(), h.end());

  dp[0] = 0;
  for (size_t i = 1; i < n; ++i) {
    size_t j = i-1;
    intmax_t a = -2*h[j];
    intmax_t b = (dp[j] + h[j]*h[j]);
    lct.push(a, b);
    dp[i] = lct.get(i) + h[i]*h[i] + c;
  }

  printf("%jd\n", dp[n-1]);
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int N, Z, W;
    cin >> N >> Z >> W;

    vector<int> a(N);
    rep(i, N) { cin >> a.at(i); }
    if (N == 1) {
        cout << abs(a[0] - W) << endl;
    } else {
        cout << max(abs(a[N-1] - W), abs(a[N-1] - a[N-2])) << endl;
    }
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

string s, t;

int main(void) {
    cin >> s >> t;

    sort(ALLOF(s));
    sort(ALLOF(t));

    bool flag = true;
    for(int i = 0; i <= t.length(); ++i) {

        if (i == t.length()) {
            auto itr = upper_bound(ALLOF(s), s[0]);

            if (itr != s.end()) {
                flag = false;
                break;
            }

            flag = s.length() < t.length();
            break;
        }

        if (s[0] < t[t.length() - 1 - i]) {
            break;
        }
        else if (s[0] > t[t.length() - 1 - i])
        {
            flag = false;
            break;
        }
        
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int input() {
	int r;
	cin >> r;
	//scanf("%lld", &r);
	return r;
}
int gcd(int i,int j) {
	if (i%j == 0)return j;
	return gcd(j, i%j);
}
int fgcd(int i, int j, int k) { return gcd(i, gcd(j, k)); }
signed main() {
	int k = input();
	int ans = 0;
	for1(i, k)for1(j, k)for1(p, k)ans += fgcd(i, j, p);
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int n,key,A[100],j;
 
void print_table(){
  for(int i=0;i<n;i++){
    if(i)cout<<' ';
    cout<<A[i];
  }
  cout<<endl;
}
 
int main(){
 
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  print_table();
  for(int i=1;i<n;i++){
    key=A[i];
    j=i-1;
    while(j>=0&&A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
    print_table();
  }
  return 0;
}

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

def main():
    H, W, A, B = map(int, input().split())

    if A * 2 > W or B * 2 > H:
        print("No")
        return
    
    for i in range(H-B):
        for j in range(W-A):
            print(1, end="")
        for j in range(A):
            print(0, end="")
        print()
    for i in range(B):
        for j in range(W-A):
            print(0, end="")
        for j in range(A):
            print(1, end="")
        print()


if __name__ == "__main__":
    main()

Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
int n;
int a[3005];
int ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	   scanf("%d",&a[i]),ans+=a[i]-1;
	printf("%d\n",ans);
	return 0;
 } 

Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define clr(x) memset(x, 0, sizeof(x))
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef pair<long , long> pll;

const ll mx = 51;
const ll mod = 998244353;


vector<vector<int>> adj;
ll a[mx], b[mx], c[mx], d[mx];

vector<ll> vals(mx);

ll res;

void gen(ll cur, ll in, ll n, ll q, ll m){
    
    if(in == n){
        ll i, j, k;
      
        
         ll cur = 0; 
        for(i = 0;i < q;i++){
            if(vals[b[i]-1] - vals[a[i]-1] == c[i]){
                cur += d[i];
            }
        }
        res = max(res, cur);
    }
    else{
        ll i;
        for(i = cur;i <= m;i++){
            vals[in] = i;
            gen(i, in+1, n, q, m);

        }
    }
}


void solve(){
    
    ll n, m, q ,i , j;

    cin>>n>>m>>q;

    

    for(i =0 ;i < q;i++){
          cin>>a[i]>>b[i]>>c[i]>>d[i];
    }

    res = 0;

    for(i = 1 ;i <= m;i++){
        vals[0] = i;
        gen(i, 1, n, q, m);
    }
    cout<<res<<"\n";
}


int main(){

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

    ll t = 1;
    
   // cin>>t;

    while(t--){
        solve();
    }
   
}




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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

ll arr[1005] ;

int main()
{
    ll n, mid = 0, ans = 1e10 ;
    cin >> n ;

    for (int i = 0; i < n; i++) {
        cin >> arr[i] ;
    }
    for (int i = 1; i <= 100; i++) {
        mid = 0 ;
        for (int j = 0; j < n; j++) {
            mid += abs(i - arr[j]) * abs(i - arr[j]) ;
        }
        ans = min(ans, mid) ;
    }

    cout << ans << endl ;
}


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

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << '\n';
  } else {
    cout << "IMPOSSIBLE\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {

	int n, a[100], smn;
	double ave = 0.0, tmp = 100000.0;

	cin >> n;

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

		ave += a[i];
	}
	ave /= n;

	//cout << ave << "\n";

	for (int i = n-1; i >=0; i--) {
		if (fabs(ave - a[i]) <= tmp) {
			tmp = abs(ave - a[i]);
			smn = i;
		}
	}

	cout << smn << "\n";

	return 0;
}

Measured memory_bytes: 256
import itertools


N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

R = sorted(P)

for index, S in enumerate(list(itertools.permutations(R))):
    PS = sum([P[n] != S[n] for n in range(N)])
    QS = sum([Q[n] != S[n] for n in range(N)])
    if PS == 0:
        index_P = index
    if QS == 0:
        index_Q = index

print(abs(index_P - index_Q))


Measured memory_bytes: 8052
#include <cmath>
#include <iostream>
#include <limits>

template <class T>
T calc_number_of_digits(T x) {
    T ret = 0;
    do {
        ++ret;
        x /= 10;
    } while (x);
    
    return ret;
}

template <class T>
T f(T a, T b) {
    return std::max<T>(calc_number_of_digits<T>(a), calc_number_of_digits<T>(b));
}

int main() {
    long long N;
    std::cin >> N;

    const auto max_a = static_cast<long long>(std::ceil(std::sqrt(N)));
    auto ret = std::numeric_limits<long long>::max();
    for (long long a = 1; a <= max_a; ++a) {
        if (N % a != 0) {
            continue;
        }

        const auto b = N / a;
        ret = std::min(ret, f(a, b));
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=1; i<=n; i++)

int main()
{
	char s[5];
	
	scanf("%s", s);
	
	if(s[2]==s[3] && s[4]==s[5]){
		printf("Yes");
	}else {
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

signed main()
{
	ios::sync_with_stdio(false);
	int x;
	cin>>x;
	if(x<30) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  size_t N; cin >> N;
  map<char, ll> res{};
  vector<char> M = {'M', 'A', 'R', 'C', 'H'};
  for (size_t i = 0; i < N; ++i) {
    string s; cin >> s;
    ++res[s[0]];
  }

  ll ans{};
  for (size_t a = 0; a < M.size(); ++a) {
    for (size_t b = a + 1; b < M.size(); ++b) {
      for (size_t c = b + 1; c < M.size(); ++c) {
        ans += res[M[a]] * res[M[b]] * res[M[c]];
      }
    }
  }

  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b;
	cin >> a >> b;
	for (int i = 0; i <= 100 * 100; ++i) {
		if (i * 8 / 100 == a && i * 10 / 100 == b) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
 	return 0;
}


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

int main(){

    int x;
    cin >> x;

    if(x<1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = ReadLine().Split().Select(double.Parse).ToArray();
		var sum = 0d;
		for(int i = 1; i <= n[0]; i++)
		{
			if(i < n[1])
			{
				var a = (int)Ceiling(Log(n[1] / i, 2));
				sum += 1d / (1 << a);
			}
			else
				sum += 1d;
		}
		WriteLine(sum / n[0]);
	}
}


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

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> h(N);
  for( int i = 0; i < N; i++ ){
    cin >> h.at(i);
  }
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( h.at(i) >= K ){
      ans++;
    }
  }
  
  cout << ans;
  //printf("%.10f", ans);
  
  return 0;
}
  
      


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main (){
    int n;cin>>n;string a[n];int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
    for(int i=0;i<n;i++){
            cin>>a[i];
            if (a[i]=="AC")cnt1++;
            else if (a[i]=="WA")cnt2++;
            else if (a[i]=="TLE")cnt3++;
            else {cnt4++;}

    }
    cout<<"AC"<<" "<<"x"<<" "<<cnt1<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<cnt2<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<cnt3<<endl;
    cout<<"RE" <<" "<<"x"<<" "<<cnt4<<endl;
    return 0;
}


Measured memory_bytes: 6752
use std::io;
use std::str::FromStr;
 
fn main() {
    let (n, x) = {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.split_whitespace();
        (usize::from_str(it.next().unwrap()).unwrap(),
        i32::from_str(it.next().unwrap()).unwrap())
    };
    let l = {
        let mut l: Vec<i32> = Vec::new();
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let it = buf.split_whitespace();
        for ln in it {
            l.push(i32::from_str(ln).unwrap());
        }
        l
    };

    let mut d = 0;
    let mut ans = 0;
    for ln in l {
        d = d + ln;
        if d <= x {
            ans += 1;
        }
    }
    println!("{}", ans + 1);
}

Measured memory_bytes: 4352
#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<<"Right"<<endl;
    }
  else {
    cout<<"Balanced"<<endl;
  }
}


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

using namespace std;

int main(void){
    int k;
    cin >> k;
    k++;
    long long sum = 0;
    int temp = 0;
    int memo[300][300];
    for(int i = 0; i <= 200; i++){
        for(int j = 0; j <= 200; j++){
            memo[i][j] = -1;
        }
    }
    for(int a = 1; a < k; a++){
        for(int b = 1; b < k; b++){
            for(int c = 1; c < k; c++){
                if(memo[a][b] == -1){
                    memo[a][b] = __gcd(a, b);
                }
                if(memo[b][c] == -1){
                    memo[b][c] = __gcd(b, c);
                }
                if(memo[a][memo[b][c]] == -1){
                    memo[a][memo[b][c]] = __gcd(a, memo[b][c]);
                }
                sum += memo[a][memo[b][c]];
            }
        }
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
    long long ans = -1000000000000000001, a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ans = max(a*c, ans);
    ans = max(a*d, ans);
    ans = max(b*c, ans);
    ans = max(b*d, ans);
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

pll a[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll h, l, n;
	cin >> n;
	ll L, r;
	for(int i =0;i<n;i++){
		cin >> h >> l;
		L = h - l;
		r = h + l;
		a[i] = {r, L};
		cerr << "! " << L << " " << r << '\n';
	}
	sort(a, a + n);
	ll ans = 0;
	ll R = -Inf;
	for(int i = 0; i < n; i++){
		if(R <= a[i].S){
			R = a[i].F;
			ans ++;
		}
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 1792
n,a,b=map(int,input().split())
ans = 0
l = list(range(1, n+1))

def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

# print(digitSum(123))
# => 6
# print(digitSum(35829))
# => 27

for i in l:
    if a <= digitSum(i) <= b:
        ans = ans + i
print(ans)




Measured memory_bytes: 3316
#include <iostream>
#include <string>

using namespace std;
int main()
{
	long s;
	int money,n,b,min,max,oof;
	min = 2000;
	max = -2000;
	int a[10000];
	cin >> n;
	s = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s = s + a[i];
		if (min > a[i]) min = a[i];
		if (max < a[i]) max = a[i];	
	}
	oof = 2000000000;
	for (b = min; b <= max; b++)
	{
		int money = 0;
		for (int i = 1; i <= n; i++)
		{
			money = money + (a[i]-b)*(a[i]-b);
		}
		if (money < oof) oof = money;
	}
	cout << oof;
	return 0;
}




Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int number_of_elements = sc.nextInt();
      	int intArray[] = new int[number_of_elements];
      	int index = 0;
      	while(sc.hasNextInt()){
          intArray[index++] = sc.nextInt();
        }
      int cost = 0;
      int dpArray0=0;
      int dpArray1=Math.abs(intArray[1]-intArray[0]);
      for(int i =2 ;i<intArray.length;i++){
        int dpArray2 = dpArray1;
      	dpArray1=Math.min(dpArray0+Math.abs(intArray[i]-intArray[i-2]),dpArray1+Math.abs(intArray[i]-intArray[i-1]));
        dpArray0 = dpArray2;
      }
      System.out.println(dpArray1);
	}
}


Measured memory_bytes: 52272
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    ll buf=n;
    ll m=0;
    while(buf>0){
        m+=buf%10;
        buf/=10;
    }
    if(n%m==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No" <<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++) ans += (s[i] == t[i]);
    cout << ans << '\n';
    
    return 0;
}


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

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	vector<long long>H(N);
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}
	long long l = -1;
	long long r = 1e9;
	while (l + 1 < r) {
		long long c = (l + r) / 2;
		long long count = 0;
		for (int n = 0; n < N; ++n) {
			long long tmph = H[n];
			tmph -= c * B;
			if (tmph > 0) {
				count += (tmph + A - B - 1) / (A - B);
			}
		}
		if (count > c) {
			l = c;
		}
		else {
			r = c;
		}
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3980
// Try diverta 2019 Programming Contest
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let k = get!();
    
    let ans = n - k + 1;
    
    println!("{}", ans);
    
}

Measured memory_bytes: 4352
n = int(input())
p = list(map(int, input().split()))

cnt = 0

for i in range(1, n-1):
    if(p[i-1] < p[i] and p[i] < p[i+1]):
        cnt += 1
    elif(p[i-1] > p[i] and p[i] > p[i+1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    long long int n,m;
    cin>>n>>m;
    n = (n%m);
    long long int ans;
    ans = min(n,abs(n-m));
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (ll)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<ll> tmp;
int main(){
  IOS();
  string s;
  cin >> s;
  ll ans = SZ(s);
  REP (i,SZ(s)-1) {
    if (s[i] != s[i+1]) ans = min(ans,max(SZ(s)-i-1,i+1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
X=io.read"*n"

function f(x)
	if(x==2)then return true end
	if(x%2==0)then return false end
	for i=3,math.sqrt(x),2 do
		if(x%i==0)then return false end
	end
	return true
end

while(true)do
	if(f(X))then print(X)return end
	X=X+1
end

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

using namespace std;

typedef long long ll;

const ll p = 1e9 + 7;

int main(){
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll h, w; cin >> h >> w;
  vector<string> a(h);
  for(int i = 0; i < h; i++) cin >> a[i];
  vector<vector<ll> > dp(h, vector<ll>(w));
  dp[h - 1][w - 1] = 1;
  for(int i = h - 1; i >=0; i--){
    for(int j = w - 1; j >= 0; j--){
      if(a[i][j] == '#') continue;
      if(i + 1 < h && a[i + 1][j] != '#') dp[i][j] += dp[i + 1][j];
      if(j + 1 < w && a[i][j + 1] != '#') dp[i][j] += dp[i][j + 1];
      dp[i][j] %= p;
    }
  }
  cout << dp[0][0] << endl;
  return 0;
}


Measured memory_bytes: 9216
import Control.Applicative ((<$>))
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B
f :: Int -> Int -> [String]
f x y = map show [x * y, (x + y) * 2]

readInts :: IO [Int]
readInts = map (fst . fromJust . B.readInt ) . B.words <$> B.getLine

main :: IO ()
main = do
  (x:y:_) <- readInts
  putStrLn $ unwords $ f x y


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

//最大公約数
int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}

//最小公倍数
int lcm(int a,int b){
    int g = gcd(a,b);
    return a/g*b;
}

int main(){
    int n;
    cin >> n;
    cout << lcm(n,2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>


using namespace std;



int main(void){
    int N,K;
    scanf("%d%d",&N,&K);
    int h[N];
    for(int i=0;i<N;i++)scanf("%d",&h[i]);
    sort(h,h+N);
    int ans=1145141919;
    for(int i=0;i<N-K+1;i++){
        if(h[i+K-1]-h[i]<ans)ans=h[i+K-1]-h[i];
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 640
import java.io.*;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            int l = str.length();
            if (1 < l && l < 101) {
                int c = 0;
                int f = 0;
                for (int i = 0; i < l; i++) {
                    if (str.charAt(i) == 'C'&&c==0) {
                        c++;
                    }
                    if(str.charAt(i)=='F'&&c==1){
                        f++;
                        break;
                    }
                }
                if(f==1){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
            }
        } catch (IOException ex) {
        }
    }
}

Measured memory_bytes: 8148
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	int arr[3];
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr, arr+3);
	cin >> N;
	cout << arr[0]+arr[1]+arr[2]*pow(2, N);
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };


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

	ll n;
	double w, m, k, h, ans = 0.0;
	string s, t;
	cin >> n;
	rep(i, n) {
		cin >> w >> s;
		if (s == "JPY") ans += w;
		else {
			ans += w * 380000.0;
		}
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


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

typedef long long ll;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if (N < A + B - 1 || N > A * B) {
        cout << "-1\n";
        return 0;
    }
    if (B == 1) {
        rep(i, N) {
            cout << i + 1;
            if (i == N - 1) cout << "\n";
            else cout << " ";
        }
        return 0;
    }
    ll q = (N - A - B + 1) / (B - 1);
    ll r = (N - A - B + 1) % (B - 1);
    vector<int> ans;
    rep(i, q + 1) {
        rep(j, B) {
            ans.push_back((i + 1) * B - j);
        }
    }
    int s = (q + 1) * B;
    if (r > 0) {
        rep(i, r + 1) {
            ans.push_back((q + 1) * B + r + 1 - i);
        }
        s += r + 1;
    }
    if (s < N) {
        for (int i = s + 1; i <= N; i++) ans.push_back(i);
    }
    rep(i, ans.size()) {
        cout << ans[i];
        if (i == ans.size() - 1) cout << "\n";
        else cout << " ";
    }
}

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

using namespace std;
typedef long long ll;

int main(){
    char b;
    cin >> b;
    if ( b == 'A'){
        cout << 'T' << endl;
    } else if ( b == 'C'){
        cout << 'G' << endl;
    } else if ( b == 'G'){
        cout << 'C' << endl;
    } else if ( b == 'T'){
        cout << 'A' << endl;        
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;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> 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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin>>N;
    int A;
    cin>>A;
    if(N%500<=A) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
/*
 * Author : Sadi
 * Wed 08/07/2020
 * 17:03:54.55
 */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
    	string str = to_string(i);
    	if((int) str.size() & 1) {
    		ans++;
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3772
import sys

N, M = map(int, input().split())

broken = set(map(int, sys.stdin))

mod = 10 ** 9 + 7
f2, f1 = 0, 1
for i in range(1, N + 1):
  if i in broken:
    if i - 1 in broken:
      print(0)
      exit()
    f2 = f1
    f1 = 0
    continue
  f = f2 + f1
  f2 = f1
  f1 = f
print(f % mod)

Measured memory_bytes: 11884
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    n:String,
    }
    let n=n.chars().collect_vec();
    let mut v:Vec<char>=Vec::new();
    for i in 0..3 {
        v.push(n[i])
    }
    let v:String=v.iter().collect();
    println!("{}",v)
}

Measured memory_bytes: 2140
import sys

input = sys.stdin.readline


def dfs(R, cnt):
    if R < 6:
        return cnt + R
    elif R < 9:
        return cnt + 1 + (R-6)
    else:
        c_6 = dfs(R-6, cnt+1)
        c_9 = dfs(R-9, cnt+1)
        return min(c_6, c_9)


def main():
    N = int(input())

    A = []
    i = 1
    while True:
        if 6**i <= 100000:
            A.append(6**i)
            i += 1
        else:
            break
    A.sort(reverse=True)
    B = []
    i = 1
    while True:
        if 9**i <= 100000:
            B.append(9**i)
            i += 1
        else:
            break
    B.sort(reverse=True)

    ans = float("inf")
    for i in range(N+1):
        n_6, n_9 = i, N-i
        c_6 = 0
        for a in A:
            while True:
                if a <= n_6:
                    n_6 -= a
                    c_6 += 1
                else:
                    break
        c_6 += n_6
        c_9 = 0
        for b in B:
            while True:
                if b <= n_9:
                    n_9 -= b
                    c_9 += 1
                else:
                    break
        c_9 += n_9
        c = c_6 + c_9
        if c < ans:
            ans = c
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    while(true){
        string s1;
        cin >> s1;
 
        if(s1==".")
            break;
 
        string s2;
        cin >> s2;
 
        if(s1==s2){
            cout << "IDENTICAL" << endl;
            continue;
        }
 
        string t1 = s1;
        string t2 = s2;
 
        while(true){
            size_t d1b = t1.find('\"');
            if(d1b==string::npos)
                break;
            t1.replace(d1b, 1, "@");
 
            size_t d1e = t1.find('\"');
            t1.replace(d1e, 1, "@");
 
            size_t d2b = t2.find('\"');
            if(d2b==string::npos)
                break;
            t2.replace(d2b, 1, "@");
 
            size_t d2e = t2.find('\"');
            t2.replace(d2e, 1, "@");
 
            string u1 = s1;
            u1.replace(d1b+1, d1e-d1b-1, "");
            string u2 = s2;
            u2.replace(d2b+1, d2e-d2b-1, "");
 
//          cout << u1 << endl;
//          cout << u2 << endl;
 
            if(u1==u2){
                t1 = u1;
                t2 = u2;
                break;
            }
        }
 
        if(t1==t2){
            cout << "CLOSE" << endl;
        }
        else{
            cout << "DIFFERENT" << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 3144
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll n;
    cin >> n;
    cout << n + n*n + n*n*n << endl;


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif

    return 0;
}

Measured memory_bytes: 3592
# include <cstdio>
using namespace std;
bool f [100001];
int c [100002];
int N ,L , R ;
int main ()
{
for ( int i =2; i <=100000; i ++) if (! f [ i ]) for ( int j = i + i ;j <=100000; j += i )
f[ j ]= true ;
for ( int i =3; i <=100000; i +=2) if (! f [ i ]&&! f [( i +1)/2]) c [ i ]++;
for ( int i =3; i <=100000; i ++) c [ i ]+= c [i -1];
scanf ("%d " ,&N );
while(N--)
{
scanf ("%d %d " ,&L ,&R );
printf ("%d\n " , c [ R ] - c [L -1]);
}
}


Measured memory_bytes: 1152
n = int(input())
mod = 10**9+7
A=[1] + [0]*(n-1)
G=[1] + [0]*(n-1)
T=[1] + [0]*(n-1)
C=[1] + [0]*(n-1)
##NG:: AGC,GAC,ACG
AG =[0]*n
GA =[0]*n
AC =[0]*n
##NG:: AGGC,AGTC,ATGC
AGG=[0]*n
AGT=[0]*n
ATG=[0]*n
for i in range(1,n):
    tmp=A[i-1]+G[i-1]+C[i-1]+T[i-1]

    A[i]=tmp%mod
    T[i]=tmp%mod
    G[i]=(tmp - AC[i-1])%mod
    C[i]=(tmp -AG[i-1]-GA[i-1]-AGG[i-1] -AGT[i-1]-ATG[i-1])%mod

    AG[i]=A[i-1]
    GA[i]=G[i-1]
    AC[i]=(A[i-1]-GA[i-1])%mod

    AGG[i]=AG[i-1]
    AGT[i]=AG[i-1]
    ATG[i]=A[i-2]# == AT[i-1]


print((A[-1]+G[-1]+C[-1]+T[-1])%mod)
#print(A,G,C,T)
#print(AG,GA,AC)
#print(AGG,AGT,ATG)


Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  cin>>n;
  vector<long> a(n);
  rep(i,n) cin>>a[i];

  long tot = accumulate(all(a), 0L);

  int ans = -1;
  long md = INT_MAX;
  rep(i,n){
    if(abs(a[i]*n - tot) < md) {
      ans = i;
      md = abs(a[i]*n - tot);
    }
  }

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


Measured memory_bytes: 256