akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int print(bool first) {
        puts(first ? "First" : "Second");
        return 0;
}

int main() {
        int n;
        scanf("%d", &n);
        vector<int> a(n);
        for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
        int even_cnt = 0;
        for (int i = 0; i < n; i ++) even_cnt += (a[i] % 2 == 0);
        assert(even_cnt != n); //includes at least one odd number
        if (even_cnt & 1) return print(true);
        if (even_cnt != n - 1) return print(false);
        bool f = true;
        while (true) {
                for (int i = 0; i < n; i ++) {
                        if (a[i] & 1) {
                                if (a[i] == 1) {
                                        return print((f && (n - 1) % 2 == 1) || (!f && ((n - 1) % 2 == 0)));
                                }
                                a[i] --;
                                break;
                        }
                }
                f ^= 1;
                int gcd = a[0];
                for (int i = 1; i < n; i ++) gcd = __gcd(a[i], gcd);
                for (int i = 0; i < n; i ++) a[i] /= gcd;
                even_cnt = 0;
                for (int i = 0; i < n; i ++) even_cnt += (a[i] % 2 == 0);
                if (even_cnt & 1) return print(f);
                if (even_cnt != n - 1) return print(!f);
        }
}


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

int main() {
    long long int N, M, K;
    cin >> N >> M >> K;

    vector<long long int> desk_A(N);
    vector<long long int> desk_A_total(N + 1, 0);
    vector<long long int> desk_B(M);
    vector<long long int> desk_B_total(M + 1, 0);

    for (long long int i = 0; i < N; ++i) {
        cin >> desk_A[i];
        desk_A_total[i + 1] = desk_A_total[i] + desk_A[i];
    }

    for (long long int i = 0; i < M; ++i) {
        cin >> desk_B[i];
        desk_B_total[i + 1] = desk_B_total[i] + desk_B[i];
    }

    long long int ans = 0;
    long long int j = M;

    for (long long int i = 0; i < N + 1; ++i) {
        if (desk_A_total[i] > K) {
            break;
        }

        long long int min_B_index = K - desk_A_total[i];
        auto it = upper_bound(desk_B_total.begin(), desk_B_total.end(), min_B_index);
        long long int index = it - desk_B_total.begin();

        ans = max(ans, i + index - 1);
    }

    cout << ans << endl;

}

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

string next(char prev1, char prev2, char s) {
	if ((s == 'o' && prev1 == 'S') || (s == 'x' && prev1 == 'W')) {
		return prev2 == 'S' ? "S" : "W";
	}
	if ((s == 'o' && prev1 == 'W') || (s == 'x' && prev1 == 'S')) {
		return prev2 == 'S' ? "W" : "S";
	}
}

void Main()
{
	int N; cin >> N;
	string s; cin >> s;
	s = s + s;
	string pattern[4] = {"SS", "SW", "WS", "WW"};
	rep(i, 4) {
		string res = pattern[i];
		REP(j,2,N + 2) {
			string _next = next(res[j - 1], res[j - 2], s[j - 1]);
			res += _next;
			if (j == N && _next[0] != res[0]) {
				break;
			}
			if (j == N + 1 && _next[0] == res[1]) {
				cout << res.substr(0, N) << endl;
				return;
			}
		}
	}
	cout << -1 << endl;
}

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


Measured memory_bytes: 792
N = int(input())

coodinates = [list(map(int, input().split())) for _ in range(N)]

flag = True
if N == 1:
    print(1)
    flag = False

if flag:
    # p, qを求める
    d = {}  # [p, q]をkeyにもつ辞書
    cnt=0
    for a in coodinates:
        for b in coodinates:
            if a == b:
                continue
            p, q = a[0] - b[0], a[1] - b[1]
            if (p, q) in d:
                d[(p, q)] += 1
            else:
                d[(p, q)] = 1
            cnt=max(cnt,d[(p,q)])

    print(N - cnt)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 5;
const int P = 998244353;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int dp[MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	int a, b, c, d; read(a), read(b), read(c), read(d);
	dp[a][b] = 1;
	for (int j = b + 1; j <= d; j++)
		dp[a][j] = 1ll * dp[a][j - 1] * a % P;
	for (int i = a + 1; i <= c; i++) {
		int sum = 0;
		for (int j = b; j <= d; j++) {
			update(dp[i][j], 1ll * dp[i - 1][j] * j % P);
			update(dp[i][j], sum);
			sum = 1ll * sum * i % P;
			update(sum, 1ll * dp[i - 1][j] * j % P);
		}
	}
	cout << dp[c][d] << endl;
	return 0;
}


Measured memory_bytes: 38724
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, W;
int v[110], w[110];
int dp[110][100010];


signed main(){
    cin >> N >> W;
    rep(i, 0, N) cin >> w[i] >> v[i];

    rep(i, 0, N) repe(j, 0, W){
        chmax(dp[i+1][min(j+w[i], W+1)], dp[i][j]+v[i]);
        chmax(dp[i+1][j], dp[i][j]);
    }

    cout << dp[N][W] << endl;

    return 0;
}

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

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String sl[] = s.split(" ");
    
    int n = Integer.parseInt(sl[0]);
    int x = Integer.parseInt(sl[1]);

    int v[] = new int[114514];
    
    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
      v[i] = Math.abs(Integer.parseInt(sl[i]) - x);
    }
    
    for(int i = 0; i < n - 1; i++)
    {
      v[i + 1] = eu(v[i], v[i + 1]);
    }
    
    System.out.println(v[n - 1]);
  }
  
  public static int eu(int a, int b)
  {
    //System.out.println(a);
    //System.out.println(b);
    if(a < b)
    {
      int c = a;
      a = b;
      b = c;
    }
    //System.out.println(a);
    //System.out.println(b);
    while(b != 0)
    {
      a %= b;
      int c = a;
      a = b;
      b = c;
    }
    //System.out.println(a);
    return a;
  }

}

Measured memory_bytes: 48168
#include <iostream>

using namespace std;

int main(){

	int a, b,c, gcd=1;
	int i;
	
	cin >> a >> b;
	while (b != 0){
		c = a%b;
		a = b;
		b = c;
	}

	cout << a << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

	int A, B, X;
	cin >> A >> B >> X;
	int need = ceil(X/500.);
	int res = min(A, B*2) * (need/2);
	if(need%2) res += min(A, B);
	cout << res << endl;
}


Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<random>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
int d;
int c[30]={};
int s[370][30];
int num=30000;
int calc(vector<int>const& t,vector<vector<int>>& last_list){
  int res=0;
  vector<int> last(30,0);
  rep1(i,d){
    res+=s[i][t[i]];
    last[t[i]]=i;
    last_list[i]=last;
    int buf=0;
    rep1(j,26){
      buf+=c[j]*(i-last[j]);
    }
    res-=buf;
    //cout<<res<<"\n";
  }
  return res;
}
int change(int nd,int nq,int& res,vector<int>& t,vector<vector<int>>& last_list){
  int flag_t=false;
  int flag_q=false;
  int x=t[nd];
  t[nd]=0;
  res+=s[nd][nq];res-=s[nd][x];
  for(int i=nd;i<=d;++i){
    if(flag_t&&flag_q)break;
    if(t[i]==x||flag_t)flag_t=true;
    else{
      res+=c[x]*(i-last_list[i][x]);
      last_list[i][x]=last_list[i-1][x];
      res-=c[x]*(i-last_list[i][x]);
    }
    if(t[i]==nq||flag_q)flag_q=true;
    else{
      res+=c[nq]*(i-last_list[i][nq]);
      last_list[i][nq]=nd;
      res-=c[nq]*(i-last_list[i][nq]);
    }
  }
  t[nd]=nq;
  return res;
}
vector<int> greedy(int d){
  vector<int> res(d+1,0);
  vector<int> last(30,0);
  rep1(i,d){
    int mx=-inf;
    int mx_ind=0;
    rep1(j,26){
      int tmp=s[i][j];
      rep1(k,26){
        if(k==j)continue;
        tmp-=c[k]*(i-last[k]);
      }
      if(mx<tmp){
        mx=tmp;
        mx_ind=j;
      }
    }
    last[mx_ind]=i;
    res[i]=mx_ind;
  }
  return res;
}
signed main(){
  cin>>d;
  rep1(i,26)cin>>c[i];
  rep1(i,d){
    rep1(j,26)cin>>s[i][j];
  }
  vector<int> t=greedy(d);
  vector<vector<int>> last_list(d+1,vector<int>(30,0));
  int res=calc(t,last_list);
  //cout<<res<<"\n";
  rep(xx,num){
    random_device rand;
    mt19937 mt(rand());
    vector<int> nd(5);rep(i,5)nd[i]=mt()%d+1;
    vector<int> nq(5);rep(i,5)nq[i]=mt()%26+1;
    vector<int> bq(5);rep(i,5)bq[i]=t[nd[i]];
    int bval=res;
    rep(i,5){
      change(nd[i],nq[i],res,t,last_list);
    }
    if(bval>res){
      rep(i,5){
        change(nd[i],bq[i],res,t,last_list);
      }
    }
  }
  rep(xx,num){
    random_device rnd;
    mt19937 mt(rnd());
    int nd=mt()%d+1;
    int nq=mt()%26+1;
    int bq=t[nd];
    int bval=res;
    int hoge=change(nd,nq,res,t,last_list);
    if(hoge<bval){
      change(nd,bq,res,t,last_list);
    }
  }
  rep1(i,d){
    cout<<t[i]<<"\n";
  }
  //cout<<res<<"\n";
  return 0;
}
/*
int m;cin>>m;
  vector<int> bres(m);
  rep(i,m){
    int d,q;cin>>d>>q;
    bres[i]=change(d,q,res,t,last_list);
  }
  rep(i,m){
    cout<<bres[i]<<"\n";
  }
  */

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f(i,n) for(ll i=0;i<n;i++)
#define fi(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF LLONG_MAX
#define ALL(a) a.begin(),a.end()
#define MAX 200005

int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    f(i,n)cin>>a[i];
    ll dp[n];
    
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    fi(i,2,n)
    {
        ll minn=INT_MAX;
        ll j=i-1;
        while(j>=0 && j+k>=i)
        {
            minn=min(minn,dp[j]+abs(a[i]-a[j]));
            j--;
        }
        dp[i]=minn;
    }
    
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)
using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int N;
vector<int> a;
set<int> used;
map<int, int> pos;
ULONG result = 0;

void calculate() {
  for (int num = 1; num <= N; num++) {
    auto prev = used.lower_bound(pos[num]);
    if (prev == used.begin()) prev = used.end();
    else prev--;
    auto next = used.upper_bound(pos[num]);
    int left, right;
    if (prev == used.end()) {
      left = pos[num];
    } else {
      left = pos[num] - *prev - 1;
    }
    if (next == used.end()) {
      right = N - pos[num] - 1;
    } else {
      right = *next - pos[num] - 1;
    }
    if (right < 0) throw runtime_error("bug 1");
    if (left < 0) throw runtime_error("bug 2");
    if (right >= N) throw runtime_error("bug 3");
    if (left >= N) throw runtime_error("bug 4");
    result += (ULONG)num * ((ULONG)right * (ULONG)left + (ULONG)right + (ULONG)left + 1);
    used.insert(pos[num]);
  }
}

int main(void) {
  cin >> N;
  a.resize(N);
  REP(i, N) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  calculate();
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 19840
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stdio.h>
#include <queue>
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define inf 1001001001000
using namespace std;
int main(void){
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<ll> l(s.size(),0);
    for(ll i=1;i<s.size();++i){
        l[i] = l[i-1];
        if(s[i] == 'C' && s[i-1] == 'A'){
            l[i]++;
        }
    }
    rep(i,q){
        ll a,b;
        cin>>a>>b;
        cout<<l[b-1]-l[a-1]<<endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;

long long fact(long long a)
{
  long long ret = 1;
  for (int i = 1; i <= a; i++)
  {
    ret = ret * i;
  }
  return ret;
}

// index が条件を満たすかどうか vector<>maeに検索したいvectorを入れる keyを超える最小の要素番号を返す
bool isOK(int index, long long key, vector<long long> &mae)
{
  if (mae[index] >= key)
    return true;
  else
    return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(long long key, vector<long long> &mae)
{
  int left = -1;               //「index = 0」が条件を満たすこともあるので、初期値は -1
  int right = (int)mae.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

  /* どんな二分探索でもここの書き方を変えずにできる！ */
  while (right - left > 1)
  {
    int mid = left + (right - left) / 2;

    if (isOK(mid, key, mae))
      right = mid;
    else
      left = mid;
  }

  /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
  return right;
}

int func(vector<int> &a)
{
  int sz = a.size();
  int ret = 0;
  VLL b(n);
  for (int i = 0; i < n; i++)
  {
    b[i] = i + 1;
  }
  for (int i = 0; i < n - 1; i++)
  {
    int tmp = binary_search(a[i], b);
    ret += fact(n - i - 1) * tmp;
    b.erase(b.begin() + tmp);
  }
  return ret;
}

int main()
{
  cin >> n;
  VI p(n), q(n);
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++)
  {
    cin >> q[i];
  }
  cout << abs(func(p) - func(q)) << endl;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy";
        return 0;
    }
    if(s == "Cloudy"){
        cout << "Rainy";
        return 0;
    }
    cout << "Sunny";
    return 0;
}


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

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var A = input[0];
            var B = input[1];

            Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
        }
    }
}

Measured memory_bytes: 13268
//
//  AOJ 0118 Property Distribution
//
//  Created by TaoSama on 2015-02-19
//  Copyright (c) 2014 TaoSama. All rights reserved.
//
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#define CLR(x,y) memset(x, y, sizeof(x))

using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;

int n, m;
char a[105][105];
int d[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
void dfs(int x, int y, char cur) {
	a[x][y] = 'X';
	for(int i = 0; i < 4; ++i) {
		int nx = x + d[i][0], ny = y + d[i][1];
		if(a[nx][ny] != 'X' && a[nx][ny] == cur && nx >= 1 && nx <= n
		        && ny >= 1 && ny <= m)
			dfs(nx, ny, a[nx][ny]);
	}
}
int main() {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(0);

	while(cin >> n >> m && n != 0 && m != 0) {
		for(int i = 1; i <= n; ++i) cin >> a[i] + 1;
		int ans = 0;
		for(int i = 1; i <= n; ++i) {
			for(int j = 1; j <= m; ++j) {
				if(a[i][j] != 'X') {
					++ans;
					dfs(i, j, a[i][j]);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1680
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    char x='a';
    x+=n;
    x--;
    if(n<=26){cout<<x<<endl;}
    else{
    ll m=1;
    V<ll> d;
    while(true){
        m*=26LL;
        ll x;
        if(d.size()>0)x=d[d.size()-1];
        else x=0;
        x+=m;
        d.push_back(x);
        if(x>=n) break;
    }
    sort(all(d));
    ll x=lb(all(d),n)-d.begin();
    x--;
    string ans;
    ll y=n-d[x]-1;
    ll z=26;
    while(y>0){
        char now='a';
        now+=y%26;
        ans+=now;
        y/=26;
    }
    while(ans.size()!=x+2) ans+='a';
    reverse(all(ans));
    cout<<ans<<endl;
    }
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N, C, K; cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; ++i){
        cin >> T[i];
    }

    sort(T.begin(), T.end());
    int ans = 0;
    for (int i = 0; i < N;) {
        ++ans;
        int start = i;
        while (i < N && T[i] - T[start] <= K && i - start < C){
            ++i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader

fun main() = aising2019c()

@OptIn(ExperimentalStdlibApi::class)
fun aising2019c() = SimpleIO_aising2019c().exec {
    val (h, w) = readLine().split(" ").map { it.toInt() }
    val board = Array(h) { readLine().map { it == '#' }.toBooleanArray() }

    val gridSize = h * w
    val uf = UnionFind(gridSize)
    fun toIndex(y: Int, x: Int) = y * w + x

    for (y in 0 until h) for (x in 0 until w) {
        if (x + 1 < w && board[y][x] != board[y][x + 1]) uf.unite(toIndex(y, x), toIndex(y, x + 1))
        if (y + 1 < h && board[y][x] != board[y + 1][x]) uf.unite(toIndex(y, x), toIndex(y + 1, x))
    }

    val blackCountByGroup = IntArray(gridSize)
    val whiteCountByGroup = IntArray(gridSize)

    for (y in 0 until h) for (x in 0 until w) {
        val groupRoot = uf.root(toIndex(y, x))
        if (board[y][x]) blackCountByGroup[groupRoot]++ else whiteCountByGroup[groupRoot]++
    }

    val answer = (0 until gridSize)
        .map { blackCountByGroup[it].toLong() * whiteCountByGroup[it] }.sum()

    println(answer)
}

private class UnionFind(initSize: Int) {
    private val parent = IntArray(initSize) { it }
    private val size = LongArray(initSize) { 1L }

    fun root(x: Int): Int {
        if (x == parent[x]) return x

        val xr = root(parent[x])
        parent[x] = xr
        return xr
    }

    fun unite(x: Int, y: Int) {
        val xr = root(x)
        val yr = root(y)
        if (xr == yr) return

        if (size[xr] >= size[yr]) {
            size[xr] += size[yr]
            parent[yr] = xr
        } else {
            size[yr] += size[xr]
            parent[xr] = yr
        }
    }

    fun isSame(x: Int, y: Int): Boolean = root(x) == root(y)

    fun unite(pair: Pair<Int, Int>): Unit = unite(pair.first, pair.second)
    fun isSame(pair: Pair<Int, Int>): Boolean = isSame(pair.first, pair.second)

    fun size(x: Int): Long = size[root(x)]
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleIO_aising2019c(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private val sb: StringBuilder = StringBuilder()
    fun readLine(): String = br.readLine()!!
    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = print(any.toString() + separator)
    fun exec(action: SimpleIO_aising2019c.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }
}
// endregion kokomade template dayo (^o^)


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll N, C, K; cin >> N >> C >> K;
    ll T[N];
    for(int i=0;i<N;i++) cin >> T[i];
    sort(T, T + N);
    int ans = 0;
    int rem = 0, d = 0;
    for(int i=0;i<N;i++){
        if(T[i] <= d && rem > 0){
            rem--;
        }else{
            ans++;
            d = T[i] + K;
            rem = C - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
//Code by: Nikhil Shukla, MMMUT GKP
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define V vector
#define pb push_back
#define all x x.begin(),x.end()
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc ll t; cin>>t; while(t--)
#define tc1 ll tt=1; while(tt--)
#define fir first
#define sec second
#define mod 998244353
#define out1(x) cout<<x<<"\n";
#define out2(x,y) cout<<x<<" "<<y<<"\n";
#define debug() cout<<"I am in\n";
#define Vll vector<long long>
#define FOR(i,x,n) for(ll i=x;i<n;i++)
#define RFOR(i,x,n) for(ll i=x;i>=n;i--)
////////////////////////////////////////////////////////////////////////////////////////
vector<ll>graph[100001];
vector<ll>temp;
vector<bool>visited(100001,false);
//long long count=0;
void dfs(long long node,ll dp[])
{
        visited[node]=1;
        for(ll i=0;i<graph[node].size();i++)
        {
            if(!visited[graph[node][i]])
            dfs(graph[node][i],dp);
            dp[node]=max(dp[node],1+dp[graph[node][i]]);
        }
}
void solve(ll n,ll m)
{
    ll dp[n+1];
    FOR(i,0,n+1)
    dp[i]=0;
    FOR(i,1,n+1)
    {
        if(!visited[i])
        dfs(i,dp);
    }
    ll ans=0;
    FOR(i,1,n+1)
    ans=max(dp[i],ans);
    cout<<ans<<"\n";
}
int main()
{
    fast()
    tc1
    {
        ll n,m;
        cin>>n>>m;
        FOR(i,0,m)
        {
            ll u,v;
            cin>>u>>v;
            graph[u].pb(v);
        }
        solve(n,m);
    }
    return 0;
}


Measured memory_bytes: 12540
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var ps = P.Make(num, num - 1, isWeighted: false);
        var ar = new[] { 0, num - 1 };
        var wei = new long[2][];
        for(var i = 0; i < 2; i++)
        {
            var queue = new Queue<int>();
            for (var j = 0; j < num; j++)
                ps[j].Weight = 0;
            queue.Enqueue(ar[i]);
            var bo = new bool[num];bo[ar[i]] = true;
            while (queue.Count != 0)
            {
                var p = queue.Dequeue();
                foreach (var ad in ps[p].adj)
                    if (!bo[ad])
                    {
                        bo[ad] = true;
                        ps[ad].Weight = ps[p].Weight + 1;
                        queue.Enqueue(ad);
                    }
            }
            wei[i] = ps.Select(v => v.Weight).ToArray();
        }
        var fct = 0;
        var sct = 0;
        for (var i = 0; i < num; i++)
            if (wei[0][i] <= wei[1][i]) fct++;
            else sct++;
        WriteLine(fct <= sct ? "Snuke" : "Fennec");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class P : IComparable<P>
{
    public int index;
    public List<int> adj;
    public Dictionary<int, int> dist;
    public long Weight;
    public P(int index)
    {
        this.index = index;
        adj = new List<int>();
        dist = new Dictionary<int, int>();
        Weight = long.MaxValue;
    }
    public static P[] Make(int num, int edge, bool isNotDirection = true, bool isWeighted = true)
    {
        var ps = Enumerable.Range(0, num).Select(v => new P(v)).ToArray();
        for (var i = 0; i < edge; i++)
        {
            var inp = Input.ar;
            inp[0]--;
            inp[1]--;
            for (var j = 0; j <= ToInt32(isNotDirection); j++)
            {
                ps[inp[j]].adj.Add(inp[1 - j]);
                if(isWeighted)
                ps[inp[j]].dist[inp[1 - j]] = inp[2];
            }
        }
        return ps;
    }
    public override string ToString()
        => $"{index + 1} {Weight}";
    public override int GetHashCode()
        => index.GetHashCode();
    public int CompareTo(P p)
        => Weight.CompareTo(p.Weight);
}


Measured memory_bytes: 45876
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
using namespace std;

int main(){
    long long n;
    cin >> n;
    map<string, long long> T;

    for(long long i = 0; i < n; i++){
        string s;
        cin >> s;
        if(T.find(s) == T.end()){
            T[s] = 1;
        }
        else{
            T[s] += 1;
        }
    }

    map<string, long long>::iterator it;

    long long maxv = 0;
    for(it = T.begin(); it != T.end(); it++){
        if(maxv < it->second){
            maxv = it->second;
        }
    }

    set<string> S;
    for(it = T.begin(); it != T.end(); it++){
        if(maxv == it->second){
            S.insert(it->first);
        }
    }

    set<string>::iterator it2;

    for(it2 = S.begin(); it2 != S.end(); it2++){
        cout << *it2 << endl;
    }

    return 0;
}

Measured memory_bytes: 34688
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
	public static void main (String [] args){
		Scanner s = new Scanner (System.in);
		String inter = s.nextLine().trim();
		String [] interArr = inter.split(" ");
		int H = Integer.parseInt(interArr[0]);
		int W = Integer.parseInt(interArr[1]);
		ArrayList <String> strings = new ArrayList <String>();
		for (int i = 0; i < H; i++){
			strings.add(s.nextLine());
		}
		char [][] matrix = new char [H][W];
		for (int x = 0; x < H; x++){
			for (int y = 0; y < W; y++){
				matrix[x][y] = strings.get(x).charAt(y);
			}
		}
		String [][] matrixOut = new String[H][W];
		for (int x = 0; x < H; x++){
			for (int y = 0; y < W; y++){
				int counter = 0;
				if (matrix[x][y] == '.'){
					if (x - 1 >= 0){
						if (matrix [x-1][y] == '#') counter++;
					}
					if (y - 1 >= 0){
						if (matrix [x][y-1] == '#') counter++;
					}
					if (x -1 >= 0 && y - 1 >= 0){
						if (matrix [x-1][y-1] == '#') counter++;
					}
					if (x + 1 < H){
						if (matrix [x+1][y] == '#') counter++;
					}
					if (y + 1 < W){
						if (matrix [x][y + 1] == '#') counter++;
					}
					if (x + 1 < H && y + 1 < W){
						if (matrix [x+1][y+1] == '#') counter++;
					}
					if (x + 1 < H && y - 1 >= 0){
						if (matrix [x+1][y-1] == '#') counter++;
					}
					if (y + 1 < W && x - 1 >= 0){
						if (matrix [x-1][y+1] == '#') counter++;
					}
					matrixOut[x][y] = Integer.toString(counter);
				} else {
					matrixOut[x][y] = Character.toString(matrix[x][y]);
				}
			}
		}
		// print matrix
		for (int x = 0; x < H; x ++){
			String out = "";
			for (int y = 0; y < W; y ++){
				out += (matrixOut[x][y]);
			}
			System.out.println(out);
		}
		
	}
	
}


Measured memory_bytes: 23380
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	bw = bufio.NewWriter(os.Stdout)
)

func init() {}
func ru() (n int) {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}
func ri() (n int) {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	b := sc.Bytes()
	neg := false
	if b[0] == 45 {
		neg = true
	}
	for _, v := range b {
		n = n*10 + int(v-48)
	}
	if neg {
		n = -n
	}
	return
}
func rs() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}
func rb() []byte {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Bytes()
}
func pf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(bw, format, a...); err != nil {
		panic(err)
	}
}
func pln(a ...interface{}) {
	if _, err := fmt.Fprintln(bw, a...); err != nil {
		panic(err)
	}
}
func pall(a []int) {
	for _, v := range a {
		fmt.Fprintln(bw, v)
	}
}
func pallol(a []int) {
	s := fmt.Sprint(a)
	if _, err := fmt.Fprintln(bw, s[1:len(s)-1]); err != nil {
		panic(err)
	}
}
func debug(a ...interface{}) {
	s := fmt.Sprint(a)
	if _, err := fmt.Fprintln(os.Stderr, s[1:len(s)-1]); err != nil {
		panic(err)
	}
}
func isEven(n int) bool            { return n&1 == 0 }
func isOdd(n int) bool             { return n&1 == 1 }
func swap(a int, b int) (int, int) { return b, a }
func fill(a []int, val int) {
	for i := 0; i < len(a); i++ {
		a[i] = val
	}
	return
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}
func smallerst(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}
func max(a []int) (idx, val int) {
	if len(a) == 0 {
		panic("func max requires at least one argument")
	}
	val = a[0]
	for i, aa := range a {
		if aa > val {
			idx, val = i, aa
		}
	}
	return
}
func min(a []int) (idx, val int) {
	if len(a) == 0 {
		panic("func min requires at least one argument")
	}
	val = a[0]
	for i, aa := range a {
		if aa < val {
			idx, val = i, aa
		}
	}
	return
}
func sum(a []int) int {
	res := 0
	for _, v := range a {
		res += v
	}
	return res
}

func sigma(x int) int     { return x * (x + 1) / 2 }
func powInt(a, b int) int { return int(math.Pow(float64(a), float64(b))) }
func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1e7), 1e7)
	solve()
	bw.Flush()
}

const (
	inf = 1 << 60
	mod = 1e9 + 7
)

type pair struct{ a, b int }
type point struct{ x, y int }

func solve() {
	m, d := ri(), ri()
	ans := 0
	for month := 1; month <= m; month++ {
		for day := 1; day <= d; day++ {
			if day < 10 {
				continue
			}
			d1 := day % 10
			d2 := day / 10
			if d1 >= 2 && d2 >= 2 && d1*d2 == month {
				ans++
			}
		}
	}

	pln(ans)
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  f80 a, b, x;
  cin >> a >> b >> x;
  f80 h = x * 2 / (a * b);
  if (h <= a) {
    cout << atan(b / h) / M_PI * 180 << endl;
  } else {
    cout << atan(2 * (a * a * b - x) / (a * a * a)) / M_PI * 180 << endl;
  }
}


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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int x;
    cin >> x;
    cout << x * x;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
long long int a[3002][3002];
int main()
{
    char s[3030],t[3030],u[3030];
    long long int i,j,len1,len2,c=0;
    scanf("%s%s",s,t);
    len1=strlen(s);
    len2=strlen(t);
    //int a[len1+1][len2+1];
    for(i=0;i<=len1+1;i++)
    for(j=0;j<=len2+1;j++)
    a[i][j]=0;
    for(i=1;i<=len1;i++)
    {
        for(j=1;j<=len2;j++)
        {
            if(s[i-1]==t[j-1])
                a[i][j]=1+a[i-1][j-1];
            else
                a[i][j]=fmax(a[i-1][j],a[i][j-1]);
        }
    }
    if(a[len1][len2]==0)
    u[c]='\0';
    else
    {
        i=len1;j=len2;c=a[len1][len2]-1;
        while(j>0 && i>0 )
        {
            if(s[i-1]==t[j-1])
            {
                u[c]=s[i-1];
                i--;
                j--;
                c--;
            }
            else
            {
                if(a[i-1][j]>a[i][j-1])
                i--;
                else
                j--;
            }
        }
        u[a[len1][len2]]='\0';
    }
    printf("%s\n",u);
    return 0;
}

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

int main()
{
  vector<int> n(3);

  rep(i,3){
    cin >> n.at(i);
  }

  int ans = 0;
  sort(n.begin(), n.end());

  // rep(i,3){
  //   cout << n[i];
  // }

  cout << n.at(2) * 10 + n.at(1) + n.at(0);
}


Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char* argv[]) {

    // input from txt （提出時にこの箇所は削除すること）
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    int n, x, t;
    int count;
    cin >> n >> x >> t;
    if ((n % x) != 0) {
        count = n / x + 1;
        cout << count * t << endl;
    }
    else {
        cout << n / x * t << endl;
    }
    /////////////////////


    return 0;
}

Measured memory_bytes: 3644
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans, dp[110000];
Pll a[200000], b[2000000];
string str, ss, dd;
bool f[2000][2000],ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	cout <<n*n-m << endl;
	return 0;
}

Measured memory_bytes: 2560
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	a,b = readline() |> split |> parseMap
	q = gcd(a,b)
	if q == 1
		println(1)
	else
	a = Int[]
	i = 1
	while i<=sqrt(q)
		if q%i == 0
			push!(a,i)
			push!(a,div(q,i))
		end
		i+=1
	end
	a = sort(a)
	f = ones(Int,length(a))
	for j in 1:length(a)
		for k in j+1:length(a)
			if gcd(a[j],a[k])>1
				f[k] = 0
			end
		end
	end
	println(sum(f))
end
end

main()

Measured memory_bytes: 169216
fun main (args:Array<String>) {
    val (a , b) = readLine()!!.split(" ").map(String::toInt)
    var list :MutableList<Int> = arrayListOf()
    var goukei = 0
    readLine()!!.split(" ").map(String::toInt).forEach{
        goukei += it
    }
    if(goukei > a){
        print("-1")
        return
    }
    print(a - goukei)

}

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

template <typename T>
string ToString(const T& n) {
  ostringstream stm;
  stm << n;
  return stm.str();
}

void addZero(string& x) {
  int tmp = 6 - x.size(); 
  for (int i = 0; i < tmp; i++) {
    x.insert(0, "0");
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, int>> city;
  vector<int> pre(N);
  vector<string> ans(M);
  for (int i = 0; i < M; i++) {
    int p, y;
    cin >> p >> y;
    p--;
    city.emplace_back(y, p, i);
  }
  sort(city.begin(), city.end());
  for (int i = 0; i < M; i++) {
    pre[get<1>(city[i])]++;
    string tmpA = ToString(get<1>(city[i]) + 1);
    addZero(tmpA);
    string tmpB = ToString(pre[get<1>(city[i])]);
    addZero(tmpB);
    ans[get<2>(city[i])] = tmpA + tmpB;
  }
  for (int i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{
    fastio;
    int n,i,p=0,a[103],b[103];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(i=0;i<n-2;i++)
    {
        if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2])
        {
            p=1;
            break;
        }
    }
    if(p==0)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m,del[610]={-1};
vector<vector<int>> G;
ld E[610];

void solve(){
    cin >> n >> m;
    G.resize(n,{});
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
    }
    E[n-1]=0;
    per(i,n-1){
        ld num=G[i].size(),ma=-1;
        E[i]=1;
        for(int t:G[i]){
            //cout << t << endl;
            E[i]+=E[t]/num;
            if (ma<E[t]) {
                ma=E[t];
                del[i]=t;
            }
        }
        //cout << i << " " << del[i] << " " <<  ma << endl;
    }
    ld ans=1000000;
    //cout << " " << endl;
    rep(k,n-1){
        vector<ld> E_(n,1000010);
        E_[n-1]=0;
        //cout << k << " " << n-1 << " " << E_[n-1] << endl;
        per(i,n-1){
            ld num=G[i].size();
            if (i==k) {
                if (num==(ld)1) break;
                num--;
            }
            E_[i]=1;
            for(int t:G[i]){
                if (i==k && t==del[k]) continue;
                //cout << t << endl;
                E_[i]+=E_[t]/num;
            }
        //cout << k << " " << i << " " << E_[i] << endl;
        }
        ans=min(ans,E_[0]);
    }
    cout << min(ans,E[0]) << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 1408
#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>;
vector <ll> a,b;
ll n,m,k;
vector <ll> tmp,tmp2;
 
int main(){
  cin >> n >> m >> k;
  vector <ll> a0(n),b0(m);
  rep(i,n)cin >> a0[i];
  rep(i,m)cin >> b0[i];
  a=a0;b=b0;
  vector <ll> ans0;
  ll sum=0,ans=0;
  while(tmp.size()!=a.size()){
    tmp.push_back(a[tmp.size()]);
    sum+=tmp.back();
    //cout << sum << endl;
    if(k<sum){
      sum-=tmp.back();
      //cout << sum << endl;
      tmp.pop_back();
      break;
    }
  }
  ans0.push_back(tmp.size());
  while(tmp2.size()!=b.size()){
    tmp2.push_back(b[tmp2.size()]);
    sum+=tmp2.back();
    //cout << sum << endl;
    while(k<sum){
      if(tmp.size()==0)goto end;
      sum-=tmp.back();
      //cout << sum << endl;
      tmp.pop_back();
    }
    ans0.push_back(tmp.size()+tmp2.size());
  }
 end:
  rep(i,ans0.size())ans=max(ans0[i],ans);
  cout << ans << endl;
}
 


Measured memory_bytes: 15952