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

int N;
int x[100010], y[100010];
int idx1[100010], idx2[100010];
//vector<vector<int> > G(100010);
//vector<vector<int> > G2(100010);
int fa[100010];
int E1[500010], E2[500010], L[500010];
int m;
int idx[500010];
long long res;

int cmp1(const void *aa, const void *bb)
{
	int i1 = *((int *)aa);
	int i2 = *((int *)bb);
	if(x[i1] > x[i2])
		return 1;
	else if(x[i1] < x[i2])
		return -1;
	else{
		return y[i1]-y[i2];
	}
}

int cmp2(const void *aa, const void *bb)
{
	int i1 = *((int *)aa);
	int i2 = *((int *)bb);
	if(y[i1] > y[i2])
		return 1;
	else if(y[i1] < y[i2])
		return -1;
	else{
		return x[i1]-x[i2];
	}
}

int cmp(const void *aa, const void *bb)
{
	int i1 = *((int *)aa);
	int i2 = *((int *)bb);
	return L[i1] - L[i2];
}

int getFa(int u)
{
	int uu = u;
	while(fa[u] != -1)
		u = fa[u];
	while(fa[uu] != -1){
		int tu = fa[uu];
		fa[uu] = u;
		uu = tu;
	}
	return u;
}

void solve()
{
	int i;
	m = 0;
	for(i=0; i<N; i++){
		idx1[i] = i;
	}
	qsort(idx1, N, sizeof(int), cmp1);
	for(i=0; i<N-1; i++){
		//G[idx1[i]].push_back(idx1[i+1]);
		//G[idx1[i+1]].push_back(idx1[i]);
		//G2[idx1[i]].push_back(abs(x[idx1[i+1]]-x[idx1[i]]));
		//G2[idx1[i+1]].push_back(abs(x[idx1[i+1]]-x[idx1[i]]));
		E1[m] = idx1[i];
		E2[m] = idx1[i+1];
		L[m] = abs(x[idx1[i+1]]-x[idx1[i]]);
		m ++;
	}
	for(i=0; i<N; i++){
		idx2[i] = i;
	}
	qsort(idx2, N, sizeof(int), cmp2);
	for(i=0; i<N-1; i++){
		//G[idx2[i]].push_back(idx2[i+1]);
		//G[idx2[i+1]].push_back(idx2[i]);
		//G2[idx2[i]].push_back(abs(y[idx2[i+1]]-y[idx2[i]]));
		//G2[idx2[i+1]].push_back(abs(y[idx2[i+1]]-y[idx2[i]]));
		E1[m] = idx2[i];
		E2[m] = idx2[i+1];
		L[m] = abs(y[idx2[i+1]]-y[idx2[i]]);
		m ++;
	}
	for(i=0; i<N; i++)
		fa[i] = -1;
	for(i=0; i<m; i++){
		idx[i] = i;
	}
	qsort(idx, m, sizeof(int), cmp);
	res = 0;
	for(i=0; i<m; i++){
		int u = E1[idx[i]], v = E2[idx[i]], len = L[idx[i]];
		int f1 = getFa(u);
		int f2 = getFa(v);
		if(f1 == f2)
			continue;
		else{
			fa[f1] = f2;
			res += len;
		}
	}
	printf("%lld\n", res);
}

int main()
{
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d%d", &x[i], &y[i]);
	solve();
	return 0;
}

Measured memory_bytes: 9972
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b;
  cin>>a>>b;
  int c=a/b;
  if(b%2==1)
    cout<<c*c*c<<endl;
  else{
    int d=a/(b/2);
    int e=d-c;
    cout<<c*c*c+e*e*e<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
int n,m,k,x,y,i,j,l,r,u,d;
string s,t;
int main()
{
	scanf("%d%d%d%d%d",&n,&m,&k,&x,&y);
	rdst(s,200005);rdst(t,200005);s=" "+s;t=" "+t;
	l=0;u=0;r=m+1;d=n+1;
	fd1(i,k){
		if (t[i]=='L'){
			r=min(m+1,r+1);
		}
		if (t[i]=='R'){
			l=max(0,l-1);
		}
		if (t[i]=='U'){
			d=min(n+1,d+1);
		}
		if (t[i]=='D'){
			u=max(0,u-1);
		}
		if (u+1>d-1){
			puts("NO");
			return 0; 
		}
		if (l+1>r-1){
			puts("NO");
			return 0;
		}
		if (s[i]=='R'){
			r--;
		}
		if (s[i]=='L'){
			l++;
		}
		if (s[i]=='U'){
			u++;
		}
		if (s[i]=='D'){
			d--;
		}
		if (u+1>d-1){
			puts("NO");
			return 0; 
		}
		if (l+1>r-1){
			puts("NO");
			return 0;
		}
	}
	if (u<x&&x<d&&l<y&&y<r) puts("YES"); else puts("NO");
	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int linearSearch(int a[], int n, int key)
{
    int i = 0;

    a[n] = key;
    while ( a[i] != key ) {
        i++;
    }
    return i != n;
}

int main(void)
{
    int n;
    int q;
    int s[10001];
    int t[501];
    int cnt = 0;

    scanf("%d", &n);

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &s[i]);
    }

    scanf("%d", &q);

    for ( int i = 0; i < q; i++ ) {
        scanf("%d", &t[i]);
    }

    for ( int i = 0; i < q; i++ ) {
        cnt += linearSearch(s, n, t[i]);
    }

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

    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
int n, k;
void kekka(int a, int b);
int main()
{
	std::cin >> n >> k;
	kekka(n, k);
 
	return 0;
}
 
void kekka(int a, int b)
{

	//std::cout << a << " " << b << std:: endl;
	int sum1 = 0, sum2 = 0, maxsum;
	for(int i =1; i <= a; i++)
	{
		if(i % 2 == 0)
		{
			sum1++;
		}else
		{
			sum2++;
		}		
	}
	//std::cout << sum1 << sum2;
	if(sum1 < sum2)
	{
		maxsum = sum2;
	}else
	{
		maxsum = sum1;
	}
	//std::cout << maxsum;
	if(b <= maxsum)
	{
		std::cout << "YES";
	}else
	{
		std::cout << "NO";
	}
}

Measured memory_bytes: 256
x = int(input())
for a in range(121):
    for b in range(120):
        a2 = a**5
        b2 = b**5
        if a2-b2 == x:
            print(str(a) +' '+str(b))
            break
        elif a2+b2 == x:
            print(str(a) +' '+str(-b))
            break
    else:
        continue
    break 

Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#define MN 5010
#define mod 1000000007

int fac[MN], cnt[MN];
int f[MN][MN];
int fa[MN]; bool ok[MN];

int Find(int x) {return fa[x] == x ? x : fa[x] = Find(fa[x]);}

int qpow(int x, int p)
{
	int ans = 1;
	for(; p; p >>= 1, x = 1ll * x * x % mod) if(p & 1) ans = 1ll * ans * x % mod;
	return ans;
}

int main()
{
	int n; scanf("%d", &n);
	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	for(int i = 1; i <= n; i++) fa[i] = i;
	for(int i = 1; i <= n; i++)
	{
		int p; scanf("%d", &p);
		if(p == -1) ok[Find(i)] = 1;
		else if(Find(p) != Find(i)) ok[Find(p)] |= ok[Find(i)], fa[Find(i)] = Find(p);
	}
	int w = 0;
	for(int i = 1; i <= n; i++)
	{
		if(ok[Find(i)]) cnt[Find(i)]++;
		if(Find(i) == i && !ok[i]) w++;
	}
	int N = 0;
	for(int i = 1; i <= n; i++)
		if(cnt[i]) cnt[++N] = cnt[i];
		
	f[0][0] = 1;
	for(int i = 1; i <= N; i++)
		for(int j = 0; j <= i; j++)
			f[i][j] = (1ll * f[i - 1][j] * (n - 1) + 1ll * (j >= 1 ? f[i - 1][j - 1] : 0) * cnt[i]) % mod;
			
	int ans = 1ll * (n - w) * qpow(n - 1, N) % mod;
	for(int i = 2; i <= N; i++)
		ans = (ans - 1ll * f[N][i] * fac[i - 1] % mod + mod) % mod;
	for(int i = 1; i <= N; i++)
		ans = (ans - 1ll * (cnt[i] - 1) * qpow(n - 1, N - 1) % mod + mod) % mod;
	printf("%d\n", ans);
}

Measured memory_bytes: 70664
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m;
	cin >> n >> m;
	if(n > m) swap(n,m);
	if(n == 1 && m == 1) cout << 1 << endl;
	else if(n == 1) cout << m - 2 << endl;
	else cout << (n - 2) * (m - 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	int X,Y,Z;
	scanf("%d %d %d",&X,&Y,&Z);
	int len = X - Z;
	int count = 0;
	while(len >= (Y + Z)){
		len -= Y;
		len -= Z;
		count ++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]
#print(AB)

AB=sorted(AB,key= lambda x: x[1])
#print(AB)

res=0
for i in range(N):
  res+=AB[i][0]
  if res>AB[i][1]:
    print("No")
    break
  if i==N-1:
    print("Yes")

Measured memory_bytes: 55260
#include <stdio.h>
int main()
{
	int N, A, B;
	int d = 0;
	int c[5];
	scanf("%d %d %d", &N, &A, &B);
	for (int k = 1; k <= N; k++) {
		c[0] = k % 10;
		c[1] = (k % 100 - c[0]) / 10;
		c[2] = (k % 1000 - c[1]) / 100;
		c[3] = (k % 10000 - c[2]) / 1000;
		c[4] = (k % 100000 - c[3]) / 10000;
		if (A <= c[0] + c[1] + c[2] + c[3] + c[4] && B >= c[0] + c[1] + c[2] + c[3] + c[4]) {
			d = d + k;
		}
	}printf("%d", d);
	return(0);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

vector<ll> get_divisors(ll n) {
    vector<ll> divisors;
    for(ll i=1;i*i<=n;++i) {
        if(n % i) continue;
        divisors.push_back(i);
        if(i * i != n) divisors.push_back(n/i);
    }
    return divisors;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, m, ans = 1;
    cin >> n >> m;
    if(n == 1) {
        cout << m << endl;
        return 0;
    }
    
    vector<ll> divisors = get_divisors(m);
    for(ll d: divisors) {
        if(m/d >= n) {
            ans = max(d, ans);
        }
    }

    cout << ans << endl;
}


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

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

    int count = 0;
    vector<int> A(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }

    for (int i = 0; i < N; i++) {
        if (A[i] * 4 * M >= sum) {
            count++;
        }
    }

    if (count >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	string s;
	cin >> s;

	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
	}
	else if(s.size() < 26){
		bool used[26] = {};
		for (char c : s)used[c - 'a'] = true;
		char n;
		rep(i, 26)if (!used[i]) {
			n = 'a' + i;
			break;
		}
		cout << s << n << endl;
	}
	else {
		string t = s;
		next_permutation(all(t));
		int end = 26;
		rep(i,26) {
			if (s[i]!=t[i]) {
				end = i + 1;
				break;
			}
		}
		cout << t.substr(0,end) << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    int tai, ans=IMAX;
    rep(i, 101) {
        tai = 0;
        rep(j, N) tai += (i - X[j]) * (i - X[j]);
        ans = min(ans, tai);
    }
    cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int x=0;
  int m=10;
  int X=N;
  while(N != 0){
    x += (N%m);
    N /= m;
  }
  
  if(X % x == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var dp = new int[n + 1, 4];
            for (int i = 1; i < n + 1; i++)
                for (int j = 0; j < 4; j++) dp[i, j] = int.MaxValue;
            var p = new int[n]; var t = new int[n];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                p[i] = int.Parse(line[0]);
                t[i] = int.Parse(line[1]);
            }
            getAns(dp, p, t);
        }
    }
    public static void getAns(int[,] dp, int[] p, int[] t)
    {
        var n = p.Length;
        if (p[0] > t[0]) { Console.WriteLine("NG 1"); goto end; }
        else dp[1, 1] = p[0];
        for (int i = 1; i < n; i++)
        {
            var ok = false;
            for (int j = 1; j <= 3; j++)
                if (dp[i, j] != int.MaxValue)
                {
                    if (j <= 2 && checkGet(p, t, i, j))
                    {
                        dp[i + 1, j + 1] = Math.Min(dp[i + 1, j + 1], dp[i, j] + Math.Abs(p[i] - p[i - 1]));
                        ok = true;
                    }
                    if (checkGoHome(p, t, i, j))
                    {
                        dp[i + 1, 1] = Math.Min(dp[i + 1, 1], dp[i, j] + p[i] + p[i - 1]);
                        ok = true;
                    }
                }
            if (!ok) { Console.WriteLine("NG {0}", i + 1); goto end; }
        }
        getAns2(dp, p);
        end:;
    }
    public static void getAns2(int[,] dp, int[] p)
    {
        var n = dp.GetLength(0);
        var ans = int.MaxValue;
        for (int i = 0; i < 4; i++)
            if (dp[n - 1, i] != int.MaxValue)
                ans = Math.Min(ans, dp[n - 1, i]);
        Console.WriteLine("OK {0}", p[n - 2] + ans);
    }
    public static bool checkGoHome(int[] p, int[] t, int i, int b) => p[i - 1] * (b + 1) + p[i] <= t[i] - t[i - 1];
    public static bool checkGet(int[] p, int[] t, int i, int b) => Math.Abs(p[i] - p[i - 1]) * (b + 1) <= t[i] - t[i - 1];
}


Measured memory_bytes: 8140
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct WarshallFloyd{
    int n;
    vector<vector<int> > d;
    WarshallFloyd(int _n){
        n = _n;
        d.resize(n, vector<int>(n));
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                d[i][j] = INF;
            }
            d[i][i] = 0;
        }
    }
    void build(){
        for(int k = 0; k < n; k++){
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, l;
    cin >> n >> m >> l;
    WarshallFloyd wf(n), wf2(n);
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        wf.d[a][b] = c;
        wf.d[b][a] = c;
    }
    wf.build();
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(wf.d[i][j] <= l){
                wf2.d[i][j] = 1;
            }
        }
    }
    wf2.build();
    int q;
    cin >> q;
    while(q--){
        int s, t;
        cin >> s >> t;
        s--; t--;
        int ans = wf2.d[s][t];
        if(ans == INF) cout << -1 << endl;
        else cout << ans - 1 << endl;
    }
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int M=2e3+5;

int n,l[M];
long long tot=0;

bool check(int a,int b,int c){
	if (a+b>c && b+c>a && c+a>b) return true;
	return false;
}

int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>l[i];
	}
	sort(l+1,l+n+1);
	for (int i=1;i<=n-2;i++){
		for (int j=i+1;j<=n-1;j++){
			int lf=j+1,rt=n,mid;
			if (lf>rt) break;
			while (lf!=rt){
				mid=(lf+rt)/2;
				if (check(l[i],l[j],l[mid])){
					lf=mid+1;
				} else {
					rt=mid;
				}
			}
			tot+=(rt-j-1);
			if (check(l[i],l[j],l[rt])) tot++;
		}
	}
	cout<<tot;
	return 0;
}


Measured memory_bytes: 3652
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N = int(input())
ok = N % sum(map(int, list(str(N)))) == 0
if ok:
    print('Yes')
else:
    print('No')


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

int l;

int main()
{
	int n;
	cin >> n >> l;
	vector<string> s;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		s.push_back(str);
	}
	sort(s.begin(), s.end());
	for(int i = 0; i < n; i++){
		cout << s[i] << flush;
	}
	cout << endl;
	return 0;
}

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

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

int main(){
  int n,k;
  vector <int>p;

  cin >>n>>k;
  rep(i,n)
  {
    int t;
    cin >>t;
    p.push_back(t);
  }
    int sum=0;
    int tmp=0;
    sort(p.begin(),p.end());
    rep(i,k)
      sum+=p[i];
    cout <<sum<<endl;


}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
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;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;


int main() {
  ll n; cin >>n;
  ll ans = 0;
  if (n % 2 == 0){
    ll m = n;
    ans += m / 10;
    /*
    while(m > 0){
      ans += m / 10;
      m /= 10;
    }*/
    m = n/10;
    while(m > 0){
      ans += m / 5;
      m /= 5;
    }
  }
  cout <<ans <<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

long long l[87] = {0};
int n;

int main()
{
	scanf("%d", &n);
	l[0] = 2;
	l[1] = 1;
	for(int i = 2;i <= 86;i++)
	{
		l[i] = l[i-1] + l[i-2];
	}
	printf("%.0lld\n", l[n]);
	return 0;
}


Measured memory_bytes: 128
N=int(input())
L=list(map(int,input().split()))
L.sort()
from bisect import bisect_left
ans=0
for i in range(0,N-2):
    for j in range(i+1, N-1):
        x=bisect_left(L[j+1:], L[i]+L[j])
        ans+=x
print(ans)

Measured memory_bytes: 51552
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s,t;
  int n,m;
  cin >> s >> t;
  n = s.size();
  m = t.size();
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s < t) cout << "Yes";
  else cout << "No";
  cout << endl;
}


Measured memory_bytes: 256
n = int(input())
l = [int(i) for i in input().split()]

ct = 1
ans = 0
if n == 1:
    print(0 if l[0] == 1 else -1)
else:
    for i in range(n):
        if l[i] == ct:
            ans += 1
            ct += 1
        else:
            pass
        
    print(n - ans if ans > 0 else -1)


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int N, K;
int Dis[10];
int main() {
	scanf("%d%d", &N, &K);
	for(int k=0; k<K; k++) {
		int x; scanf("%d", &x);
		Dis[x] = 1;
	}
	int ans = 0;
	for(int i=N; ; i++) {
		int now = i;
		ans = i;
		bool isCan = true;
		while(now) {
			if(Dis[now%10] == 1) {isCan = false; break;}
			now /= 10;
		}
		if(isCan) break;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let k: usize = sc.cin();
    let s: String = sc.cin();
    if s.len() <= k {
        put!(s);
    } else {
        println!("{}...", &s[0..k]);
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2140
n, x = map(int, input().split())
aa = list(map(int, input().split()))

moves = 0
if aa[0] > x:
    moves += aa[0] - x
    aa[0] = x

for i in range(n-1):
    # invariant: aa[i] <= x
    if aa[i] + aa[i+1] > x:
        diff = (aa[i] + aa[i+1]) - x
        aa[i+1] -= diff
        moves += diff

print(moves)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e15+5;
const ll N=1e5+10;
ll n,d;
ll coor[20][20];

bool dist(ll i,ll j)
{
	ll ans=0;
	for(ll k=0;k<d;k++)
	{
		ll temp=abs(coor[i][k]-coor[j][k]);
		ans+=temp*temp;
	}
	ll sq=sqrt(ans);
	return (sq*sq)==ans;
}
int main()
{
	boost;
	cin>>n>>d;
	for(ll i=0;i<n;i++) for(ll j=0;j<d;j++) cin>>coor[i][j];
	ll ans=0;	
	for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(dist(i,j)) ans++;
	cout<<ans;	
	return 0;
} 


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    bool ok = (s[0] == 'A');

    int cnt = 0;
    for(int i=2; i<n-1; ++i){
        if(s[i] == 'C')
            ++ cnt;
    }
    ok &= (cnt == 1);

    cnt = 0;
    for(int i=0; i<n; ++i){
        if(isupper(s[i]))
            ++ cnt;
    }
    ok &= (cnt == 2);

    if(ok)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;

    return 0;
}


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

/* dp[i]は位置iに到達するまでの最小コスト*/
int dp[200001];

int N, K;
int h[100001];

int main(void){
    // Your code here!
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> h[i];
    for(int i = 0; i <= 200000; i++) dp[i] = -1;
    
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++){
            if(i + j < N) {
                if(dp[i+j] != -1) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
                else dp[i+j] = dp[i] + abs(h[i] - h[i+j]);
            }
        }
    }
    
    cout << dp[N-1] << endl;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, K;

ll i, j, k;
ll X[66], Y[66],C[66];

double p2(double a){
    return a * a;
}

bool ck(double x,double y,double a){
    //cout << x << "," << y << ",";
    ll i,k=0;
    fornum(i,0,N){
        double rr = sqrt(p2(X[i] - x) + p2(Y[i] - y)) * C[i];
        if(rr<=a+1e-8){
            ++k;
        }
    }
    //cout << k << endl;
    return k >= K;
}

bool bs(double a){
    ll i, j;
    fornum(i,0,N){
        if(ck(X[i],Y[i],a))
            return true;
    }
    fornum(i,0,N){
        fornum(j,i+1,N){
            double at = a / C[i];
            double bt = a / C[j];
            double d = sqrt(p2((double)X[i] - X[j]) + p2((double)Y[i] - Y[j]));
            //cout << i << "<<" << j << endl;
            //cout << at << "," << bt << "," << d << endl;
            if(d>at+bt)
                continue;
            //cout << i << "-" << j << endl;
            double ac = (p2(d) + p2(at) - p2(bt)) / (2 * at * d);
            if(p2(ac)>1)
                continue;
            double as = sqrt(1 - p2(ac));
            double gx = (X[j] - X[i]) / d, gy = (Y[j] - Y[i]) / d;
            double ogx = -gy, ogy = gx;
            double x, y;
            //cout << ac << as << endl;
            x = X[i] + at * ac * gx + at * as * ogx;
            y = Y[i] + at * ac * gy + at * as * ogy;
            if(ck(x,y,a)){
                //cout << "aa" << ac << "," << as << endl;
                //cout << x << "," << y << "," << a << endl;
                return true;
            }
            x = X[i] + at * ac * gx - at * as * ogx;
            y = Y[i] + at * ac * gy - at * as * ogy;
            if(ck(x,y,a)){
                //cout << "bb" << at << "," << bt << endl;
                //cout << x << "," << y << "," << a << endl;
                return true;
            }
        }
    }
    return false;
}

int main(){
    scanf("%lld%lld", &N, &K);
    fornum(i,0,N){
        scanf("%lld%lld%lld", &X[i], &Y[i], &C[i]);
    }
    double l = 0, r = 1e8;
    //bs(2.4+1e-8);
    //return 0;
    while(l+1e-8<r){
        double c = (l + r) / 2;
        if(bs(c)){
            r = c;
        }else{
            l = c + 1e-8;
        }
    }
    printf("%.12lf", l);
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

type task struct {
	a int
	b int
}

type byB []task

func (a byB) Len() int           { return len(a) }
func (a byB) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byB) Less(i, j int) bool { return a[i].b < a[j].b }

func main() {
	var n int
	fmt.Scan(&n)

	tasks := make([]task, n)
	for i := range tasks {
		fmt.Scan(&tasks[i].a, &tasks[i].b)
	}

	sort.Sort(byB(tasks))

	sum := 0
	ans := "Yes"
	for _, task := range tasks {
		sum += task.a
		if sum > task.b {
			ans = "No"
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long t=1;
    //cin>>t;
    for(long long q=0;q<t;q++){
        long long n;
        cin>>n;
        long long a[n];
        long long b[n+1];
        for(long long i=0;i<=n;i++)
            b[i]=0;
        for(long long i=0;i<n;i++){
            cin>>a[i];
            b[a[i]]++;
        }
        long long ans=0;
        for(long long i=1;i<=n;i++)
            ans+=((b[i]*(b[i]-1))/2);
        for(long long i=0;i<n;i++){
            long long val=ans-((b[a[i]]*(b[a[i]]-1))/2)+(((b[a[i]]-2)*(b[a[i]]-1))/2);
            cout<<val<<"\n";
        }
    }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=998244353;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int n;cin>>n;
        string ans="No";
        while(n){
            if(n%10==7)ans="Yes";
            n=n/10;
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 


Measured memory_bytes: 3644
#include <stdio.h>

int main() {
    int n, m, a, i, soma=0, total;
    scanf("%d %d", &n, &m);
    for(i=0; m>i; ++i){
        scanf("%d", &a);
        soma = soma + a;
    }
    if(soma>n){
        printf("-1");
    }
    else{
    total = n - soma;
    printf("%d", total);
    }
    return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int x;
    cin>>x;

    int ans = 0;
    ans = (x/500)*1000;
    x%=500;
    ans += (x/5)*5;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

X = {}
ans = 0
for i in range(n):
  L = i+A[i]
  R = i-A[i]
  
  if L not in X:
    X[L] = 0
    
  X[L]+=1
  
  if R in X:
    ans += X[R]
    
print(ans)    

Measured memory_bytes: 40412
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = (n-1); i >= (b); i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
int gcd(int a, int b){return b ? gcd(b, a % b): a;}
void yes(){cout<<"Yes"<<endl;return;}
void no(){cout<<"No"<<endl;return;}

int main()
{
    int n;
    cin >> n;
    int b[100], ans[100];
    REP(i,0,n) {
        cin >> b[i];
    }
    REP(i,0,n){
        bool valid = false;
        rREP(j,0,n){
            if (b[j] == 1) {
                b[j] = 0;
                REP(k,j+1,n) {
                    if (b[k] != 0) b[k]--;
                }
                ans[i] = 1;
                REP(k,0,j) {
                    if(b[k] == 0) ans[i]++;
                }
                valid = true;
                break;
            }
        }
        if(!valid) {
            cout << "-1" << endl;
            return 0;
        }
    }
    REP(i,0,n) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
const int dx2[] = { -1, -1, 1, 1 }; const int dy2[] = { -1, 1, 1, -1 };
int main() {
	char c;
	int cell[10][10]={0};
	int x, y, size;
	while (cin>>x>>c>>y>>c>>size){
		
		switch (size)
		{
		case 3:
			REP(i, 4){
				if (0 <= x + dx[i] * 2 && x + dx[i] * 2 <= 9 && 0 <= y + dy[i] * 2 && y + dy[i] * 2 <= 9)
					cell[x + dx[i] * 2][y + dy[i] * 2]++;
			}
		case 2:
			REP(i, 4){
				if (0 <= x + dx2[i]  && x + dx2[i]  <= 9 && 0 <= y + dy2[i]  && y + dy2[i]  <= 9)
					cell[x + dx2[i] ][y + dy2[i]]++;
			}
		case 1:
			REP(i, 4){
				if (0 <= x + dx[i] && x + dx[i] <= 9 && 0 <= y + dy[i] && y + dy[i] <= 9)
					cell[x + dx[i]][y + dy[i]]++;
			}
			cell[x][y]++;
			break;
		}
	}
	int maxb=0;
	int count=0;
	REP(i,10){
		REP(j,10){
			if(cell[i][j]==0)
			count++;
			maxb=max(maxb,cell[i][j]);
		}
	}
	cout<<count<<endl<<maxb<<endl;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, M; cin >> N >> M;
  vector<int> a(M), b(M);
  rep(i, M) cin >> a[i] >> b[i];
  
  vector<int> ans(N,0);
  rep(i, M) {
    ans[a[i]-1]++;
    ans[b[i]-1]++;
  }
  
  rep(i, N) cout << ans[i] << endl;
    
  
}

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

int main() {

  int N, num;
  cin >> N;
  int count = 100;
  for (int i = 0; i < N; i++) {
    cin >> num;
    int j = 0;
    while(num%2==0){
          num /= 2;
          j++;
    }
    count = min(count, j);
  }

  cout << count << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
 
int main(){
    string O,E;
 
    cin >> O >> E;

    for(int i = 0; i < E.size(); i++){
        cout << O[i] << E[i];
    }

    if(O.size() != E.size()){
        cout << O[O.size() - 1] << endl;
    }else{
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll a;
    cin >> a;
    cout << (a + a * a + a * a * a) << endl;
}

Measured memory_bytes: 3192
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdint>

using namespace std;

int main() {
    size_t N;
    scanf("%zu", &N);

    vector<int64_t> A(N), B(N);
    for (size_t i=0; i<N; ++i)
        scanf("%lld %lld", &A[i], &B[i]);

    int64_t res=0;
    for (size_t i=N; i-->0;) {
        if ((A[i]+res) % B[i] == 0) continue;

        res += B[i] - (A[i]+res)%B[i];
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int c(char *p,int d){return ((26+*p-*(p+1))%26==d);}
int a(char *p){return((*p<'a')||(*p>'z'));}

char *decode (char *inbuf, int s) {
  int p = 0;
  while (inbuf[p]){
    if(!a(&inbuf[p])) {
      int t = inbuf[p] + s;

      if (t > 'z')      inbuf[p] = (char)(t - 26);
      else if (t < 'a') inbuf[p] = (char)(t + 26);
      else              inbuf[p] = (char)t;
    }
    p++;
  }
  return (inbuf);
}

int main(s){
  char inbuf[82];
  while(fgets(inbuf,80,stdin)){
    char *p=inbuf;
    while(*p){
      //      s = 0;
      if((c(p,12))&&((c(p+1,3)&&a(p+3))||(c(p+1,7)&&c(p+2,7)&&a(p+4))||(c(p+1,2\
5)&&c(p+2,16)&&a(p+4)))){s='t'-*p;p+=3;break;}
            p++;
    }
    printf("%s",decode(inbuf, s));
  }
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  string S;
  int w;
  cin >> S >> w;

  string s;
  for(int i = 0;i < S.size();i++) {
    if(i % w == 0) s.push_back(S.at(i));
  }

  cout << s << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int i,j,c=0,l,m,n,f=0;
// int m,n;
    cin>>m>>n;
    cin>>a;
    if(a[m]=='-')
        f=1;
    for(i=0; i<m; i++)
    {
        if(a[i]=='-')
            f=0;
    }
    for(i=m+1; i<n+m+1; i++)
    {
        if(f==1&&a[i]>='0'&&a[i]<='9')
            c++;
    }
//    cout<<c<<endl;
    if(f==1&&c==n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input_num = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Console.WriteLine(Lcm(input_num[0], input_num[1]));
        }
        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

}

Measured memory_bytes: 13396
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a%b)

def gcd_list(l):
    # print(l)
    if len(l) == 1:
        return l[0]
    temp = [gcd(l[0],l[1])]
    n = 0
    while(n<len(l)-2):
        # print(temp)
        temp.append( gcd(temp[n], l[n+2]) )
        n = n+1
    # print(temp)
    return(temp[len(temp)-1])

n, start = map(int, input().split(" "))
li = list(map(int, input().split(" ")))
diff = min(li) - start
if(len(li) == 1):
    print(abs(diff))
else:
    li.append(start)
    diff = min(li) - start
    for i in range(len(li)):
        li[i] = li[i] - start - diff
    # print(li)
    print(gcd_list(li))


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  map<string, int> s;
  for (int i = 0; i < n; i++) {
    string ss;
    cin >> ss;
    s[ss]++;
  }
  int max = 0;
  for (auto it = s.begin(); it != s.end(); it++) {
    if (it->second > max) {
      max = it->second;
    }
  }

  vector<string> ans;

  for (auto it = s.begin(); it != s.end(); it++) {
    if (max == it->second) {
      ans.push_back(it->first);
    }
  }

  sort(ans.begin(), ans.end());

  for (auto it = ans.begin(); it != ans.end(); it++) {
    cout << *it << endl;
  }
}

Measured memory_bytes: 26868
def main():
    N,K,*A=map(int, open(0).read().split())
    S=sum(A)
    X=[S]
    for i in range(2,int(S**.5)+1):
        if S%i==0:
            X.append(i)
            if i*i!=S:
                X.append(S//i)
    ans=1
    for x in X:
        B=[a%x for a in A]
        y=sum(B)//x
        z=sum(sorted(B, reverse=True)[y:])
        if z<=K:
            ans=max(ans,x)
    print(ans)

if __name__ == "__main__":
    main()

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

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

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

    // YY は 99までOK
    // MM　は　12　まで
    if (s / 100 > 12 || s / 100 == 0)
    {
        if (s - (s / 100) * 100 > 12)
        {
            cout << "NA" << endl;
        }
        else if (s - (s / 100) * 100 > 0)
        {
            cout << "YYMM" << endl;
        }
        else
        {
            cout << "NA" << endl;
        }
    }
    else if (s / 100 > 0)
    {
        if (s - (s / 100) * 100 > 12 || s - (s / 100) * 100 == 0)
        {
            cout << "MMYY" << endl;
        }
        else if (s - (s / 100) * 100 > 0)
        {
            cout << "AMBIGUOUS" << endl;
        }
        else
        {
            cout << "NA" << endl;
        }
    }
    else
    {
        cout << "NA" << endl;
    }
    return 0;
}

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

int main() {
  char b; cin >>b;
  char ans = 'G';
  if (b=='A') ans = 'T';
  else if (b=='T') ans = 'A';
  else if (b=='G') ans = 'C';
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

// b棟 f階 の r番目 の部屋に v人 が追加で入居したことを示します

int main(){

    // i棟目のj階k号室
    unsigned int n;
    unsigned int i, j, k;
    unsigned int b, f, r;
    int v;
    unsigned int houses[4][3][10] = {0};

    cin >> n;

    for( i = 0; i < n; i++ ){
        cin >> b >> f >> r >> v;
        houses[b-1][f-1][r-1] += v;
    }

    // 表示
    for( i = 0; i < 4; i++ ){
        for( j = 0; j < 3; j++ ){
            for( k = 0; k < 10; k++ ){
                cout << " " <<houses[i][j][k];
            }
            cout << endl;
        }
        if( i != 3 ){
            for( j = 0; j < 20; j++){
                cout << "#";
            }
            cout << endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<vector<long long>> p(3, vector<long long>(N));
	for (auto &row : p) {
		for (auto &x : row) {
			cin >> x;
		}
		sort(row.begin(), row.end());
	}

	vector<long long> s(N, 0);
	for (int i = 0; i < N; i++) {
		s[i] = lower_bound(p[0].begin(), p[0].end(), p[1][i]) - p[0].begin();
	}
	partial_sum(s.begin(), s.end(), s.begin());

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		auto pos = lower_bound(p[1].begin(), p[1].end(), p[2][i]) - p[1].begin();
		if (pos > 0) {
			ans += s[pos - 1];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3440