akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n, t;
    cin >> n >> t;
    vector<int> a = inp(n);

    // 最も差のある場所で売買したい

    int mi = a[0];

    map<int, int> dif;

    Rep(i, 1, n) {
        chmin(mi, a[i]);

        ++dif[a[i] - mi];
    }

    int ans = dif.rbegin()->second;
    Cout(ans);

    return 0;
}

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long ll;

int L[MAX/2+2],R[MAX/2+2];

ll merge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  ll cnt = 0;
  int n1 = mid-left;
  int n2 = right-mid;
  for(int t=0;t<n1;t++) L[t] = A[left+t];
  for(int t=0;t<n2;t++) R[t] = A[mid+t];
  L[n1] = R[n2] = SENTINEL;
  i=j=0;

  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

ll mergeSort(int A[],int n,int left,int right){
  int mid;
  ll v1,v2,v3;
  if(left+1 < right){
    mid = (left+right)/2;
    v1 = mergeSort(A,n,left,mid);
    v2 = mergeSort(A,n,mid,right);
    v3 = merge(A,n,left,mid,right);
    return v1+v2+v3;
  }else return 0;
}

int main(){
  int A[MAX],n;

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

  ll ans = mergeSort(A,n,0,n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4668
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	d := 1.0 / float64(n)
	c := 1.0 / float64(2)
	sum := float64(0.0)
	for i := 1; i <= n; i++ {
		calc := d
		for j := i; j < k; j *= 2 {
			calc *= c
		}
		sum += calc
	}
	fmt.Println(sum)
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTP(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;



int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int x;
    std::cin >> x;
    int ans = x / 500 * 1000;
    ans += (x % 500) / 5 * 5;

    std::cout << ans;


    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String args[]) {
        double a, b, c, d, ac = 0, bd = 0, f = 0;
        Scanner sc = new Scanner(System.in);
        a = sc.nextDouble();
        b = sc.nextDouble();
        c = sc.nextDouble();
        d = sc.nextDouble();
        ac = c - a;
        bd = d - b;
        ac *= ac;
        bd *= bd;
        f = ac + bd;
        double ans = Math.sqrt(f);
        System.out.println(ans);
        sc.close();
    }
}



Measured memory_bytes: 27972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

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

using namespace std;

int main(){
	int n;
	double input, ans1, ans2, mid, min;
	vector<double> a;
	
	scanf("%d", &n);
	
	REP(i,n){
		scanf("%lf", &input);
		a.push_back(input);
	}
	
	sort(a.begin(), a.end() );
	ans1 = a[n-1];
	
	mid = ans1/2;
	min = 1000000009;
	
	REP(i,n-1){
		//printf("|%lf - %lf| = %lf\n", mid, a[i], fabs(mid-a[i]));
		if (fabs(mid-a[i]) < min){
			min = fabs(mid-a[i]);
			ans2 = a[i];
		}
	}
	
	printf("%.0lf %.0lf\n", ans1, ans2);
	
	return 0;
	
}


Measured memory_bytes: 1400
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    IN(x);
    ll y = x / 100;
    cout << (x % 100 <= y * 5) << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

cnt = 0
for a in A:
    if a< 0:
        cnt += 1

if cnt % 2 == 0:
    B = [abs(a) for a in A]
    ans = sum(B)
else:
    C = [abs(a) for a in A]
    C_min = min(C)
    C_min_id = C.index(C_min)

    C[C_min_id] = C[C_min_id] * (-1)
    ans = sum(C)
print(ans)


Measured memory_bytes: 21224
import math

N = int(input())
a = list(map(int, list(input())))

x = []
while len(x) != 1:
	inx = 1 << (math.floor(math.log2(N)) - 1)

	N -= inx
	x = [0] * N
	for i in range(N):
		x[i] = abs(a[i] - a[i + inx])

	a = x

print(x[0])

Measured memory_bytes: 21348
n = int(input())
l = [list(input().split()) for i in range(n)]
l_with_index = []
for i in range(len(l)):
    l[i].append(i+1)
    l_with_index.append(l[i])
tmp = sorted(l_with_index, key=lambda x:int(x[1]), reverse=True)
l_with_index = sorted(tmp, key=lambda x:x[0])
for i in range(len(l_with_index)):
    print(l_with_index[i][2])

Measured memory_bytes: 3064
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 2e6 + 10;
int F[N], G[N];

int64 comb(int n, int m) {
  if (n < m) return 0;
  return (int64)F[n] * G[m] % MOD * G[n - m] % MOD;
}

void init(int n) {
  static int inv[N];
  inv[1] = 1;
  for (int i = 2; i < n; ++i) {
    inv[i] = (MOD - MOD / i) * (int64)inv[MOD % i] % MOD;
  }
  F[0] = G[0] = 1;
  for (int i = 1; i < n; ++i) {
    F[i] = (int64)F[i - 1] * i % MOD;
    G[i] = (int64)G[i - 1] * inv[i] % MOD;
  }
}

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int solve(int n, int m) {
  int ret = 0;
  for (int j = 1; j <= m; ++j) {
    add(ret, comb(n + 1 + j, j + 1));
  }
  return ret;
}

int main() {
  init(N);
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  --x1; --y1;
  int ret = solve(x2, y2);
  add(ret, MOD - solve(x1, y2));
  add(ret, MOD - solve(x2, y1));
  add(ret, solve(x1, y1));
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 23680
/*{{{*/
//#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
template<class T, class U> void _R(pair<T, U> &x) {_R(x.F); _R(x.S);}
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

template<class T, class... U> void DB(const T &head, const U &... tail) {
#ifdef HOME
    _W('#'); W(head, tail...);
#endif
}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)

#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef int64_t ll;
/*}}}*/

const int N = 100000+10;
int n, h;
vi a(N), b(N);

int main(){
    R(n,h);
    FOR(i,n) R(a[i],b[i]);

    sort(a.begin(), a.begin()+n, [](int x, int y){ return x>y; });
    sort(b.begin(), b.begin()+n, [](int x, int y){ return x>y; });

    int cnt = 0;
    FOR(i,n){
        if(a[0]>=b[i]){
            break;
        }
        else{
            ++cnt, h -= b[i];
            if(h <= 0) break;
        }
        DB(cnt, i);
    }
    if(h > 0){
        int t = h/a[0];
        cnt += t, h -= t*a[0];
    }
    while(h > 0) ++cnt, h -= a[0];


    W(cnt);

    return 0;
}

/*

2 10
4 9
3 8

*/


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin >> A.at(i);
  }
  int total=0;
  for(int i=0;i<M;i++){
   total+=A.at(i);
  }
  if(total<=N){
   cout << N-total <<endl;
  }
  else{
   cout << -1 <<endl;
  }
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string str;
  cin>>str;
  for(int i=0;i<str.length();i++)
  {
    if(str[i] == '?')
    {
      cout<<'D';
    }
    else
      cout<<str[i];
  }
  cout<<endl;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf =0x3f3f3f3f;
#define scn(a) scanf("%d",&a)
#define scd(a) scanf("%lf",&a)
#define scl(a) scanf("%lld",&a)
#define ptf(a) printf("%d\n",a)
#define mes(a,b) memset(a,b,sizeof(a))
#define fon(s,n) for(int i=s;i<=n;i++)
#define range(i,a,b) for(int i=a;i<=b;++i)
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define maxn 1000010
const int S=20;
ll gcd(ll a,ll b) { return b>0 ? gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll q_pow(ll a,ll b,ll mod)
{
	ll ans=1,res=a;
	while(b){
		if(b&1) ans=ans*res%mod;
		res=res*res%mod;
		b>>=1;
	}
	return ans%mod;
}

int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int cnt[105]={0};
int main()
{
    int n,k,d,a;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++){
		scn(d);
		for(int j=1;j<=d;j++){
			scn(a);
			cnt[a]++;
		}
	}	
    int ans=0;
	for(int i=1;i<=n;i++) if(cnt[i])ans++;
	ptf(n-ans);

    return 0;
}


Measured memory_bytes: 3836
from numpy import array, eye

mod = 10 ** 9 + 7

N, K, *A = map(int, open(0).read().split())
A = array(A, dtype=object).reshape(N, N)

ans = eye(N, dtype=object)
while K:
    if K & 1:
        ans = (ans.dot(A)) % mod
    A = A.dot(A) % mod
    K //= 2

print(ans.sum() % mod)

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

using namespace std;

int main()
{
    int a,b,c,sum=0,d,k;

    cin>>k;
    for(a=1;a<=k;a++)
        for(b=1;b<=k;b++)
        for(c=1;c<=k;c++)
      {
        d=__gcd(a,b);
        sum=sum+__gcd(d,c);
      }
      cout<<sum;
}


Measured memory_bytes: 3540
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, Q, q1[212345], q2[212345];

int main() {

	cin >> N >> Q;
	rep(i, Q) cin >> q1[i] >> q2[i];
	ll ans = (N - 2) * (N - 2);

	map<ll, ll> m1, m2;
	m1[N] = N - 2;
	m2[N] = N - 2;

	rep(i, Q) {
		if (q1[i] == 1) {
			if ((*m1.begin()).first > q2[i]) {
				ans -= (*m1.begin()).second;
				if (m2.find((*m1.begin()).second + 2) == m2.end()) m2[(*m1.begin()).second + 2] = q2[i] - 2;
				m2[(*m1.begin()).second + 2] = min(m2[(*m1.begin()).second + 2], q2[i] - 2);
			}
			else {
				ans -= (*m1.upper_bound(q2[i])).second;
			}
		}
		else {
			if ((*m2.begin()).first > q2[i]) {
				ans -= (*m2.begin()).second;
				if (m1.find((*m2.begin()).second + 2) == m1.end()) m1[(*m2.begin()).second + 2] = q2[i] - 2;
				m1[(*m2.begin()).second + 2] = min(m1[(*m2.begin()).second + 2], q2[i] - 2);
			}
			else {
				ans -= (*m2.upper_bound(q2[i])).second;
			}
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 12868
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,a;
    cin>>n;
    std::deque<long long int> deq;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    long long int sum=1000;
    long long int kabu=0;
    for (int i=0;i+1<n;i++) {
        if (deq[i]<deq[i+1]) {
            kabu+=sum/deq[i];
            sum-=deq[i]*(sum/deq[i]);
        } else {
            sum+=deq[i]*kabu;
            kabu=0;
        }
    }
    if (deq[n-1]>deq[n-2]) {
        sum+=kabu*deq[n-1];
        cout<<sum<<endl;
    } else {
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 3624
while True:
    s = input()
    if s == "#":
        break

    clauses = s.split("|")
    for clause in clauses:
        literals = set(clause[1:-1].split("&"))
        for literal in literals:
            if literal[0] == "~" and literal[1] in literals:
                break
        else:
            print("yes")
            break
    else:
        print("no")


Measured memory_bytes: 5576
#include <stdio.h>

int main(void){
	while(1){
		long n;
		int four[100]={0};
		int i=0, j;
		
		scanf(" %ld", &n);
		if(n==-1) break;
		else if(n==0) {
			printf("%ld\n", n);
			continue;
		}
		
		while(n > 0){
			four[i] = n%4;
			i++;
			n /= 4;
		}
		
		for(j=i-1; j>=0; j--)
			printf("%d", four[j]);
		printf("\n");

	}

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <stack>
#include <string>

void out(int n, int* a);

int main() {
	std::stack<int> s;
	std::string e;
	while (std::cin >> e) {
		if (e == "+") {
			int a = s.top();
			s.pop();
			int b = s.top();
			s.pop();
			s.push(b + a);
		} else if (e == "-") {
			int a = s.top();
			s.pop();
			int b = s.top();
			s.pop();
			s.push(b - a);
		} else if (e == "*") {
			int a = s.top();
			s.pop();
			int b = s.top();
			s.pop();
			s.push(b * a);
		} else {
			s.push(std::stoi(e));
		}
	}
	std::cout << s.top() << std::endl;
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0; i<N; i++){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i=0; i<K; i++){
        ans += p.at(i);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');

            int[] intArray = str1
                .Select(int.Parse)
                .ToArray();
            double[] HeightArray = str2
                .Select(double.Parse)
                .ToArray();
            int Answer=0;
            double Comparison=0;
            double[] AbsArray = new double[HeightArray.Length];

            for (int i = 0; i < HeightArray.Length; i++)
            {
                AbsArray[i] = System.Math.Abs(intArray[0] - (HeightArray[i] * 0.006)-intArray[1]);
                if (i == 0)
                {
                    Answer = i;
                    Comparison = AbsArray[i];
                }else if (AbsArray[i] < Comparison)
                {
                    Answer = i;
                    Comparison = AbsArray[i];
                }
            }
            Console.WriteLine(Answer+1);
        }
    }
}


Measured memory_bytes: 13328
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define sec setprecision
#define Pair pair<ll,ll>
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x)%mod , n / 2)%mod);
	else
		return (x * pow(x, n - 1))%mod;
}
int main() {
	ll n, m; cin >> n >> m;
	vector<Pair>a(n);
	rip(i, n)cin >> a[i].first >> a[i].second;
	sort(all(a));
	ll count = 0;
	ll money = 0;
	rip(i, n) {
		if (count + a[i].second <= m) {
			money += a[i].second * a[i].first;
			count += a[i].second;
		}
		else {
			money += a[i].first * (m - count);
			break;
		}
	}
	cout << money << endl;
}

Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    while (1) {

        int n, x; cin >> n >> x;
        if (n == 0 && x == 0) break;
        int cnt = 0;

        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                for (int k = j + 1; k <=n; k++) {
                    if (i + j + k == x) cnt++;
                }
            }
        }

        cout << cnt << endl;
    }


    return 0;
}


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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;

int check[1000010];
 
int main()
{
     int n,c=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
	     cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
	     if(check[a[i]]>0){
	     check[a[i]]=2;
	     continue;
	     }
	     else{
	     for(int j=a[i];j<=1000000;j+=a[i])
	     check[j]++;
	     }
	}
	for(int i=0;i<n;i++){
	     if(check[a[i]]==1)
	     c++;
	}
	cout<<c<<"\n";

	return 0;
}


Measured memory_bytes: 8244
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible\n";
    else cout << "Impossible\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

    string S, T;
    cin >> S >> T;
    int table1[26], table2[26];
    for(int i = 0; i < 26; i ++){
        table1[i] = -1;
        table2[i] = -1;
    }
    for(int i = 0; i < S.size(); i ++){
        if(table1[S[i] - 'a'] >= 0){
            if(table1[S[i] - 'a'] != T[i] - 'a'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(table2[T[i] - 'a'] >= 0){
            if(table2[T[i] - 'a'] != S[i] - 'a'){
                cout << "No" << endl;
                return 0;
            }
        }
        if(table1[S[i] - 'a'] < 0)table1[S[i] - 'a'] = T[i] - 'a';
        if(table2[T[i] - 'a'] < 0)table2[T[i] - 'a'] = S[i] - 'a';
    }
    cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <cmath>
#include <algorithm>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int x,a,b;	cin >> x >> a >> b;
    if(abs(x-a) > abs(x-b)){
	cout << "B" << endl;
    }else{
	cout << "A" << endl;
    }
    return 0;
}


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

const int MAXN = 1000;
const int MAXM = 200000;

vector<int>G[MAXN + 5]; int to[MAXM + 5];
void addedge(int u, int i) {G[u].push_back(i);}

int tag[MAXN + 5], que[2*MAXN + 5];
bool ans1[MAXM + 5], ans2[MAXM + 5];

int n, m;
int main() {
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++) {
        int a; scanf("%d%d", &a, &to[i]);
        addedge(a, i);
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) tag[j] = 0;
        int s = 1, t = 0;
        for(int p=0;p<G[i].size();p++)
            tag[que[++t] = to[G[i][p]]] = G[i][p];
        while( s <= t ) {
            int x = que[s++], y = tag[x];
            for(int p=0;p<G[x].size();p++) {
                int q = to[G[x][p]];
                if( q != i ) {
                    if( tag[q] != -1 ) {
                        if( tag[q] == 0 )
                            tag[que[++t] = q] = y;
                        else if( tag[q] != y )
                            tag[que[++t] = q] = -1;
                    }
                }
                else ans1[G[x][p]] = 1;
            }
        }
        for(int p=0;p<G[i].size();p++)
            if( tag[to[G[i][p]]] == -1 ) ans2[G[i][p]] = 1;
    }
    for(int i=1;i<=m;i++)
        puts(ans1[i] ^ ans2[i] ? "diff" : "same");
}

Measured memory_bytes: 3968
//#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
typedef long long ll ;
#define int ll
#define mod 1000000007
#define gcd __gcd
#define rep(i , j , n) for(int i = j ; i <= n ; i++)
#define red(i , n , j)  for(int i = n ; i >= j ; i--)
#define ME(x , y) memset(x , y , sizeof(x))
//ll lcm(ll a , ll b){return a*b/gcd(a,b);}
ll quickpow(ll a , ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;b>>=1,a=a*a%mod;}return ans;}
//int euler1(int x){int ans=x;for(int i=2;i*i<=x;i++)if(x%i==0){ans-=ans/i;while(x%i==0)x/=i;}if(x>1)ans-=ans/x;return ans;}
//const int N = 1e7+9; int vis[n],prime[n],phi[N];int euler2(int n){ME(vis,true);int len=1;rep(i,2,n){if(vis[i]){prime[len++]=i,phi[i]=i-1;}for(int j=1;j<len&&prime[j]*i<=n;j++){vis[i*prime[j]]=0;if(i%prime[j]==0){phi[i*prime[j]]=phi[i]*prime[j];break;}else{phi[i*prime[j]]=phi[i]*phi[prime[j]];}}}return len}
#define SC scanf
#define INF  0x3f3f3f3f
#define PI acos(-1)
#define pii pair<int,int>
#define fi first
#define se second
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
using namespace std;
const int N = 1e6+100;
const int maxn = 1e5+2;
int a[maxn];
int pre[maxn] , suf[maxn];
int fac[maxn] , inv[maxn];

int C(int n , int m){
    return fac[n] % mod * inv[n - m] % mod * inv[m] % mod ;
}

void solve(){
    fac[0] = inv[0] = 1 ;
    rep(i , 1 , maxn-2) fac[i] = fac[i-1] * i % mod ;
    inv[maxn-2] = quickpow(fac[maxn-2] , mod - 2);
    red(i , maxn-3 , 1) inv[i] = inv[i+1] * (i + 1) % mod;

    int n , k ;
    cin >> n >> k;
    rep(i , 1 , n){
        cin >> a[i];
    }
    sort(a + 1  , a + 1 + n);
    rep(i , 1 , n) pre[i] = pre[i-1] + a[i];
    red(i , n , 1) suf[i] = suf[i+1] + a[i];
    //int a = k - 2 , b = a , ans = 0 ;
    /*for(int i = n - k + 1 , j = k ; i >= 1 ; i-- , j++ , a++){
        ans = (ans + (suf[j] - pre[i]) % mod * C(a , b) % mod) % mod;
    }
    cout << ans << endl;*/
    int prel = n - k + 1 , sufl = k;
    int ans = 0 , a = k - 2 , b = a;
    rep(i , 1 , n-k+1){
        ans = (ans +  (suf[sufl] - pre[prel]) % mod * C(a , b) % mod)%mod;
        prel--;
        sufl++;
        a++;
    }
    cout << ans << endl;
}

signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0); cout.tie(0);
    //cnt = 0;
    //int t ;
    //scanf("%lld" , &t);
    //while(t--){
        solve();
    //}
}


Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') flag=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*flag;
}
ll a,b,c,ans;
int main(){
	a=read(),b=read(),c=read();
	if(a+b>=c-1) ans=b+c;
	else ans=b+a+b+1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n, i;

  scanf("%d", &n);

  for(i = 3; i <= n; i++) {
    if(i % 3 == 0) printf(" %d", i);
    else if(i / 10 == 3 || i / 100 == 3) printf(" %d", i);
    else if(i - ((i / 10) * 10) == 3) printf(" %d", i);
    else if(i / 10 - ((i / 100) * 10) == 3) printf(" %d", i);
    else if(i / 100 - ((i / 1000) * 10) == 3) printf(" %d", i);
    else if(i / 1000 - ((i / 10000) * 10) == 3) printf(" %d", i);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 600
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

s = input()
cnt = 0
ans = 0
for i in s:
    if i=='R':
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
print(max(ans,cnt))

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        li n,k;

        cin>>n>>k;

        li a[n];

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

        li b[n];

        for(li i=0;i<n;i++)
            cin>>b[i];

        sort(a,a+n);

        sort(b,b+n,greater<li>());

        li start=0,end=1e12;

        li mid=(start+end)/2;

        while(start<end)
        {            
            mid=(start+end)/2;
            
            li cnt=0;

            f(i,0,n-1)
            {
                cnt+=max(a[i]-mid/b[i],0ll);
            }

            if(cnt<=k)
                end=mid;
            else
                start=mid+1;
        }

        cout<<end;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    rep(i, n) {
        if (i == 0 || h[i-1] < h[i]) {
            --h[i];
        }
        if (i >= 1 && h[i] - h[i-1] < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

int main(){
  int n; cin >> n;
  int a[n];
  
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
  }
  
  int cnt = 0;
  for(int i=1 ; i<n-1 ; i++){
    int maxa = max({a[i-1],a[i],a[i+1]});
    int mina = min({a[i-1],a[i],a[i+1]});
    
    if(a[i] != maxa and a[i] != mina) cnt++;
  }
  
  cout << cnt << endl;
}
    
    
    


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)

	ans := 0
	cont := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'R' {
			ans += 1
		} else {
			ans = 0
		}
		if cont < ans {
			cont = ans
		}
	}
	fmt.Println(cont)
}


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

using namespace std;

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int>> w(M);
    for (int i = 0; i < M; ++i) {
        cin >> get<1>(w[i]) >> get<0>(w[i]);
        get<2>(w[i]) = i;
    }
    sort(w.begin(), w.end());
    vector<int> numcity(N);
    vector<tuple<int, int, int>> o;
    for (auto &a : w) {
        int x = ++numcity[get<1>(a)];
        o.push_back(make_tuple(get<2>(a), x, get<1>(a)));
    }
    sort(o.begin(), o.end());
    for (auto &a : o) {
        cout << setfill('0') << setw(6) << get<2>(a);
        cout << setfill('0') << setw(6) << get<1>(a) << endl;
    }
}



Measured memory_bytes: 4340
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    rep(i, s.size()) {
        if(s[i] == '?') s[i] = 'D';
    }
    output(s);
    
    
    return 0;
}


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

int main(){
  int sum0=0,sum1=0,x;
  string S;
  cin >> S;
    for(int i=0;i<S.size();i++){
      if(S[i]=='0'){sum0++;}
      else{sum1++;}
    }
  x=abs(sum1-sum0);
  cout << S.size()-x <<endl;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::min;
fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64,
    }
    println!("{}", n / (a + b) * a + min(n % (a + b), a));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string s;
    int i, N, countN=0, countW=0, countS=0, countE=0;

    cin >> s;

    N = s.size();

    for(i=0; i<N; i++){
        if(s[i]=='N'){
            countN++;
        }
        if(s[i]=='W'){
            countW++;
        }
        if(s[i]=='S'){
            countS++;
        }
        if(s[i]=='E'){
            countE++;
        }
    }

    if(countN!=0 && countW!=0 && countS!=0 && countE!=0){
        cout << "Yes" << endl;
    }

    else if(countN!=0 && countS!=0 && countW==0 && countE==0){
        cout << "Yes" << endl;
    }

    else if(countN==0 && countS==0 && countW!=0 && countE!=0){
        cout << "Yes" << endl;
    }

    else if(countN==0 && countW==0 && countS==0 && countE==0){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
    

    return 0;
}

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

int main () {
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int> > r(n);
    
    string s;
    int p;
    for (int i = 0; i < n; ++i) {
        cin >> s >> p;
        r[i] = make_pair(make_pair(s, -p), i);
    }

    sort(r.begin(), r.end());
    for (int i = 0; i < n; ++i) {
        cout << r[i].second + 1 << endl;
    }

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int n = sc.nextInt();
        for(int i = 0;i < n;++i){
            String e = sc.next();
            switch(e) {
                case "print":
                    System.out.println(str.substring(sc.nextInt(), sc.nextInt()+1));
                    break;
                case "reverse": {
                    int b = sc.nextInt(), l = sc.nextInt();
                    StringBuilder sb = new StringBuilder(str.substring(b, l + 1)).reverse();
                    if(b > 0) sb.insert(0, str.substring(0, b));
                    sb.append(str.substring(l+1));
                    str = sb.toString();
                }
                break;
                case "replace":{
                    int b = sc.nextInt(), l = sc.nextInt();
                    String p = sc.next();
                    StringBuilder sb = new StringBuilder();
                    if(b > 0) sb.append(str.substring(0,b));
                    sb.append(p);
                    sb.append(str.substring(l+1));
                    str = sb.toString();
                }break;
                default:
                    break;
            }
        }
    }

}

Measured memory_bytes: 29280
import math
from functools import reduce

def gcdli(xl):
    #xlはlist
    return reduce(math.gcd , xl)

def gcd(a , b):
    while b != 0:
        a , b = b , a % b
    return a

def c162(k):

    count = 0
    li = []
    for i in range(1 , k + 1):
        for w in range(1 , k + 1):
            for q in range(1 , k + 1):
                li = [i , w , q]
                count += gcdli(li)
    """
    for i in range(1 , k + 1):
        for w in range(1 , k + 1):
            count += gcd(i , w)
    """
    return count

def main():
    k = int(input())
    print(c162(k))
if __name__ == '__main__':
    main()

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

typedef pair<int, int> ii;
typedef long long ll;
const int mod = 1000000007;

int mul(int x, int y) {
  return (ll)x * y % mod;
}
int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
int mpow(int x, int y) {
  if (y == 0) return 1;
  int ret = mpow(x, y / 2);
  ret = mul(ret, ret);
  if (y & 1) ret = mul(ret, x);
  return ret;
}
int inv(int x) {
  return mpow(x, mod - 2);
}
int two[200005];

struct X {
  int a, b, c;
  X() {}
  X(int x, int y, int z): a(x), b(y), c(z) {}
};

int n;
vector<int> v[200005];
int sz[200005];

deque<X> pl[200005];
deque<X> *dq[200005];

int cnt;
deque<X>* newd() {
  return &pl[cnt ++];
}

deque<X>* merge(deque<X>* d1, deque<X>* d2, int &ssz) {
  if (d1->size() < d2->size()) swap(d1, d2);
  deque<X> &p = *d1;
  deque<X> &q = *d2;

  ssz = max(ssz, (int)q.size());
  for (int i = 0; i < (int)q.size(); i ++) {
    p[i].a = add(p[i].a, q[i].a);
    p[i].b = mul(p[i].b, q[i].b);
    p[i].c = add(p[i].c, q[i].c);
  }
  return d1;
}

void dfs(int x) {
  if (v[x].size() == 0) {
    dq[x] = newd();
    dq[x]->push_back(X(1, 1, 1));
    return;
  }
  dq[x] = nullptr;
  int ssz = 0;

  for (int i = 0; i < (int)v[x].size(); i ++) {
    int y = v[x][i];
    dfs(y);

    if (dq[x] == nullptr) dq[x] = dq[y];
    else {
      dq[x] = merge(dq[x], dq[y], ssz);
    }
  }

  auto &d = *dq[x];
  for (int i = 0; i < ssz; i ++) {
    d[i].a = mul(d[i].a, d[i].b);
    d[i].b = sub(two[d[i].c], d[i].a);
    d[i].a = mul(d[i].a, inv(d[i].b));
  }
  d.push_front(X(1, 1, 1));
}

int main() {
  scanf("%d", &n);

  two[0] = 1;
  for (int i = 1; i <= n + 1; i ++) {
    two[i] = mul(two[i - 1], 2);
  }

  for (int i = 1; i <= n; i ++) {
    int pi;
    scanf("%d", &pi);
    v[pi].push_back(i);
  }

  dfs(0);

  int ans = 0;
  for (X x : *dq[0]) {
    int tmp = mul(mul(x.a, x.b), two[n + 1 - x.c]);
    ans = add(ans, tmp);
  }
  printf("%d\n", ans);
}

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

int main(){
  long long N;
  cin >> N;
  
  vector<int> V(0);
  while(N>0){
    N--;
    V.push_back(N%26);
    N /= 26;
  }
  
  for(int i=V.size()-1;i>=0;i--) cout << (char)('a'+V[i]);
  cout << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second

int main() {
  map<int, int> m;
  int n, x;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &x);
    m[x]++;
  }
  int kind = 0;
  int sum = 0;
  for (auto it : m) {
    kind++;
    sum += it.S - 1;
  }
  printf("%d\n", kind - (sum % 2 == 1));
  return 0;
}



Measured memory_bytes: 4992
loop do
    input = gets.split(" ")
    if input[1].to_s == "?" then
        break
    else
        case input[1]
            when "+" then
                result = input[0].to_i + input[2].to_i
            when "-" then
                result = input[0].to_i - input[2].to_i
            when "*" then
                result = input[0].to_i * input[2].to_i
            when "/" then
                result = input[0].to_i / input[2].to_i
        end
    end
    puts result
end

Measured memory_bytes: 8708
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};


struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main(){
    int n,m;
    cin >> n >>m;
    UnionFind uf(n);
    // uf.unite(1,2);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        
        uf.unite(a,b);
    }
    int ans =0;
    rep(i,n){
        int s = uf.size(i);
        if(ans<s)ans=s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=2e5+50;
const int inf=0x3f3f3f3f;
const int MOD=998244353;
const int HASH=131;

ll l[maxn],r[maxn];
ll sum[maxn],ans[maxn];
int main()
{
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=k;i++)
    {
        cin>>l[i]>>r[i];
    }
    sum[1]=1;
    ans[1]=0;
    for(ll i=2;i<=n;i++)
    {
        for(ll j=1;j<=k;j++)
        {
            ans[i]=(ans[i]+sum[max((ll)0,i-l[j])]-sum[max((ll)0,i-r[j]-1)])%MOD;
        }
        sum[i]=(sum[i-1]+ans[i])%MOD;
    }
    cout<<(ans[n]+MOD)%MOD<<endl;
    return 0;
}


Measured memory_bytes: 6740