akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n, q;
  cin >> n >> q;
  vector< priority_queue<int> > v(n);
  rep_i(i, n){
    priority_queue<int> a;
    v.push_back(a);
  }

  int tmp, tmp2, tmp3;
  rep_i(i, q){
    cin >> tmp;
    switch (tmp)
    {
    case 0:
      cin >> tmp2 >> tmp3;
      v[tmp2].push(tmp3);
      break;
    case 1:
      cin >> tmp2;
      if(v[tmp2].empty()){
        break;
      }
      say(v[tmp2].top());
      break;
    case 2:
      cin >> tmp2;
      if(v[tmp2].empty()){
        break;
      }
      v[tmp2].pop();
      break;
    default:
      break;
    }
  }
}


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

bool match(string s, string t)
{
  int n = s.size();
  bool flag = true;
  for (int i = 0; i < n; i++)
  {
    if (s.at(i) == '?' || s.at(i) == t.at(i))
    {
      continue;
    }
    flag = false;
    break;
  }
  return flag;
}

int main()
{
  string S, T;
  cin >> S >> T;
  int n = T.size();
  reverse(S.begin(), S.end());
  reverse(T.begin(), T.end());
  bool flag = false;
  for (int i = 0; i < S.size() - n + 1; i++)
  {
    if (match(S.substr(i, n), T))
    {
      flag = true;
      S.replace(i, n, T);
      break;
    }
  }
  if (!flag)
  {
    cout << "UNRESTORABLE" << endl;
  }
  else
  {
    reverse(S.begin(), S.end());
    replace(S.begin(), S.end(), '?', 'a');
    cout << S << endl;
  }
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    N, A = list(map(int, input().split()))
    X = list(map(int, input().split()))

    # dp[i][j] := 左からi+1枚目までにj枚を選んで、選んだカードの総和がkになるカードの選び方
    dp = [[[0 for _ in range(50*50+1)] for __ in range(N+1)] for ___ in range(N+1)]
    dp[0][0][0] = 1  # 何も選んでない初期値
    for i in range(0, N):
        for j in range(0, N):
            for k in range(50*50+1):
                #if dp[i][j][k] != 0:
                if 1:
                    dp[i+1][j][k] += dp[i][j][k]  # i枚目を選ばない
                if k-X[i] >= 0:
                    dp[i+1][j+1][k] += dp[i][j][k-X[i]]  # i枚目を選んだ

    ans = 0
    for j in range(1, N+1):  # 1枚以上選ぶ必要がある
        ans += dp[N][j][j*A]
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 94940
from itertools import combinations
N,M = map(int,raw_input().split())
lab = [map(float,raw_input().split()) for _ in range(N)]
dist = [[sum((lab[i][k]-lab[j][k])**2 for k in range(3)) for i in range(N)] for j in range(N)]
print max(sum(dist[i][j] for i,j in combinations(ele,2)) for ele in combinations(range(N),M))

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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

ld th[3005];
ld nex[3005];

int inline solve() {
    //input;//,output;
    fix;
    fast_io;
    int n;
    cin >> n;
    th[0] = 1;
    for (int i = 0; i < n; ++i) {
        ld p;
        cin >> p;
        nex[0] = 0;
        for (int j = 0; j <= i; ++j) {
            nex[j] += (1 - p) * th[j];
            nex[j + 1] = p * th[j];
            th[j] = nex[j];
        }
        th[i + 1] = nex[i + 1];
    }
    ld ans = 0;
    for (int i = 0; i <= n; ++i) {
        if(i > n - i) ans += th[i];
    }
    cout << ans;
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
6
2 1 6 3 4 5
2 1 3 4 5 6
6 0
1 7 8 2 4 6
 * */

Measured memory_bytes: 384
import copy

D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D):
    s.append(list(map(int,input().split())))
last = [0]*26
    
ans = 0
md = [0]*26
cand = []
tl = []

for day in range(D):
    for j in range(26):
        last[j] += 1
    
    for k in range(26):
        #k番目を選ぶことによる
        merit = s[day][k]
        merit += last[k] * c[k]
        demerit = 0
        for j in range(26):
            if j != k:
                demerit += c[j] * last[j]
        md[k] = merit - demerit

    #日程の確定
    md2 = sorted(md)
    t = md.index(md2[-1])
    last[t] = 0
    tl.append(t+1)
    
    can = md.index(md2[-2])
    cand.append(can+1)
    #print(t+1)
    

    
#得点計算

def calcans(tl):
    last = [0]*26
    ans = 0
    for day in range(D):
        #満足度プラス計算
        ans += s[day][tl[day]-1]
        for j in range(26):
            last[j] += 1
        last[tl[day]-1] = 0
        #満足度マイナス計算
        minus = 0
        for j in range(26):
            minus += c[j] * last[j]
        ans -= minus
    return ans

normal = calcans(tl)
change = -1

tl2 = copy.deepcopy(tl)
for ii in range(D):
    tl2[ii] = cand[ii]
    challenge = calcans(tl2)
    if normal < challenge:
        normal = challenge
    else:
        tl2[ii] = tl[ii]
        
    
for tlc in tl2:
    print(tlc)

Measured memory_bytes: 9420
#include<cstdio>
#include<cstring>
#define M 400004
#define N 100001
int S,T,a[N],b[M],c[M],e[N],f[N],g[N],h[N],l,n,o[N],p[N],q[N],r,t,x;bool d[M];
inline void add(int u,int v){b[++t]=a[u],c[a[u]=t]=v,d[t]=true,b[++t]=a[v],c[a[v]=t]=u;}
inline bool bfs()
{
    for(memset(h+1,-1,T<<2),q[l=0]=S,r=1;l<r;)for(int u=q[l++],i=a[u];i;i=b[i])if(d[i]&&h[c[i]]<0)h[q[r++]=c[i]]=h[u]+1;
    return h[T]>=0;
}
bool dfs(int u)
{
    if(u==T)return true;
    for(int&i=e[u];i;i=b[i])if(d[i]&&h[c[i]]==h[u]+1&&dfs(c[i]))return d[i]=false,d[i^1]=true;
    return false;
}
int i,j;
int main()
{
    scanf("%d",&n),t=1,x=n;
    for(i=0;i<n;i++)scanf("%d",o+i);
    for(i=0;i<n;i++)scanf("%d",p+i);
    for(i=0;i<n;i++)if(o[i]!=i&&!f[i])for(j=i,T++;!f[j];j=o[j])f[j]=T;
    for(i=0;i<n;i++)if(p[i]!=i&&!g[i])for(j=i,T++;!g[j];j=p[j])g[j]=T;
    for(i=0,T++;i<n;i++)
    if(o[i]==i&&p[i]==i)x--;
    else if(o[i]==i)add(g[i],T);
    else if(p[i]==i)add(S,f[i]);
    else if(o[i]!=p[i])add(g[i],f[i]);
    else add(f[i],g[i]),add(g[i],f[i]);
    while(bfs())for(memcpy(e,a,T+1<<2);dfs(S);)x--;
    return 0&printf("%d\n",x);
}

Measured memory_bytes: 7168
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<cassert>
using namespace std;
long long gcd(long long a,long long b)
{
	if(!b)return a;
	return gcd(b,a%b);
}
int n;
map<long long,bool>mp;
long long a[510][510];
bool used[250050];
int p[250050],cnt;
long long calc(int i,int j)
{
	long long res=1,s;
	if(i>1)res=res/gcd(res,a[i-1][j])*a[i-1][j];
	if(i<500)res=res/gcd(res,a[i+1][j])*a[i+1][j];
	if(j>1)res=res/gcd(res,a[i][j-1])*a[i][j-1];
	if(j<500)res=res/gcd(res,a[i][j+1])*a[i][j+1];
	s=res;
	while(mp[s+1])s+=res;
	mp[s+1]=1;
	if(s+1>1e15)assert(0);
	return s+1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=62500;++i)
	{
		p[++cnt]=2*i+1;
		p[++cnt]=4*i+2;
		mp[2*i+1]=1,mp[4*i+2]=1;
	}
	int st=1,ed=125000;
	for(int i=1;i<=499;i+=2)
		for(int j=1;j<=499;j+=2)
		{
			if((i+j)&3)a[i][j+1]=p[st++],a[i+1][j]=p[st++];
			else a[i][j+1]=p[ed--],a[i+1][j]=p[ed--];
		}
	for(int i=1;i<=500;++i)
		for(int j=2-(i&1);j<=500;j+=2)a[i][j]=calc(i,j);
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)printf("%lld ",a[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 20992
#include<stdio.h>
#define W 10000
#define MAX 100000
int n,k;
int T[MAX];


// 最大積載量 P の k 台のトラックで何個の荷物を積めるか?
int check(int P){
    int i=0;
    for(int j=0; j<k; j++){
        int s=0;
        while(s+T[i] <= P){
            s+=T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    int left=0;
    int right = MAX * W; // 荷物の個数 × 1個当たりの最大重量
    int mid;
    while(right -left>1){
        mid=(left + right) /2;
        int v = check(mid);  // mid == P を決めて何個積めるかチェック
        if(v >= n) right=mid;
        else left = mid;
    }
    
    return right;
}

int main(){
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++){
        scanf("%d",&T[i]);
    }
    int ans = solve();
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> ab(N);
    vector<pair<int,int>> cd(N);
    int x,y;
    for(int i=0;i<N;i++){
        cin >> x >> y;
        ab[i] = make_pair(x,y);
    }
    for(int i=0;i<N;i++){
        cin >> x >> y;
        cd[i] = make_pair(x,y);
    }
    sort(cd.begin(),cd.end());
    vector<vector<bool>> used(2*N+1,vector<bool>(2*N+1,false));
    int ans = 0;
    for(int i=0;i<N;i++){
        int c = cd[i].first,d = cd[i].second;
        pair<int,int> p = make_pair(-1,-1);
        for(int j=0;j<N;j++){
            int a = ab[j].first,b = ab[j].second;
            if(c > a && d > b && used[a][b]==false){
                if(p.second < b){
                    p = make_pair(a,b);
                }
            }
        }
        if(p.first!=-1 && p.second!=-1){
            used[p.first][p.second] = true;
            ans++;
        }
    }
    cout << ans << endl;
}



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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int N,K;
    cin>>N>>K;
    int A[N+1];
    for(int i=1; i<=N; i++)
        cin>>A[i];


    for(int i=K+1; i<=N; i++)
    {
        if(A[i-K]<A[i])
            cout<<"Yes"<<nl;
        else cout<<"No"<<nl;
    }
    return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
 
int main(void) {
    int N, M, X;
    scanf("%d %d %d", &N, &M, &X);

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

    // コスト初期値
    int cost = 0;

    // コスト計算
    int left  = 0;
    int right = 0;

    for(i=0;i<M;i++){
        if(A[i] < X){
            left++;
        }
        else if(X < A[i]){
            right++;
        }
    }
    
    if(left < right) cost = left;
    else cost = right;
    
    // コスト表示    
    printf("%d", cost);
}

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

using namespace std;

int main() {
    long long x,ans=1e18;
    cin>>x;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            
            ans=min(ans,i+(x/i));
        }
    }
    cout<<ans-2;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	ll num[6]; for (int i = 0; i < 6; i++) cin >> num[i];
	ll dif1 = num[0] * (num[2] - num[4]);
	ll dif2 = num[1] * (num[3] - num[5]);
	ll dif_tot = dif1 + dif2;
	if (dif_tot == 0) cout << "infinity" << endl;
	else if ((dif1 > 0 && dif_tot > 0) || (dif1 < 0 && dif_tot < 0)) cout << 0 << endl;
	else { // グラフが交差している場合
		ll num = 2 * (abs(dif1) / abs(dif_tot) + 1) - 1;
		if (abs(dif1) % abs(dif_tot) == 0) num--;
		cout << num << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# D - We Love ABC

S = list(input())
MOD = 10**9 + 7

n_possible = 1 # その場所以前の文字列としてあり得るパターン
A = 0 # その場所以前の文字列におけるA数
B = 0
C = 0

for s in S:
    if s == "A":
        A += n_possible
    elif s == "B":
        B += A
    elif s == "C":
        C += B
    else:
        # X = 3*X + Y
        # この場所の？を (AorABorABCの一部に含めない場合) + (AorABorABCの一部に含める場合)
        C = 3*C + B
        B = 3*B + A
        A = 3*A + n_possible
        n_possible *= 3
    n_possible %= MOD
    A %= MOD
    B %= MOD
    C %= MOD
        
print(C)

Measured memory_bytes: 3956
#include <iostream>
#include <cstring>

using namespace std;

#define DELICIOUS 100
#define DONUTS DELICIOUS

int D, O, N, U, T, S;

int e[110], c[110], h[110], a[110];

int dp1[110][110], dp2[110], dp3[110][110];

int main() {
	cin >> S >> T >> U >> N >> O >> D;
	
	for (int i=0; i<T; i++) cin >> e[i] >> c[i];
	for (int i=0; i<N; i++) cin >> h[i] >> a[i];
	
	memset(dp1, -1, sizeof(dp1));
	dp1[0][0] = 0;
	for (int i=0; i<T; i++) {
		for (int j=i; j>=0; j--) {
			for (int k=0; k<=S; k++) {
				if (dp1[j][k] < 0) continue;
				if (k+e[i]<= S) dp1[j+1][k+e[i]] = max(dp1[j+1][k+e[i]], dp1[j][k] + c[i]);
			}
		}
	}
	
	memset(dp2, 0, sizeof(dp2));
	for (int i=0; i<N; i++) {
		for (int j=0; j<=DONUTS * U; j++) {
			if (j + a[i] <= DONUTS * U) dp2[j + a[i]] = max(dp2[j + a[i]], dp2[j] + h[i]);
		}
	}
	
	memset(dp3, -1, sizeof(dp3));
	dp3[0][S] = 0;
	for (int i=0; i<D; i++) {
		for (int j=0; j<=S; j++) {
			if (dp3[i][j] < 0) continue;
			for (int k=0; k<=j; k++) {
				if (dp1[U][k] < 0) continue;
				int nxj = min(j-k+O, S);
				dp3[i+1][nxj] = max(dp3[i+1][nxj], dp3[i][j] + dp2[ dp1[U][k] ]);
			}
		}
	}
	
	int ans = -1;
	for (int i=0; i<=S; i++) ans = max(ans, dp3[D][i]);
	cout << ans << endl;
	
	return 0;
}

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

int main() {
  int n;
  long long d;
  cin >> n >> d;
  int c = 0;
  vector<pair<long long, long long>> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i).first >> a.at(i).second;
  }
  for(int i = 0; i < n; i++) {
    a.at(i).first *= a.at(i).first;
    a.at(i).second *= a.at(i).second;
  }
  vector<long long> b(n);
  for(int i = 0; i < n; i++) {
    a.at(i).first += a.at(i).second;
    if(a.at(i).first == d * d) c++;
    b.at(i) = pow(a.at(i).first, 0.5);
  }
  for(int i = 0; i < n; i++) {
    if(b.at(i) < d) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 7964
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,n;
    cin>>k>>n;
    int i;vector<int> a(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int key=a[0];
    for(i=0;i<n-1;i++){
        a[i]=a[i+1]-a[i];
    }
    a[n-1]=abs(k-a[n-1])+key;
    cout<<k-(*max_element(a.begin(),a.end()));
    
}


Measured memory_bytes: 1024
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{

  ll n;
  cin >> n;
  ll a[n];
  ll ma = 0;

  for (ll i = 0; i < n; i++)
    cin >> a[i];

  for (ll i = 0; i < n - 1; i++)
  {
    for (ll j = i + 1; j < n; j++)
    {
      ma = max(ma, abs(a[j] - a[i]));
    }
  }

  cout << ma << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static int n;
	static long a, b;
	static long[] h;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {


			n = in.nextInt();
			a = in.nextLong();
			b = in.nextLong();
			h = in.nextLongArray(n);

			int l = 0, r = 1000000009;
			while (r - l > 1) {
				int m = l + (r - l) / 2;

				if (can(m)) {
					r = m;
				} else {
					l = m;
				}
			}
			out.println(r);

		}
	}
	static boolean can(int k) {
		long d = a - b;
		long need = 0;
		for (int i = 0; i < n; i++) {
			long x = h[i];
			x -= k * b;
			if (x <= 0) {
				continue;
			}
			need += (x + d - 1) / d;
		}
		return need <= k;
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

using namespace std;

const int INF = 1 << 30;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  map<pair<int, int>, vector<pair<pair<int, int>, int>>> G;
  for (int i = 0; i < M; i++) {
    int p, q, c;
    cin >> p >> q >> c;
    p--, q--;
    G[make_pair(p, c)].emplace_back(make_pair(make_pair(q, c), 0));
    G[make_pair(q, c)].emplace_back(make_pair(make_pair(p, c), 0));
    G[make_pair(p, c)].emplace_back(make_pair(make_pair(q, 0), 0));
    G[make_pair(q, c)].emplace_back(make_pair(make_pair(p, 0), 0));
    G[make_pair(p, 0)].emplace_back(make_pair(make_pair(q, c), 1));
    G[make_pair(q, 0)].emplace_back(make_pair(make_pair(p, c), 1));
  }
  map<pair<int, int>, int> dist;
  dist[make_pair(0, 0)] = 0;
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      que;
  que.push(make_pair(0, make_pair(0, 0)));
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int u = q.second.first, a = q.second.second;
    for (auto g : G[make_pair(u, a)]) {
      int v = g.first.first, b = g.first.second, c = g.second;
      if (dist.find(make_pair(v, b)) == dist.end() ||
          dist[make_pair(v, b)] > dist[make_pair(u, a)] + c) {
        dist[make_pair(v, b)] = dist[make_pair(u, a)] + c;
        que.push(make_pair(dist[make_pair(v, b)], make_pair(v, b)));
      }
    }
  }
  if (dist.find(make_pair(N - 1, 0)) != dist.end()) {
    cout << dist[make_pair(N - 1, 0)] << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 94504
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    string N;
    int K;
    cin >> N >> K;

    int len=N.size();
    
    vector<vector<vector<ll> > > dp(len+1,vector<vector<ll> >(K+1, vector<ll>(2,0)));
    dp[0][0][0]=1;
    for(int i=0; i<len; i++){
        for(int j=0; j<=K; j++){
            if(N[i]=='0'){
                dp[i+1][j][1]+=dp[i][j][1];
                dp[i+1][j][0]+=dp[i][j][0];
                if(j+1>K)continue;
                dp[i+1][j+1][1]+=dp[i][j][1]*9;
            }else{
                dp[i+1][j][1]+=dp[i][j][1]+dp[i][j][0];
                if(j+1>K)continue;
                dp[i+1][j+1][1]+=dp[i][j][1]*9+dp[i][j][0]*(N[i]-'1');
                dp[i+1][j+1][0]+=dp[i][j][0];
            }
        }
    }
    //cout << dp[1][0][1] << endl;
    cout << dp[len][K][1]+dp[len][K][0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;

int main() {
    // input
    int a, b, q; cin >> a >> b >> q;
    vector<ll> s(a);
    REP (i, a) cin >> s[i];
    vector<ll> t(b);
    REP (j, b) cin >> t[j];
    while (q --) {
        ll x; cin >> x;

        // solve
        ll answer = LLONG_MAX;
        REP (order, 2) {
            REP (p, 2) {
                auto it = lower_bound(ALL(s), x);
                if (it == s.end()) {
                    it = prev(it);
                }
                if (p and it != s.begin()) {
                    it = prev(it);
                }
                ll y = *it;
                REP (q, 2) {
                    auto it = lower_bound(ALL(t), y);
                    if (it == t.end()) {
                        it = prev(it);
                    }
                    if (q and it != t.begin()) {
                        it = prev(it);
                    }
                    ll z = *it;
                    answer = min(answer, abs(y - x) + abs(z - y));
                }
            }
            swap(a, b);
            s.swap(t);
        }

        // output
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
int main(void){
  int a[3];
  int i;
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  int count5=0,count7=0;
  for(i=0;i<3;i++){
    if(a[i]!=5&&a[i]!=7){
      break;
    }
    else if(a[i]==5){
      count5++;
    }
    else if(a[i]==7){
      count7++;
    }
  }
  if(count5==2&&count7==1){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
const fs = require('fs');
const stdin = fs.readFileSync('/dev/stdin', 'utf-8');
const lines = stdin.split("\n");

//const line = lines[0].split(" ");
const N = lines[0].trim();
const D = N.split('');

var sum = 0;
for(var i=0; i < D.length; ++i) {
  sum += Number(D[i]);
}
if(Number(N) % sum == 0) {
  console.log('Yes');
} else {
  console.log('No');
}


Measured memory_bytes: 21064
tmp = input().split()
N = int(tmp[0])
L = int(tmp[1])

s = 0
# if N==2:
#     if L>0:
#         print(L+2-1)
#     elif L<0 and abs(L)>N:
#         print(L+1-1)
#     else:
#         print(L+1-1)
#     exit()

if L>0:
    for i in range(2,N+1):
        s += L+i-1
    print(s)
elif L<0 and L*(-1)>N-1:
    for i in range(1,N):
        s += L+i-1
    print(s)
else:
    for i in range(1,N+1):
        s += L+i-1
    print(s)

Measured memory_bytes: 3064
//AtCoder Regular Contest 66 Problem B
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll UM = 1, MOD = 1e9+7;
ll dp[65][3];
//state 0, not smaller yet => so far a+b == n
//state 1, so far a+b < n but it is still possible to get a+b==n
//state, so far a+b < n and no matter what I do a+b < n
int main(){
    ll n; cin>>n;
    //i know for sure bit 63 is 0 in n
    dp[63][0] = 1;
    dp[63][1] = 0;
    dp[63][2] = 0;

    for(ll i=62; i>=0; i--){
        ll bit_N = (n&(UM<<i));
        /*  0<=a,b<=n 
            a+b<=n 
            mask b is subset of a   */
        if(bit_N == 0LL){
            dp[i][0] = dp[i+1][0] + dp[i+1][1];
            //If i was at state 0, i can pick a=b=0 and stay in state 0
            //If i was at state 1, i can pick a=b=1 and get state 0 (was smaller, now its equal again)
            dp[i][1] = dp[i+1][1];
            //If i was at state 1, i can pick a=1 b=0 and stay in state 1
            dp[i][2] = 3LL*dp[i+1][2] + dp[i+1][1];
            //If i was at state 2, i can pick a=b=0, a=1 b=0, a=1 b=1 and stay in state 2
            //If i was at state 1, i can pick a=b=0 and get state 2
        }else{
            dp[i][0] = dp[i+1][0];
            //If i was at state 0, i can pick a=1 b=0 and stay in state 0
            dp[i][1] = dp[i+1][1] + dp[i+1][0];
            //If i was at state 1, i can pick a=b=1 and stay in state 1
            //If i was at state 0, i can pick a=b=0 and get state 1
            dp[i][2] = 3LL*dp[i+1][2] + 2LL*dp[i+1][1];
            //If i was at state 2, i can pick a=b=0, a=1 b=0, a=1 b=1 and stay in state 2
            //If i was at state 1, i can pick a=b=0, a=1 b=0 and get state 2
        }
        for(int j=0; j<3; j++)dp[i][j] = dp[i][j]%MOD;
    }
    ll ans = (dp[0][0] + dp[0][1] + dp[0][2])%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  cout<<pow(n,3)<<endl;
}

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

int main() {

  int N;
  cin >> N;
  vector<int> Cnt(N,0);

  for(int i=0; i<N-1; i++){
    int a;
    cin >> a;
    Cnt.at(a-1)++;
  }

  for(int i=0; i<N; i++){
    cout <<  Cnt.at(i) << endl;
  }

}

Measured memory_bytes: 4056
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		String ans = "safe";
		if(W >= S){
			ans = "unsafe";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27068
#include<stdio.h>
int main()
{
    long long n,sum=0,T,max,min;
    scanf("%lld",&T);
    for(int i=1; i<=T; i++)
    {
        scanf("%lld ",&n);
        if(i==1)
            max=min=n;
        if(max<n)
            max=n;
        else if(min>n)
            min=n;
        sum=sum+n;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    int N,C;
    SCD2(N,C);
    vector<vector<int> >stc;
    static int rec[100003][31] = {};

    REP(i,N){
        int s,t,c;
        SCD3(s,t,c);
        VI x = {s,t,c};
        stc.PB(x);
    }

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

    REP(i,N){
        FORq(j,stc[i][0],stc[i][1]){
            rec[j][stc[i][2]] = 1;
        }
    }

    int M = 0;
    REP(i,100002){
        int m = 0;
        REP(j,31){
            m += rec[i][j];
        }
        M = max(M,m);
    }

    PRINTD(M);
}

Measured memory_bytes: 18352
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}

int main() {
    ll x, y;
    cin >> x >> y;
    if (abs(x - y) <= 1) {
        cout << "Brown\n";
    }
    else {
        cout << "Alice\n";
    }
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define f first
#define s second
#define pb push_back
signed main()
{
 string s,t;
 cin>>s>>t;
 int n1=s.size();
 int n2=t.size();
 if(n2==n1+1)
 {
     string p=t.substr(0,n1);
     if(p==s)
        cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;
 }
 else
    cout<<"No"<<endl;

}


Measured memory_bytes: 3632
import java.util.*;
public class Main {
	int a, b;

	boolean ball(int num) {
		int before = a + b;
		if(num > a)      a = num;
		else if(num > b) b = num;
		if(a + b == before) {
			return(false);
		}
		return(true);
	}

	void doIt() {
		Scanner stdIn = new Scanner(System.in);
		int limit = stdIn.nextInt();
		for(int r = 0; r < limit; r++) {
			boolean flag = true;
			a = b = Integer.MIN_VALUE;
			int[] input = new int[10];
			for(int c = 0; c < 10; c++) {
				input[c] = stdIn.nextInt();
			}
			for(int c = 0; c <10; c++) {
				flag = ball(input[c]);
				if(!flag)break;
			}
			System.out.println((flag) ? "YES" : "NO");
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}
}

Measured memory_bytes: 18300
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		m[a]++
	}

	ans := 0
	for k := range m {
		t := m[k-1] + m[k] + m[k+1]
		if ans < t {
			ans = t
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 8064
x, n = gets.split.map(&:to_i)
p x and return if n == 0
arr = gets.split.map(&:to_i)

unless arr.index(x)
  p x
  return
end

a = x + 1
b = x - 1
while true
  p b and return if arr.index(b).nil?
  p a and return if arr.index(a).nil?

  a += 1
  b -= 1
end


Measured memory_bytes: 14324
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

int a[100010] = {};

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

  int N;
  cin >> N;
  REP(i, N) {
    int x;
    cin >> x;
    a[x]++;
  }
  ll ans = 1;
  if (N % 2 == 1 && a[0] != 1) ans = 0;

  for (int i = 1; i < N; i++) {
    if (i % 2 != N % 2) {
      if (a[i] != 2) ans = 0;
      ans *= 2;
      ans %= 1000000007;
    } else {
      if (a[i] != 0) ans = 0;
    }
  }

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


Measured memory_bytes: 640
//============================================================================
// Name        : abc131_b.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 B - Bite Eating

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 200 点

 問題文
 N 個のリンゴがあります。これらはそれぞれリンゴ 1、リンゴ 2、リンゴ 3、...、リンゴ N と呼ばれており、
 リンゴ i の「味」は L+i-1 です。「味」は負になることもありえます。
 また、1 個以上のリンゴを材料として、アップルパイをつくることができます。
 その「味」は、材料となったリンゴの「味」の総和となります。
 あなたはこれらのリンゴを全て材料として、アップルパイをつくる予定でしたが、
 おなかがすいたので 1 個だけ食べることにしました。勿論、食べてしまったリンゴはアップルパイの材料にはできません。
 つくる予定だったアップルパイとできるだけ同じものをつくりたいので、
 N 個のリンゴ全てを材料としてできるアップルパイの「味」と、
 食べていない N-1 個のリンゴを材料としてできるアップルパイの「味」の差の絶対値ができるだけ小さくなるように、
 食べるリンゴを選ぶことにしました。
 このようにして選ばれたリンゴを食べた時、食べていない N-1 個のリンゴを材料としてできるアップルパイの「味」を求めてください。
 なお、この値は一意に定まることが証明できます。

 制約

 ・2 <= N <= 200
 ・-100 <= L <= 100
 ・入力は全て整数である。
 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

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

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, l;
	cin >> n >> l;

	// aji = l+i-1 であり，aji=0 のリンゴがあればそれを選び，
	// なければ aji の絶対値が小さいリンゴを選ぶ．
	// aji=l+i-1= (1<=i<=n)
	// => l+1-1 <= aji <= l+n-1 <=> l <= aji <= l+n-1
	// なので， l>0 なら aji=l が最善，l+n-1<0 なら aji=l+n-1 が最善，
	// それ以外なら aji=0 を満たすリンゴがあるので aji=0 が最善．
	int aji_picked = 0;
	if (l > 0) {
		aji_picked = l;
	} else if (l + n - 1 < 0) {
		aji_picked = l + n - 1;
	}

	// aji は min = l, max = l+n-1 であり，公差1とすれば総和が求められる
	cout << ((n * (l + l + n - 1)) / 2 - aji_picked) << endl; // prints [!!!Hello World!!!]
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i > 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int a;
  string s;
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << endl;
  return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let points = read_vec::<i32>();
    let (sx,sy,tx,ty) = (points[0],points[1],points[2],points[3]);
    let dx = (tx-sx).abs();
    let dy = (ty-sy).abs();
    let mut ans = Vec::new();
    ans.push(create_chars('U', dy));
    ans.push(create_chars('R', dx));
    ans.push(create_chars('D', dy));
    ans.push(create_chars('L', dx));
    ans.push("L".to_string());
    ans.push(create_chars('U', dy+1));
    ans.push(create_chars('R', dx+1));
    ans.push("D".to_string());
    ans.push("R".to_string());
    ans.push(create_chars('D', dy+1));
    ans.push(create_chars('L', dx+1));
    ans.push("U".to_string());
    println!("{}",ans.connect(""));
}
fn create_chars(c:char,time:i32)->String{
    let mut v = Vec::new();
    for _ in 0..time { v.push(c)}
    v.into_iter().collect::<String>()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n; cin>>n;
    if(n<=111)
    {
        cout<<"111"<<endl;
        return 0;
    }
    if(n>111 && n<=222)
    {
        cout<<"222"<<endl;
        return 0;
    }
    if(n>223 && n<=333)
    {
        cout<<"333"<<endl;
        return 0;
    }
    if(n>333 && n<=444)
    {
        cout<<"444"<<endl;
        return 0;
    }
    if(n>444 && n<=555)
    {
        cout<<"555"<<endl;
        return 0;
    }
    if(n>555 && n<=666)
    {
        cout<<"666"<<endl;
        return 0;
    }
    if(n>666 && n<=777)
    {
        cout<<"777"<<endl;
        return 0;
    }
    if(n>777 && n<=888)
    {
        cout<<"333"<<endl;
        return 0;
    }
    if(n>888 && n<=999)
    {
        cout<<"999"<<endl;
        return 0;
    }
}


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

using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    // vector<bool> check(N, false);
    bool which = true;
    for(int i = 0; i<N; i++){
        cin >> A.at(i);
        if(A.at(i) % 2 != 0){
            // check.at(i) = true;
        }else{
            if(A.at(i) % 3 == 0 || A.at(i) % 5 == 0){
                // check.at(i) = true;
            }else{
                which = false;
            }
        }
    }

    if(which){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }

}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入

int main(){
    int X;
    cin >> X;
    int A,B;
    for(ll i=1;i<1000;i++){
        for(ll j=-100;j<1000;j++){
            if(pow(i,5)-pow(j,5)==X){
                A=i;
                B=j;
            }
            
        }
    }

    cout << A << " " << B << endl;
    
    
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 200004;
const int MOD =998244353
 ;
const int INV2 = (MOD+1)/2;
int k,x,y;


     signed main(){
         string s,t;int a[('z'-'a')+1]={},b[('z'-'a')+1]={};
         cin>>s>>t;
         for(int i=0;i<s.size();i++)a[s[i]-'a']++;
         for(int i=0;i<t.size();i++)b[t[i]-'a']++;
         sort(a,a+('z'-'a')+1);sort(b,b+('z'-'a')+1);
         for(int i=0;i<('z'-'a')+1;i++)if(a[i]!=b[i]){
              cout<<"No"<<endl;
              return 0;
         }
         cout<<"Yes"<<endl;
         return 0;


}


        


Measured memory_bytes: 776
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;

  cin >> N;

  if(N % 4 == 0 || N % 7 == 0){
    ans++;
  }else{
    int n = N;
    while(n > 0){
      n = n-4;
      if(n % 7 == 0) {
        ans++;
        break;
      }
    }
  }
  if(ans>0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;

  }

  
}


Measured memory_bytes: 256
/// In the name of God
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 1e5 + 10;
int a[maxn];
main(){
    IOS;
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];
    int mx = 0;
    sort(a, a + n);
    ll sum = 0;
    for(int i=0; i<n; i++){
        if(a[i] > sum * 2)
            mx = i;
        sum += a[i];
    }
    cout << n - mx << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n, m, k;
    cin >> n >> m >> k;
    vector <int> a(n), b(m);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }   

    vector <int> bp = {0};
    for (int i = 0; i < m; ++i)
        bp.app(bp.back()+b[i]);

    int ptr = m;

    int cur = 0, ans = 0;
    for (int i = 0; i <= n; ++i) {
        if (i)
            cur += a[i-1];

        if (cur > k)
            break;

        while (bp[ptr] + cur > k)
            --ptr;

        ans = max(ans,i+ptr);
    }   
    cout << ans << endl;
}

Measured memory_bytes: 8452
#include <iostream>

using namespace std;

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

    if(x < 600)
        cout << 8 << '\n';
    else if(x < 800)
        cout << 7 << '\n';
    else if(x < 1000)
        cout << 6 << '\n';
    else if(x < 1200)
        cout << 5 << '\n';
    else if(x < 1400)
        cout << 4 << '\n';
    else if(x < 1600)
        cout << 3 << '\n';
    else if(x < 1800)
        cout << 2 << '\n';
    else if(x < 2000)
        cout << 1 << '\n';

    return 0;
}


Measured memory_bytes: 3592
import * as readline from "readline";

/* ここに処理を書く */
const main = (args: any[]) => {
  const num: number = args[0];
  const numStr: string = num.toString();
  
  const numArray: string[] = numStr.split('');
  let matchCount = 0;
  for(let i=0;i<numArray.length-1;i++){
  	if(numArray[i] === numArray[i+1]) matchCount++;
    else matchCount = 0;
    
    if(matchCount>=2) {
      console.log("Yes");
      return;
    }
  }
  console.log("No");
  return;
};

/* 標準入力処理 */
const stdin = (main: Function) => {
  const args: any[] = [];
  const reader = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });
  reader.on("close", function() {
    main(args);
  });
  reader.on("line", function(line: any) {
    if (line === "") {
      reader.close();
    }
    line.split(" ").forEach((arg: any) => {
      args.push(isNaN(arg) ? arg : Number(arg));
    });
  });
};
/* 実行 */
stdin(main);


Measured memory_bytes: 7628
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


char c;

int main(){
	cin >> c;
	
	cout << (char)(c+1) << endl;
	
	return 0;
}

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

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

    //good luck kittu!
    int k, a, b;
    cin>>k>>a>>b;
    int x, y;
    x = (a+k-1)/k; 
    y = b/k;
    x = y - x + 1;
    if(x>=1) cout<<"OK\n";
    else cout<<"NG\n";
    return 0;
}

Measured memory_bytes: 3640
# include<bits/stdc++.h>
using namespace std;
const int MAX=2e5+5;
int n,ans;
int a[MAX];
map<int,int> ma;
bool use[MAX];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	  scanf("%d",&a[i]),++ma[a[i]];
	sort(a+1,a+1+n);
	for(int i=31;i>=1;--i)
	  {
	  	for(int j=1;j<=n;++j)
	  	  if(ma[a[j]])
		  {
	  	  	int x=(1<<i)-a[j];
	  	  	if(x<=0) break;
	  	  	if(x!=a[j])
	  	  	{
	  	  		if(ma[x]) ++ans,--ma[x],--ma[a[j]];
			}
			else
			{
				if(ma[x]>=2) ++ans,ma[x]-=2;
			}
		  }
	  }
	return printf("%d",ans),0;
}


Measured memory_bytes: 39168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll s[205000];
ll a[205000];
int main()
{
	ll n,k,x;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[i]=x;
	}
	int g=1,h=0,flag=0;
	while(k--)
	{
		s[g]++;
		if(flag)
		{
			h++;
		}
		g=a[g];
		if(s[g]==2)
		{
			flag=1;
		}
		if(s[g]==3)
		{
			break;
		}
	}
	if(k>0)
	{
		k%=h;
	}
	for(int i=0;i<k;i++)
	{
		g=a[g];
	}
	cout<<g<<endl;
	return 0;	
}

Measured memory_bytes: 6720
N, M = map(int,input().split())
num = [1]*N
red = [False]*N
red[0] = True
for i in range(M):
  x, y = map(int,input().split())
  if red[x-1]:
    red[y-1] = True
  num[x-1] -= 1
  num[y-1] += 1
  if num[x-1] == 0:
    red[x-1] = False
print(red.count(True))

Measured memory_bytes: 4596