akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

class Tree
{
public:
	string name;
	Tree* parent;
	vector<Tree*> child;
	
	Tree()
	:parent(NULL)
	{}
	
	~Tree()
	{
		REP(i,child.size()) delete child[i];
	}
};

Tree* tree;

Tree* find(Tree* t, string name)
{
	if(name==t->name) return t;
	
	REP(i, t->child.size())
	{
		Tree* ret=find(t->child[i], name);
		if(ret!=NULL) return ret;
	}
	return NULL;
}

bool isChild(Tree* t, string name)
{
	REP(i, t->child.size())
	{
		if(t->child[i]->name==name) return true;
	}
	
	return false;
}

bool isParent(Tree* t, string name)
{
	if(t->parent->name == name) return true;
	return false;
}

bool isSibling(Tree* t, string name)
{
	Tree* p=t->parent;
	
	return isChild(p, name);
}

bool isDescendant(Tree* t, string name)
{
	Tree* ret=find(t, name);
	if(ret==NULL) return false;
	
	return true;
}

bool isAncestor(Tree* t, string name)
{
	if(t->name==name) return true;
	if(t->parent==NULL) return false;
	
	return isAncestor(t->parent, name);
}

int main()
{
	int n,q;
	while(cin >> n >> q, (n||q))
	{
		tree = new Tree;
		Tree* now = tree;
		Tree* prev = tree;
		int sp=-1;
		cin.ignore();
		
		REP(i,n)
		{
			string str;
			getline(cin,str);
			
			int cnt=0;
			REP(j,str.size()) if(str[j]==' ') ++cnt;
			string name(str.begin()+cnt, str.end());
			
			REP(j, (sp-cnt)+1)
				now=now->parent;

			Tree* nw= new Tree;
			nw->parent=now;
			nw->name=name;
			
			now->child.push_back(nw);
			now = nw;
			sp=cnt;
		}
		
		REP(i,q)
		{
			bool ret;
			string a,b,c;
			cin >> a >> b >> b >> b >> c >> c;
			
			c=c.substr(0,c.size()-1);
			
			Tree* s=find(tree, c);
			if(s==NULL) cout << "False" << endl;
			else
			{
				if(b[0]=='c') ret=isChild(s,a);
				if(b[0]=='p') ret=isParent(s,a);
				if(b[0]=='s') ret=isSibling(s,a);
				if(b[0]=='d') ret=isDescendant(s,a);
				if(b[0]=='a') ret=isAncestor(s,a);
				
				cout << (ret?"True":"False") << endl;
			}
		}
		
		cout << endl;
		
		delete tree;
	}
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t=1;
	while(t--){
	   vector<int> hp(101,0);
	   int x,n;
	   cin>>x>>n;
	   for(int i=0;i<n;i++){
	   	int p;
	   	cin>>p;
	   	hp[p]=1;
	   }
	   int res=0;
	   int ans=INT_MAX;
	   for(int i=0;i<=101;i++){
	   	if(abs(i-x)<ans&&hp[i]==0){
	   		ans=abs(x-i);
	   		res=i;
		   }
	   }
	   cout<<res<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var (N, M) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var AB = Range(0, M).Select(i => ReadLine().Split(' ').Select(int.Parse).ToArray()).ToArray();

        var uf = new UnionFind(N);
        foreach (var (A, B) in AB)
            uf.Unite(A - 1, B - 1);

        var ans = Range(0, N).Select(i => uf.Find(i)).Distinct().Count() - 1;

        WriteLine(ans);
    }
}

class UnionFind
{
    private int[] d;
    public UnionFind(int n) => d = Enumerable.Repeat(-1, n).ToArray();
    public int Find(int x) => (d[x] < 0) ? x : d[x] = Find(d[x]);
    public bool Unite(int x, int y)
    {
        (x, y) = (Find(x), Find(y));
        if (x == y)
            return false;
        if (-d[x] < -d[y])
            (x, y) = (y, x);
        (d[x], d[y]) = (d[x] + d[y], x);
        return true;
    }
    public bool Same(int x, int y) => Find(x) == Find(y);
    public int Size(int x) => -d[Find(x)];
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 44852
import numpy as np

n, k = map(int, input().split())
*h, = map(int, input().split())
h = np.array(h)
table = np.zeros(n+k, dtype=int)

for i in range(1, n):
    l = max(0, i - k)
    table[i] = (table[l:i] + np.abs(h[i] - h[l:i])).min()

print(table[n-1])

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

using namespace std;
#define ll long long
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef vector<ll> Array;

ll l[20][202020];
ll r[20][202020];
ll dp1[20][202020];
ll dp2[20][202020];

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

	ll n, k;
	cin >> n >> k;
	Array x(n);
	REP(i, n)cin >> x[i];
	REP(i, n)dp1[0][i] = l[0][i] = lower_bound(all(x), x[i] + k) - x.begin();
	REP(i, n)dp2[0][i] = r[0][i] = upper_bound(all(x), x[i] - k) - x.begin() - 1;
	REP(i, 19)REP(j, n)l[i + 1][j] = l[i][min(n - 1, l[i][j])];
	REP(i, 19)REP(j, n)r[i + 1][j] = r[i][max(0LL, r[i][j])];
	REP(i, 19)REP(j, n)dp1[i + 1][j] = dp1[i][j] + dp1[i][l[i][j]];
	REP(i, 19)REP(j, n)dp2[i + 1][j] = dp2[i][j] + dp2[i][r[i][j]];
	ll q;
	cin >> q;
	while (q--) {
		ll L, R;
		cin >> L >> R;
		L--;
		ll ans = R - L;
		ll x = L, y = R - 1;
		for (int i = 19; i >= 0; i--) {
			if (l[i][x] < R)ans += (1LL << i) - dp1[i][x], x = l[i][x];
			if (r[i][y] >= L)ans += dp2[i][y], y = r[i][y];
		}
		cout << ans << "\n";
	}

	return 0;
}


Measured memory_bytes: 130180
#include "bits/stdc++.h"
using namespace std;
long long n , s;
int main(){
    cin >> n >> s;
    for(int base = 2 ; base < 1e6 ; ++base){
        long long num = n;
        long long sum = 0;
        while(num){
            sum += num % base;
            num /= base;
        }
        if(sum == s){
            printf("%d\n" , base);
            return 0;
        }
    }
    long long ans = 1e15 + 15;
    if(n == s){
        ans = s + 1;
    }
    for(int a = 1 ; a < 1e6 && a <= s ; ++a){
        long long b = s - a;
        long long base = (n - b) / a;
        if(base < 2){
            continue;
        }
        if(a * base + b != n){
            continue;
        }
        if(b >= base){
            continue;
        }
        ans = min(ans , base);
    }
    if(ans >= 1e15){
        ans = -1;
    }
    printf("%lld\n" , ans);
}


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

int main()
{
    int n;
    string s;
    cin >> n >> s;

    if (n % 2)
    {
        cout << "No" << endl;
        return 0;
    }
    rep(i, n / 2)
        if (s[i] != s[i + n / 2])
        {
            cout << "No" << endl;
            return 0;
        }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] count = new int[4];
        for(int i=0;i<n;i++){
            String s = sc.next();
            switch (s){
                case "AC":
                    count[0]++;
                    break;
                case "WA":
                    count[1]++;
                    break;
                case "TLE":
                    count[2]++;
                    break;
                case "RE":
                    count[3]++;
                    break;
            }
        }
        System.out.println("AC x " + count[0]);
        System.out.println("WA x " + count[1]);
        System.out.println("TLE x " + count[2]);
        System.out.println("RE x " + count[3]);
    }
}


Measured memory_bytes: 48656
// C++ program to count the Minimum number of 
// increasing subsequences 
#include <bits/stdc++.h> 
using namespace std; 
  
int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
  
// Driver program 
int main() 
{ 
	int n;
	cin >> n;
    int arr[n];
    for (int i = 0; i < n; ++i) {
    	cin >> arr[i];
    }
    //int n = sizeof(arr) / sizeof(int); 
    cout << MinimumNumIncreasingSubsequences(arr, n) << endl;; 
    return 0; 
} 

Measured memory_bytes: 5376
#include <stdio.h>

int count(int t[], int N) {
    int i, j, n;
    n = 0;
    for (i = 0; i < N; i++) {
        for (j = i - 1; j >= 0; j--) {
            if (t[i] < t[j]) {
                n--;
                break;
            }
        }
        n++;
    }
    return n;
}

int main(int argc, char const *argv[]) {
    
    int N;
    scanf("%d",&N);
    int t[N];
    int i;
    for(i = 0 ; i<N ; i++){
        scanf("%d", &t[i]);
    }

    int n = 0;
    n = count(t,N);

    printf("%d",n);

    return 0;
}


Measured memory_bytes: 128
x=int(input())
ans=[]
for a in range(500,-500,-1):
  for b in range(500,-500,-1):
    if a**5-b**5 == x:
      ans.append(a)
      ans.append(b)
      print(*ans)
      exit()
ans = 0
for o in w:
  if o == 1:
    ans+=1
print(ans)

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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

int main()
{
    _fastio
   string s;
   cin>>s;
   ll mx=0,a=0;
   for0(i,s.size())
   {
    if(s[i]=='R')
    {
        a+=1;
    }
    else
    {
        mx=max(mx,a);
        a=0;
    }
   }
   mx=max(mx,a);
   cout<<mx<<en;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int cats[MAX];

void solve(void){
    int N, mn, mx; cin >> N;
    rep(N, i) scanf("%d ", &cats[i]);
    sort(cats, cats+N);
    mn = cats[0], mx = cats[N-1];
    if (mx-mn >= 2) {
        cout << "No" << endl;
        return;
    }
    if (mx == mn) {
        cout << ((N-1==mx || 2*mx <= N)?"Yes":"No") << endl;
        return;
    }
    int x = count(cats, cats+N, mn);
    cout << ((x+1<=mx && (N-x)/2==(mx-x))?"Yes":"No") << endl;
}

int main(void){
  solve();
  return 0;
}


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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
w, h = map(int,input().split())
P = [int(input()) for i in range(w)]
Q = [int(input()) for i in range(h)]
R = [P, Q]

nn = [w+1, h+1]
A = []
for i in range(w):
    A.append([P[i], i, 0])
for i in range(h):
    A.append([Q[i], i, 1])

A.sort()
ans = 0
for i in range(len(A)):
    d = A[i][0]
    j = A[i][1]
    t = A[i][2]
    ans += d * nn[(t+1)%2]
    # print(d, nn[(t+1)%2])
    nn[t] = max(1, nn[t]-1)
    if nn == [1, 1]:
        break
print(ans)

Measured memory_bytes: 73052
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  std::string s;
  Solver() {
    S002 r;
    r >= s;
  }
  void solve() {
    std::reverse(s.begin(), s.end());
    long i = 0;
    loop {
      if( i == (long)s.size() ) break;
      if( strncmp(&s.c_str()[i], "maerd", 5) == 0 ) i += 5;
      else if( strncmp(&s.c_str()[i], "remaerd", 7) == 0 ) i += 7;
      else if( strncmp(&s.c_str()[i], "esare", 5) == 0 ) i += 5;
      else if( strncmp(&s.c_str()[i], "resare", 6) == 0 ) i += 6;
      else {
        puts("NO");
        return;
      }
    }
    puts("YES");
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;


#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  int ans = 700;
  rep(i,3){
    char c; cin >> c;
    if(c == 'o') ans += 100;
  }
  cout << ans << endl;
}

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

const int N = 310, mod = 1e9 + 7;

int dp[N][N][N];

inline void Inc(int &x, int y) {
	x += y, x -= x >= mod ? mod : 0;
}

typedef pair<int, int> P;

vector<P> q[N];

int main() {
	int n, m, res = 0; scanf("%d%d", &n, &m);
	for (int i = 1, l, r, a; i <= m; i++)
		scanf("%d%d%d", &l, &r, &a), q[r].push_back(P(l, a));
	dp[0][0][0] = 1;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= i; j++)
			for (int k = 0; k <= j; k++) if (dp[i][j][k]) {
				bool flg = true;
				for (auto v : q[i]) {
					int c = 1;
					if (j >= v.first) c++;
					if (k >= v.first) c++;
					if (v.second != c) {
						flg = false; break;
					}
				}
				if (!flg) continue;
				Inc(dp[i + 1][j][k], dp[i][j][k]), Inc(dp[i + 1][i][k], dp[i][j][k]), Inc(dp[i + 1][i][j], dp[i][j][k]);
				if (i == n) Inc(res, dp[i][j][k]);
			}
	printf("%d\n", res);
}


Measured memory_bytes: 112896
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n)(for i-0;i<(n);++i)
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r;
  } else {
    cout << r + (100 * (10 - n));
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        char[] cs = in.next().toCharArray();
        for (int i = cs.length - 1; i >= 0; i--) {
            System.out.print(cs[i]);
        }
        System.out.println();
    }
}

Measured memory_bytes: 26004
#include<unordered_map>
#include<set>    // multiset
#include<iostream>
using namespace std;
#define df 0
#define D_MAX 100000
typedef long int li;

void merge(int x,int y,unordered_map<int,int>& uf);
int find(int x,unordered_map<int,int>& uf);
void print(unordered_map<int,int>& uf);

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  set<int> vtx;
  unordered_map<int,int> uf;
  for(int i=0;i<n;i++){
    int x,y; cin >>x >>y;
    //    x=(i+1)/2+1;y=i/2+1;
    x--;y--;y+=D_MAX;
    if(df){
      //      printf("%d %d ",x,y);
    }
    vtx.insert(x);
    vtx.insert(y);
    merge(x,y,uf);
    //    if(df)print(uf);
    if(df){
      printf("%d ",uf.size());
    }
  }
  unordered_map<int,int> l,r;
  for(const int& x: vtx){
    if(df){
      printf("%d->%d/",x,find(x,uf));
    }
    if(x<D_MAX){
      l[find(x,uf)]++;
    }else{
      r[find(x,uf)]++;
    }
  }
  if(df){
    printf("\nl:");
    print(l);
    printf("r:");
    print(r);
  }
  li sum=0;
  for(const pair<int,int>& p: l){
    sum+=(li)p.second*r[p.first];
  }
  cout << sum-n;
}

void merge(int x,int y,unordered_map<int,int>& uf){
  //  if(df)printf("m");
  if(df && uf.size()>450){
    printf("(x,y):(%d %d)->",x,y);
  }
  x=find(x,uf),y=find(y,uf);
  if(df && uf.size()>450){
  printf("(%d %d)->",x,y);
  }
  if(x==y)return;
  if(x>y)swap(x,y);
  if(df && uf.size()>450){
    printf("(%d %d)\n",x,y);
  }
  uf[x]+=uf[y];
  uf[y]=x;
}
int find(int x,unordered_map<int,int>& uf){
  //  if(df)printf("f");
  if(df && uf.size()>450){
    printf("%d->",x);
  }
  if(uf.count(x)==0){
    uf[x]=-1;
  }
  if(uf[x]<0){
  if(df && uf.size()>450){
    printf("%d\n",x);
  }
    return x;
  }
  return uf[x]=find(uf[x],uf);
}

void print(unordered_map<int,int>& uf){
  printf("uf:");
  for(const pair<int,int>& p: uf){
    printf("(%d %d)",p.first,p.second);
  }
  printf("\n");
}


/// confirm df==0 ///


Measured memory_bytes: 8996
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=0;i<b-a+1;i++){
		int af=(a+i)/10000,as=(a+i)/1000-10*af,at=(a+i)/100-100*af-10*as,afo=(a+i)/10-1000*af-100*as-10*at,al=(a+i)%10;
		if(af==al and as==afo){
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int n, i;
    int arr[100];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf(" %d", &arr[i]);
    }
    for (i = 0; i < n; i++)
    {
        if (i)
            printf(" ");
        printf("%d", arr[n - i - 1]);
    }
    printf("\n");
    return 0;
}


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

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

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

ll n, A[N], mn, mx, t[3];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i <= n; i++) {
        cin >> A[i];
        t[0] += A[i];
    }
    mn = mx = A[n];
    for (int i = n - 1; i >= 0; i--) {
        mn = (mn + 1) / 2 + A[i];
        mx = (mx + 1) / 2 + A[i];
    }
    if (mn > 1) 
        kill(-1);
    t[2] = t[0] - 1;
    ll now = 0, last = 1;
    for (int i = 1; i <= n; i++) {
        ll d = min(last, t[2] - now);
        now += d;
        t[1] += last - d;
        last = last + d - A[i];
    }
    cout << t[0] + t[1] + t[2] << endl;
    return 0;
}


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

namespace AtCorder1
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.WriteLine(Test(Console.ReadLine()));
		}

		private static String Test(String s)
		{
			var ls = new List<int>();

			do
			{
				var r = s.TakeWhile(t => t == 'R').Count();
				var l = s.Skip(r).TakeWhile(t => t == 'L').Count();
				int h = (r + l) / 2;
				if ((r + l) % 2 == 0)
				{
					ls.AddRange(Enumerable.Repeat(0, r - 1)
						.Append(h)
						.Append(h)
						.Concat(Enumerable.Repeat(0, l - 1)));
				}
				else
				{
					ls.AddRange(Enumerable.Repeat(0, r - 1)
						.Append(h + (r % 2))
						.Append(h + (l % 2))
						.Concat(Enumerable.Repeat(0, l - 1)));
				}

				s = s.Substring(r + l);
			} while (s.Any());

			return String.Join(" ", ls);
		}
	}
}

Measured memory_bytes: 49620
n=int(input())
x=input()
pc=[0]
m=2*10**5
for i in range(1,m+2):
  cnt=0
  j=i
  while i:
    cnt+=i%2
    i//=2
  pc+=[j%cnt]
f=[0]*(m+2)
for i in range(1,m+2):
  if pc[i]==0:f[i]=1
  else:f[i]=f[pc[i]]+1
cnt=x.count('1')
ix=int(x,2)
ixp=ix%(cnt+1)
ixm=ix%(cnt-1) if cnt-1 else 0
d=1<<(n-1)
for i in range(n):
  dp=pow(2,n-i-1,cnt+1)
  if cnt-1:dm=pow(2,n-i-1,cnt-1)
  if x[i]=='0':print(f[(ixp+dp)%(cnt+1)]+1)
  else:
    if cnt-1:print(f[(ixm-dm)%(cnt-1)]+1)
    else:print(0)

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  ll temp=0;
  ll ans=0;
  for(ll i=n-1;i>-1;i--) {
    if(a[i]>i || a[i]<temp) {
      cout << -1 << endl;
      return 0;
    }
    if(a[i]!=temp) {
      ans+=a[i];
      temp=a[i];
    }
    if(temp>0) {
      temp--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

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

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

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

void main() {
    LL a,b,c,k;
    R(a,b,c,k);
    REP(i,k%2) tie(a,b,c)=make_tuple(b+c,a+c,a+b);
    W(a-b);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 256
using System;

namespace B___Increment_Decrement
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = 0;
            var max = 0;
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'I')
                {
                    x++;
                }
                if (S[i] == 'D')
                {
                    x--;
                }
                if(x>max)
                {
                    max = x;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int r;
    cin >> r;
    cout << 3 * r*r;
}

Measured memory_bytes: 3596
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		int n = ni();
		long[] la = nal(n);
		long[] da = new long[60];
		long result = 0;
		for(int i = 0; i < n; i++) {
			char[] ca = Long.toBinaryString(la[i]).toCharArray();
			for(int j = 0; j < ca.length;j++) {
				if(ca[ca.length - 1 - j] == '1')da[j]++;
			}
		}

		for(int i = 0; i < da.length; i++) {
			final long l = pow(i);
			final long i1 = da[i] * (n - da[i]) % mod;
			result += (l * i1) % mod;
            result %= mod;
		}
		System.out.println(result);
	}
	
	private static long pow(final long a) {
        long result = 1;
        for (long i = 0; i < a; i++) {
        	result *= 2;
        	result %= mod;
        } 
        return result;
    }
	static int mod = 1000000007;


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 97360
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int main()
{
	int d[110];
	int b[110];
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= M; i++)
	{
		cin >> b[i] >> d[i];
	}
	int c[110] = { 0 };

	for (int i = 1; i <= M; i++)
	{
		c[b[i]]++;
		c[d[i]]++;
	}
	for (int i = 1; i <= N; i++)
	{
		
		cout << c[i] << endl;
	}

	
}

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

using namespace std;

int main(){
    long A,B;
    long K;
    cin >> A >> B >> K;
    if(K >= A + B){
        A = 0;
        B = 0;
    }else if(K >= A){
        B -= K - A;
        A = 0;
    }else{
        A -= K;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, string) {
	n, s := scanInt(sc), scanString(sc)
	return n, s
}

func resolve(n int, str string) int {
	num := 0
	for i := 0; i <= 9; i++ {
		for j := 0; j <= 9; j++ {
			for k := 0; k <= 9; k++ {
				if accept(str, i, j, k) {
					num++
				}
			}
		}
	}
	return num
}

func accept(str string, i, j, k int) bool {
	ans := []byte{
		'0' + byte(i),
		'0' + byte(j),
		'0' + byte(k),
	}
	ansIdx := 0
	for idx := 0; idx < len(str); idx++ {
		if ansIdx == len(ans) {
			return true
		}
		if ans[ansIdx] == str[idx] {
			ansIdx++
		}
	}
	return ansIdx == len(ans)
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

const int maxn = 2e5 + 5;
char s[maxn];

int main() {
    scanf("%s", s);
    int n = strlen(s);

    long long ans = 0;
    int cont = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'A') ++cont;
        else if (cont == 0 || i + 1 == n || s[i] != 'B' || s[i + 1] != 'C') cont = 0;

        if (i + 2 < n && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' || 
            cont > 0 && i + 1 < n && s[i] == 'B' && s[i + 1] == 'C') {
            ans += cont;
            if (s[i + 1] == 'C') i += 1;
            else i += 2;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl


using ll = long long;
const ll mod = LLONG_MAX;


int main(){
  string s;
  cin>>s;
  bool flag=false;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[2-i]){
      cout<<"No"<<endl;
      flag=true;
      break;
    }
  }
  if(!flag)cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
let rec fix f x = f (fix f) x;;
Scanf.(Array.(scanf " %d %d" @@ fun n m ->
  let e = make n [] in
  let e_rev = make n [] in
  init (n-1+m) (fun i -> scanf " %d %d" @@ fun u v ->
    let u,v = u-1,v-1 in
    e.(u) <- v :: e.(u);
    e_rev.(v) <- u :: e_rev.(v)
  ) |> ignore;
  let root = fst @@ fold_left (fun (root,i) ls ->
    (if List.length ls = 0 then i else root),i+1
  ) (0,0) e_rev in
  let q = Queue.create () in
  let v_left = init n (fun i -> List.length e_rev.(i)) in
  Queue.add root q;
  let par = make n 0 in
  while not @@ Queue.is_empty q do
    let i = Queue.pop q in
    List.iter (fun j ->
      v_left.(j) <- v_left.(j) - 1;
      if v_left.(j) = 0 then (
        par.(j) <- i + 1;
        Queue.add j q;
      )
    ) e.(i)
  done;
  iter (Printf.printf "%d\n") par
))

Measured memory_bytes: 15104
/**
 * auther: moririn_cocoa
 */
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second

int main(int argc, char* argv[]) {
  
  int A;
  int B;
  int C;
  
  cin >> A;
  cin >> B;
  cin >> C;
  
  if ( A + B + C == 17 ) {
    
    cout << "YES" << endl;
  }
  
  else {
    
    cout << "NO" << endl;
  }
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define M (1000000007)

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

    ll n, k;
    cin >> n >> k;

    ll ans = 0;

    for (ll i = k; i <= n + 1; i++) {
        ll start = (i - 1) * i / 2;
        ll end = (n + (n - i + 1)) * i / 2;
        // printf("i:%lld, st:%lld, ed:%lld\n", i, start, end);
        ans = (ans + (end - start + 1)) % M;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
  int n,k;
  cin>>n>>k;
   int a[n];
   int i;
   for(i=0;i<n;i++)
   cin>>a[i];
   vector<int> dp(n,INT_MAX);
   dp[1]=abs(a[0]-a[1]);
   dp[0]=0;
   for(i=2;i<n;i++)
   {
   	for(int j=1;j<=k;j++)
   	{
   		if(i-j>=0)
   		{
   			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		   }
	   }
	   }	
	   cout<<dp[n-1];
	   return 0;
}

Measured memory_bytes: 1024
//package code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
public class Main {
    
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        String s = in.next();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


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

using namespace std;

namespace IntegerMath
{
  int64_t sqrt(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::sqrtl( 
        static_cast<long double>(x)
      ) )
    );
  }
  
  uint64_t sqrt(uint64_t x) {
    return static_cast<uint64_t>(
      ::floorl( ::sqrtl( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t log2(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log2l( 
        static_cast<long double>(x)
      ) )
    );
  }    

  int64_t log10(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log10l( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t number_of_digits(int64_t x) {
    return static_cast<int64_t>(
      ::ceill( ::log10l( 
        static_cast<long double>(x + 1)
      ) )
    );
  }

  uint64_t gcd(uint64_t a, uint64_t b)
  {
    uint64_t n = std::min(a, b), m = std::max(a, b);
    return (n == 0) ? m : gcd(m % n, n);
  }

  uint64_t lcm(uint64_t a, uint64_t b)
  {
    uint64_t d = gcd(a, b);
    return (a % d == 0) ? (a / d) * b : a * (b / d);
  }
};

bool query(uint64_t N, uint64_t K, const vector<int64_t> &A, uint64_t m)
{
  vector<int64_t> r(N);
  for (uint64_t n = 0; n < N; ++n) {
    r[n] = A[n] % m;
  }
  
  sort(r.begin(), r.end());
  
  vector<int64_t> cumsum(N + 1, 0);
  for (uint64_t i = 0; i < r.size(); ++i) {
    cumsum[i + 1] = r[i] + cumsum[i];
  }
  
  for (uint64_t i = 0; i < N; ++i) {
    uint64_t x = cumsum[i], y = cumsum[N] - cumsum[i], z = ((N - i) * m) - y;
    if (x <= K && x == z) { return true; }
  }
  
  return false;
}

int main()
{
  uint64_t N, K;
  cin >> N >> K;
  
  vector<int64_t> A(N);
  for (uint64_t n = 0; n < N; ++n) {
    cin >> A[n];
  }
  
  uint64_t S = accumulate(A.begin(), A.end(), 0);
  
  set<uint64_t, std::greater<uint64_t>> P;
  for (uint64_t i = 1; i <= IntegerMath::sqrt(S) + 1; ++i) {
    if ((S % i) == 0) {
      P.insert(i);
      P.insert(S / i);
    }
  }
  
  uint64_t T = 1;
  for (uint64_t p : P) {
    bool flag = query(N, K, A, p);
    if (flag) { T = max(T, p); }
  }
  cout << T << endl;
  
  return 0;
}

Measured memory_bytes: 384
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main(){
int N;
cin>>N;
pair<ll,ll> path[N-1];
rep(i,N-1){
  int u,v;
  cin>>u>>v;
  path[i]=make_pair(u,v);

}
ll ans=0;
rep3(i,N){
ans+=i*(N-i+1);
}
rep(i,N-1){
  ans-=min(path[i].first,path[i].second)*(N-max(path[i].first,path[i].second)+1);
}
cout<<ans<<endl;
}

Measured memory_bytes: 6636
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long solve(long n, long k)
{
  long a = n % k;
  return std::min(a, std::abs(a - k));
}

int main()
{
  long n, k;
  std::cin >> n >> k;

  std::cout << std::setprecision(20);
  std::cout << solve(n, k) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

bool is_YYMM(int i1, int i2) {
    if(i2 <= 0 || i2 >= 13) return false;
    return true;
}

int main(int argc, char **argv) {
    int n;
    cin >> n;
    int i1 = n / 100;
    int i2 = n % 100;

    bool r1 = is_YYMM(i1, i2);
    bool r2 = is_YYMM(i2, i1);

    if(r1) {
        if(r2)
            cout << "AMBIGUOUS" << endl;
        else
            cout << "YYMM" << endl;
    } else {
        if(r2)
            cout << "MMYY" << endl;
        else
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int N;
	cin >> N;

	int flag = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if (i*j == N) {
				flag = 1;
			}
		}
	}

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

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int	
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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 T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }


int main()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	if (k != 1)
		ans = n - k;


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

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
int N;
scanf("%d",&N);
if(0<N&&N<10){
    printf("%d",N);
}else if(9<N&&N<100){
    printf("9");
}else if(99<N&&N<1000){
    printf("%d",9+N-99);
}else if(999<N&&N<10000){
    printf("909");
}else if(9999<N&&N<100000){
    printf("%d",909+N-9999);
}else if(N==100000){
    printf("90909");
}
}


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


int main(){
	set<int> groupA, groupB;
	groupA.insert(1);
	groupA.insert(3);
	groupA.insert(5);
	groupA.insert(7);
	groupA.insert(8);
	groupA.insert(10);
	groupA.insert(12);
	groupB.insert(4);
	groupB.insert(6);
	groupB.insert(9);
	groupB.insert(11);

	int x,y;
	cin >> x >> y;
	if(groupA.count(x) && groupA.count(y)){
        cout << "Yes\n";
        return 0;
	}
	if(groupB.count(x) && groupB.count(y)){
        cout << "Yes\n";
        return 0;
	}
	if(x == 2 && y == 2){
        cout << "Yes\n";
        return 0;
	}
	cout << "No\n";


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, a[100001], b[100000];
long long sum = 0;

int main()
{
    cin >> n;
    for (int i = 0; i < (n + 1); ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i], sum += b[i];
    for (int i = 0; i < n; ++i)
    {
        int c = min(a[i], b[i]);
        a[i] -= c;
        b[i] -= c;
        c = min(a[i + 1], b[i]);
        a[i + 1] -= c;
        b[i] -= c;

        sum -= b[i];
    }
    cout << sum << endl;
    return 0;
}


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

int main(){
  int W,H,N,x,y,a,w=0,h=0;
  cin>>W>>H>>N;
  for(int i=0;i<N;i++){
    cin>>x>>y>>a;
    if(a==1&&w<x)w=x;
    else if(a==2&&W>x)W=x;
    else if(a==3&&h<y)h=y;
    else if(a==4&&H>y)H=y;
  }if(H<=h||W<=w)cout<<0<<endl;
else {
  cout<<abs(H-h)*abs(W-w)<<endl;
}
 return 0;
 }

Measured memory_bytes: 256