akhauriyash/Code-Regression huggingface dataset:
#ある池に生えている藻類は、以下のように成長します。
#西暦 i 年になる瞬間に生えている重さの合計を xi グラムとすると、 i≥2000 に対して、以下の式が成り立ちます:
#xi+1=rxi−Dr,
#D, x2000 が与えられます。x2001, ..., x2010 を計算し、順に出力してください。

r, D, x = map(int, input().split())

for i in range(10):
    x = r*x - D
    print(x)

Measured memory_bytes: 38424
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef long long int integer;

int main() {
  integer n, m;
  while (cin >> n >> m and n) {
    vector<pair<integer,integer> > p(n);
    REP(i, n) {
      integer D, P;
      cin >> D >> P;
      p[i].second = D, p[i].first = -P;
    }
    sort(p.begin(), p.end());
    
    REP(i, n) {
      integer dec = min(p[i].second, m);
      p[i].second -= dec;
      m -= dec;
    }

    integer ans = 0;
    REP(i, n) {
      ans += -p[i].first * p[i].second;
    }
    cout << ans << endl;
  }
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    string n;
    cin >> n;
    int ans = 0;
    REP(i,n.size()){
        ans += n[i]-48;
    }
    if(ans%9==0)COUT("Yes");
    else COUT("No");
}


Measured memory_bytes: 3728
n,h=map(int,input().split())
p=[]
for i in range(n):
    a,b=map(int,input().split())
    p.append([a,0])
    p.append([b,1])

p=sorted(p,key=lambda x:-x[0])

i=0
ans=0
while h>0:
    if p[i][1]==1:
        h-=p[i][0]
        ans+=1
        i+=1
    else:
        ans-=(-h//p[i][0])
        break

print(ans)


Measured memory_bytes: 40876
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

ll dp[nn][3], a[nn], b[nn], c[nn];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        cin>>n;
        rep(i, n)
            cin>>a[i]>>b[i]>>c[i];

        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];

        for(i=1;i<n;i++)
        {
            dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
            dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i];
            dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
        }

        ll ans = 0;
        rep(i, 3)
            ans = max(ans, dp[n-1][i]);
        cout<<ans<<endl;

    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 13312
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a;*/


	/*int h, n;
	cin >> h >> n;
	int s = 0;
	int a;
	rep(i, n) {
		cin >> a;
		s += a;
	}
	if (s >= h)puts("Yes");
	else puts("No");*/


	/*int n, k;
	cin >> n >> k;
	vector<ll>h(n);
	rep(i, n)cin >> h[i];
	ll ans = 0;
	int mi = min(n, k);
	sort(all(h));
	rep(i, n - mi) {
		ans += h[i];
	}
	cout << ans;*/


	ll h;
	cin >> h;
	ll ans = 1;
	h /= 2;
	ll enemy = 2;
	while (h > 0) {
		ans += enemy;
		enemy *= 2;
		h /= 2;
	}
	cout << ans;
	return 0;
}

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

int main(){
    string c;
    cin>>c;
    vector<string> vv(5);
    vv[0]="a";
    vv[1]="e";
    vv[2]="i";
    vv[3]="o";
    vv[4]="u";
    bool ans=false;
    for (int i=0; i<5; i++){
        if (c==vv[i]) ans=true;
    }
    if (ans) cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define maxn 106
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,mx;
int cnt[maxn];
int main()
{
    n=read();
    for(int i=1;i<=n;i++)
    {
        int x=read();
        mx=max(mx,x);
        cnt[x]++;
    }
    for(int i=mx;i>(mx+1)/2;i--)
    {
        if(cnt[i]<2)
        {
            puts("Impossible");
            return 0;
        }
    }
    if(mx&1&&cnt[(mx+1)/2]!=2)  puts("Impossible");
    else if(!(mx&1)&&cnt[mx/2]!=1)  puts("Impossible");
    else puts("Possible");
    return 0;
}

Measured memory_bytes: 256
r,g,b,n=gets.split.map(&:to_i)

x,y,z=[r,g,b].sort

count=0

xs=0
while xs<=n
  ys=0
  while ys+xs<=n
    count+=1 if (n-(ys+xs))%z==0
    ys+=y
  end
  xs+=x
end

puts count

Measured memory_bytes: 1788
#import sys

#input = sys.stdin.readline

#import heapq

def main():
#    h,w,a,b = map(int, input().split())
    n,k = map(int, input().split())
    h = list(map(int,input().split()))
    count=0
    for i in range(n):
        if h[i]>=k:
            count+=1

    print(count)
#    for i in range(h):
#            print(aaa)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11908
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const ll INF = 1e17;

int main(){
  optimize_cin();
  int h, w, m; cin >> h >> w >> m;
  vector<int> countx(h, 0), county(w, 0);
  set<P> s;
  rep(i, m){
    int x, y; cin >> x >> y;
    --x; --y;
    ++countx[x];
    ++county[y];
    s.emplace(x, y);
  }

  int maxx = 0, maxy = 0;
  rep(i, h) chmax(maxx, countx[i]);
  rep(i, w) chmax(maxy, county[i]);

  ll ans = maxx + maxy;
  vector<int> goodx, goody;
  rep(i, h) if(countx[i]==maxx) goodx.pb(i);
  rep(i, w) if(county[i]==maxy) goody.pb(i);

  for(auto x : goodx){
    for(auto y : goody){
      if(s.count(P(x, y))) continue;
      cout << ans << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 23776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	int cnt = 0;
	rep1(i, n) {
		string s = to_string(i);
		if (s.size() % 2)cnt++;
	}

	cout << cnt << endl;

}

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

#define ll long long
#define ar array
 
using namespace std;


int main() {
	
	int k;
	
	cin>>k;
	
	if(k%2==0){
		k=(k/2)*(k/2);
		cout << k <<endl;
	}else{
		k=((k-1)/2)*(((k-1)/2)+1);
		cout << k <<endl;
	}
	
   	return 0;
}
   

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

int main(){
	int N, i, m = 0, sum = 0;
	scanf("%d", &N);
	int *p = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &p[i]);
		if(m < p[i]){
			m = p[i];
		}
		sum += p[i];
	}
	printf("%d\n", sum - m / 2);
	return 0;
}

Measured memory_bytes: 128
import * as fs from 'fs';

//in
// SAT
//out
// 1
const main = (inp: string) => {
    const weeks: { [s: string]: number } = {
        SUN: 7,
        MON: 6,
        TUE: 5,
        WED: 4,
        THU: 3,
        FRI: 2,
        SAT: 1
    }

    console.log(weeks[inp]);

};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7372
#include<string>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include <iomanip>
#include<cmath>
#include<stack>
#include <algorithm>
#include<cstdio>
#include <cstring>
#include <iostream>
#define inf 0n7fffffff
using namespace std;
int main ()
{
    int a,b,c;
    int m[15]={0};
    scanf("%d%d%d",&a,&b,&c);
    m[a]++;
    m[b]++;
    m[c]++;
    if(m[5]==2&&m[7]==1)
        printf("YES");
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, T = [int(x) for x in input().split()]
    t = [int(x) for x in input().split()]

    ans = 0
    for i in range(1, N):
        ans += min(t[i] - t[i - 1], T)


    print(ans + T)
    
    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 25336
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
 
int main() {
	// your code goes here
	long double a,b,c;
	cin>>a>>b>>c;
  long double eps=1.0E-14;
	if(sqrt(a)+sqrt(b)+eps<sqrt(c)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    map<ll, string> ma = {
        {25, "Christmas"},
        {24, "Christmas Eve"},
        {23, "Christmas Eve Eve"}, 
        {22, "Christmas Eve Eve Eve"},
    };
    int D;
    cin >> D;
    cout << ma[D] << endl;
    return 0;
}


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

int main() {
    std::string s;
    
    std::cin >> s;

    if ( s == "SUN" ) {
        std::cout << 7 << std::endl;
    }
    else if ( s == "MON" ) {
        std::cout << 6 << std::endl;
    }
    else if ( s == "TUE" ) {
        std::cout << 5 << std::endl;
    }
    else if ( s == "WED" ) {
        std::cout << 4 << std::endl;
    }
    else if ( s == "THU" ) {
        std::cout << 3 << std::endl;
    }
    else if ( s == "FRI" ) {
        std::cout << 2 << std::endl;
    }
    else if ( s == "SAT" ) {
        std::cout << 1 << std::endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
    unsigned long long a, b, c;
    scanf("%llu %llu %llu", &a, &b, &c);
    unsigned long long ab = a * b * 4;
    unsigned long long x = 1;
    while ((x + 1) * (x + 1) <= ab) x ++;
    if (x * x == ab){
        a+b+x < c ? puts("Yes"):puts("No");
    } else {
        c > x + a + b?puts("Yes"):puts("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 
typedef long long ll;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define DBGV(v,n) forn(i,n) cout << v[i] << " "; cout << endl
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl

vector <int> v[100005];
vector <int> dp(100005,0);
vector <bool> visto(100005,false);

void DFS(int n)
{
	visto[n]=true;
	for(auto u : v[n])
	{
		if(!visto[u]) DFS(u);
		dp[n]=max(dp[n],dp[u]+1);
	}
}
 
int main()
{ 
	FIN;
	
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif
	
	int n, m;
	cin >> n >> m;
	forn(i,m)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y); 
	}
	forn(i,n+1)
	{
		if(visto[i]==false) DFS(i);
	}
	int ans = 0;
	forn(i,n+1) {ans=max(ans,dp[i]);}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8192
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		int[] arr = new int[100];
		while(true) {
			String s = r.readLine();
			if(s == null) break;
			arr[Integer.valueOf(s) - 1]++;
		}
		int max = 0;
		for(int a : arr) {
			max = Math.max(a, max);
		}
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < arr.length; i++) {
			if(arr[i] == max) {
				list.add(i + 1);
			}
		}
		Collections.sort(list);
		for(int l : list) {
			System.out.println(l);
		}
	}
}

Measured memory_bytes: 9104
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    for (int i = 9; i >= 1; i--) {
        if (N % i == 0) {
            if (N / i <= 9){
                cout << "Yes" << endl;
                break;
            } else {
                cout << "No" << endl;
                break;
            }
            
        } else {
            continue;
        }
    }
    // cout << "No" << endl;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

const int MAXN = 1e5 + 5;

ll n, m, par[MAXN], vis[MAXN];
vector<ll>adj[MAXN];

void bfs(ll source)
{
	vis[source] = 1;
	queue<ll>q;
	q.push(source);
	while(!q.empty())
	{
		ll p = q.front();
		q.pop();
		for(auto it : adj[p])
		{
			if(vis[it]) continue;
			vis[it] = 1;
			par[it] = p;
			q.push(it);
		}
	}
}

int main()
{
	FAST_IO;

 	cin >> n >> m;
 	for(int i=0;i<m;i++)
 	{
 		ll u, v;
 		cin >> u >> v;
 		adj[u - 1].pb(v - 1);
 		adj[v - 1].pb(u - 1);
 	}   
 	for(int i=0;i<n;i++) par[i] = -1;
 	bfs(0);
 	for(int i=1;i<n;i++)
 	{
 		if(par[i] == -1) 
 		{
 			cout << "No" << endl;
 			return 0;
 		}
 	}
 	cout << "Yes" << endl;
 	for(int i=1;i<n;i++) cout << par[i] + 1 << endl;
    return 0;
}

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

int main() {
  int s,a,b;
  cin >> s;
  a = s/100;
  b = s%100;
  
  
  if(a > 12 || a == 0){
    if(b > 0 && b < 13) cout << "YYMM";
    else cout << "NA";
  }
  else{
    if(b > 12 || b == 0) cout << "MMYY";
    else cout << "AMBIGUOUS";
  }
 
  
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define inf (0x3f3f3f3f)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define Rep(i, a) for (int i = 0; i < a; ++ i)
#define For(i, a, b) for (int i = a; i <= b; ++ i)
#define Forr(i, a, b) for (int i = a; i >= b; -- i)
#define Travel(i, x) for (int i = head[x]; i; i = nxt[i])

using namespace std;

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

template<class T>inline T read(T &_) {
	T __ = getchar(), ___ = 1; _ = 0;
	for (; !isdigit(__); __ = getchar()) if (__ == '-') ___ = -1;
	for (; isdigit(__); __ = getchar()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
	return _ *= ___;
}

template<class T>inline bool chkmax(T &_, T __) { return _ < __ ? _ = __, 1 : 0; }
template<class T>inline bool chkmin(T &_, T __) { return _ > __ ? _ = __, 1 : 0; }

inline void proStatus() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>());
}

const int N = 5e3 + 7;

PII a[N], b[N];

char s[N], t[N];

int n, ans = inf, c, d;

int main() {

	scanf("%d%s%s", &n, s + 1, t + 1);

	For(i, 1, n) { 
		if (s[i] != s[i - 1]) 
			a[++ c] = mp(i, s[i] ^ 48);
		if (t[i] != t[i - 1]) 
			b[++ d] = mp(i, t[i] ^ 48);
	}

	For(i, 0, n) { 
		if ((a[1].y + b[1].y + i) & 1) continue;
		int res = 0, now = 1;
		while (now <= c) { 
			int ps = a[now].x, pt = now + i <= d ? b[now + i].x : n + 1;
			res += abs(pt - ps), ++ now;
		}
		while (now + i <= d) res += n + 1 - b[now + i].x, ++ now;
		For(j, 1, i) {
			int pt = j <= d ? b[j].x : n + 1; 
			res += pt - 1; 
		}
		chkmin(ans, res);
	}
	swap(c, d), swap(a, b);
	For(i, 0, n) { 
		if ((a[1].y + b[1].y + i) & 1) continue;
		int res = 0, now = 1;
		while (now <= c) { 
			int ps = a[now].x, pt = now + i <= d ? b[now + i].x : n + 1;
			res += abs(pt - ps), ++ now;
		}
		while (now + i <= d) res += n + 1 - b[now + i].x, ++ now;
		For(j, 1, i) {
			int pt = j <= d ? b[j].x : n + 1; 
			res += pt - 1; 
		}
		chkmin(ans, res);
	}

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

	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int res = 0;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    int l, r;
    cin >> l >> r;
    res += r - l + 1;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>

using std::vector;
using std::cout;
using std::cin;

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

int main() {
    int64_t a,b,c;
    char temp;
    cin >> a >> temp >> b >> temp >> c;

    int64_t sm = a * 1000000 + b * 10000 + c * 10;
    if (sm <= 2019040300) {
        cout << "Heisei";
        return 0;
    }

    cout << "TBD";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  cout << n * n * n << endl;
  cout<<fixed;
  return 0;
}


Measured memory_bytes: 892
X,N=map(int,input().split())
hazusu=list(map(int,input().split()))
kouho=100
ans=0
for i in reversed(range(-2,102)):
    if i in hazusu:
        continue
    d=abs(X-i)
    if d<=kouho:
        kouho=d
        ans=i
print(ans)

Measured memory_bytes: 61920
fun main(args: Array<String>) {
    val (N, value) = readLine()!!.split(" ").map(String::toInt)
    for (n10000 in 0..N) {
        for (n5000 in 0..(N - n10000)) {
            val n1000 = N - n10000 - n5000
            if (n10000 * 10000 + n5000 * 5000 + n1000 * 1000 == value) {
                print(listOf(n10000, n5000, n1000).joinToString(" "))
                return
            }
        }
    }
    print(listOf(-1, -1, -1).joinToString(" "))
}

Measured memory_bytes: 38032
#include<bits/stdc++.h>
using namespace std;
long long n,a[1000],ans,m;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=m;i++) ans+=a[i];
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int maze[25][25];
int mark[25][25];
int wayx[] = {0, 0, 1, -1};
int wayy[] = {1, -1, 0, 0};
inline long long read()
{
	char c=getchar();long long flag=1,ans=0;;
	while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return (ans*flag);
}
struct node{
    int i, j;
    node(int a, int b) {
        i = a;
        j = b;
    }
};
int bfs(int x, int y, int ex, int ey, int h, int w) {
    memset(mark, 0, sizeof(mark));
    queue<node> qe;
    qe.push(node(x, y));
    mark[x][y] = 1;
    int i = 0, j = 0;
    while(!qe.empty()) {
        i = qe.front().i, j = qe.front().j;
        qe.pop();
        for(int n = 0; n < 4; ++ n) {
            if(i + wayx[n] >= 0 && i + wayx[n] < h && j + wayy[n] >= 0 && j + wayy[n] < w) {
                if(!mark[i + wayx[n]][j + wayy[n]] && maze[i + wayx[n]][j + wayy[n]]) {
                    mark[i + wayx[n]][j + wayy[n]] = mark[i][j] + 1;
                    qe.push(node(i + wayx[n], j + wayy[n]));
                }
            }
        }
    }
    // for(int _i = 0; _i < h; ++ _i) {
    //     for(int _j = 0; _j < w; ++ _j) {
    //         cout << mark[_i][_j] << " ";
    //     }
    //     cout << endl;
    // }
    return mark[ex][ey] - 1;
}
int main() {
    int h = read(), w = read();
    // cin >> h >> w;
    memset(maze, 0, sizeof(maze));
    // getchar();
    for(int i = 0; i < h; ++ i) {
        // string input;
        // cin >> input;
        for(int j = 0; j < w; ++ j) {
            char s;
            scanf("%c", &s);
            // if(input[j] == '.') 
            if(s == '.')maze[i][j] = 1;
        }
        getchar();
    }
    int ans = 0;
    for(int i = 0; i < h; ++ i) {
        for(int j = 0; j < w; ++ j) {
            for(int k = 0; k < h; ++ k) {
                for(int l = 0; l < w; ++ l) {
                    if(maze[i][j] && maze[k][l]) {
                        ans = max(bfs(i, j, k, l, h, w), ans);
                        // cout << ans << endl;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    int count = 1;
    for (int i = 0; i < N; i++) {
        if (A.at(i) == count) {
            count++;
        }
        else {
            ans ++;
        }
    }
    if (count != 1) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>

using namespace std;

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

  int ans = 0;
  string alphabet = "abcdefghijklmnopqrstuvwxyz";

  for(int i = 1; i < S.length() - 1; i++) {
    string a = S.substr(0, i);
    string b = S.substr(i);
    map<char, int> ma, mb;
    for (int j = 0; j < a.length(); j++) {
      ma[a[j]] = 0;
    }
    for (int j = 0; j < b.length(); j++) {
      mb[b[j]] = 0;
    }

    int cnt = 0;
    for (int j = 0; j < alphabet.length(); j++) {
      auto ita = ma.find(alphabet[j]);
      auto itb = mb.find(alphabet[j]);
      if (ita != ma.end() && itb != mb.end()) {
        cnt++;
      }
    }
    
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=3e6+5;
const double pi=3.14159265358979323846;
ll f[maxn];
ll C[30][30];
void table_C(){
    memset(C,0,sizeof(C));
    C[0][0]=1;
    for(int i=1;i<=28;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++) C[i][j]=C[i-1][j]+C[i-1][j-1];
    }
}
void table()
{
    f[0]=1;
    for(ll i=1;i<maxn;i++) f[i]=f[i-1]*i%mod;
}
 
void exgcd( ll a,ll b, ll &x,ll &y,ll &d )
{
    if(!b){ x=1;y=0;d=a; }
    else
    {
        exgcd(b,a%b,x,y,d);
        int t=x;
        x=y;
        y=t-(a/b)*y;
    }
}
ll solve(ll a,ll b) // 求a mod b 下的逆元如ax ≡ 1 mod p 求x 则 solve(a,p)
{
    ll x,y,d;
    exgcd(a,b,x,y,d);
    ll t=b/d;
     x=(x%t+t)%t;//最小正整数解
    return x;
}
ll CC( ll n,ll m,ll p )
{
    if(n<m) return 0;
    return f[n]*(solve(f[m]*f[n-m]%p,p)%p)%p;
}

ll ktl( ll n ) //卡特兰数 
{
	return ( CC(n*2,n,mod)-CC(2*n,n+1,mod)+mod )%mod; 
}

ll h( ll n,ll m ,ll t=1) // n个数中选择 m 个至少相邻 t 个的数，
{
	return CC(n-t*(m-1),m,mod);
} 

ll qpow( ll x,ll y )
{
	ll res=1;
	while( y )
	{
		if( y&1 ) res=res*x%mod;
		y>>=1;
		x=x*x%mod;
	}
	return res;
}

ll dp[maxn];

int main()
{
    int n;
    cin>>n;
    
    dp[0]=1;
    for( int i=1;i<=n;i++ )
    {
    	for( int j=3;i-j>=0;j++ )
    	{
    		dp[i]=(dp[i]+dp[i-j])%mod;
    	}
    }
    cout<<dp[n];
    
}



Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(abs(a-b)<=d && abs(b-c)<=d){
    	printf("Yes\n");
    }
    else if(abs(a-c)<=d){
    	printf("Yes\n");
    }
	 else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = [int(input()) for _ in range(n)]
a.insert(0, 0)

left = [0] * (n+1)
right = [0] * (n+2)
for j in range(1, n):
   left[j] = max(left[j-1], a[j])

right[n+1] = 0
for j in reversed(range(2, n+1)):
   right[j] = max(right[j+1], a[j])

for i in range(1, n+1):
   print(max(left[i-1], right[i+1]))


Measured memory_bytes: 15656
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


def main() -> None:
    n, k = [int(s) for s in input().split()]
    h = []
    for i in range(n):
        h += [int(input())]
    h.sort()

    mn = sys.maxsize
    for i in range(n - k + 1):
        cnt = h[i + k - 1] - h[i]
        mn = min(mn, cnt)

    print(mn)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7384
let k = stdin.ReadLine() |> int64

let rec repsept a count =
    if count > k then -1L
    else 
        let a' = (a * 10L + 7L) % k
        if a'= 0L then count
        else repsept a' (count+1L)

repsept 0L 1L |> stdout.WriteLine

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

signed main() {
int N, K;
cin >> N >> K;

vector<int> cnt(201000, 0);
int A;
for( int i = 0; i < N; i++ ){
cin >> A;
cnt.at(A)++;
}

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

int syurui = 0;
for( int i = 0; i < 201000; i++ ){
if ( cnt.at(i) > 0 ) syurui++;
}
 
int ans = 0;

if( syurui <= K ){
cout << 0 << endl;
return 0;
}else{
for( int i = 0; i < 201000; i++ ){
if( cnt.at(i) > 0){
syurui--;
ans += cnt.at(i);
if ( syurui == K ) break;
}
}
}
cout << ans << endl;
}



Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int n = Integer.parseInt(input1[0]);
        int k = Integer.parseInt(input1[1]);
        String[] input2 = br.readLine().split(" ");
        int[] numbers = new int[n];
        int ans = 0;
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(input2[i]);
            if(numbers[i] >= k){
                ans++;
            }
        }
        
        out.println(ans);
        out.close();
        
    }
}

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

#define REP(i, N) for (int i = 0; i < N; ++i)

int N;
vector<int> A;
vector<bool> chosen;

int main() {

    cin >> N;

    A.resize(N);
    REP(i, N) cin >> A[i];

    chosen.assign(N, false);

    int xr = 0;
    REP(i, N) xr ^= A[i];

    int res = 0;

    for (int i = 31; i >= 0; --i) {
        if ((xr & (1 << i)) == 0) continue;
        ++res;
        bool valid = false;
        REP(j, N) {
            if (not chosen[j] and ((A[j] & (1 << i)) != 0) and ((A[j] & ((1 << i) - 1)) == 0)) {
                chosen[j] = true;
                A[j]--;
                valid = true;
                xr ^= A[j];
                break;
            }
        }
        // REP(i, N) cout << A[i] << " \n"[i == N - 1];
        if (not valid) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << res << endl;

}

Measured memory_bytes: 640
/*
cat <<EOF >mistaken-paste
*/

#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 300000
#define M_MAX 200000

ull n, m;
ull q;


sll smax (sll x, sll y) {
	return (x > y) ? x : y;
}


sll a[N_MAX];
sll cover[N_MAX + 1];
ull num[N_MAX + 1];

ull solve () {
	sll i, j, ki, li;
	// ull result = 0;
	sll result = 0;
	double dresult = 0;
	// ull maybe = 0;
	sll maybe = 0;
	// ull sum = 0;
	sll sum = 0;
	sll item;
	ull *dpcell;

	for (i = 0; i < n; i++) {
		num[a[i]]++;
	}
	for (i = 1; i <= n; i++) {
		sll end = i + 1;
		sll begin = end - num[i];

		cover[smax(begin, 1)]++;
		cover[end]--;
	}
	for (i = 1; i <= n; i++) {
		sum += cover[i];
		cover[i] = sum;

		if (cover[i] > 0) result++;
	}

	while (q--) {
		sll x, y;
		scanf("%lld%lld", &x, &y);
		ull prev = a[x - 1];
		a[x - 1] = y;


		sll pleft = prev - --num[prev];
		if (pleft > 0 && --cover[pleft] == 0) {
			result--;
		}

		sll pright = y - num[y]++;
		if (pright > 0 && ++cover[pright] == 1) {
			result++;
		}

		printf("%llu\n", n - result);
	}

	return 0;
}

int32_t main (void) {
	int32_t i, j;
	int32_t x, y;

	scanf("%llu", &n, &m);
	scanf("%llu", &q);
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}

	solve();

	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    while(tt--)
    {
        int n;
        cin >> n;
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            if(n%i==0)
                ans--;
            ans=ans+n/i;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
typedef pair<int,int> P;

bool myCompareX(P lhs,P rhs){
	return lhs.first < rhs.first;
}

bool myCompareYgreater(P lhs,P rhs){
	return lhs.second > rhs.second;
}

int main()
{
	int n;
	vector<P> redPoints;
	vector<P> bluePoints;
	int pairNumber = 0;
	cin>>n;
	for(int i = 0; i < n; i++){
		int a,b;
		cin>>a>>b;
		redPoints.push_back(P(a,b));
	}

	sort(redPoints.begin(),redPoints.end(),myCompareYgreater);

	for(int i = 0; i < n; i++){
		int a,b;
		cin>>a>>b;
		bluePoints.push_back(P(a,b));
	}

	sort(bluePoints.begin(),bluePoints.end(),myCompareX);

	for(auto itrBlue = bluePoints.begin(); itrBlue != bluePoints.end(); itrBlue++){
		int index = 0;
		for(auto itrRed = redPoints.begin(); itrRed != redPoints.end(); itrRed++){
			if(itrRed->first < itrBlue->first && itrRed->second < itrBlue->second){
				redPoints.erase(redPoints.begin() + index);
				pairNumber++;
				break;
			} 
			index++;
		}
	}
	cout<<pairNumber<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

struct edge{ll to,cost;};

vector<edge> G[100000];
ll N,M,C;
ll A[200000],B[200000],D[200000];
ll d[100000];
ll cost[100000];//??????????????´???????????¨?¶????????????????
const ll INF =0xffffffffffffff;
ll rank[100000];
ll cntd[100000];
P did[100000];
ll nowcost;
int main()
{
	scanf("%lld%lld%lld",&N,&M,&C);
	nowcost=0;
	rep(i,M){
		scanf("%lld%lld%lld",&A[i],&B[i],&D[i]);
		A[i]--;
		B[i]--;
		nowcost+=D[i];
		G[A[i]].pb(edge{B[i],D[i]});
		G[B[i]].pb(edge{A[i],D[i]});
	}
	priority_queue<P,vector<P>,greater<P> > q;
	fill(d,d+N,INF);
	d[0]=0;
	q.push(P(0,0));
	while(!q.empty()){
		P p=q.top();
		q.pop();
		ll x=p.sc;
		if(d[x]<p.fr) continue;
		rep(i,G[x].size()){
			edge e=G[x][i];
			if(d[e.to]>d[x]+e.cost){
				d[e.to]=d[x]+e.cost;
				q.push(P(d[e.to],e.to));
			}
		}
	}
	rep(i,N){
		did[i]=P(d[i],i);
	}
	sort(did,did+N);
	rank[did[0].sc]=0;
	cntd[0]=did[0].fr;
	ll cnt=0;
	rep1(i,N-1){
		if(did[i].fr>did[i-1].fr) cnt++;
		rank[did[i].sc]=cnt;
		cntd[cnt]=did[i].fr;
	}
	cnt++;
	ll ans=nowcost;
	rep(i,M){
		if(rank[A[i]]>rank[B[i]]){
			cost[rank[A[i]]]+=D[i];
		}
		else{
			cost[rank[B[i]]]+=D[i];
		}
	}
	rep(i,cnt){
		nowcost-=cost[i];
		ans=min(ans,C*cntd[i]+nowcost);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 25444
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int i = 0;

		while(sc.hasNext()){
			String str = sc.next();

			if(str.equals("END_OF_TEXT")){
				break;
			}else if(str.equalsIgnoreCase(W)){
				i++;
			}
			}
		System.out.println(i);
	}
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


ll solve(ll n){
	ll ret = 0;
	while(n){
		ret += n%10;
		n /= 10;
	}
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;

	cin >> N;

	ll cur = 9, cnt = 0;
	while(cur <= N){
		chmax(ans, solve(cur));
		cur = cur * 10ll + 9ll;
		cnt++;
	}
	cur /= 10;
	while( cur <= N ){
		chmax(ans, solve(cur));
		cur = cur + pow(10, cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;


int main(){
  int n,m;
  cin >> n >> m;
  map<ll,ll> ma;
  vector<ll> a(n);
  ll kotae=0;
  ll tmp=0;
  ll tmp2=1;
  REP(i,n){
    ll b;
    cin >> b;
    a[i]=(tmp+b)%m;
    tmp=a[i];
    ma[a[i]]++;
    if(a[i]%m==0){
      kotae++;
    }
  }
  ll k=ma.size();
  REPEACH(i,ma){
    if(i.second>=2){
      kotae+=i.second*(i.second-1)/2;
    }
  }
  cout << kotae << endl;
}

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


int main() {
    ll n;
    cin >> n;
    unordered_map<ll,ll> m;
    vector<ll> v(n);
    rep(i,n){
        int in;
        cin >> in;
        v[i] = in;
        m[in]++;
    }
    ll sum =0;
    for(auto a:m){
        sum += a.second*(a.second-1)/2;
    }
    for(int i=0;i<n;i++){
        cout << sum - (m.at(v[i]))*(m.at(v[i])-1)/2 + (m.at(v[i])-1)*(m.at(v[i])-2)/2 << endl;
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 9160
h, w = gets.split.map(&:to_i)
a = (1..h).map { gets.split.map(&:to_i) }
b = (1..h).map { Array.new(w) }
(0..h-1).each {|i| b[i][0] = 1 - a[i][0] }
(0..w-1).each {|j| b[0][j] = 1 - a[0][j] }
(1..h-1).each do |i|
  (1..w-1).each do |j|
    if a[i][j] == 1
      b[i][j] = 0
    else
      b[i][j] = [b[i-1][j-1], b[i-1][j], b[i][j-1]].min + 1
    end
  end
end
p b.map {|row| row.max }.max ** 2


Measured memory_bytes: 38456
#include<cstdio>

int n, q;
int cnt[100001], b[100000], c[100000];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        cnt[a]++;
    }
    scanf("%d", &q);
    long ans = 0;
    for (int i = 1; i < 100001; i++) ans += cnt[i] * i;
    for (int i = 0; i < q; i++) scanf("%d %d", &b[i], &c[i]);
    for (int i = 0; i < q; i++) {
        cnt[c[i]] += cnt[b[i]];
        ans += (c[i] - b[i]) * cnt[b[i]];
        cnt[b[i]] = 0;
        printf("%ld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2896
N=int(input())
A=list(map(int,input().split()))

dp=[0 for i in range(N)]
dp[0]=1000

for i in range(N-1):
    if dp[i]>=dp[i+1]:
        dp[i+1]=dp[i]
    for j in range(i+1,N):
        if A[j]>A[i]:
            test=A[j]*(dp[i]//A[i])+dp[i]%A[i]
            if test>=dp[j]:
                dp[j]=test

print(dp[-1])


Measured memory_bytes: 65340
#include<stdio.h>
int main(void)
{
	int n,m,d,i,j,l,g=0;
	char a[300][300];
	scanf("%d %d %d",&n,&m,&d);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}
	if(n>=1 && n<=100 && m>=1 && m<=100 && d>=2 && d<=100){
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				l=0;
				while(l<=d-1){
					if(a[i+l][j]=='.' && l!=d-1){
						l++;
					}
					else if(a[i+l][j]=='.' && l==d-1){
						g+=1;
						l++;
					}
					else{
						l=100;
					}
				}
				l=0;
				while(l<=d-1){
					if(a[i][j+l]=='.' && l!=d-1){
						l++;
					}
					else if(a[i][j+l]=='.' && l==d-1){
						g+=1;
						l++;
					}
					else{
						l=100;
					}
				}
			}
		}
		printf("%d\n",g);
	}
	return 0;
}


Measured memory_bytes: 2704
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int d=sc.nextInt();
  double dd=Math.pow(d,2);
  int count=0;
  for(int i=0;i<n;i++){
    double a=Math.pow(sc.nextInt(),2)+Math.pow(sc.nextInt(),2);
    if(a<=dd){
      count++;
    }
  }
  System.out.println(count);
}
}

Measured memory_bytes: 61124
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<string.h>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<map>
#include<set>
#include<bitset>
#include<iostream>
#include<sstream>
#include<numeric>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
#define drep(i,n) for(int i = n-1; i >= 0; i--)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y);
#define mins(x,y) x = min(x,y);
#define pb push_back
#define snuke srand((unsigned)clock()+(unsigned)time(NULL))
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

const int MX = 100005, INF = 1000000000, mod = 1000000009;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-9;
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 }; //<^>v

// a > b
int gcd(int a, int b) {
	if (b > 0) {
		return gcd(b, a % b);
	} else {
		return a;
	}
}
int main() {
	int n;
	int x;
	cin >> n >> x;
	int d;
	cin >> d;
	d = abs(x - d);
	for (int i = 1; i < n; i++) {
		int t;
		cin >> t;
		t = abs(x - t);
		if (d < t) {
			int tmp = d;
			d = t;
			t = tmp;
		}
		d = gcd(d, t);
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
		public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b =sc.nextInt();
        int k =sc.nextInt();
				int i = 0;
				int j = 0;
				if(b - a + 1 <= 2 * k - 1){
						for(;a + i <= b;i++){
						System.out.println(a + i);
						}
				}
				else{
						for(;j <= k-1;j++){
								System.out.println(a + j);
						}
						for(j = 0;j <= k-1;j++){
								System.out.println(b - k + 1 + j);
						}
				}
    }
}


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

int main() {
  int n; cin >> n;
  map<char, int> ss;

  rep(i, n) {
    char c; cin >> c;
    ss[c];
  }

  if (ss.size() == 3) p("Three");
  else p("Four");
}


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

int main(void){
	string s;
	cin>>s;
	int n = s.size();
	int arr[n];
	arr[0] = (s[0]=='R');
	for (int i = 1; i < n; ++i){
		arr[i] = s[i]=='R'?arr[i-1]+1:0;
	}
	int ans = arr[0];
	for (int i = 0; i < n; ++i){
		ans = max(ans, arr[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

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

using namespace std;

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

    rep(i,n){
        if(t[i]=='?'){
            cout << 'D';
        }else{
            cout << t[i];
        }
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 3724
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
template<const LL mod> struct MI{
	LL a;
	MI operator + (const MI & b) {
		MI res{a + b.a};
		if(res.a >= mod) res.a -= mod;
		return res;
	}
	MI operator - (const MI & b) {
		MI res{a - b.a};
		if(res.a <= 0) res.a += mod;
		return res;
	}
	MI operator * (const MI & b) {
		return MI{a * b.a % mod};
	}
	MI operator / (const MI & b) {
		return MI{a * fastpo(b.a, mod - 2, mod) % mod};
	}
};
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const LL LIM = 1e18;
int main() {
	int n;
	cin >> n;
	LL res = 1;
	bool big = false;
	bool zero = false;
	for(int i = 1; i <= n; i++) {
		LL x;
		cin >> x;
		if(x == 0) {
			zero = true;
		}else if(res >= (LIM + x) / x) {
			big = true;
		}
		res *= x;
	}
	if(zero) res = 0;
	else if(big) res = -1;
	cout << res << endl;
}






Measured memory_bytes: 3640
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
dy=[1, 0, -1, 0]
dx=[0, 1, 0 ,-1]

from collections import deque
d=[[-1]*w for _ in range(h)]
queue=deque()
queue.append((0,0))
d[0][0]=1

while queue:
    y,x=queue.popleft()
    for d_y, d_x in zip(dx,dy):
        new_y=y+d_y
        new_x=x+d_x
        if new_y<0 or h<=new_y or new_x<0 or w<=new_x:
            continue
        if s[new_y][new_x]=='.' and d[new_y][new_x]==-1:
            d[new_y][new_x]=d[y][x]+1
            queue.append((new_y, new_x))

ans=0
black=0
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            black+=1

print(h*w-black-d[h-1][w-1] if d[h-1][w-1]!=-1 else -1)


Measured memory_bytes: 3316
object Main extends App {

  import scala.io.StdIn._
  import scala.math._


  val Array(n, d) = readLine.trim.split(' ').map(_.toInt)
  val clue = Array.tabulate(n){_ ⇒
    val Array(t, f) = readLine.trim.split(' ').map(_.toInt)
    Clue(t, f)
  }.sorted
  var passengers = 0L
  var floor = 1
  var time = 0
  var sumTime: Long = 0L
  var useStair: Boolean = false
  for (c ← clue if !useStair){
    if (c.floor - 1 + floor - 1 <= c.time - time) {
      //println(s"put ${passengers} passengers to Ground At ${time + floor - 1}")
      sumTime += (floor - 1) * passengers
      passengers = 0L
      time += floor - 1
      floor = 1
    }
    if (math.abs(c.floor - floor) <= c.time - time && passengers < d){
      //println(s"take ${c} passenger (whole ${passengers + 1}) At ${c.time}")
      sumTime += (c.time - time) * passengers
      passengers += 1
      time = c.time
      floor = c.floor
    } else {
      //println(s"can't take $c passenger, elevator ${floor} floor, ${passengers} passengers at ${time} ")
      useStair = true
    }
  }
  sumTime += passengers * (floor - 1)
  println(
    if (useStair) -1
    else sumTime
  )

  case class Clue(time: Int, floor: Int) extends Ordered[Clue] {
    override def compare(that: Clue): Int = time.compare(that.time)
  }

  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 160896
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);

        // Alice,Bob got poit.
        int a = 0;
        int b = 0;
        boolean isAlice = true;
        for (int i = list.size()-1; i >= 0; i--){
            if (isAlice) {
                a += list.get(i);
            } else {
                b += list.get(i);
            }
            isAlice = !isAlice;
        }
        // 出力
        System.out.println(a-b);
    }
}


Measured memory_bytes: 21844