akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e6+10;
ll a[maxn];
int main()
{
   ll k,n;
   cin>>k>>n;
   for(int i=1;i<=n;i++) cin>>a[i];
   ll mx=k-a[n]+a[1];
   for(int i=1;i<n;i++)
   {
       mx=max(mx,a[i+1]-a[i]);
   }
   cout<<k-mx<<endl;
   //system("pause");
   return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
ll N;
Graph g;
vector<int> visited;
vector<ll> d;
vector<ll> cnt;

void push(int now) {
	if (d[now] >= 3) {
		cnt[now]++;
		return;
	}
	visited[now] = true;
	for (auto &&e : g[now]) {
		if (!visited[e.dst])
			push(e.dst);
	}
}

int main() {
	cin >> N;
	g = Graph(N);
	d.assign(N, 0);
	visited.assign(N, 0);
	cnt.assign(N, 0);
	ll bigd = 0;
	for (int i = 0;i < N - 1;i++) {
		ll a, b;
		cin >> a >> b;
		d[a]++;
		d[b]++;
		bigd = max({ bigd, d[a], d[b] });
		g[a].push_back(Edge(a, b, 1));
		g[b].push_back(Edge(b, a, 1));
	}
	if (bigd <= 2) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0;i < N;i++) {
		if(d[i] == 1)
			push(i);
	}
	ll ans = 0;
	for (int i = 0;i < N;i++) {
		if(d[i] >= 3)
			ans += max((ll)0, cnt[i] - 1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10240
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}



Measured memory_bytes: 4016
MOD = 10**9 + 7

def modPow(a, b, mod):
    x = 1
    
    while b > 0:
        if b & 1:
            x = (x*a)%mod

        a = (a**2)%mod
        b //= 2

    return x



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

X = [0]*(K+1)
for i in range(1, K+1):
    X[i] = modPow(K//i, N, MOD)

for i in range(K, 0, -1):
    for j in range(i*2, K+1, i):
        X[i] -= X[j]

    X[i] %= MOD

print(sum(i*X[i] for i in range(1, K+1))%MOD)


Measured memory_bytes: 11308
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;++i){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    long long ans=0;
    for(int i=0;i<n-k;++i){
        ans +=h[i];
    }
    cout << ans << endl;
    return 0;
}
     


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w;
    vector<int> l;
    int k;
    for(int i=0;i<3;i++){
        cin >> w;
        l.push_back(w);
    }
    cin >> k;
    for(int i=0;i<k;i++){
        sort(l.begin(),l.end());
        l[2]*=2;
    }
    int ans=accumulate(l.begin(),l.end(),0);
    cout << ans << endl;


    return 0;
}

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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef array<int, 2> duo;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, m; cin >> n >> m;
        duo from, to;
        cin >> from[0] >> from[1] >> to[0] >> to[1];
        from[0]--, from[1]--, to[0]--, to[1]--;
        vector<string> grid(n); cin >> grid;
        vector<vector<int>> dist(n, vector<int>(m, 1e9));
        dist[from[0]][from[1]] = 0;
        vector<vector<bool>> vis(n, vector<bool>(m));
        priority_queue<tri> q;
        q.emplace(tri{0, from[0], from[1]});
        while (q.size()) {
                duo cur = {q.top()[1], q.top()[2]};
                q.pop();
                if (vis[cur[0]][cur[1]]) continue;
                vis[cur[0]][cur[1]] = 1;
                for (int ver = -2; ver <= +2; ver++) {
                        for (int hor = -2; hor <= +2; hor++) {
                                duo next {cur[0] + ver, cur[1] + hor};
                                if (next[0] < 0 || next[1] < 0 || next[0] >= n ||
                                    next[1] >= m || grid[next[0]][next[1]] == '#') continue;
                                int cost = 0;
                                if (abs(ver) + abs(hor) > 1) cost = 1;
                                if (dist[cur[0]][cur[1]] + cost < dist[next[0]][next[1]]) {
                                        dist[next[0]][next[1]] = dist[cur[0]][cur[1]] + cost;
                                        q.emplace(tri{-dist[next[0]][next[1]], next[0], next[1]});
                                }
                        }
                }
        }


        cout << (dist[to[0]][to[1]] == 1e9 ? -1 : dist[to[0]][to[1]]);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 8680
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    string s;
    cin >> s;
    string ans = "";
    rep(i,s.size()){
        if (s[i]=='0'){
            ans += '0';
        }
        else if (s[i]=='1'){
            ans += '1';
        }else {
            if (ans.size() == 0) continue;
            else ans.pop_back();
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
-- Structured Program I - Print a Rectangle

import Control.Applicative

main :: IO ()
main = do
  xs <- map words . takeWhile (/= "0 0") . lines <$> getContents
  mapM_ putStrLn $ map rectangle xs

rectangle :: [String] -> String
rectangle [h, w] = concat $ replicate (read h) $ replicate (read w) '#' ++ "\n"



Measured memory_bytes: 4628
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;

vll fac, finv, inv;

void COMinit(ll MAX) {
    if(MAX<1) return;
    fac.resize(MAX);
    finv.resize(MAX);
    inv.resize(MAX);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if(k==0 || n==k) return 1;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modadd(ll a,ll b,ll mod=MOD){
    return (a%mod+b%mod)%mod;
}

ll modsub(ll a,ll b,ll mod=MOD){
    a%=mod;
    b%=mod;
    if(a>=b) return a-b;
    else return mod-b+a;
}

ll modmul(ll a,ll b,ll mod=MOD){
    return ((a%mod)*(b%mod))%mod;
}

ll modpow(ll a, ll n,ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll moddiv(ll a,ll b,ll mod=MOD) {
    return modmul(a, modpow(b, mod-2));
}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    
    if(N>M){
        ll tmp=M;
        M=N;
        N=tmp;
    }
    
    COMinit(M+2);
    
    vll factorial(M+1);
    factorial[0]=1;
    for(ll i=1;i<=M;i++){
        factorial[i]=modmul(factorial[i-1],i);
    }
    
    if(N<M-1){
        cout<<0<<endl;
        return 0;
    }
    
    if(N==M)cout<<modmul(2,modmul(factorial[M],factorial[N]))<<endl;
    else cout<<modmul(1,modmul(factorial[M],factorial[N]))<<endl;
    
    
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	string s; cin >> s;

	int num = stoi(s);
	int sn = 0;

	for (int i = 0;i < s.size();i++){
		sn += s[i] - '0';
	}

	cout << (num%sn ? "No" : "Yes") << endl;

	return 0;

}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/
 
#include <bits/stdc++.h>
 
#define rt0 return 0
#define rep(i,n) for(LL i=0;i<n;i++)
#define repn(i,n) for(LL i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))
 
using namespace std;
 
const LL MOD=1e9+7;
 
LL n,a[200010],ans;
bool vis[200010];
vector <LL> pw;
map <LL,LL> mp;
 
LL FIND(LL ubb,LL targ)
{
	LL lb=0,ub=ubb;
	while(lb<=ub)
	{
		LL mid=(lb+ub)/2;
		if(a[mid]==targ) return mid;
		if(a[mid]>targ) ub=mid-1;
		else lb=mid+1;
	}
	return -1;
}
 
int main()
{
	pw.pb(1);
	repn(i,40) pw.pb(pw[i-1]*2LL);//,cout<<pw[i]<<endl;
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	for(LL i=n-1;i>=0;i--)
	{
		if(vis[i]) continue;
		vis[i]=true;
		LL sum=pw[lower_bound(pw.begin(),pw.end(),a[i])-pw.begin()];
		if(sum==a[i]) sum=pw[lower_bound(pw.begin(),pw.end(),a[i]*2)-pw.begin()];
		LL targ=sum-a[i];
		LL pos=upper_bound(a,a+n,targ)-a-1;
		if(pos==n||a[pos]!=targ) continue;
		LL npos=pos-mp[targ]-(a[i]==targ);
		if(npos>=0&&a[npos]==targ&& !vis[npos])
		{
			ans++;
			mp[targ]+=1+(a[i]==targ);
			vis[npos]=true;
		}
		else vis[i]=false;
	}
	cout<<ans<<endl;
	rt0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define INF 100000000

int n;
int d[14][14];
int dp[2<<14][14];

int duplication(string l, string r){
  int n = min(l.size(),r.size());
  string::size_type szl = l.find(r);
  string::size_type szr = r.find(l);
  // if(szl != string::npos || szr != string::npos)return n;
  for (int i = n; i>=0; i--){
    string lsub = l.substr(l.size()-i,i);
    string rsub = r.substr(0,i);
    if (lsub==rsub){
      return i;
    }
  }
  return 0;
}

int tsp(vector<string>& s){
  int m = s.size();
  rep(i,1<<m){
    rep(j,m){
      dp[i][j]=INF;
    }
  }

  rep(i,m){
    dp[1<<i][i] = s[i].length();
  }

  rep(i,1<<m){
    rep(j,m){
      if(i>>j&1){
        rep(k,m){
          if (!(i>>k&1)){
            dp[i|1<<k][k] = min(dp[i|1<<k][k],dp[i][j]+d[j][k]);
          }
        }
      }
    }
  }
  int mi = INF;
  rep(i,m){
    if(mi>dp[(1<<m)-1][i])mi=dp[(1<<m)-1][i];
  }
  return mi;
}

int main(){
  while(1){
    int c=0;
    cin >> n;
    if(!n)break;
    vector<string> s(n),ss;
    rep(i,n)cin >> s[i];
    vector<int> del;
    rep(i,n)rep(j,n){
      if(i==j)continue;
      string::size_type szl = s[i].find(s[j]);
      if(szl != string::npos)del.push_back(j);
    }
    sort(del.begin(),del.end());
    rep(i,n){
      int flag = 1;
      rep(j,del.size()){
        if(i==del[j])flag = 0;
      }
      if(flag)ss.push_back(s[i]);
    }
    rep(i,ss.size()){
      rep(j,ss.size()){
        d[i][j] = ss[j].size()-duplication(ss[i],ss[j]);
      }
    }
    c = tsp(ss);
    cout << c << endl;
  }

  return 0;
}



Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
		cout<<"Bad"<<endl;
	}
	else{
		cout<<"Good"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000000000000000
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;

int main() {

	int a, b;
	cin >> a >> b;

	int ans = 1;

	for (int i = 0; i < a; i++) {
		ans = ans * 100;
	}



	ans = ans * b;

	if (b <= 99) {
		cout << ans << endl;
		return 0;
	}
	else if(a==0){
		cout << 101  << endl;
		return 0;
	}
	else if (a == 1) {
		cout << 10100 << endl;
		return 0;
	}
	else if (a == 2) {
		cout << 1010000 << endl;
		return 0;
	}

	return 0;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/abc120/tasks/abc120_d
# Unionfind


n, m = map(int, input().split())


class UnionFind:
    def __init__(self, n):
        self.n = n
        # 各要素の親要素の番号を格納するリスト
        # 根がルートの時は、グループの要素数を格納　最初は全て根で要素数1
        self.parents = [-1] * n

    # 再帰 groupの根を返す
    # 経路圧縮あり
    def find(self, x):
        # 0より小さい場合は根
        if self.parents[x] < 0:
            # indexを返す
            return x
        else:
            # 根になるまで親を辿る
            # 経路圧縮 根のindexが全ての親に再帰的につく
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # groupを併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # 最初から統合されている
        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        # 根のグループ数を追加 xの方グループの要素数が多い前提なので多い方に寄せる
        self.parents[x] += self.parents[y]
        # 親(根)のindexを入れる
        self.parents[y] = x

    # xのgroupのサイズ
    def size(self, x):
        return - self.parents[self.find(x)]

    # 根が同じか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # ルートが同じ要素を返す
    def members(self, x):
        root = self.find(x)
        # 根が同じ要素
        return [i for i, in range(self.n) if self.find(i) == root]

    # 全ての根の要素を返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    # グループの数を数える
    def group_count(self):
        return len(self.roots())

    # {root: [要素]}
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


edge = []
for _ in range(m):
    a, b = map(int, input().split())
    edge.append((a - 1, b - 1))

ans = [n * (n - 1) // 2]

uf = UnionFind(n)
# 辺を後ろから追加していく
for a, b in reversed(edge):
    if not uf.same(a, b):
        ag = uf.size(a)
        bg = uf.size(b)
        uf.union(a, b)
        ans.append(ans[-1] - ag * bg)
    else:
        ans.append(ans[-1])

ans.pop()
for i in reversed(ans):
    print(i)


Measured memory_bytes: 22500
#include <cstdio>

const int MN = 200005;

int N, p[MN], q[MN];
int t[MN], f[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &p[i]), q[p[i]] = i;
	t[N] = 0;
	for (int i = N - 1; i >= 1; --i) {
		if (t[i + 1] == 0) {
			if (q[i] > q[i + 1]) t[i] = 1, f[i] = i + 1;
			else t[i] = 0;
		} else {
			if ((q[i] < q[i + 1] && q[i + 1] < q[f[i + 1]]) ||
			/**/(q[i + 1] < q[f[i + 1]] && q[f[i + 1]] < q[i]) ||
			/**/(q[f[i + 1]] < q[i] && q[i] < q[i + 1]))
				t[i] = t[i + 1], f[i] = f[i + 1];
			else t[i] = t[i + 1] + 1, f[i] = i + 1;
		}
	}
	printf("%d\n", t[1]);
	return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n<<=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
struct Prime{
  vector<ll> pl;
  void init(int a){ // a以下の素数列挙
    pl.resize(0);
    vector<bool> z(a+1, true);
    FOR(i, 2, a+1){
      if(z[i])pl.push_back(i);
      for(int b=i*2; b <= a; b+=i) z[b]=false;
    }
  }
  void prime_division(ll a, vector<pair<ll, int> >&v){ // vに素因数分解の結果が入る
    v.resize(0);
    for(ll b: pl){
      if(b*b > a) break;
      if(a%b) continue;
      int c = 0;
      while(a%b==0) a/=b, c++;
      v.push_back(make_pair(b, c));
    }
    if(a>1) v.push_back(make_pair(a, 1));
  }
} prime;
ll n;
vector<pair<ll, int> > v;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  prime.init(33000);
  cin >> n;
  cout << n << ":";
  prime.prime_division(n, v);
  each(itr, v) FOR(i, 0, itr->se) cout << " " << itr->fi;
  cout << endl;
  return 0;
}


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

  
int main() {
  int N,X,Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  vi ans(N,0);
  rep(i,N) {
    srep(j,i,N) {
      int d = j-i;
      chmin(d,abs(X-i)+abs(Y-j)+1);
      ans[d]++;
    }
  }
  srep(k,1,N) {
    cout << ans[k] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, c, k = MAP()
t = sorted(list(INT() for i in range(n)))

ans = 0
num = 0
time = inf
for i in range(n):
        if t[i]<=time+k and num < c:
                num += 1
        elif t[i]>time+k or num == c:
                ans += 1
                num = 1
                time = inf
        time = min(time, t[i])
ans += 1
print(ans)

Measured memory_bytes: 15144
import scala.io.StdIn

object Main {
	def main(args: Array[String])={
		val num = StdIn.readLine.split(" ").map(_.toInt)
		val N = num(0)
		val M = num(1)
		val X = num(2)
		val Y = num(3)

		val xSeq = StdIn.readLine.split(" ").map(_.toInt).toSeq
		val ySeq = StdIn.readLine.split(" ").map(_.toInt).toSeq

		val zRange = ( xSeq.max + 1 to  ySeq.min).intersect( X + 1 to Y )

		println(if(zRange.isEmpty) "War" else "No War" )
	}
}

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

using namespace std;

const int N = 1e5 + 10;

int n;
int p[N];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            cnt++;
        }
    }
    if (p[n - 1] == n) cnt++;
    cout << cnt << endl;
    return 0;
}




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

using namespace std;

typedef long long ll;

void solve(){
    string s;
    cin>> s;
    for(auto c: s)
      if(c=='7'){
        cout << "Yes";
        return;
      }
    cout << "No";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1, i = 1;
    //cin >> t;
    while(t--){
        solve();
        ++i;
    }
    return 0;
}


Measured memory_bytes: 3644
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n = inp[0]
d = []
n.times do
  d.push(inps[0])
end
h = {}
("a".."z").each do |c|
  h[c] = 99999999
end

d.each do |s|
  nh = {}
  ("a".."z").each do |c|
    nh[c] = 0
  end
  s.each_char do |c|
    nh[c] += 1
  end
  ("a".."z").each do |c|
    h[c] = [nh[c],h[c]].min
  end
end
("a".."z").each do |c|
  h[c].times do
    print c
  end
end
puts 

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 50
#define MAX 10

    int N,M,A,B;
    string S;
    ll x[100010],y[100010];

    bool fir=true;



int main(){
    ios_base::sync_with_stdio(false);
    cin>>S;
    int i=0;
    A=-1;
    for(auto x:S){
      if(S[i]=='A'&&A==-1)A=i;
      if(S[i]=='Z')B=i;
      i++;
    }
    cout<<B-A+1<<endl;
}
//ABC057 Maximum Average Sets


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 111;
int n, h, w;
int c[MAX][MAX];
int a[MAX * MAX];

PII next() {
    static int nowH = -1, nowW = 0, nextD = -1;
    if ((nowW == w - 1 && nextD == 1) || (nowW == 0 && nextD == -1)) {
        nextD *= -1;
        nowH++;
    }
    else nowW += nextD;
    PII res = MP(nowH, nowW);
    return res;
}

int main(void) {
    scanf("%d%d", &h, &w);
    scanf("%d", &n);
    REP(i, n) {
        scanf("%d", a + i);
    }
    int now = 0;
    REP(i, n) {
        REP(j, a[i]) {
            int nh, nw;
            tie(nh, nw) = next();
            //cerr << nh << " " << nw << endl;
            c[nh][nw] = i + 1;
        }
    }
    REP(i, h) REP(j, w) {
        printf("%d%c", c[i][j], (j + 1 == w ? '\n' : ' '));
    }
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int p[3],d[2],n[6],x,y=0,q=5000;
	
	for(int i=0;i<3;i++){cin >> p[i];}
	for(int i=0;i<2;i++){cin >> d[i];}
	for(int i=0;i<3;i++){
		x=p[i];
		for(int i=0;i<2;i++){n[i+y]=x+d[i];}
		y=y+2;
	}
	for(int i=0;i<6;i++){
		if(n[i]<q)q=n[i];
	}
	cout << q-50 << endl;
	return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
typedef long long int64;

int main() {
  int64 T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  int64 i1 = (A1 - B1) * T1;
  int64 i2 = (A2 - B2) * T2;

  if (i1 + i2 == 0) {
    cout << "infinity\n";
    return 0;
  }
  int s1 = (i1 > 0) ? 1 : -1;
  int s2 = (i2 > 0) ? 1 : -1;
  if (s1 * s2 > 0) {
    cout << "0\n";
    return 0;
  }
  int64 p = i1 + i2;
  if (p * s1 > 0) {
    cout << "0\n";
    return 0;
  }
  int64 toge = i1;
  p = abs(p);
  toge = abs(toge);
  int64 tmp = toge / p;
  int64 ans = abs(tmp) * 2 + 1;
  if (toge % p == 0) ans--;
  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace ZDY{
    #pragma GCC optimize(3)
    #define il __inline__ __attribute__ ((always_inline))
    #define rg register
    #define ll long long
    #define ull unsigned long long
    #define db double
    #define sht short
    #define MB template <class T>il
    #define Fur(i,x,y) for(int i=x;i<=y;++i)
    #define Fdr(i,x,y) for(int i=x;i>=y;--i)
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define fcin ios::sync_with_stdio(false)
    #define l2(n) (int(log2(n)))
    #define inf 0x3f3f3f3f
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>y?x:y;}
    MB T MIN(T x,T y){return x<y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    MB void SWAP(T &x,T &y){T t=x;x=y;y=t;}
}using namespace ZDY;using namespace std;
namespace IO{const char* ln="\n";const int str=1<<20;struct IN{char buf[str],*s,*t;bool _;IN():s(buf),t(buf),_(0){}il char gc(){return s==t&&((t=(s=buf)+fread(buf,1,str,stdin))==s)?EOF:(*s++);}IN&operator>>(char&ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)_=1;else ch=c;return *this;}IN& operator>>(char* ch){clr(ch,0);if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;*ch=c;ch++;while((c=gc())!=EOF&&!isspace(c))*ch=c,ch++;if(c==EOF)_=1;return *this;}IN& operator>>(string& ch){if(_)return *this;char c;while((c=gc())!=EOF&&isspace(c));if(c==EOF)return _=1,*this;ch+=c;while((c=gc())!=EOF&&!isspace(c))ch+=c;if(c==EOF)_=1;return *this;}template<typename T>IN&operator>>(T&x){if(_)return *this;char c=gc();bool ff=0;while(c!=EOF&&(c<'0'||c>'9'))ff^=(c=='-'),c=gc();if(c==EOF){_=1;return *this;}x=0;while(c!=EOF&&'0'<=c&&c<='9')x=(x<<3)+(x<<1)+c-48,c=gc();if(c==EOF)_=1;if(ff)x=-x;return *this;}}in;struct OUT{char buf[str],*s,*t;OUT():s(buf),t(buf+str){}~OUT(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,str,stdout),*s++=c):(*s++=c);}OUT&operator<<(const char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(char*s){while(*s)pt(*s++);return *this;}OUT&operator<<(string s){for(int i=0;s[i];i++)pt(s[i]);return *this;}template<typename T>OUT&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[30],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}}out;}using namespace IO;
#define N 100011
int n;
int main(){
	fcin;
	string s;
	cin>>s;
	Fur(i,0,s.size()-1){
		if(s[i]=='D'||s[i]=='U')continue;
		int t=(s[i]=='R');
		if(t&&(i&1))return cout<<"No\n",0;
		if(!t&&(i%2==0))return cout<<"No\n",0;
	}
	cout<<"Yes\n";
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
L = list(sorted(map(int, readline().split())))

ans = 0
import bisect
for i in range(n):
    a = L[i]
    for j in range(i + 1, n):
        b = L[j]
        cs = bisect.bisect_left(L, a + b)
        ans += cs - j - 1
print(ans)

Measured memory_bytes: 3568
Module Module1

    Sub main()

        Dim userInput As String, userInput2 As String
        Dim result(4) As String

        Const RESULT_AC = "AC"
        Const RESULT_WA = "WA"
        Const RESULT_TLE = "TLE"
        Const RESULT_RE = "RE"

        userInput = Console.ReadLine()

        For i = 0 To 3
            result(i) = 0
        Next

        For i = 0 To CInt(userInput) - 1
            userInput2 = Console.ReadLine()

            Select Case userInput2
                Case RESULT_AC
                    result(0) = result(0) + 1
                Case RESULT_WA
                    result(1) = result(1) + 1
                Case RESULT_TLE
                    result(2) = result(2) + 1
                Case RESULT_RE
                    result(3) = result(3) + 1
            End Select
        Next

        Console.WriteLine(RESULT_AC & " x " & result(0))
        Console.WriteLine(RESULT_WA & " x " & result(1))
        Console.WriteLine(RESULT_TLE & " x " & result(2))
        Console.WriteLine(RESULT_RE & " x " & result(3))
    End Sub
end module

Measured memory_bytes: 34720
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			long[] array = new long[N + 1];
			for(int i = 0; i < N; i++){
				array[i] = sc.nextLong();
			}
			array[N] = 0;
			
			long[] r_cost = new long[N + 1];
			r_cost[N] = 0;
			for(int i = N - 1; i >= 0; i--){
				r_cost[i] = r_cost[i + 1] + Math.abs(array[i + 1] - array[i]);
			}
			//System.out.println(Arrays.toString(r_cost));
			
			
			try(final PrintWriter pw = new PrintWriter(System.out)){
				long curr_pos = 0;
				long curr_cost = 0;
				for(int i = 0; i < N; i++){
					final long next_cost = curr_cost + Math.abs(curr_pos - array[i + 1]) + r_cost[i + 1];
					pw.println(next_cost);
					
					curr_pos = array[i];
					curr_cost += Math.abs(array[i] - (i == 0 ? 0 : array[i - 1]));
				}
				
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

typedef long long LL;
typedef long double LD;

LD calc(int n, LD d1, LD d) {
	if (n == 1) {
		return d1 + d / 2;
	}
	return d1 + (n * 2 - 1) * d / 2 + calc(n - 1, d1 + (2 * d1 + 5 * d) / n / 2, d + d * 2 / n);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	LD d1, x;
	cin >> n >> d1 >> x;
	cout << fixed << setprecision(10) << calc(n, d1, x) << endl;
}

Measured memory_bytes: 15872
#include <stdio.h>
int main()
{
     int a=0;
     char str [10];
     scanf("%d %s",&a, &str);
     if (a>=3200)
     {
         printf("%s\n",str);
         return 0;
     }
     else {
        printf("red\n");
     return 0;
     }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	long long ans[10010] = {}; 
	for(int x = 1; x <= 100; x++){
		for(int y = 1; y <= 100; y++){		
			for(int z = 1; z <= 100; z++){
				int a = x*x+y*y+z*z+x*y+y*z+z*x; 
				if(a <= 10000) ans[a] ++; 
			}
		}
	}
	for(int x = 101; x <= 10000; x++){
		for(int y = 1; y <= 10000/x; y++){		
			for(int z = 1; z <= 10000/x; z++){
				int a = x*x+y*y+z*z+x*y+y*z+z*x; 
				if(a <= 10000) ans[a] += 3; 
			}
		}
	}
	for(int i = 1; i <= N; i++){
		cout << ans[i] << "\n"; 
	}
}

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

using namespace std;

typedef long long ll;

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

	int n, m, k;
	cin >> n >> m >> k;

	int dp[n+1][m+1];
	memset(dp, 0, sizeof(dp));

	rep(j, m) dp[0][j+1] = dp[0][j] + n;
	rep(i, n) dp[i+1][0] = dp[i][0] + m;

	rep(i, n) rep(j, m){
		dp[i+1][j+1] = dp[i+1][j] + (n - (i + 1)) - (i + 1);
	}

	// rep(i, n+1) rep(j, m+1) cout << dp[i][j] << (j == m ? "\n" : " ");

	rep(i, n+1) rep(j, m+1){
		if(dp[i][j] == k){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}


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

int main(){
  int N;
  cin >> N;
  string str = "Three";
  
  for (int i = 0; i < N; i++){
    char c;
    cin >> c;
    
    if ( c == 'Y' ){
      str ="Four";
      break;
    }
  }
  
  cout << str << endl;
}
    

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

const double EPS = 1e-9;
const int MAX_N = 306;
int N;
int a[MAX_N];
double dp[MAX_N][MAX_N][MAX_N];

double go(int x, int y, int z)
{
	if(!x && !y && !z) return 0;
	double& res = dp[x][y][z];
	if(res > 0) return res;
	const double p1 = 1.0*x/N, p2 = 1.0*y/N, p3 = 1.0*z/N, p4 = 1.0*(N-x-y-z)/N;
	double tmp = 1.0;
	if(x) {
	    tmp += p1*go(x-1, y, z);
	}
	if(y){
	    tmp += p2*go(x+1,y-1,z);
	}
	if(z){
	    tmp += p3*go(x,y+1,z-1);
	}
	res =tmp/(1.0-p4);
	return res;
}

void solve()
{
    int x=0,y=0,z=0;
    for(int i=1;i<=N;++i){
        if(a[i]==1)x++;
        else if(a[i]==2)y++;
        else z++;
    }
	memset(dp,-1,sizeof(dp));
	double ans = go(x,y,z);
	printf("%.12lf\n", ans);
}

int main()
{
	cin >> N;
	for(int i=1;i<=N;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 224256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] x1 = new long[n];
		long[] y1 = new long[n];
		long[] x2 = new long[m];
		long[] y2 = new long[m];
		long min;
		long dist;
		int p;

		for(int i=0; i<n; i++){
			x1[i] = sc.nextLong();
			y1[i] = sc.nextLong();
		}
		for(int i=0; i<m; i++){
			x2[i] = sc.nextLong();
			y2[i] = sc.nextLong();
		}

		for(int i=0; i<n; i++){
			min = Long.MAX_VALUE;
			p=0;
			for(int j=0; j<m; j++){
				dist = Math.abs(x1[i]-x2[j]) + Math.abs(y1[i]-y2[j]);
				if( dist < min ){
					min = dist;
					p = j;
				}
			}

			System.out.println(p+1);
		}

		return;
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <list>
#include <cassert>
using namespace std;

const int MAXN = 1e5 + 5;
vector<int> adj[MAXN];
int dp[MAXN], deg[MAXN];

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

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		++deg[v];
	}

	list<int> q;
	for (int u = 1; u <= n; ++u) {
		if (!deg[u]) q.push_back(u);
	}

	vector<int> dag;
	while (!q.empty()) {
		int u = q.front();
		q.pop_front();
		dag.push_back(u);

		for (int v : adj[u]) {
			if (--deg[v] == 0) q.push_back(v);
		}
	}
	assert(dag.size() == n);

	for (int i = dag.size() - 1; i >= 0; i--) {
		int u = dag[i];
		for (int v : adj[u]) dp[u] = max(dp[u], dp[v] + 1);
	}
	//~ for (int u = 1; u <= n; u++) cerr << dp[u] << ' '; cerr << '\n';

	int ans = 0;
	for (int u = 1; u <= n; u++) ans = max(ans, dp[u]);
	cout << ans << endl;
}


Measured memory_bytes: 7032
n = int(input())
a, b, c = input(), input(), input()
ans = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    if a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2
print(ans)


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

struct less_key {
    bool operator()(const std::pair<i64,i64> &left, const std::pair<i64,i64> &right) {
        return left.first < right.first;
    }
};

i64 gcd (i64 a, i64 b, i64 & x, i64 & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    i64 x1, y1;
    i64 d = gcd (b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

i64 rev(i64 a, i64 m) {
    i64 x, y;
    i64 g = gcd(a, m, x, y);
    if (g != 1) {
        throw g;
    }
    return (x % m + m) % m;
}

i64 binpow(i64 a, i64 p) {
    if (p == 0) {
        return 1;
    }
    if (p == 1) {
        return a;
    }
    i64 t = binpow(a, p / 2);
    t *= t;
    t %= mod;

    if (p % 2) {
        t *= a;
        t %= mod;
    }

    return t;
}

const i64 MAXN = 100005;

i64 n, k;
i64 a[MAXN];
i64 b[MAXN];


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;

    return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

bool dp[80][80][15000];

int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<int>> C(H, vector<int>(W));
    rep(i, H) {
        rep(j, W) {
            cin >> C[i][j];
        }
    }

    rep(i, H) {
        rep(j, W) {
            int b;
            cin >> b;
            C[i][j] -= b;
        }
    }

    int s = C[0][0];
    dp[0][0][abs(s)] = true;

    rep(i, H) {
        rep(j, W) {
            rep(k, 15000) {
                if (dp[i][j][k]) {
                    if (i < H - 1) {
                        int x = C[i + 1][j];
                        if (abs(k - x) < 15000) dp[i + 1][j][abs(k - x)] = true;
                        if (abs(k + x) < 15000) dp[i + 1][j][abs(k + x)] = true;
                    }

                    if (j < W - 1) {
                        int x = C[i][j + 1];
                        if (abs(k - x) < 15000) dp[i][j + 1][abs(k - x)] = true;
                        if (abs(k + x) < 15000) dp[i][j + 1][abs(k + x)] = true;
                    }
                }
            }
        }
    }

    int ans = INF;
    rep(i, 15000) {
        if (dp[H - 1][W - 1][i]) ans = min(ans, i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 92800
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		for(int i=1;i<=9;i++)for(int j=1;j<=9;j++){
			ln(String.format("%dx%d=%d",i,j,i*j));	
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <algorithm>
#include <climits>
typedef long long ll;

const int max_t = 20;
int dist[max_t][max_t];

int main() {
	//freopen("aoj0189.txt", "r", stdin);
	while (1) {
		int n, t = 0;
		scanf("%d", &n);
		if (n == 0) break;
		
		for (int i = 0; i < max_t; i++) {
			std::fill(dist[i], dist[i] + max_t, INT_MAX);
		}
		for (int i = 0; i < n; i++) {
			int from, to;
			int d;
			scanf("%d%d%d", &from, &to, &d);
			t = std::max(t, from);
			t = std::max(t, to);
			dist[from][to] = d;
			dist[to][from] = d;
		}
		for (int i = 0; i <= t; i++) {
			dist[i][i] = 0;
		}

		for (int k = 0; k <= t; k++) {
			for (int i = 0; i <= t; i++) {
				for (int j = 0; j <= t; j++) {
					if (dist[i][k] != INT_MAX && dist[k][j] != INT_MAX)
						dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}

		int min_len = INT_MAX;
		int start = -1;
		for (int i = 0; i <= t; i++) {
			int len = 0;
			for (int j = 0; j <= t; j++) {
				if (j == i) continue;

				len += dist[i][j];
			}
			if (len < min_len) {
				min_len = len;
				start = i;
			}
		}

		printf("%d %d\n", start, min_len);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

// consts
int MOD = 1000000007;  // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

long long modinv(long long a) {
    long long b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

long long mod(long long val) {
    long long res = val % MOD;
    if (res < 0) res += MOD;
    return res;
}

ll dp[200005];

ll f(ll n) {
    if (n < 0) return 0;
    if (n == 0) return 0;
    if (n == 1) return 1;
    if (dp[n] != -1) return dp[n];
    return dp[n] = mod(n + f(n - 1));
}

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (int i = 0; i < 200005; ++i) dp[i] = -1;
    for (ll i = k; i <= n + 1; ++i) {
        // cout << "===" << endl;
        // cout << "k = " << i << endl;
        // cout << "===" << endl;
        ll m = f(i - 1);  // i = 2 => f(1) = 1, i = 3 => f(2) = 3, i = 1 => f(0) = 0
        ll M = f(n);
        ll d = f(n - i);
        auto c = mod(mod(M - d) - m + 1);
        // cout << "m = " << m << ", M = " << M << ", d = " << d << "c = " << c << endl;
        ans += c;
        ans = mod(ans);
    }
    cout << ans << endl;
    return 0;
}


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

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

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

  int n, a; cin >> n >> a;
  cout << n*n-a << '\n';
  return 0;
}


Measured memory_bytes: 256