akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            ReadString();
            var E = ReadIntArray();
            bool answer = E.Where(x => x % 2 == 0).All(x => x % 3 == 0 || x % 5 == 0);
            Console.WriteLine(answer ? "APPROVED" : "DENIED");
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

const int MAXN=60;

int n,m;
char a[MAXN][MAXN];
int cnt[MAXN][MAXN];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",a[i]+1);
		// printf("%s\n",a[i]+1);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='.'){
				// printf("%d %d\n",i,j);
				for(int dx=-1;dx<=1;dx++){
					for(int dy=-1;dy<=1;dy++){
						if(dx==0&&dy==0)
							continue;
						// printf("\t%d %d\n",i+dx,i+dy);
						cnt[i][j]+=(a[i+dx][j+dy]=='#')?1:0;
						// printf("%d\n",cnt[i][j]);
					}
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#')
				putchar('#');
			else
				printf("%d",cnt[i][j]);
		}
		putchar('\n');
	}
	return 0;
}


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

//namespace _1_A
//{
class Program
{
    static void Main(string[] args)
    {
        int i = 1;
        int n = int.Parse(Console.ReadLine());
        while (++i <= n)
        {
            int x = i;
            if (x % 3 == 0)
            {
                Console.Write(" " + i);
                continue;
            }
            while(x != 0)
            {
                if(x % 10 == 3)
                {
                    Console.Write(" " + i);
                    break;
                }
                x /= 10;
            }
            
        }

        Console.WriteLine();

        //Console.Read();
    }
}
//}

Measured memory_bytes: 9368
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll mod = 1000000007;
const int INF = 1<<29;


int main(){
  ll K, N; cin >> K >> N;
  vector<ll> a(N);
  rep(i, N) cin >> a[i];

  ll res = INF;
  //時計回り
  res = min(res, a[N - 1] - a[0]);
  for (int i = 1; i < N; ++i){
    ll dist = (a[N - 1] - a[i]) + (K - a[N - 1]) + a[i - 1];
    res = min(res, dist);
  }
  //反時計回り
  res = min(res, a[N - 1] - a[0]);
  for (int i = N - 2; i >= 0; --i){
    ll dist = a[i] + (K - a[i + 1]);
    res = min(res, dist);
  }
  cout << res << endl;
}


Measured memory_bytes: 1792
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] arr = new int[n];
    int ans=0;
    for(int i=0;i<n;i++) {
      arr[i]=sc.nextInt();
    }

    for(int i=0;i<n;i++) {
      for (int j=i+1;j<n;j++) {
        ans+= arr[i] * arr[j];
      }
    }
    System.out.println(ans);
  }
}

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

#define ll long long
#define MOD 1000000007


int main(){
   ll n,m;
   cin>>n>>m;
    vector<ll> a(m);


       for (int i = 0; i < m; i++) {
           cin >> a.at(i);
       }

   vector<ll> dp(n+1);

   ll co=0;
   for(int i=0;i<=n;i++){
       if(i==0){
           dp.at(i)=1;
       }else if(i==1){
           dp.at(i)=1;
       }else if(i>1){
           dp.at(i) = (dp.at(i-1)%MOD+dp.at(i-2)%MOD)%MOD;
       }
       if(m==0)continue;
       if(a.at(co)==i){
           dp.at(i)=0;
           co++;
           if(co>=m)co=0;
       }
   }

   cout<<dp.at(n)%MOD<<endl;

}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

void Main() {
	string S; cin >> S;
	int N = S.size();
	int B = 1<<26;
	vint dp(B, INF);
	dp[0] = 0;	
	int bit = 0;

	for (int i = 0; i < N; i++) {
		bit ^= (1 << (S[i]-'a'));
		for (int i = 0; i < 27; i++) {
			int x = 1<<i;
			if (i == 26) x = 0;
			chmin(dp[bit], dp[bit^x]+1);
		}
	}
	
	cout << max(1, dp[bit]) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 262864
import sys
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

ans = [-1] * n
for i in sc:
    s, c = i
    if (ans[s-1] == c) | (ans[s-1] == -1):
        ans[s-1] = c
    else:
        print(-1)
        sys.exit()

for i in range(n):
    if ans[i] == -1:
        if (i == 0) & (n != 1):
            ans[i] = 1
        else:
            ans[i] = 0

if n != 1:
    if ans[0] == 0:
        print(-1)
        sys.exit()

print(*ans, sep='')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    
    int L = s.size();
    int start = 0;
    int end = 0;
    
    
    
    for(int i = 0;i < L;i++){
        if(s.at(i) == 'A') {start = i;
        break;}
    }
    
    
    for(int j =L-1;j >= 0;j--){
        if(s.at(j) == 'Z') {end = j;
        break;}
    }
    
    cout << (end - start)+ 1 << endl;
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define rrng(obj) (obj).rbegin(), (obj).rend()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,v.size())i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(v.size())o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pair<char,int> a,pair<char,int> b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  int n;
  cin>>n;
  int r;
  cin>>r;
  if(n<=10){
    cout<<r+100*(10-n)<<endl;
  }else{
    cout<<r<<endl;
  }

} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

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

using namespace std;

int main() {
  long long a,b,c,d; cin >> a >> b >> c >> d;
  long long x=abs(c-a),y=abs(d-b);
  if(x&&y) cout << x+y-__gcd(x,y) << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n; //データセット数
    cin >> n;
        
    for(int i = 1; i <= n; i++){
        int countout = 0; //OUTの発生回数
        int counthit = 0; //HITの発生回数
        int score = 0; //イニングの得点

        while(countout != 3){
            string state;
            cin >> state;
            if(state == "OUT") countout++;
            else if(state == "HIT"){
                counthit++;
                if(counthit == 4){
                    score++;
                    counthit--;
                }
            }    
            else if(state == "HOMERUN"){
                score += counthit + 1;
                counthit = 0;
            }
        } 
        cout << score << endl;     
    }
}



Measured memory_bytes: 3056
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n, a;
    cin >> n >> a;
    if (n % 500 <= a) cout << "Yes" << endl;
    else cout << "No" << endl;

}
  


    



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

int main(){
  	int N,Ans;
  	Ans = 0;
  	cin >> N;
  
  	for(int i = 0; i < N; i++){
    	int L, R;
      	cin >> L >> R;
      
    	Ans += R - L + 1;
    }
  	cout << Ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
typedef long long int ll;
static const int MAX_N = 200000;

int N;
ll sum[MAX_N];

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		ll A;
		cin >> A;
		if(i != 0) A += sum[i - 1];
		sum[i] = A;
	}
	int s = 0, u = 2;
	ll ans = LLONG_MAX;
	for(int t = 1; t < N - 2; t++){
		while(s < t - 1 && abs(sum[s + 1]) < abs(sum[t] - sum[s + 1])) s++;
		while(u < N - 1 && abs(sum[u + 1] - sum[t]) < abs(sum[N - 1] - sum[u + 1])) u++;
		for(int j = 0; j < 4; j++){
			if(j & 1) s++;
			if(j & 2) u++;
			ll min_sum = min({sum[N - 1] - sum[u], sum[u] - sum[t], sum[t] - sum[s], sum[s]});
			ll max_sum = max({sum[N - 1] - sum[u], sum[u] - sum[t], sum[t] - sum[s], sum[s]});
			ans = min(ans, max_sum - min_sum);
			if(j & 1) s--;
			if(j & 2) u--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String ss=sc.next();
    int ans=0;
    for(int i=0;i<ss.length();i++){
      ans=(ans+Integer.parseInt(ss.substring(i,i+1)))%9;
    }
           if(ans==0){
             System.out.println("Yes");
           }
           else{
             System.out.println("No");
           }
  }
  
}

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

int main(){
    long long n,k;
    long long i=1,j=0;
    long long out = 0;
    cin >> n >> k;
    while(true){
        j++;
        i=i*k;
        if(i>n) break;
    }
    out = out + j;
    cout << out;
    return 0;
}

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

int main(){
    int a, b, c, work;
    cin >> a >> b >> c;
    if(a > b){
        work = a;
        a = b;
        b = work;
    }
    if(a > c){
        work = a;
        a = c;
        c = work;
    }
    if(b > c){
        work = b;
        b = c;
        c = work;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(1024, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 1023; count = 0;
	}
	hashmap64(size_t s) :map(1<<s, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = (1 << s) - 1; count = 0;
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (~map[temp].first) {
			if (map[temp].first == suf) {
				return map[temp].second;
			}
			temp = mask&(temp + 1);
		}
		std::cerr << "?????¨????????????????????§????????????\n";
		std::abort();
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (!~map[t].first) {
					mkey = map[t];
					map[t].first = ~0;
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};
int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(19);
	uint32 n;
	std::cin >> n;
	int64 a,sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans,i+1-map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 10900
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define int long long

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

signed main(){
  
  set<int> st;
  
  int n; cin >> n;
  vector<int> p(n);
  vector<int> idx(n);
  rep(i, n){
    cin >> p[i];
    p[i]--;
    idx[p[i]] = i;
  }
  lint ans = 0;
  st.insert(idx[n - 1]);

  int inf = INF;

  st.insert(-inf);
  st.insert(inf);

  for(int i = n - 2; i >= 0; i--) {
    
    // 二番目に大きい値が i となるような通り数を加算したい
    int id = idx[i];
    st.insert(id);
    auto cur_itr = st.find(id);
    auto left_itr = cur_itr;
    auto right_itr = cur_itr;
    left_itr--;
    right_itr++;
    
    // 左固定
    if(*left_itr != -inf) {
      
      int r = n;
      if(*right_itr != inf) r = *right_itr;
      int val1 = r - id;
      auto leftleft = left_itr;
      leftleft--;
      int l = -1;
      if(*leftleft != -inf) {
        l = *leftleft;
      }

      int mid = *left_itr;
      int val2 = mid - l;
      ans += val1 * val2 * (i + 1);
    }
    
    // 右固定
    if(*right_itr != inf) {
      int l = -1;
      if(*left_itr != -inf) l = *left_itr;
      int val1 = id - l;
      auto rightright = right_itr;
      rightright++;
      int r = n;
      if(*rightright != inf) {
        r = *rightright;
      }

      int mid = *right_itr;
      int val2 = r - mid;   
      ans += val1 * val2 * (i + 1);
      
    }
  }
  
  cout << ans << endl;

  return 0;
}


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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<long> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    set<pair<long, int>> g;
    for (int i = 0; i < n; i++) {
        if (b[i] < a[i]) {
            cout << -1;
            return 0;
        }
        g.insert({-b[i], i});
    }
    
    long res = 0;
    while (!g.empty()) {
        auto p = *g.begin();
        g.erase(p);
        int i = p.second;
        if (b[i] == a[i]) {
            continue;
        }

        long z = b[(i + 1) % n] + b[(i + n - 1) % n];
        long c = (b[i] - a[i]) / z;
        if (c == 0) {
            cout << -1;
            return 0;
        }
        b[i] -= c * z;
        res += c;
//        cout << i << " " << b[i] << " " << res << "\n";
        g.insert({-b[i], i});
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;


unordered_map<ll, int>A;
int main(){
	int N;
	cin>>N;
	ll ans = 1;
	
	for(int i = 1; i <= N; i++){
		int a = i;
		for(int j = 2; j <= i; j++){
			
		if(a % j == 0){
			a /= j;
			A[j]++;
			j--;
			
		}
	}
	}
	
	for(auto itr = A.begin(); itr != A.end(); ++itr){
		ans *= (itr->second + 1 % mod);
		ans %= mod;
		
	}		
	ans %= mod;
	cout<<ans<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#define fastio cin.tie(0); ios::sync_with_stdio(0)
#define multitc int _t; cin>>_t; while(_t--)
#define arrin(arr, n, type) arr.assign(n,type()); for(auto& i : arr) cin>>i;
#define all(x) (x).begin(), (x).end()
const int dir[9][2] = {{0,-1},{-1,0},{0,1},{1,0},{1,1},{-1,-1},{1,-1},{-1,1},{0,0}};
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll INF = 1e15+7;
const ll MOD = 998244353;
using namespace std;
using namespace __gnu_pbds;
int nextInt(){int x; cin>>x; return x;}
ll nextLong(){ll x; cin>>x; return x;}
template<typename T>
void arrin2d(vector<vector<T>>& arr, int y, int x)
{
    arr.assign(y,vector<T>(x));
    for(int i=0;i<y;++i)
    {
        for(int j=0;j<x;++j)
        {
            cin>>arr[i][j];
        }
    }
}
 
//using template
//code goes here
 
int main()
{
    ll n;
    cin>>n;
    ll ret = 0;
    ret += n/500*1000 + n%500/5*5;
    cout<<ret;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=3;++i)
	{
		if(a*b*i%2==1)
		{
			cout<<"Yes";
			return 0;	
		} 
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::iter::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

macro_rules! rotate {
    ($a: expr, $b: expr, $c: expr, $d: expr) => {{
        let t = $a;
        $a = $b;
        $b = $c;
        $c = $d;
        $d = t;
    }}
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();

    let mut dup = false;
    let mut hist = vec![];

    for _ in 0..n {
        let mut u: u32 = sc.read();
        let mut s: u32 = sc.read();
        let mut e: u32 = sc.read();
        let mut w: u32 = sc.read();
        let mut n: u32 = sc.read();
        let mut d: u32 = sc.read();

        let mut min = vec![1000];
        for k in 0..6 {
            for _ in 0..4 {
                let cand = vec![u, s, e, w, n, d];
                if min > cand {
                    min = cand;
                }
                rotate!(n, e, s, w);
            }
            if k % 2 == 0 {
                rotate!(u, n, d, s);
            } else {
                rotate!(u, w, d, e);
            }
        }

        if hist.contains(&min) {
            dup = true;
            break;
        }
        hist.push(min);
    }

    println!("{}", if dup { "No" } else { "Yes" });
}



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



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BUnhappyHackingABCEdit {
public:
    void solve(std::istream &in, std::ostream &out) {
        string S;
        in >> S;
        string res;
        trav(c, S) {
            if (c == 'B') {
                if (not res.empty()) {
                    res.pop_back();
                }
            } else {
                res.pb(c);
            }
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BUnhappyHackingABCEdit solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}
int const MOD = 1e9 + 7;

ll pow_mod(ll a, ll x, const ll &mod) {
    if (x == 0) return 1;
    ll ans = pow_mod(a, x >> 1, mod);
    ans = ans * ans % mod;
    if (x & 1 == 1) 
        ans = ans * a % mod;
    return ans;
}
int y[maxn];


void getfactor(int n)
{
    for (int i = 1; i * i <= n; i++)
    {
        for (int j = i + 1; j * i <= n; j++)
        {
            y[i * j] += 2;
        }
        y[i * i]++;
    }
}


int main(void) {
    FAST_IO;
    // init();
    ll n;
    cin >> n;
    getfactor(n);
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        int x = n - i;
        ans += y[x];
    }
    cout << ans <<endl;
    
    return 0;
}

Measured memory_bytes: 7548
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  solve
  def solve: Unit ={
    val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
    if (h == 0) return
    val state = Array.tabulate(h){_ ⇒ readLine.trim}
    val girl = state.indices.flatMap(h ⇒ state(h).indices.map{w ⇒ Coordinate(w, h)}).find{c ⇒ state(c.y)(c.x) == 'A'}.get
    val minTime = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ Int.MaxValue}}.also{arr ⇒ arr(girl.y)(girl.x) = 0}
    var current = List(girl)
    while (current.nonEmpty){
      var next = Nil: List[Coordinate]
      for {c ← current; n ← c.neighbor} {
        if ((0 until h).contains(n.y) && (0 until w).contains(n.x) && state(n.y)(n.x) != '#' && minTime(n.y)(n.x) > minTime(c.y)(c.x) + 1) {
          minTime(n.y)(n.x) = minTime(c.y)(c.x) + 1
          next ::= n
        }
      }
      current = next
    }
    val pattern = readLine.trim.map{_.asDigit}.toArray
    val count = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ 0}}
    var ghost = state.indices.flatMap(h ⇒ state(h).indices.map{w ⇒ Coordinate(w, h)}).find{c ⇒ state(c.y)(c.x) == 'B'}.get

    var time = 0
    var firstContact: Option[(Int, Int, Int)] = None
    while (count(ghost.y)(ghost.x) <= pattern.length && firstContact.isEmpty){
      count(ghost.y)(ghost.x) += 1
      if (minTime(ghost.y)(ghost.x) <= time){
        firstContact = Some(time, ghost.y, ghost.x)
      }
      ghost = move(ghost, pattern(time % pattern.length), h, w)
      time += 1
    }
    var additional = 0
    while (firstContact.isEmpty && additional <= h * w){
      if (minTime(ghost.y)(ghost.x) <= time + additional){
        firstContact = Some(time + additional, ghost.y, ghost.x)
      }
      ghost = move(ghost, pattern((time + additional) % pattern.length), h, w)
      additional += 1
    }
    println(
      firstContact match {
        case Some((t, y, x)) ⇒ s"$t $y $x"
        case None ⇒ "impossible"
      }
    )
    solve
  }
  def move(coordinate: Coordinate, direction: Int, h: Int, w: Int): Coordinate = {
    (direction match {
      case 8 ⇒ Coordinate(0, -1) + coordinate
      case 6 ⇒ Coordinate(1, 0) + coordinate
      case 4 ⇒ Coordinate(-1, 0) + coordinate
      case 2 ⇒ Coordinate(0, 1) + coordinate
      case _ ⇒ coordinate
    }).let{c ⇒
      if ((0 until h).contains(c.y) && (0 until w).contains(c.x)) c
      else coordinate
    }
  }
  case class Coordinate(x: Int, y: Int) {
    def +(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)
    def neighbor: List[Coordinate] = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))
    def nextPosition: List[Coordinate] = this::neighbor
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 52568
N, D = map(int, input().split())
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

ans = 0
for i in range(N):
    if X[i]**2+Y[i]**2 <= D**2:
        ans += 1
print(ans)

Measured memory_bytes: 24920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	string s;
	cin>>s;
	cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14,5)<<endl;
	return 0;
}

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

int main(){
  int64_t n,ans;
  cin>> n;
  for (int i=sqrt(n); i>0; i--){
    if (n%i==0){
      ans=i+n/i-2;
      break;
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




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

int r; cin>>r;
cout<<3*r*r<<endl;



	return 0;
}


Measured memory_bytes: 256
n = int(input())
s_word = list(input())
start_w = s_word[0]
goal_num = 0
for i in range(n-1):
    if s_word[i+1] != start_w:
        start_w = s_word[i+1]
        goal_num += 1
goal_num +=1
print(goal_num)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

// https://ei1333.github.io/algorithm/cumulative-sum2d.html
template <class T> struct CumulativeSum2D {
    vector<vector<T>> data;

    CumulativeSum2D(int W, int H) : data(W + 1, vector<T>(H + 1, 0)) {}

    void add(int x, int y, T z) {
        ++x, ++y;
        if (x >= (int)data.size() || y >= (int)data[0].size())
            return;
        data[x][y] += z;
    }

    void build() {
        FOR(i, 1, data.size()) FOR(j, 1, data.size()) {
            data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
        }
    }

    T query(int sx, int sy, int gx, int gy) {
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }

    void print() {
        for (auto &x : data) {
            for (auto &y : x) {
                cout << y << " ";
            }
            cout << endl;
        }
    }
};

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    char c;
    int n, k, x, y;
    cin >> n >> k;
    CumulativeSum2D<int> s(k * 2, k * 2);
    REP(i, n) {
        cin >> x >> y >> c;
        if (c == 'W') {
            y += k;
        }
        y %= 2 * k;
        if (y >= k) {
            y -= k;
            x += k;
        }
        x %= 2 * k;
        // 上半分の黒色エリア
        s.add(x, y, 1);
        // 下半分の黒色エリア
        s.add((x + k) % (2 * k), y + k, 1);
    }
    // 二次元累積和
    s.build();
    // s.print();
    int maxv = 0;
    REP(x, k) REP(y, k) {
        auto t = s.query(x, y, x + k, y + k);
        // 今までの最大値、今回の黒色の数、白色の数
        maxv = max({maxv, t, n - t});
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 16000
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val b = readLine()!!.split(" ").map { it.toInt() }
    
    var sum = b[0]+b[n-2]
    for ( i in 1..b.size-1) {
        sum += Math.min(b[i-1], b[i])
    }

    println(sum)

}

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

int lobit(int x) {
	int res = 0;
	for (; !(x % 2); x /= 2)
		res++;
	return res;
}

int main() {
	int N;
	scanf("%d", &N);
	
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++)
			printf("%d ", lobit(i ^ j) + 1);
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int num[100001],tmp[100001];
map <int,int> M;

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>num[i],tmp[i]=num[i];
  sort(tmp,tmp+n);
  for(int i=0;i<n;i++) M[tmp[i]]=i;
  
  int ans=0;
  for(int i=0;i<n;i++)
    if(i%2!=M[num[i]]%2)ans++;
  cout <<ans/2<<endl;
  

  return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt(); //n回
		int k = stdIn.nextInt();//足す
		
		int ans = 1;
		
		for(int i = 0; i < n; i++) {
			ans = Math.min(ans*2, ans+k);
		}
		System.out.println(ans);
		
		
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,m,a[100010],ans,cnt;
bool used[100010];
vector<int>v[100010];
vector<int>V[100010];
vector<int>vv;
void dfs(int x,int node){
	used[x]=true;
	V[node].pb(a[x]);
	for(int y:v[x]){
		if(!used[y])dfs(y,node);
	}
}
signed main(){
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	if(n-1==m){
		puts("0");
		return 0;
	}
	rep(i,n)if(!used[i])dfs(i,i);
	rep(i,n){
		if(!V[i].empty()){
			cnt++;
			sort(all(V[i]));
			rep(j,V[i].size()){
				if(j==0)ans+=V[i][j];
				else vv.pb(V[i][j]);
			}
		}
	}
	sort(all(vv));
	rep(i,2*(n-m-1)-cnt){
		if(vv.size()<=i){
			puts("Impossible");
			return 0;
		}
		ans+=vv[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 12404
#include <iostream>
#include <vector>
#include <string>
using namespace std;
long long gcd(long long a,long long b){
    if(a<b) swap(a,b);
    while(a%b!=0){
        swap(a,b);
        b%=a;
    }
    return b;
}
bool judge(long long a,long long b,long long g){
    if(a>b) return false;
    if(b-a+1>=g) return true;
    if(a%g>b%g) return true;
    if(a%g==0) return true;
    else return false;
}
int main(){
    int q;
    cin >> q;
    vector<string> ans;
    long long a,b,c,d;
    for(int i = 0;i<q;i++){
        cin >> a >> b >> c >> d;
        if(judge(a-b+1,a-c-1,gcd(b,d))||a<b||b>d) ans.push_back("No");
        else ans.push_back("Yes");
    }
    for(int i = 0;i<ans.size();i++){
        cout << ans[i] << endl;
    }
}

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

int n,m;
int main(){
  string s;
  cin >> s;
  ll sum = 0;
  n = s.size() -1;
  queue<int> que;
  for(int bit=0 ; bit<(1<<n) ; bit++){
    ll t = s[0] - '0';
    for(int j=0 ; j<n ; j++){
      if(bit & (1<<j)){
        sum += t;
        t = s[j+1] - '0';
      }else{
        t *= 10;
        t += s[j+1] - '0';
      }
    }
    sum += t;
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")



int main() {
    ll a,b,x; cin >> a >> b >> x;

    ll ans = b/x-a/x;
    if(a%x == 0) ans ++;

    cout << ans;

    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 110
#define F(a,b) for(register int (a)(0);(a)^(b);(a)++)
#define TP putchar(('#'))
#define PP putchar((10))
using namespace std;
int n,m;
string a[szxb];
inline void tpp(){F(i,(m+2)){TP;}PP;return;}
signed main()
{
	scanf("%d%d",&n,&m);getchar();
	F(i,n){getline(cin,a[i]);}tpp();
	F(i,n){TP,cout<<a[i],TP,PP;}tpp();
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

var h, w int

func can(x, y int) bool {
	return !(x < 0 || w <= x || y < 0 || h <= y)
}

func main() {
	fmt.Scan(&h, &w)

	a := [55]string{}
	for i := 0; i < h; i++ {
		fmt.Scan(&a[i])
	}

	cnt := [55][55]int{}
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			for _, dy := range []int{-1, 0, 1} {
				for _, dx := range []int{-1, 0, 1} {
					var nx, ny int = x + dx, y + dy
					if !can(nx, ny) {
						continue
					}
					if a[ny][nx] == '#' {
						cnt[y][x]++
					}
				}
			}
		}
	}

	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if a[y][x] == '#' {
				fmt.Print("#")
			} else {
				fmt.Print(cnt[y][x])
			}
			if x == w-1 {
				fmt.Println("")
			}
		}
	}
}

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

int main() {
	string S;
	cin >> S;
	for (int i = 0; i < (S.size() - 1); ++i) {
		if (S[i] == S[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0; i < (S.size() - 2); ++i) {
		if (S[i] == S[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}


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

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int) 3e3 + 2, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

string s, t, ans;
int mem[N][N];

class FLCS {
public:
    void init() {
        clr(mem, -1);
        ans.clear();
    }

    int solve(int i, int j) {
        if (i == sz(s) || j == sz(t))
            return 0;
        int &ret = mem[i][j];
        if (~ret)
            return ret;
        if (s[i] == t[j])
            return ret = solve(i + 1, j + 1) + 1;
        int ch1 = solve(i + 1, j);
        int ch2 = solve(i, j + 1);
        return ret = max(ch1, ch2);
    }

    void build(int i, int j) {
        if (i == sz(s) || j == sz(t))
            return;
        if (s[i] == t[j]) {
            ans.push_back(s[i]);
            build(i + 1, j + 1);
            return;
        }
        int ch1 = solve(i + 1, j);
        int ch2 = solve(i, j + 1);
        if (ch1 > ch2)
            build(i + 1, j);
        else
            build(i, j + 1);
    }

    void solve(istream &cin, ostream &cout) {
        init();
        cin >> s >> t;
        solve(0, 0);
        build(0, 0);
        cout << ans << el;
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	FLCS solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> D(K);
    for (int i=0;i<K;i++) cin >> D[i];
    while (1){
        bool flag = true;
        int n = N;
        while (n>0){
            int p = n%10;
            for (int i=0;i<K;i++){
                if (p==D[i]) {
                    flag=false;
                    break;
                }
            }
            n /= 10;
        }
        if (flag) break;
        N++;
    }
    cout << N << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
class JNum{
	static constexpr uint64_t mod = 1000000007;
	uint64_t num;
public:
	JNum(uint64_t x):num(x%mod){}
	JNum operator+(const JNum& j)const{
		return (num + j.num)%mod;
	}
	JNum operator*(const JNum& j)const{
		return (num * j.num)%mod;
	}
	void operator+=(const JNum& j){
		num += j.num;
		num %= mod;
	}
	void operator*=(const JNum& j){
		num *= j.num;
		num %=mod;
	}
	uint64_t out()const{return num;}
};
using namespace std;
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	uint64_t a[4], n;
	for(int i=0;i<4;i++)get(a[i]);
	get(n);
	uint64_t bp = a[0] * 4;
	if(bp > a[1] * 2){
		bp = a[1] *2;
	}
	if(bp > a[2]){
		bp = a[2];
	}
	uint64_t ans = 0;
	if(bp * 2 > a[3]){
		ans += a[3] * (n / 2);
		n %= 2;
	}
	ans += n * bp;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256