akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl x(n), y(n), h(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }

    exrep(cx, 0, 100) {
        exrep(cy, 0, 100) {
            ll H;
            rep(i, n) {
                if(h[i] == 0) {
                    continue;
                }
                H = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
                break;
            }
            bool ok = true;
            rep(i, n) {
                if(max(0LL, H - abs(x[i] - cx) - abs(y[i] - cy)) != h[i]) {
                    ok = false;
                    break;
                }
            }
            if(ok) {
                cout << cx << " " << cy << " " << H << endl;
                re0;
            }
        }
    }
    
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    string s;cin>>s;
    if(s=="ARC"){
        cout<<"ABC"<<endl;
        return 0;
    }
    cout<<"ARC"<<endl;
    return 0;
}

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

using namespace std;

int main(int argc, char **argv)
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if((x-r >= 0) && (y-r >= 0) && (x + r <= W) && (y + r <= H)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}



Measured memory_bytes: 3112
function Main(input) {
	input = input.split(" ").map(Number);
  if(input[0]*input[1]==15){
    console.log("*")
  }else if(input[0]+input[1]==15){
  console.log("+")
  }else{
  console.log("x")
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
#include <iostream>
using namespace std;
int main(){
	int M, N;
	cin>>M>>N;
	if (abs(M-N)>=2){
		cout << 0 << endl;
	}
	else if (M==N){
		long long s = 1;
		for (int i=1; i<=M; i++){
			s = s*i % 1000000007;
		}
		
		cout << s*s*2%1000000007;
	}
	else {
		long long s = 1;
		for (int i=1; i<=M; i++){
			s = s*i % 1000000007;
		}
		long long x = 1;
		for (int i=1; i<=N; i++){
			x = x*i % 1000000007;
		}
		cout << x*s %1000000007;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct P {
	int c;
	int p;
	int i;
};

int count_sort(vector<P>& ps, int n)
{
	int c = 0;
	FOR_LT(i, 0, n) {
		FOR_LT(j, 0, i) {
			if (ps[j].i > ps[i].i) c++;
		}
	}
	return c;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

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

	int ans = INT_MAX;
	vector<P> ps(n);
	FOR_LT(s, 0, (1 << n)) {
		FOR_LT(i, 0, n) {
			ps[i].i = i;
			if ((s >> i) & 1) {
				ps[i].c = bs[i];
				ps[i].p = (i + 1) & 1;
			}
			else {
				ps[i].c = as[i];
				ps[i].p = i & 1;
			}
		}
		stable_sort(ps.begin(), ps.end(), [](const auto & lhs, const auto & rhs) {
			return lhs.c < rhs.c;
			});

		bool is_ok = true;
		FOR_LT(j, 0, n) {
			if (ps[j].p == (j & 1)) {
				int si = ps[j].i;
				int sv = INT_MAX;
				FOR_LT(k, j + 1, n) {
					if (ps[k].c != ps[j].c) break;
					if (ps[k].p != (j & 1)) continue;

					if (ps[k].i < si) {
						si = ps[k].i;
						sv = k;
					}
				}
				if (sv != INT_MAX) {
					swap(ps[j], ps[sv]);
				}
				continue;
			}

			bool is_found = false;
			int  si = INT_MAX;
			int  sv = INT_MAX;
			FOR_LT(k, j + 1, n) {
				if (ps[k].c != ps[j].c) break;
				if (ps[k].p != (j & 1)) continue;

				is_found = true;
				if (ps[k].i < si) {
					si = ps[k].i;
					sv = k;
				}
			}
			if (!is_found) {
				is_ok = false;
				break;
			}
			swap(ps[j], ps[sv]);
		}
		if (!is_ok) continue;

		int count = count_sort(ps, n);

		ans = min(ans, count);
	}

	if (ans == INT_MAX) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    ll ans = 0;
    exrep(i, 0, n-3) {
        exrep(j, i+1, n-2) {
            exrep(k, j+1, n-1) {
                if(a[i] == a[j] || a[j] == a[k]) {
                    continue;
                }
                if(a[i] + a[j] > a[k]) {
                    ans++;
                }
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3640
def get_gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def get_lcm(a, b, gcd=0):
    if gcd == 0:
        return a * b // get_gcd(a, b)
    else:
        return a * b // gcd


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

S = input()
T = input()

gcd = get_gcd(N, M)
lcm = get_lcm(N, M, gcd)

if [s for i, s in enumerate(S) if i % (lcm / M) == 0] == [t for i, t in enumerate(T) if i % (lcm / N) == 0]:
    print(lcm)
else:
    print(-1)


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

bool crave[1000001];

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> db, s;

  rep(i, n) {
    cin >> a[i];
    if (s.find(a[i]) == s.end()) s.insert(a[i]);
    else db.insert(a[i]);
  }
  rep(i, 1000001) crave[i] = true;

  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());

  rep(i, a.size()) {
    if (db.find(a[i]) != db.end()) crave[a[i]] = false;
    for (int j=2*a[i]; j<=1000000; j+=a[i]) {
      crave[j] = false;
    }
  }

  int ans = 0;
  rep(i, a.size()) {
    if (crave[a[i]]) ans++;
  }

  cout << ans << endl;

  return 0;
}

/*
*/


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int Q;
    cin >> Q;
    rep(q, Q){
        int k;
        cin >> k;
        lint ans = 0;
        vector<lint> d(n+1), m(n+1), dm(n+1);
        d[0] = 0;
        m[0] = 0;
        dm[0] = 0;
        REP(i, 1, n+1){
            d[i] = d[i-1] + (lint)(s[i-1] == 'D');
            m[i] = m[i-1] + (lint)(s[i-1] == 'M');
            dm[i] = dm[i-1] + (lint)(s[i-1] == 'M') * d[i];
            ans += (lint)(s[i-1] == 'C') * dm[i];
            if(i >= k){
                d[i] -= (lint)(s[i-k] == 'D');
                m[i] -= (lint)(s[i-k] == 'M');
                dm[i] -= (lint)(s[i-k] == 'D') * m[i];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 25576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string s, t;
  cin >> s >> t;

  int n = s.size(), m = t.size();
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  rep(i, n - m + 1) {
    bool flag = true;
    FOR(j, i, i + m) {
      if (s[j] == '?') continue;
      if (s[j] != t[j - i]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      FOR(j, i, i + m) s[j] = t[j - i];
      repr(j, n - 1) cout << (s[j] == '?' ? 'a' : s[j]);
      cout << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;



  
  return 0;
}

Measured memory_bytes: 256
k = int(input())
ans = 0
a = ["0","1","2","3","4","5","6","7","8","9"]
old = ["0","1","2","3","4","5","6","7","8","9"]
b = []
l = 0
while l <= 9:
	b = []
	for i in range(10):
		x = str(i)
		for j in old:
			if abs(i- int(j[0])) <= 1:
				y = x + j
				b.append(y)
	a.extend(b)
	old = b.copy()
	l += 1
c = set()
for i in a:
	c.add(int(i))
d = list(c)
d.sort()
print (d[k])

Measured memory_bytes: 94888
#include "bits/stdc++.h"
#define rep(i, j) for (long long i = j; i > 0; i--)
using namespace std;


int main() {
	long long ans = 0;
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());

	string mihon = s[0];
	long long num = 1;
	for (int i = 1; i < n; i++) {
		if (mihon == s[i])
			num++;
		else {
			mihon = s[i];
			ans += num * (num - 1) / 2;
			num = 1;
		}
	}
	ans += num * (num - 1) / 2;
	cout << ans << endl;

	return 0;
}

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

const int maxn = 1e5 + 20;
int n, des, asc, ans, a[maxn];

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n - 1; i++)
    {
		if(a[i] < a[i + 1])
        {
			if(asc > 0)
            { 
				asc = 0; 
				ans++;
			}
			else
				des++;
		}
		if(a[i] > a[i + 1])
        {
			if (des > 0)
            {
				des = 0; 
				ans++;
			}
			else
				asc++;
		}
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 640
a,b = map(int, raw_input().split())
s = raw_input()
def f(s,a):
	for i,l in enumerate(s):
		if i != a and l not in map(str, range(10)): return False
	return True
print 'Yes' if s[a] == '-' and f(s,a) else 'No'

Measured memory_bytes: 64368
a, b = map(int,input().split())

# mini = 0
#
# maxi = 2000

smaller = 0
larger = 0

if a < b:
    smaller = a
    larger = b
else:
    smaller = b
    larger = a


start = smaller * 10
# print(start)

for i in range(start,1500):
    # print(i, int(i * 0.08), int(i * 0.1))
    if int(i * 0.08) == smaller and int(i * 0.1) == larger:
        print(i)
        exit(0)

print(-1)



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

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    var c = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
    int a = 0, b = 0;
    for (int i = 0; i < n; i++) {
      if ((i & 1) == 0) a += c[i];
      else b += c[i];
    }
    Console.WriteLine(Math.Abs(a - b));
  }
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<=5) cout << 0 << endl;
    else if(a<=12) cout << b/2 << endl;
    else cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [0] * N
for i in range(N):
	s[i] = input()
ans = 0

for j in range(N):
	ans += s[j].count("AB")

x, y, z = 0, 0, 0  # xは~A、yはB~、zはB~Aの個数
for k in range(N):
	if s[k][0] == "B" and s[k][-1] =="A":
		z += 1
	elif s[k][0] == "B":
		y += 1
	elif s[k][-1] == "A":
		x += 1

if x >= 1 and y >= 1:
	ans += z + min(x, y)
elif x >= 1 or y >= 1:
	ans += z
else:
	ans += max(0, z - 1)

print(ans)


Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>

int *array;

int fibonacci(int);

int main(){
  int n;
  int i;
  int answer;

  scanf("%d",&n);
  array = malloc((n+1) * sizeof(int));

  for(i=0;i<n+1;i++) array[i] = -1;

  answer = fibonacci(n);

  printf("%d\n",answer);

  free(array);
  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1){
    array[n] = 1;
    return array[n];
  }

  if(array[n] != -1) return array[n];

  array[n] = fibonacci(n-2) +  fibonacci(n-1);

  return array[n];
}

Measured memory_bytes: 596
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  s[k - 1] += 'a' - 'A';
  cout << s << endl;
  return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

vector<pii> es[100100];
vector<int> d(100100, (1 << 30));

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    string s;
    cin >> n >> m >> s;

    priority_queue<pii, vector<pii>, greater<pii>> pq;
    pq.emplace(0, n);
    vector<int> pars(n + 1, -1);

    for(int i = n - 1; i >= 0; i--) {
        if (s[i] != '0') continue;
        while(!pq.empty()) {
            auto p = pq.top(); 
            // cout << i << " " << p.first << " " << p.second << endl;
            if (p.second - i > m) {
                pq.pop();
            }
            else {
                pq.emplace(p.first + 1, i);
                pars[i] = p.second;
                break;
            }
        }
        if (pq.empty()) {
            cout << -1 << endl;
            return 0;
        }
    }

    while(!pq.empty() and pq.top().second > 0) pq.pop();
    if (pq.empty()) {
        cout << -1 << endl;
    } else {
        int idx = 0;
        while(pars[idx] != -1) {
            cout << pars[idx] - idx << " ";
            idx = pars[idx];
        }
        cout << endl;
        // cout << pq.top().first << endl;
    }
    return 0;
}


Measured memory_bytes: 4600
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    string s;
    cin>>s;
    long long int curr=0,flag=0,ans=INT_MIN;
    long long int i=0,n=s.length();
    while(i<n)
    {
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
        break;
        else i++;
    }
    if(i==n)
    {
        cout<<"0";return;
    }
    flag++;
    for(i;i<s.length();i++)
    {
        
        if((s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') && flag==1)
        curr++;
        else if((s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') && flag==0)
        {curr=1;flag=1;}
        else
        {
            ans=max(ans,curr);curr=0;flag=0;
        }
        //cout<<flag<<" "<<curr<<" "<<ans<<" "<<i<<endl;
    }
    ans=max(ans,curr);
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
	int a, b, k, i, j;
	int ans[200];
	int co, ansi, flag, temp;

	scanf("%d %d %d", &a, &b, &k);
	if (b <= k) {
		for (i = a; i <= b; i++) {
			printf("%d\n", i);
		}
		return 0;
	}
	co = ansi = 0;
	for (i = a; i <= b; i++) {
		co++;
		if (co > k) {
			break;
		}
		ans[ansi++] = i;
	}
	co = 0;
	for (i = b; i >= a; i--) {
		flag = 0;
		co++;
		if (co > k) {
			break;
		}
		for (j = 0; j < ansi; j++) {
			if (ans[j] == i) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			ans[ansi++] = i;
		}
	}
	for (i = 0; i < ansi - 1; i++) {
		for (j = i + 1; j < ansi; j++) {
			if (ans[i] > ans[j]) {
				temp = ans[i];
				ans[i] = ans[j];
				ans[j] = temp;
			}
		}
	}
	for (i = 0; i < ansi; i++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);

  ll n;
  cin >> n;
  ll a[200010];
  rep(i, n) cin >> a[i];
  ll csum[200010];
  csum[0] = 0;
  rep(i, n) csum[i + 1] = csum[i] + a[i];

  //[l, r)の和
  auto sum = [&](ll l__, ll r__) {
    return csum[r__] - csum[l__];
  };

  auto binary_search = [&](ll l_, ll r_) {
    ll lo = l_, hi = r_;
    while (hi - lo > 1)
    {
      ll mi = (lo + hi) / 2;
      if (sum(l_, mi) <= sum(mi, r_))
        lo = mi;
      else
        hi = mi;
    }
    return lo;
  };

  ll ans = LINF;

  //[0,i)と[i,n)に分ける
  REP(i, 2, n - 1)
  {

    //[0,x)の和<=[x,i)の和を満たす最大のx
    ll l = binary_search(0, i);
    ll P1 = sum(0, l), Q1 = sum(l, i);
    ll P2 = sum(0, l + 1), Q2 = sum(l + 1, i);
    ll P, Q;
    if (abs(P1 - Q1) <= abs(P2 - Q2))
      P = P1, Q = Q1;
    else
      P = P2, Q = Q2;

    //[i,x)の和<=[x,n)の和を満たす最大のx
    ll r = binary_search(i, n);
    ll R1 = sum(i, r), S1 = sum(r, n);
    ll R2 = sum(i, r + 1), S2 = sum(r + 1, n);
    ll R, S;
    if (abs(R1 - S1) <= abs(R2 - S2))
      R = R1, S = S1;
    else
      R = R2, S = S2;

    ll score = max({P, Q, R, S}) - min({P, Q, R, S});
    ans = min(ans, score);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const double EPS=1e-6;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) a.rbegin(),a.rend()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) FLL(a,0)
#define declare(a,it) __typeof(a) it=(a)
#define FOR(it,a) for(declare(a.begin(),it);it!=a.end();++it)
#define FORR(it,a) for(declare(a.rbegin(),it);it!=a.rend();++it)
template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
int s2i(string& a){stringstream ss(a);int r;ss>>r;return r;}
int geti(){int n;scanf("%d", &n);return n;}

vector<int> vh[110000];
vector<int> vw[110000];


class UnionFind{
  vector<int> par;
public:
  UnionFind(int n):par(n){
    for(int i = 0; i < n; ++i)
      par[i] = i;
  };
		
  int find(int x){
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
  }
		
  bool unit(int a,int b){
    int ap = find(a);
    int bp = find(b);
			
    if(ap == bp)
      return false;
    par[ap] = bp;
    return true;
  }
};

int xx[40000];
int yy[40000];

int main(int argc, char *argv[])
{
  int n,w,h;
  cin >> n >> w >> h;
  for(int i = 0; i < n; ++i){
    int x,y;
    cin >> x >> y;
    xx[i] = x;
    yy[i] = y;
    vh[x].push_back(i);
    vw[y].push_back(i);
  }

  UnionFind uf(n);

  for(int i = 1; i <= w; ++i)
    for(int j = 0; j+1 < (int)vh[i].size(); ++j)
      uf.unit(vh[i][j], vh[i][j+1]);

  for(int i = 1; i <= h; ++i)
    for(int j = 0; j+1 < (int)vw[i].size(); ++j)
      uf.unit(vw[i][j], vw[i][j+1]);

  
  set<int> co;
  for(int i = 0; i < n; ++i)
    co.insert(uf.find(i));

  if(co.size() == 1){
    cout << n-1 << endl;
    return 0;
  }
  
  int tans = n - co.size();
  tans += co.size()*2 - 1;

  if(!vw[1].empty() || !vh[1].empty() ||
     !vw[h].empty() || !vh[w].empty())
    --tans;
  
  cout << tans << endl;

  
  
  return 0;
}

Measured memory_bytes: 9976
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;
//2,3,4,5,6,7,8,9,T(10),J(jack),Q(queen),K(king),A (ace)
//0,1,2,3,4,5,6,7,8,    9       10        11     12
int rank(char c){
    if(isdigit(c)) return c-'2';
    if(c == 'T') return 8;
    else if(c == 'J') return 9;
    else if(c == 'Q') return 10;
    else if(c == 'K') return 11;
    else if(c == 'A') return 12;
}

struct Tramp{
    char type;
    int ran;
    Tramp(char t,char r){
        type = t;
        ran = rank(r);
    }
    Tramp(){
    };
};

int main(){
    while(true){
        char tramp;
        cin >> tramp;
        if(tramp == '#') return 0;
        vector<vector<Tramp> > ts(4);

        for(int i=0;i<4;i++){
            for(int j=0;j<13;j++){
                char t,n;
                cin >> n >> t;
                ts[i].push_back(Tramp(t,n));
            }
        }

        int first = 0;
        vector<int> p(2);
        for(int i=0;i<13;i++){
            Tramp f = ts[first][i];
            int winner = first;
            for(int k=0;k<4;k++){
                if(k == first) continue;
                Tramp s = ts[k][i];
                if(f.type == tramp){
                    if(s.type == tramp and f.ran < s.ran){
                        f = s;
                        winner = k;
                    }
                }else if(s.type == tramp){
                    f = s;
                    winner = k;
                }else if(f.type == s.type and f.ran < s.ran){
                    f = s;
                    winner = k;
                }
            }
            p[winner%2]++;
            first = winner;
        }

        if(p[0] < p[1]) cout << "EW" << " " << p[1]-6 << endl;
        else cout << "NS" << " " << p[0]-6 << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  map<string, int> mp;
  rep(i, 0, N) {
    VAR(string, si);
    mp[si]++;
  }
  VAR(int, M);
  rep(i, 0, M) {
    VAR(string, si);
    mp[si]--;
  }
  int ans = 0;
  each(x, mp) {
    ans = max(ans, x.second);
  }
  print(ans);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    rep(i, N) {
        REP(j, -1, 1) {
            cnt[a[i] + j + 1]++;
        }
    }
    int ans = 0;
    REP(i, 0, 100002) ans = max(ans, cnt[i]);
    cout << ans << endl;


    return 0;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    map< int, int > cnt;
    range(i, 0, N) cnt[input()]++;
    
    int ans = 0;
    for (auto p: cnt) {
        if (p.first <= p.second) ans += p.second - p.first;
        else ans += p.second;
    }
    
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

int main() {
    string s, t;
    cin >> s >> t;

    if (s.compare(t) == 0){
        cout << "No" << endl;
        return 0;
    }
    sort(s.begin(), s.end(), less<char>());
    sort(t.begin(), t.end(), greater<char>());
    string ss[] = {s, t};
    sort(ss, ss + 2);
    if (ss[0] == s){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[100005][3];
signed main()
{
    
    int n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    string t;
    cin>>t;
    t="#"+t;
    long double len=(n*1.0)/k;
    int ans=0;
    for(int i=1;i<=k;i++)
    {
        int z=0;
        for(int j=0;j*k+i<=n;j++)
        {
            if(t[j*k+i]=='r')
            {
                dp[j+1][0]=max(dp[j][1],dp[j][2]);
                dp[j+1][1]=max(dp[j][0],dp[j][2]);
                dp[j+1][2]=max(dp[j][1],dp[j][0])+p;
            }
            else if(t[j*k+i]=='s')
            {
                dp[j+1][0]=max(dp[j][1],dp[j][2])+r;
                dp[j+1][1]=max(dp[j][0],dp[j][2]);
                dp[j+1][2]=max(dp[j][1],dp[j][0]);
            }
            else if(t[j*k+i]=='p')
            {
                dp[j+1][0]=max(dp[j][1],dp[j][2]);
                dp[j+1][1]=max(dp[j][0],dp[j][2])+s;
                dp[j+1][2]=max(dp[j][1],dp[j][0]);
            }
            z=max({dp[j+1][0],dp[j+1][1],dp[j+1][2]});
        }
        ans+=z;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, k;

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

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	int g, ma = -1;
	bool flag = false;
	FOR(i, n) {
		int a;
		cin >> a;
		ma = max(ma, a);
		if (a == k) flag = true;
		if (i == 0) g = a;
		else g = gcd(g, a);
	}
	if (flag || (g == 1 && ma >= k) || (g != 1 && ma >= k && k % g == 0)) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <int> v[305];
int n, k;
const int inf = 1e8;
int cnt[305];

int solve() {	
	if(v[1].empty()) {
		return inf;
	}	
	memset(cnt, 0, sizeof cnt);
	for(int i = 1; i <= n; i++) {
		cnt[v[i].front()] += 1;
	}
	
	int ans = 0;
	int bad = 0;
	for(int i = 1; i <= k; i++) {
		if(ans < cnt[i]) {
			ans = cnt[i];
			bad = i;
		}
	}
	for(int i = 1; i <= n; i++) {
		v[i].erase(find(v[i].begin(), v[i].end(), bad));
	}
	return min(ans, solve());
}
int main (int argc, char const* argv[])
{
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= k; j++) {
			int x;
			scanf("%d", &x);
			v[i].push_back(x);
		}
	}	
	printf("%d\n", solve());
	return 0;
}

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

int main(){
    int time, h, m,s;
    
    cin >> time;
    h = time / 3600;
    m = (time - h * 3600) / 60;
    s = time - 3600 * h - 60 * m;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,a,b,c,x;
	long long ans=0;
	bool f=false;
	while(true){
		cin>>n>>a>>b>>c>>x;
		if(n+a+b+c+x==0) return 0;
		vi y(n);
		for(int i=0;i<n;i++){
			cin>>y[i];
		}
		for(int i=0;i<n;i++){
			while(true){
				//cout<<x<<" "<<y[i]<<" "<<ans<<endl;;
				if(y[i]==x){
					if(i!=n-1){
						ans++;
						x = (a*x+b)%c;
					}
					break;
				}
				ans++;
				x = (a*x+b)%c;
				if(ans>10000){
					cout<<-1<<endl;
					f=true;
					break;
				}

			}
			if(f) break;
		}
		if(!f){
			cout<<ans<<endl;
		}
		ans=0;
		f=false;
	}
}

Measured memory_bytes: 2948
import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b=map(int, readline().rstrip().split())
    if b%a==0:
        print(a+b)
    else:
        print(b-a)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Measured memory_bytes: 6384
import queue

k = int(input())

lunlun = queue.Queue()
for i in range(1,10):
    lunlun.put(i)

def make_lunlun(p):
    last = p%10
    if last != 0:
        lunlun.put(p * 10 + last - 1)
    lunlun.put(p*10 + last)
    if last != 9:
        lunlun.put(p * 10 + last + 1)

i = 0
while i < k:
    p = lunlun.get()
    make_lunlun(p)
    i += 1
    if i == k:
        print(p)
        break


Measured memory_bytes: 12452
function Main(input) {

	input = input.split("\n");
    
    let An = input[1].split(" ").map(BigInt);
    
    let A_Sum = BigInt(0);
    An.forEach(value => A_Sum += value);
    
    let tmp = BigInt(0);
    
    for (const A of An) {
        
        A_Sum -= A;
        tmp += A * A_Sum;
        
    }
    
    console.log(Number(tmp % BigInt(1000000007)));
    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 77800
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=101,maxv=1e5+1;
const ll INF=2e12;
ll w[maxn],v[maxn];
ll dp[maxn][maxv];
// dp[i][j] : denotes the minimum weight of the picked items 
// (only first i items are considered) and with total value j.
void solve()
{
	ll N,W;
	cin>>N>>W;
	for(ll i=1;i<=N;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(ll i=0;i<=N;i++)
	{
		for(ll j=0;j<=maxv;j++)
		{
			// Base Cases
			if(j==0) dp[i][j]=0;
			//Min weight when no items are picked and value is zero
			// Valid State
			else if(i==0) dp[i][j]=INF;
			// this state is impossible, so give a high value for
			// min weight.
			else
			{
				if(j-v[i]>=0)
					dp[i][j]=min(w[i]+dp[i-1][j-v[i]],dp[i-1][j]);
				else dp[i][j]=dp[i-1][j];
			}
		}
	}
	/*for(ll i=1;i<=N;i++)
	{
		for(ll j=1;j<=maxv;j++)
		{
			if(dp[i][j]==2e12) cout<<"-  ";
			else cout<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	for(ll i=maxv-1;i>=1;i--)	// to find the valid state where
							// dp[i][j] i.e weight <= W.
						//Traverse from max value.
	{
		if(dp[N][i]<=W)
		{
			cout<<i<<"\n";
			break;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}


Measured memory_bytes: 79232
#include <iostream>

using namespace std;


int main() {
    int input, remainder, copied;
    int reversed = 0;
    cin >> input;
    
    copied = input;
    while(input!=0) {
        remainder = input % 10;
        reversed = reversed * 10 + remainder;
        input = input / 10;
    }

    if(reversed == copied)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
macro_rules! bind_from_vec {
    ( $($variable:ident),+ = $vector:expr ) => {
        let mut v = $vector.clone().into_iter();
        $(let $variable = v.next().unwrap();)+
    };
}
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}
pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line!().split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
    bind_from_vec!(n, m, c = read_to_vec());
    let b = read_to_vec::<i32>();
    let mut a = Vec::with_capacity(n as usize);
    for _ in 0..n {a.push(read_to_vec::<i32>());}
    let a = a;

    println!("{}", a.iter().filter(|code| code.iter().zip(&b).fold(0, |acc, (&a, &b)| acc + a*b) + c > 0).count());
}


Measured memory_bytes: 4352
import com.sun.org.apache.xpath.internal.operations.Bool
import java.lang.Math.*

const val MOD = 1000000007L

fun main(args: Array<String>) {
    val (a, b) = readLongList()

    if ((a + b) % 2L == 0L) {
        println((a + b) / 2)
    } else {
        println("IMPOSSIBLE")
    }
}


fun readList() = readLine()!!.split(' ')
fun readInt() = readLine()!!.split(' ').map(String::toInt).first()
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

inline fun <reified T> dualArray(h: Int, w: Int, init: (Int, Int) -> T) {
    Array(h) { i ->
        return@Array Array(w) { j ->
            return@Array init(i, j)
        }
    }
}

// 速度のためforEachは避ける
inline fun Int.rep(start: Int = 0, shiftLast: Boolean = false, body: (Int) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

inline fun Long.rep(start: Long = 0, shiftLast: Boolean = false, body: (Long) -> Unit) {
    for (i in start until if (shiftLast) this + start else this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    val former = mutableListOf<Long>()
    val latter = mutableListOf<Long>()
    (1..max).filter { value % it == 0L }
        .forEach {
            former.add(it)
            latter.add(value / it)
        }
    former.addAll(latter.reversed())
    return former
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

// 二分探索
fun List<Long>.binarySearch(target: Long, _start: Int = 0, _end: Int = this.size): Int {
    var start = (_start - 1).toLong()
    var end = _end.toLong()
    while (end - start > 1) {
        val mid = (start + end) / 2
        if (this[mid.toInt()] < target) {
            start = mid
        } else {
            end = mid
        }
    }
    return end.toInt()
}

// bit全探索
inline fun Int.bitAllSearch(body: (Array<Int>) -> Unit) {
    for (bit in 0 until (1 shl this)) {
        val s = mutableListOf<Int>()
        for (i in 0 until this) {
            if ((bit and (1 shl i)) shr i == 1) { // i が bit に入るかどうか
                s.add(i)
            }
        }
        body(s.toTypedArray())
    }
}

Measured memory_bytes: 38180
(* O(√n) *)
let n = read_int () in
let f m = if m = 0 then 0 else if n mod m = n / m then m else 0 in
let rec sum acc i =
  if i * i > n then acc
  else if n mod i <> 0 then sum acc @@ i + 1
  else
    let j = n / i in
    sum (acc + f (i - 1) + if i <> j then f @@ j - 1 else 0) @@ i + 1 in
sum 0 1 |> Printf.printf "%d\n"

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int n;
long long h,ans;
double tmp;
double tmp2;
typedef pair <long,long> pii;
int main(int argc,char const* argv[])
{
  cin >> n >> h;
  priority_queue<pii> katana;
  vector<long long>slashes(n);
  long long a,b,ans=0,throwdamage,slashdamage;
  
  for(int i=0;i<n;i++)
    {
      cin >> a >> b;
      katana.push(make_pair(b,a));
      slashes[i]=a;
    }
  sort(slashes.begin(),slashes.end(),greater<long long>());
  slashdamage=slashes[0];
  for(int i=0;i<n;i++)
    {
      throwdamage=katana.top().first;
      katana.pop();
      if(throwdamage>=slashdamage)
	{
	  h-=throwdamage;
	  ans++;
	  if(h<=0) break;
	}
    }
  if(h<=0)
    {
      cout << ans << endl;
      return 0;
    }
  else
    {
      ans+=h/slashdamage;
      tmp2=h/slashdamage;
      tmp=(h+0.0)/(slashdamage+0.0);
      if(tmp > tmp2) ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3188
//API???????????????
import java.util.Scanner;
import java.io.IOException;
class Main {
  	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int[] A = new int[H];
		
		for(int i = 0; i < H; i++){
			A[i] = scan.nextInt();
		}
		buildMaxHeap(A);
		for(int i= 0; i < H; i++){
			if(i != H - 1){
				System.out.print(" " + A[i]);
			}else{
				System.out.println(" " + A[i]);
			}
		}
	}
	
	public static void maxHeapify(int[] A, int i){
		int l = (i + 1) * 2 - 1;
		int r = (i + 1) * 2; 
		
		//????????????????????????????????§???????????§????????????????????¶
		int large = i;
		if(l < A.length && A[l] > A[i]) large = l;
		if(r < A.length && A[r] > A[large]) large = r;
		//i?????????????????§????????´???
		if(large != i){
			int temp = A[i];
			A[i] = A[large];
			A[large] = temp;
			maxHeapify(A, large);
		}
	}
	
	public static void buildMaxHeap(int[] A){
		for(int i = A.length / 2; i >= 0; i--){
			maxHeapify(A, i);
		}
	}
}

Measured memory_bytes: 167528
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
     lld n,b;
     cin>>n>>b;
     if(n<=5)
     {
         cout<<"0"<<endl;
     }
     else if(n<=12)
     {
         cout<<b/2<<endl;
     }
     else
        cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long R){
  if(N<10){
    cout<<R+100*(10-N)<<endl;
  }else{
    cout<<R<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
  cin.tie(0);
  ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long R;
    scanf("%lld",&R);
    solve(N, R);
    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
S = [0]*N
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    S[A[j]-1] += 1
cnt = 0
for e in S:
  if e == 0:
    cnt += 1
print(cnt)

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

int main(){
	int n, ans;
    double min, in, t, a;
    min = 100000000;
	cin >> n >> t >> a;
    rep(i, n){
      cin >> in;
      if(min > abs(t-0.006*in-a)){
        ans = i+1;
        min = abs(t-0.006*in-a);
      }
    }
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

long long MAX_V = 200005;
long long INF = 1e15;

struct edge {long long to, cost; };
typedef pair<long long, long long> P;

vector<vector<edge>> G(MAX_V);
vector<long long> d(MAX_V);
long long V;

// s 番目の頂点から各頂点への最短距離を求める
void dijkstra(long long s) {
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();

        long long v = p.second;
        if (d[v] < p.first) continue;

        for (long long i = 0; i < (ll)G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    ll n,m,s; cin>>n>>m>>s;
    if(s>2999) s=2999;
    rep(i,m){
        ll u,v,a,b; cin>>u>>v>>a>>b;
        u--; v--;
        for(ll j=0; j+a<3000; j++){
            G[u*3000 + j+a].push_back({v*3000 + j, b});
            G[v*3000 + j+a].push_back({u*3000 + j, b});
        }
    }
    rep(i,n){
        ll c,d; cin>>c>>d;
        for(ll j=0; j<2999; j++) G[i*3000 + j].push_back({i*3000 + min(j+c, 2999ll), d});
    }
    dijkstra(s);

    for(ll i=1; i<n; i++){
        ll res=1e15;
        rep(j, 3000) chmin(res, d[i*3000+j]);
        cout<<res<<endl;
    }

}

Measured memory_bytes: 29200