akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

if a[0]:
   if n == 0 and a[0] == 1:
      print(1)
   else:
      print(-1)
   exit()

b = [0 for _ in range(n)]
b.append(a[-1])
for i in range(n)[::-1]:
   b[i] = b[i+1] + a[i]

node = 1
ans = 1
for i in range(1, n+1):
   t = min(node*2, b[i])
   ans += t
   node = t - a[i]
   if node < 0:
      print(-1)
      exit()

print(ans)


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

using namespace std;

int main(void)
{
    int x;
    cin >> x;
    int num[x+1000];

    for (int i = 0; i < x+1000;i++){
        num[i] = i;
    }
    num[1] = 0;
    int root_x = sqrt(x) + 1;
    int p = 2;
    for (p = 2; p <= root_x;p++){
        for (int i = 2; i < x+1000; i++){
            if(num[i]%p==0 && i>p)
                num[i] = 0;
        }
    }
        for (int i = 0; i < x + 1000;i++){
            if(num[i]!=0 && num[i]>=x){
                printf("%d\n", num[i]);
                break;
            }
        }

            return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

constexpr int N = 200'225;
constexpr int P = 1000'000'007;
vector<int> g[N];
int sz[N], p2[N];
int n, ans, inv2 = (P + 1) / 2;

int dfs(int u, int p) {
  sz[u] = 1;
  for (int v : g[u]) {
    if (v != p) {
      sz[u] += dfs(v, u);
    }
  }
  if (p != 0) {
    ans += (int64_t) (1 + P - p2[sz[u]]) * (1 + P - p2[n - sz[u]]) % P;
    ans %= P;
  }
  return sz[u];
}

void solve(std::istream &in, std::ostream &out) {
  p2[0] = 1;
  for (int i = 1; i < N; ++i) {
    p2[i] = (int64_t) p2[i - 1] * inv2 % P;
  }
  in >> n;
  ans = (P - (int64_t)n * inv2 % P) % P;
  for (int i = 1, v, u; i < n; ++i) {
    in >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(1, 0);
  cout << (int64_t)(ans + (int64_t)(1 + P - p2[n]) % P) % P << '\n';
}


Measured memory_bytes: 19456
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

const long LEN = 1000005;

long n;
std::string s;
long q;

long d[LEN], m[LEN], c[LEN], dm[LEN], mc[LEN], dmc[LEN];

long seg_anscal(long a, long b){
    return dmc[b] - dmc[a] - d[a]*(mc[b] - mc[a]) - dm[a]*(c[b] - c[a]);
}

long ans_cal(long k){
    long res = 0;
    for(long i = 0; i < n; i++){
        long r = i+1;
        long l = std::max(0l, i-k+1);
        if(s[i] == 'C'){
            res += dm[r] - dm[l] - d[l]*(m[r]-m[l]);
        }
    }
    return res;
}

int main(){
    scanf("%ld", &n);
    std::cin >> s;
    for(int i = 0; i < n; i++){
        d[i+1] = d[i];
        if(s[i] == 'D'){
            d[i+1]++;
        }
        m[i+1] = m[i];
        if(s[i] == 'M'){
            m[i+1]++;
        }
        c[i+1] = c[i];
        if(s[i] == 'C'){
            c[i+1]++;
        }
    }
    for(int i = 0; i < n; i++){
        dm[i+1] = dm[i];
        if(s[i] == 'M'){
            dm[i+1] += d[i];
        }
        mc[i+1] = mc[i];
        if(s[i] == 'C'){
            mc[i+1] += m[i];
        }
    }
    for(int i = 0; i < n; i++){
        dmc[i+1] = dmc[i];
        if(s[i] == 'C'){
            dmc[i+1] += dm[i];
        }
    }

    /*
    printf("   ");
    for(int i = 0; i <= n; i++){
        printf("%2d ", i);
    }
    printf("\n");
    printf("D   ");
    for(int i = 0; i <= n; i++){
        printf("%2ld ", d[i]);
    }
    printf("\n");
    printf("M   ");
    for(int i = 0; i <= n; i++){
        printf("%2ld ", m[i]);
    }
    printf("\nC   ");
    for(int i = 0; i <= n; i++){
        printf("%2ld ", c[i]);
    }
    printf("\nDM  ");
    for(int i = 0; i <= n; i++){
        printf("%2ld ", dm[i]);
    }
    printf("\nMC  ");
    for(int i = 0; i <= n; i++){
        printf("%2ld ", mc[i]);
    }
    printf("\nDMC ");
    for(int i = 0; i <= n; i++){
        printf("%2ld ", dmc[i]);
    }
    printf("\n");
    //*/

    scanf("%ld", &q);
    for(int i = 0; i < q; i++){
        long k;
        scanf("%ld", &k);
        printf("%ld\n", ans_cal(k));
    }
    return 0;
}


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

int main() {

	int A, B;
	cin >> A >> B;

	if (A+B>=A+A-1 && A+B>=B+B-1){
		cout << A+B << endl;
	}
	else if (A+B<=B+B-1 && A+A-1<=B+B-1) {
		cout << B+B-1 << endl;
	}
	else if (A + B <= A + A - 1 && A + A - 1 >= B + B - 1) {
		cout << A+A-1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

k = int(input())
x,y = [int(i) for i in readline().split()]

if k%2 == 0 and (x+y)%2:
    print(-1)
    exit()

ans = [(x,y)]

while (abs(x)+abs(y) > 2*k):
    if x >= k: x -= k
    elif x <= -k: x += k
    else: 
        d = abs(x)
        x = 0
        if y > 0: y -= (k-d)
        else: y += (k-d)
#    print(x,y)
    ans.append((x,y))        

#print(x,y,"near")

if abs(x) + abs(y) == k: pass
else:
    if (x+y)%2:
        if x >= k: x -= k
        elif x <= -k: x += k
        else: 
            d = abs(x)
            x = 0
            if y > 0: y -= (k-d)
            else: y += (k-d)
        #    print(x,y)
        ans.append((x,y))        

        #print(x,y,"parity")
    sx = 1 if x>0 else -1
    sy = 1 if y>0 else -1
    x,y = abs(x),abs(y)
    swap = 0
    if x > y:
        swap = 1
        x,y = y,x

    x,y= (x-y+2*k)//2, (y-x)//2   
    
    if swap: x,y=y,x
    ans.append((x*sx,y*sy))


print(len(ans))
for i in reversed(ans):
    print(*i)

        
    







Measured memory_bytes: 58336
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int n_a = 0, n_b = 0, n_ab = 0;
    int ans = 0;
    rep(i,n) {
        string s; cin >> s;
        if (s.back() == 'A' && s.front() == 'B') n_ab++;
        else if (s.back() == 'A') n_a++;
        else if (s.front() == 'B') n_b++;
        rep(j,s.size()-1) if (s.substr(j,2) == "AB") ans++;
    }
    ans += min(n_a,n_b);
    if (n_a != 0 || n_b != 0) ans += n_ab;
    else {
        if (n_ab != 0) ans += n_ab - 1; 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int n;
vector<pair<ll, ll>> edges[100001];
bool visited[100001];
int ans[100001];

void solve(int cur, ll cost, int color){
    if(visited[cur]) return;
    visited[cur] = true;
    ans[cur] = cost%2 ? 1-color : color;
    rep(i, edges[cur].size()){
        pair<ll, ll> p = edges[cur][i];
        if(visited[p.first]) continue;
        solve(p.first, p.second, ans[cur]);
    }
}

int main() {
    cin >> n;
    rep(i, n-1){
        ll from, to, cost;
        cin >> from >> to >> cost;
        from--; to--;
        edges[from].push_back(make_pair(to, cost));
        edges[to].push_back(make_pair(from, cost));
    }
    fill(visited, visited+n, false);
    fill(ans, ans+n, 0);
    solve(0, 0, 0);
    rep(i, n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >>a;
  
  if(a == 0){
    cout<< 0 << endl;
  }
  else{
  int x=a % 3;
    if(x==0){
      cout<<3<< endl;
    }
    else {
       cout<<x<< endl;
    }
  }
}


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



int main(){
    int a,b,c;;
    cin >> a >> b >> c;

    if(c-(a-b)  > 0){
        cout << c-(a-b) << endl;
    }else{
        cout << 0 << endl;
    }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define endl '\n'
#define ll long long int
#define N 1500
using namespace std;

inline void init()
{
	cout << setprecision(20);
	ll s;
	cin >> s;
	cout << "0 0 ";
		cout << "1000000000 1 " << (ceil((long double)s/1000000000.0))*1000000000-s << " " << ceil((double)s/1000000000.0) << endl;
}

inline void solve()
{
}

int main()
{
	//freopen("input.in","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	init();
	solve();
	cout << flush;

	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final String[] tmp1 = br.readLine().split("\\s");
      final int n = Integer.parseInt(tmp1[0]);
      final int m = Integer.parseInt(tmp1[1]);
      final int c = Integer.parseInt(tmp1[2]);

      final int[] b = new int[m];
      final String[] tmp2 = br.readLine().split("\\s");
      for (int i = 0; i < tmp2.length; i++) {
        b[i] = Integer.parseInt(tmp2[i]);
      }

      int result = 0;

      final int[][] a = new int[n][m];
      for (int i = 0; i < a.length; i++) {
        int sum = 0;
        final String[] tmp3 = br.readLine().split("\\s");
        for (int j = 0; j < a[i].length; j++) {
          a[i][j] = Integer.parseInt(tmp3[j]);
          sum += a[i][j] * b[j];
        }
        if (0 < sum + c) {
          result++;
        }
      }
      System.out.print(result);

    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;


long long gcd(long long a, long long b) {
    if (a == 0) return b;
    return gcd(b % a, a);
}

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];

    long long ans = A[0];
    for(int i=1; i<N; i++)
        ans = gcd(ans, A[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# Atcoder Review Problems
# sugar Water
A, B, C, D, E, F = map(int, input().split())
# 別々に構成してもいい
dp_sugar = [0 for i in range(3001)]
dp_sugar[0] = True
for i in range(1, 3001):
    if i >= C:
        dp_sugar[i] |= dp_sugar[i-C]
    if i >= D:
        dp_sugar[i] |= dp_sugar[i-D]

dp_water = [0 for i in range(3001)]
dp_water[0] = 1
for i in range(1, 3001):
    if i >= 100*A:
        dp_water[i] |= dp_water[i-100*A]
    if i >= 100*B:
        dp_water[i] |= dp_water[i-100*B]

data = []
for i in range(1, F+1):
    # 水の量をiで固定
    if dp_water[i]:
        submax = 0
        for j in range(F+1-i):
            # 砂糖の量j
            if dp_sugar[j] and 100*j <= E*i:
                submax = j
        data.append((i+submax, submax, 100*submax/(i+submax)))
data.sort(key=lambda x: x[-1])
x,y,z=data[-1]
print(x,y)

Measured memory_bytes: 70388
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Str s;
	AtCoder::input(&s);
	AtCoder::exp(&s[0], &s);

	const int size = s.size();
	bool toggle = true;
	for (int i = 0; i < size; i++) {
		if (toggle) {
			toggle = false;
			if ("L" == s[i]) {
				printf("No\n");
				return 0;
			}
		} else {
			toggle = true;
			if ("R" == s[i]) {
				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
typedef long long ll;
using namespace std;

int main(void) {
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    ll a = A;
    ll b = B;
    ll c = C;
    const ll th = pow(10, 18);
    ll result = (K % 2 == 0) ? a - b : b - a;
    if (abs(result) > th) cout << "Unfair" << endl;
    else cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int nax = 5e5 + 10;
int lc[nax * 40], rc[nax * 40], root[nax];
int sg[nax * 40];
int cnt;

void update (int &v, int x, int y, int pos, int val) {
    ++ cnt;
    sg[cnt] = sg[v];
    lc[cnt] = lc[v];
    rc[cnt] = rc[v];
    v = cnt;
    if (x == y) {
        sg[v] = val;
    } else {
        int mid = x + y >> 1;
        if (pos <= mid) update(lc[v], x, mid, pos, val);
        else update(rc[v], mid + 1, y, pos, val);
        sg[v] = sg[lc[v]] + sg[rc[v]];
    }
}

int query (int v, int x, int y, int l, int r) {
    if (l == x && r == y) {
        return sg[v];
    } else {
        int mid = x + y >> 1;
        if (l > mid) return query(rc[v], mid + 1, y, l, r);
        else if (r <= mid) return query(lc[v], x, mid, l, r);
        else return query(lc[v], x, mid, l, mid) + query(rc[v], mid + 1, y, mid + 1, r);
    }
}

int n, q;
int c[nax];
int lst[nax];
/**
    last appearance
    moving by r
*/

int main () {
    cin.tie(0)->sync_with_stdio(false);
    cin >> n >> q;

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

    for (int i = 1 ; i <= n ; ++ i) {
        int cur = root[i - 1];
        if (lst[c[i]]) {
            update(cur, 1, n, lst[c[i]], 0);
        }
        update(cur, 1, n, i, 1);
        root[i] = cur;
        lst[c[i]] = i;
    }

    for (int i = 1 ; i <= q ; ++ i) {
        int l, r;
        cin >> l >> r;
        cout << query(root[r], 1, n, l, r) << '\n';
    }

}


Measured memory_bytes: 240948
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
#define int long long 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef __int128 _int ;
const int maxn=2e5+6;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n,k;
int a[maxn];
map<int,int>num;
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	cin>>n;
	int ans=0;
	num.clear();
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ans+=num[i-a[i]];
		num[i+a[i]]+=1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 27716
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    long double a, b;
    cin >> a >> b;
    long double x = a * b;
    cout << (int)(a * b) << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	int A,B,C;
	cin >> A >> B >> C;
	//解毒剤入りの美味しくないクッキーを A 枚、
	//解毒剤入りの美味しいクッキーを B 枚、
	//毒入りの美味しいクッキーを C 枚
	
	//まず最初に毒入りの美味しいクッキーを食べます
	ll ans = 0;
	if(C>0){
		ans ++;
		C--;
	}
	//次に解毒剤入の美味しいクッキーを食べます
	if(B>=C){
		ans += B;
		ans += C;
	}else{
		ans += B*2;
		C-=B;
		ans += min(C,A);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// 2019/8/9 19:38 start
#include<iostream>
using namespace std;

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

    cin >> A >> B >> C;

    if( A < B + C){
        C = B + C - A;
    }else{
        C = 0;
    }

    cout << C << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
  for(int i=0;i<w+2;i++){
    cout << '#';
  }
  cout << endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<w+2;j++){
      if(j==0||j==w+1){
        cout << '#';
      }else{        
        cout << s[i][j-1];  
      }
    }
    cout << endl;
  }
  for(int i=0;i<w+2;i++){
    cout << '#';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N;
    cin >> N;
    string ans = "";
    while (N > 0) {
        int r = N % 26;
        if (r == 0) {
            r = 26;
        }
        char tmp = 'a' - 1 + r;
        N /= 26;
        if (r == 26) N -= 1;
        ans += tmp;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}


Measured memory_bytes: 3624
listA = [1, 3, 5, 7, 8, 10, 12]
listB = [4, 6, 9, 11]
listC = [2]
a = {}
b = {}
c = {}

N = [int(i) for i in input().split()]

for i in range(2):
	a[i] = N[i] in listA
	b[i] = N[i] in listB
	c[i] = N[i] in listC


if a[0] == True and a[1] == True:
	print ("Yes")
elif b[0] == True and b[1] == True:
	print ("Yes")
elif c[0] == True and c[1] == True:
	print ("Yes")
else:
	print ("No")


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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

#define endl "\n"

int main()
{
	faster;
	
	int a,b,h,m;
	cin >> a >> b >> h >> m;

	double ha =(30)*h,ma = 5.5*m;

	double angel = abs(ha-ma)* acos(-1) / 180;

	double res = a*a + b * b - (2.0* a * b * cos(angel));

	cout << fixed << setprecision(20) << sqrt(res) << endl;
	return 0;
}

Measured memory_bytes: 4088
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int yen = kb.nextInt();
        int total = 0;
        total += (yen/500)*1000;
        yen -= (yen/500)*500;
        total += (yen/5)*5;
        
        System.out.println(total);
        
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long X;
  cin>>X;
  for(long long i=-1000;i<=1000;i++)
    for(long long j=-1000;j<i;j++)
      if(i*i*i*i*i-j*j*j*j*j==X)
      {
        cout<<i<<" "<<j<<endl;
        return 0;
      }
  cout<<"I don't know either"<<endl;
  return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 0){
        string t = s.substr(0,n/2);
        if(s == t+t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const double PI = acos(-1);
int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; string s;
	cin >>n >>s;
	char ch ='!';
	int ans =0;
	for(auto x: s){
		if(ch != x) ans++;
		ch = x;
	}
	cout << ans <<"\n";
	return 0;
	
}


Measured memory_bytes: 512
import java.util.*;
import java.util.function.BiPredicate;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int inputN = Integer.parseInt(sc.next());
        sc.nextLine();
        List<Integer> arr = Arrays.asList(sc.nextLine().split(" ")).stream().map( (String x) -> Integer.parseInt(x)).collect(Collectors.toList());

        int count = 0;
        int sum = arr.stream().mapToInt(x ->{
            char[] str = new StringBuffer(Integer.toBinaryString(x)).reverse().toString().toCharArray();
            int cnt = 0;
            for(int i = 0; i<str.length; i++ ) {
                if (str[i] == '0') {
                    cnt++;
                } else {
                    break;
                }
            }
            return cnt;
        }).sum();
        System.out.println(sum);

    }
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    double res = 0;
    REP(i, n)
    {
        cin >> x[i] >> u[i];
        if (u[i] == "JPY")
        {
            res += x[i];
        }
        else
        {
            res += (x[i] * 380000.0);
        }
    }
    cout << res << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  int ans = 1;
  
  for(int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  
  for(int i=1; i<N; i++) {
    if(d.at(i) != d.at(i-1)) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    ll M;

    cin >> N >> M;
    vector<ll> num(N, -1);

    REP(i, M){
        ll s, c;
        cin >> s >> c;
        if( num[s-1] == -1 || num[s-1] == c){
            num[s-1] = c;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    if( N == 1 ){
        if(num[0] == -1){
            cout << 0 << endl;
        }else{
            cout << num[0] << endl;
        }
    }else{
        if( num[0] == 0 ){
            cout << -1 << endl;
            return 0;
        }

        if( num[0] == -1){
            cout << 1;
        }else{
            cout << num[0];
        }

        for( int i =1; i < N; i++){
            if( num[i] == -1 ){
                cout << 0;
            }else{
                cout << num[i];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll unsigned long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

map<Pll, ll> mp;

ll comb(ll n, ll k){
  if(n <= 1)return 1;
  if(k > n - k)return comb(n, n - k);
  if(mp.find(mk(n , k)) != mp.end())return mp[mk(n ,k)];
  ll res = 0;
  res += comb(n - 1, k);
  if(k > 0)res += comb(n - 1, k - 1);
  return mp[mk(n, k)] = res;
}

int main(int argc, char const* argv[])
{
  int n, a, b;
  cin >> n >> a >> b;
  vector<ll> v;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    v.pb(x);
  }
  sort(v.begin(), v.end(), greater<ll>());
  vector<ll> sv;
  sv.pb(v[0]);
  for(int i = 1; i < n; i++){
    sv.pb((ll)sv[i-1] + v[i]);
  }
  vector<ll> p;
  for(int i = 0; i < n; i++){
    int lnum, rnum;
    int left = i;
    while(v[i] == v[left] && left >= 0)left--;
    if(left == -1)lnum = i + 1;
    else lnum = i - left;
    int right = i + 1;
    while(v[i] == v[right] && right < n)right++;
    if(right == n)rnum = n - i - 1;
    else rnum = right - i - 1;
    p.pb(comb(lnum + rnum, lnum));
  }
  ll sum = 0;
  int num = 1;
  ll res = 0;
  for(int i = a; i <= b; i++){
    ll s_i = sv[i - 1];
    if((ll)s_i * num > (ll)sum * i){
      sum = s_i;
      num = i;
      res = p[i-1];
    }else if((ll)s_i * num == (ll)sum * i){
      res += p[i-1];
    }
  }
  cout << setprecision(12);
  cout << (double)sum / (double)num << endl;
  cout << res << endl;
	return 0;
}


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

main(void){
  int N,Y;cin >> N >> Y;
  int res10000=-1,res5000=-1,res1000=-1;
    for(int a=0;a<=N;a++){
      for(int b=0;b+a<=N;b++){
        int c=N-a-b;
        int sum=10000*a+5000*b+1000*c;
        if(sum==Y) {
		  res10000=a;
          res5000=b;
          res1000=c;
        }
      }
    }
  cout<<res10000<<" "<<res5000<<" "<<res1000<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

constexpr ll MOD = 998244353;
struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
	mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) 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.
	// Do not use if MOD is not prime number !!
	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;}
};

const int cmax = 200010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

mint com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
	mint ret=fac[n]*finv[k]*finv[n-k];
    return ret;
}

void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    mint mm = m;
    vector<mint> vm;
    vm.push_back(mm);
    rep(i, n-1) {
        mm *= mint(m-1);
        vm.push_back(mm);
    }
    com_init();
    mint ans = 0;
    for(ll i = 0; i <= k; i++) {
        ans += com(n-1, i) * vm[n-1-i];
    }
    cout << ans.x << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 9992
n, l = list(map(int, input().split()))

s = n * (l - 1) + (n * (n + 1) / 2)

# if (l >= 0):
#     ax = l
# else:
#     if (-l <= n):
#         ax = 0
#     else:
#         ax = l - 1 + n

# s -= ax

d = 1000
rtn = s

for i in range(1,n+1):
    s_tmp = s - (l + i - 1)
    if (abs(s - s_tmp) < d):
        d = abs(s - s_tmp)
        rtn = s_tmp

print(int(rtn))

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

int main()
{
    int a,b,c,d,m,i,k=0,j,nu[5];
    cin>>m;
    nu[0]=m/1000;
    nu[1]=m%1000/100;
    nu[2]=m%100/10;
    nu[3]=m%10;
    if(nu[0]==nu[1] && nu[1]==nu[2] || nu[1]==nu[2] && nu[2]==nu[3])
    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dis[305][305];
int main()
{
    int n;
    while(cin>>n)
    {
        ll mxdis = 0;
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                scanf("%lld",&dis[i][j]);
                mxdis = max(mxdis,dis[i][j]);
            }
        }
        ll ans = 1;
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                if(i==j && dis[i][j]!=0)
                {
                    ans = -1;
                    break;
                }

                if(i!=j && dis[i][j]<=0)
                {
                    ans = -1;
                    break;
                }

                if(dis[i][j]!=dis[j][i])
                {
                    ans =-1;
                    break;
                }

                if(dis[i][j]>0)
                {
                    for(int k=1; k<=n; k++)
                    {
                        if(k!=i && k!=j)
                        {
                            if(dis[i][k] + dis[k][j]<dis[i][j])
                            {
                                ans = -1;
                                break;
                            }
                        }
                    }
                }
            }

            if(ans==-1)
                break;
        }

        mxdis = 0;
        if(ans!=-1)
        {
            for(int i=1; i<=n; i++)
            {
                for(int j=i+1; j<=n; j++)
                {
                    int flg = 1;
                    for(int k=1; k<=n; k++)
                    {
                        if(k!=i && k!=j)
                        {
                            if(dis[i][j]
                                    == dis[i][k]+dis[k][j])
                            {
                                flg = 0;
                            }
                        }
                    }
                    if(flg)
                    {
                        mxdis+=dis[i][j];
                    }
                }
            }
        }

        if(ans!=-1)
            ans = mxdis;

        printf("%lld\n",ans);



    }
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	int count = 1;
	sort(S.begin(), S.end());
	for (int i = 0; i < N - 1; i++) {
		if (S[i] != S[i + 1]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++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(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;


  
int main() {
  int N,M;
  cin >> N >> M;
  vi cnt(N,0);
  rep(i,M) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    cnt[a]++;
    cnt[b]++;
  }
  rep(i,N) {
    cout << cnt[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A,B,max;
    scanf("%d%d",&A,&B);
    if( A*B >= A+B ){
        if( A*B >= A-B ){
            max = A*B;
        }else{
            max = A-B;
        }
    }else{
        if( A+B >= A-B ){
            max = A+B;
        }else{
            max = A-B;
        }
    }
  printf("%d\n",max);
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
int main(){
   LL n, dig;
   cin >> n;
   LL sum = 0;
   LL cnt = 0;
   while(n){
    dig = n % 10;
    sum = sum + dig;
    n = n / 10;
    cnt++;
  }
  LL tmp=(dig-1)+(cnt-1)*9;
  LL ans = max(tmp,sum);
  cout << ans;


   


}

    



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 307;
const int MAX2 = 507;
const int ADD = 250;
const int LEN = 21;
const int BASE = 1000000000;
const int MOD = 1000000007;

int n;
Int A[MAX][MAX];
Int B[MAX][MAX];

int main()
{
  cin >> n;
  FOR (i,0,n)
    FOR (j,0,n)
    {
      int t;
      scanf("%d", &t);
      A[i][j] = t;
    }

  FOR (i,0,n)
    FOR (j,0,n)
      B[i][j] = LINF;
  FOR (i,0,n)
    B[i][i] = 0;

  Int res = 0;
  FOR (i,0,n)
    FOR (j,i+1,n)
    {
      bool was = 0;
      FOR (k,0,n)
        if (k != i && k != j)
          if (A[i][k] + A[k][j] == A[i][j]) was = 1;
      if (!was)
      {
        res += A[i][j];
        B[i][j] = B[j][i] = A[i][j];
      }
    }

  FOR (k,0,n)
    FOR (i,0,n)
      FOR (j,0,n)
        if (B[i][j] > B[i][k] + B[k][j])
          B[i][j] = B[i][k] + B[k][j];

  FOR (i,0,n)
    FOR (j,0,n)
      if (A[i][j] != B[i][j])
      {
        cout << -1 << endl;
        return 0;
      }

  cout << res << endl;


  

  return 0;
}




Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
int main(void) {
	int N, M, *A, SN = 0;
	int i, count = 0;

	scanf("%d", &N);
	scanf("%d", &M);

	A = (int *)malloc(N);
	for (i = 0; i < N; i++) {
		scanf("%d",&A[i]);
		SN += A[i];
	}
	for (i = 0; i < N; i++) {
		if (A[i] >= (double)SN / (4 * M)) {
			count += 1;
		}
	}
	
	if (count >= M) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define UB upper_bound
#define LB lower_bound
#define PB push_back
#define mp make_pair
#define F first
#define S second
#define be(a) (a).begin(),(a).end()
#define deb(x) cout<< #x <<" "<<endl;
#define deb2(x, y) cout<< #x <<" "<< x <<endl<< #y <<" "<<y<<endl
#define fo(i, n) for(long long i=0; i<n; i++)
#define Fo(i, n, k) for(long long i=k; i<n; i++)
#define mod 1000000007
#define int long long

typedef long long ll;

void fileIO()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
typedef vector<pair<int, int>> vll;
typedef unordered_map<int, int> ump;



bool sortbysecdesc(const pair<int, int> &a, 
                    const pair<int, int> &b) 
{ 
    return a.second>b.second;
}





int slimeCost(vector<int> a, int i, int j, vector<int> prefix_sum)
{

    int n = a.size();
    
    vector<vector<int>> dp(n, vector<int>(n, 0));

    for(int i = 0; i<n-1; i++) dp[i][i+1] = a[i] + a[i+1];


    for(int gap = 2; gap<n; gap++)
    {
        for(int i = 0; i < n-gap; i++)
        {
            int j = i + gap;

            dp[i][j] = 1e16;

            for(int k = i; k<j; k++)
            {
                int temp = dp[i][k] + dp[k+1][j];

                if(i == 0) temp += prefix_sum[k];

                else temp += (prefix_sum[k] - prefix_sum[i-1]);

                temp += ( prefix_sum[j] - prefix_sum[k] );

                dp[i][j] = min(dp[i][j], temp);

            }
        }
    }

    return dp[0][n-1];



    
}



int32_t main()
{
    IOS;
    fileIO();
    int T;
    T = 1;
    //cin>>T;

    while(T--)
    {
        int n;

        cin>>n;

        vector<int> a(n);

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

        vector<int> prefix_sum(n);

        prefix_sum[0] = a[0];

        for(int i = 1; i<n; i++) prefix_sum[i] = prefix_sum[i-1] + a[i];

        

        int res = slimeCost(a, 0, n-1, prefix_sum);

        cout<<res<<"\n";

    }
    
    return 0;
}

    

Measured memory_bytes: 4520
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// --------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  set<ll> ans;
  for(ll i=1; i*i<=N; i++){
    if(N%i == 0){
      ll m1 = i;
      ll m2 = N/i;
      if(m1 != 1 && N/(m1-1) == N%(m1-1)) ans.emplace(m1-1);
      if(m2 != 1 && N/(m2-1) == N%(m2-1)) ans.emplace(m2-1);
    }
  }
  ll ret = 0;
  for(auto x: ans) ret += x;
  cout << ret << "\n";
  return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector <int> H(n), P(n);
  for(int i=0; i<n; i++) cin >> H[i];
  for(int i=1; i<n; i++) if(H[i-1] >= H[i]) P[i] = 1;
  for(int i=1; i<n; i++) if(P[i]) P[i] += P[i-1];
  cout << *max_element(P.begin(), P.end()) << "\n";
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nx = ReadInts();
            var l = ReadInts();
            var ans =0;
            var tmp = 0;

            var list = new List<int>() { 0 };
            for (int i = 0; i < nx[0]; i++)
            {
                list.Add(tmp + l[i]);
                tmp += l[i];
            }
            foreach (var item in list)
            {
                if (item <= nx[1]) ans++;
            }
            WriteLine(ans);
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
        static long fibonacci(int n)
        {
            switch (n)
            {
                case 0:
                case 1:
                    return n;
                default:
                    return fibonacci(n - 2) + fibonacci(n - 1);
            }
        }
    }
}


Measured memory_bytes: 13268