akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 500000;

struct Node {int location, p, l, r;};
struct Point {int id, x, y;};

int np = 0;
Node T[N];
Point P[N];
vi ans;

bool lessX(const Point &a, const Point &b) { return a.x < b.x;}
bool lessY(const Point &a, const Point &b) { return a.y < b.y;}

int makekDTree(int l, int r, int d) {
	if (l >= r) return -1;
	if (d%2 == 0) sort(P+l, P+r, lessX);
	else sort(P+l, P+r, lessY);
	int mid = (l+r)/2;
	int t = np++;
	T[t].location = mid;
	T[t].l = makekDTree(l, mid, d+1);
	T[t].r = makekDTree(mid+1, r, d+1);
	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int d) {
	int i = T[v].location, x = P[i].x, y = P[i].y;
	if (sx <= x && x <= tx && sy <= y && y <= ty) ans.push_back(P[i].id);
	if (d%2 == 0) {
		if (T[v].l != -1 && sx <= x) find(T[v].l, sx, tx, sy, ty, d+1);
		if (T[v].r != -1 && x <= tx) find(T[v].r, sx, tx, sy, ty, d+1);
	}
	else {
		if (T[v].l != -1 && sy <= y) find(T[v].l, sx, tx, sy, ty, d+1);
		if (T[v].r != -1 && y <= ty) find(T[v].r, sx, tx, sy, ty, d+1);
	}
}

int main() {
	int n; cin >> n;
	rep(i, n) {
		scanf("%d %d", &P[i].x, &P[i].y);
		P[i].id = i;
	}
	int root = makekDTree(0, n, 0);
	int q; cin >> q;
	rep(i, q) {
		int sx, tx, sy, ty;
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0);
		sort(ans.begin(), ans.end());
		for(auto i : ans) printf("%d\n", i);
		printf("\n");
	}
}



Measured memory_bytes: 16504
N = int(input())
L_L = [int(x) for x in input().split()]

L_L.sort()
ans = 0

for i in range(N):
    _li = L_L[i]
    for j in range(i+1, N):
        _lj = L_L[j]
        if _li == _lj:
            continue
        for k in range(j+1, N):
            _lk = L_L[k]
            if _li == _lk or _lj == _lk:
                continue
            if _li + _lj > _lk:
                ans += 1


print(ans)


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

int main(void){
char str[1005],command[1100],*com,*temp,*p;
int i,j,q,a,b,tmp;
scanf("%s",str);
scanf("%d",&q);
for(i=0;i<q;i++){
scanf("\n%[^\n]",command);
com=strtok(command," ");
if( strcmp(com,"print")==0){
	temp=strtok(NULL," ");a=atoi(temp);
	temp=strtok(NULL," ");b=atoi(temp);
	for(j=a;j<=b;j++){
	printf("%c",str[j]);
	}printf("\n");
   }else if( strcmp(com,"reverse")==0){
	temp=strtok(NULL," ");a=atoi(temp);
	temp=strtok(NULL," ");b=atoi(temp)-1;
	for(j=0;j<=(b-a)/2;j++){
		tmp=str[a+j];str[a+j]=str[b-j+1];str[b-j+1]=tmp;
	}
   }else if( strcmp(com,"replace")==0){
	temp=strtok(NULL," ");a=atoi(temp);
	temp=strtok(NULL," ");b=atoi(temp);
	p=strtok(NULL," ");
	for(j=a;j<=b;j++){
		str[j]=*p;
		p++;
	}
   }
  }
	return 0;
}

Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[3],k;cin>>a[0]>>a[1]>>a[2]>>k;sort(a,a+3);
  	while(k--){a[2]+=a[2];}
  	cout<<a[0]+a[1]+a[2];
}

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

typedef pair<int, int> P;

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

    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    ll five = 10;
    while(n/five > 0){
        ans += n/five;
        five *= 5;
    }

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

Measured memory_bytes: 384
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


X, Y =  map(int, sys.stdin.readline().split())

cnt = 0
while True:
    if X > Y:
        print(cnt)
        exit()
    X *= 2
    cnt += 1


Measured memory_bytes: 64492
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;

/** Prbolem1077 : The Great Summer Contest **/
int main()
{
	int a, b, c, d, e, f;
	while (cin>>a>>b>>c>>d>>e>>f, a||b||c||d||e||f) {
		int X = a+d, Y = b+e, Z = c+f;
		
		int ans=0;
		rep(i, 3) {
			int TX = X-i, TY = Y-i, TZ = Z-i;
			int t = i;
			if (TX>=0 && TY>=0 && TZ>=0)
				ans = max(ans, i+TX/3+TY/3+TZ/3);
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    int n;
    cin >> n;
    vector<int> d(n);
    for (int &e : d)
    {
        cin >> e;
    }

    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << "\n";
    return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>to[2000005];
vector<int>regist;

void dfs(int v,int parent){
    for(int u : to[v]){
        if(u==parent){
            continue;
        }
        else{
            regist.at(u)=regist.at(u)+regist.at(v);
            dfs(u,v);
        }
    }
}


int main(){
    int N,Q;
    cin>>N>>Q;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);   
    }
    regist.resize(N);
    for(int i=0;i<Q;i++){
        int p,q;
        cin>>p>>q;
        regist.at(p-1)=regist.at(p-1)+q;
    }
    dfs(0,-1);
    for(int i=0;i<N;i++){
        cout<<regist.at(i)<<" ";
    }
}

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

int main(void) {
    int N,X,T; cin >> N >> X >> T;
    int ans;
    if(N%X==0) ans = (N/X)*T;
    else ans = (N/X+1)*T;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n][n];
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    ll g[1 << n] = {};
    for(int bit = 0; bit < (1 << n); bit++){
        rep(i,n){
            for(int j = i + 1; j < n; j++){
                if((bit & (1 << i)) && (bit & (1 << j))) g[bit] += a[i][j];
            }
        }
    }
    vector<ll> dp(1 << n, -INF);
    dp[0] = 0;
    for(int used = 0; used < (1 << n); used++){
        int unused = used ^ ((1 << n) - 1);
        for(int use = unused; use > 0; use = (use - 1) & unused){
            dp[used | use] = max(dp[used | use], dp[used] + g[use]);
        }
    }
    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		Set<Integer> s = new HashSet<Integer>();
		for ( int i=0; i<k; i++ ) {
			int d = sc.nextInt();
			for ( int j=0; j<d; j++ ) {
				int a = sc.nextInt();
				s.add(a);
			}
		}
		System.out.println(n-s.size());
	}
}


Measured memory_bytes: 46568
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Array
import Data.Array.IO
import Data.Array.MArray
import Control.Monad
import Data.IORef

main::IO()
main=do
  hwc<-getLine
  let h:w:[]=map read (words hwc)::[Int]
  ar<-getter h w
  ref1<-newIORef []
  ref2<-newIORef []
  forM_ [(i,j)|i<-[1..h],j<-[1..(w-1)]] (\ (i,j) -> do
                                                    v<-readArray ar (i,j)
                                                    u<-readArray ar (i,j+1)
                                                    case (mod v 2) of
                                                          0 -> return ()
                                                          1 -> do
                                                                val<-readIORef ref1
                                                                writeIORef ref1 ((i,j):val)
                                                                writeArray ar (i,j) (v-1)
                                                                writeArray ar (i,j+1) (u+1)
                                                                return () )
  forM_ [1..(h-1)] (\ i -> do
                            v<-readArray ar (i,w)
                            u<-readArray ar (i+1,w)
                            case (mod v 2) of
                              0 -> return ()
                              1 -> do
                                    val<-readIORef ref2
                                    writeIORef ref2 ((i,w):val)
                                    writeArray ar (i,w) (v-1)
                                    writeArray ar (i+1,w) (u+1)
                                    return ())
  hori_moves<-readIORef ref1
  virt_moves<-readIORef ref2
  print (length (hori_moves++virt_moves))
  forM_ (reverse hori_moves) horiz_move
  forM_ (reverse virt_moves) virt_move

horiz_move::(Int,Int)->IO ()
horiz_move (i,j) = let i_s = show  i in
                   let j_s = show  j in
                   let jj_s = show (j+1) in
                   putStr (concat [i_s," ",j_s," ",i_s," ",jj_s,"\n"])

virt_move::(Int,Int)->IO ()
virt_move (i,j) = let i_s = show  i in
                   let j_s = show  j in
                   let ii_s = show (i+1) in
                   putStr (concat [i_s," ",j_s," ",ii_s," ",j_s,"\n"])

getter::Int->Int->IO (IOArray (Int,Int) Int)
getter h w = do
  d<-forM [1..h] (\ _ -> getLine)
  let dat = map read (concat (map words d)) ::[Int]
  ar<-newListArray ((1,1),(h,w)) dat
  return ar

Measured memory_bytes: 43388
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(r);
    auto ans = (r < 1200)
            ?"ABC"
            :(r < 2800)
            ?"ARC"
            :"AGC";
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

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

    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC\n";
    } else {
        cout << "ABC\n";
    }

    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n > 0){
    if (n & 1) res = res * x;
    x = x * x;
    n = n >> 1;
  }
  return res;
}

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

  vector<ll> ps;
  vector<ll> v;
  for (ll i = -120; i <= 120; ++i) {
    ll p = mpow(i, 5);
    ps.push_back(p);
    v.push_back(i);
  }

  ll a = 0;
  ll b = 0;
  bool ok = false;
  for (ll i = 0; i < v.size(); ++i) {
    a = v[i];
    b = ps[i] - x;
    for (ll j = 0; j < v.size(); ++j) {
      if (ps[j] == b) {
        ok = true;
        b = v[j];
        break;
      }
    }
    if (ok) break;
  }

  cout << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

int main(){
  int N;
  std::cin >> N;
  for (int i=1; i<10; i++)
    if (N%i==0 and N/i<10){
      std::cout << "Yes" << std::endl;
      return 0;
    }
  std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys 
import copy
input = sys.stdin.readline

n = int(input())
x = list(map(int, input().split()))
xx = sorted(x)

l = xx[(n-1)//2]
r = xx[n//2]
mid = (l+r)/2

for i in range(n):
    if x[i] >= mid:
        print(l)
    else:
        print(r)


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

using namespace std;

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

int main() {
	int ai, ao, at, aj, al, as, az;
	cin >> ai >> ao >> at >> aj >> al >> as >>az;
	ll ans  = 0;
	ans += (ai / 2) * 2;
	ans += ao;
	ans += (aj / 2) * 2;
	ans += (al / 2) * 2;
	ll ans2 = 0;
	if (aj > 0 && al > 0 && ai > 0) {
		ai--;
		aj--;
		al--;
		ans2 += 3;
		ans2 += (ai / 2) * 2;
		ans2 += ao;
		ans2 += (aj / 2) * 2;
		ans2 += (al / 2) * 2;
	}
	
	cout << max(ans, ans2) << endl;
	return 0;
}

Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n,k;
    cin>>n>>k;
    int s=0;
    int A[n];
    for(int i=0;i<n;i++)cin>>A[i];

    sort(A,A+n);
    for(int i=0;i<k;i++)s+=A[i];

    cout<<s;

    

return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-------------------------------------------------


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

    ll x, y;
	cin >> x >> y;
	int cnt = 1;
	while(x * 2 <= y) x *= 2,cnt++; 
	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
def inputs():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    for d in range(D):
        sd = list(map(int, input().split()))
        s.append(sd)
    t = []
    for d in range(D):
        t.append(int(input()))
    return D, c, s, t


def score(D, c, s, t):
    S = 0
    last = [0 for _ in range(26)]
    score_by_day = []

    for day in range(1, D+1):
        ctype = t[day-1]-1
        S += s[day-1][ctype]
        last[ctype] = day

        S -= sum(c[i]*(day-last[i]) for i in range(26))
        score_by_day.append(S)

    return score_by_day


if __name__ == "__main__":
    D, c, s, t = inputs()

    sbd = score(D, c, s, t)
    for sc in sbd:
        print(sc)


Measured memory_bytes: 9520
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
	    int n = Integer.parseInt(line);
	    
	    for(int i=0;i<n;i++){
	        Count count = new Count();
	        while(count.isOver()){
	            line = br.readLine().toString();
	            if(line.equals("HIT")){
	                count.hit();
	            }else if(line.equals("OUT")){
	                count.out();
	            }else if(line.equals("HOMERUN")){
	                count.homerun();
	            }
	        }
    		System.out.println(count.score);
	    }
	}
    public static class Count{
        public int[] runner;
        public int out;
        public int score;
        Count(){
            runner = new int[3];
            out = 0;
            score = 0;
        }
        public boolean isOver(){
            if(out>=3){
                return false;
            }
            return true;
        }
        public void hit(){
            if(runner[2] == 1){
                score++;
            }
            for(int i=2;i>=1;i--){
                runner[i] = runner[i-1];
            }
            runner[0] = 1;
        }
        public void homerun(){
            for(int i=0;i<3;i++){
                if(runner[i] == 1){
                    score++;
                    runner[i] = 0;
                }
            }
            score++;
        }
        public void out(){
            out++;
        }
    }
}

Measured memory_bytes: 24196
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

int readint()
{
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9')
	{
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}

const int maxn=100005;
int n;
class EDGE{
public:
	int from,to,m;
};
bool cmp(EDGE x,EDGE y){
	return x.m<y.m;
}
ll ans;
vector<EDGE>edge;
vector<pii>X,Y;
int f[maxn];

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

void Union(int x,int y){
	x=Find(x);y=Find(y);
	if(x!=y)f[x]=y;
}

int main(){
	scanf("%d",&n);
	REP(i,n){
		int x,y;
		scanf("%d%d",&x,&y);
		X.push_back(mk(x,i));
		Y.push_back(mk(y,i));
		f[i]=i;
	}
	sort(X.begin(),X.end());
	rep(i,X.size()-1)
	edge.push_back((EDGE){X[i].se,X[i+1].se,X[i+1].fi-X[i].fi});
	sort(Y.begin(),Y.end());
	rep(i,Y.size()-1)
	edge.push_back((EDGE){Y[i].se,Y[i+1].se,Y[i+1].fi-Y[i].fi});
	sort(edge.begin(),edge.end(),cmp);
	rep(i,edge.size()){
		EDGE x=edge[i];
		if(Find(x.from)==Find(x.to))continue;
		Union(x.from,x.to);
		ans+=x.m;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 7528
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0; i<s.size(); i++)
		if(s[i]=='C')
			for(int j=i+1; j<s.size(); j++)
				if(s[j]=='F')
					{cout<<"Yes";return 0;}
	cout<<"No";
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, m,n) for (int i = m; i < (int)(n); i++)
int main(){
double N,M; cin>>N>>M; vector<double>price(N); double sum=0;
  rep(i,N){cin>>price.at(i); sum+=price.at(i);}
  sort(price.begin(),price.end());
   reverse(price.begin(),price.end());
  if(price.at(M-1)<sum/(4.0*M)){cout<<"No"<<endl;}
  else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[105];
int n;
int main()
{
    cin>>n;
    a[0]=2;
    for(int i=1;i<=n;i++)
      a[i]=a[i-1]*2+2;
    cout<<a[n]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=1e5;
const long inf=1e9;
int main(){
	int N; cin>>N;
	if(N / 10 == 9 || N % 10 == 9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int, int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int reverse01(int i){
    return (1 - i) * (1 - i); 
}

int main(){
    int N; cin >> N;
    string s;
    cin >> s;
    // hitsuji: 0, okami: 1
    vpii init;
    init.push_back({0, 0}); 
    init.push_back({0, 1}); 
    init.push_back({1, 0}); 
    init.push_back({1, 1}); 
    vi ans_animal;
    bool found = false;
    rep(j, 0, 4){
        vi animal(N, -1);
        animal[0] = init[j].first;
        animal[1] = init[j].second;
        rep(i, 1, N-1){
            bool okami = (animal[i] == 1);
            if((okami && s[i] == 'o') || (!okami && s[i] == 'x')){
                animal[i+1] = reverse01(animal[i-1]);
            }
            if((okami && s[i] == 'x') || (!okami && s[i] == 'o')){
                animal[i+1] = animal[i-1];
            }
        }
        // i=0 and test i=0's saying

        bool mujun = false;
        vi tmp = {0, N-1};
        for(auto &i : tmp){
            bool okami = (animal[i] == 1);
            int bac, fro;
            if(i==0){
                bac = N-1;
                fro = 1;
            } else {
                bac = N-2;
                fro = 0;
            }
            if((okami && s[i] == 'o') || (!okami && s[i] == 'x')){
                if(animal[bac] != animal[fro]) continue;
                else{
                    mujun = true;
                }
            }
            else if((okami && s[i] == 'x') || (!okami && s[i] == 'o')){
                if(animal[bac] == animal[fro]) continue;
                else{
                    mujun = true;
                }
            } else continue;
        }
        if(!mujun){
            found = true;  
            ans_animal = animal;
            break;
        }
    }
    if(found){
        rep(i, 0, N){
            if(ans_animal[i] == 0) cout << "S";
            else cout << "W";
        }
        cout << endl;
    } else {
        cout << "-1";
    }
    return 0;
}




Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	char d[1000][1001];
	for(int i=0;i<h;i++) scanf("%s",d[i]);
	vector<P> *v; vector<P> p; v=&p;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		if(d[i][j]!='.'){
			int z=0;
			for(int k=-1;k<=1;k++) for(int r=-1;r<=1;r++) if(d[i+k][j+r]=='.') z++;
			if(z>=d[i][j]-48) v->push_back(P(i,j));
		}
	}
	int res=0;
	while(v->size()){
		res++;
		vector<P> *p= new vector<P>;
		for(int i=0;i<v->size();i++){
			P x=v->at(i);
			d[x.first][x.second]='.';
		}
		for(int q=0;q<v->size();q++){
			P x=v->at(q);
			for(int i=x.first-1;i<=x.first+1;i++) for(int j=x.second-1;j<=x.second+1;j++){
				if(d[i][j]=='.') continue;
				int z=0;
				for(int k=-1;k<=1;k++) for(int r=-1;r<=1;r++) if(i+k!=-1&&i+k!=h&&j+r!=-1&&j+r!=w) if(d[i+k][j+r]=='.') z++;
				if(z>=d[i][j]-48) p->push_back(P(i,j));
			}
		}
		sort(p->begin(),p->end());
		p->erase(unique(p->begin(),p->end()),p->end());
		v=p;
	}
	printf("%d\n",res);
}

Measured memory_bytes: 64328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,m;
	cin>>n;
	vi t(n);
	queue<int> q;
	queue<int> p;	
	map<int,int> mp;
	rep(i,0,n){
		int a; cin>>a;
		t[i]=a;
	}
	cin>>m;
	rep(i,0,m){
		int a,b; cin>>a>>b;
		--a;
		p.push(b);
		q.push(a);
	}
	while(!q.empty()){
		int ans=0;
		int c=q.front(); q.pop();
		int d=p.front(); p.pop();
		//cout<<c<<" c"<<endl;
		rep(i,0,n){
			if(i==c){
				ans+=d;
			}
			else ans+=t[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i , j , k , dice[2][7] ;
    
    for(i = 0 ; i < 2 ; i++){
        for(j = 1 ; j < 7 ; j++){
            scanf("%d" , &dice[i][j]) ;
        }
    }
    
    for(i = 0 ; i < 6 ; i++){
        if(dice[0][1] == dice[1][1]){
            for(j = 0 ; j < 4 ; j++){
                for(k = 1 ; k < 7 ; k++){
                    if(dice[0][k] != dice[1][k]){break ;}
                }
                if(k == 7){
                    printf("Yes\n") ;
                    return 0 ;
                }
                
                dice[1][0] = dice[1][2] ;
                dice[1][2] = dice[1][3] ; 
                dice[1][3] = dice[1][5] ;
                dice[1][5] = dice[1][4] ;
                dice[1][4] = dice[1][0] ;
            }
        }
        dice[1][0] = dice[1][1] ;
        
        switch(i){
            case 2 :
                dice[1][1] = dice[1][3] ;
                dice[1][3] = dice[1][6] ;
                dice[1][6] = dice[1][4] ;
                dice[1][4] = dice[1][0] ;
                break ;
                
            default :
                dice[1][1] = dice[1][2] ;
                dice[1][2] = dice[1][6] ;
                dice[1][6] = dice[1][5] ;
                dice[1][5] = dice[1][0] ;
                break ;
        }
    }
    printf("No\n") ;
    return 0 ;
}


Measured memory_bytes: 2112
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

vector<pair<int, int>>a[100000];
long long b[100000];
int c, d;
int k;

void dfs(int x){
	for (int i = 0; i < a[x].size(); i++){
		if (b[a[x][i].first] < 0){
			b[a[x][i].first] = b[x] + a[x][i].second;
			dfs(a[x][i].first);
		}
	}
	return;
}
int main(void){
	int n, m;
	int s, t;
	int x, y, z;
	long long  ans;
	long long gcdn;
	int q;

	for (int i = 0; i < 100000; i++)b[i] = -1;

	scanf("%d", &n);

	for (int i = 0; i < n-1; i++){
		scanf("%d %d %d", &x,&y,&z);
		a[x - 1].push_back(make_pair(y - 1, z));
		a[y - 1].push_back(make_pair(x - 1, z));
	}
	scanf("%d %d", &q, &k);

	b[k - 1] = 0;
	dfs(k - 1);

	for (int qq = 0; qq < q; qq++){
		scanf("%d %d", &x, &y);
		printf("%lld\n",b[x-1] + b[y-1]);
	}

	return 0;
}


Measured memory_bytes: 12672
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

namespace {

}

int main()
{
	int N = 0, Y = 0;

	cin >> N >> Y;

	bool isExit = false;

	int i = 0, j = 0, k = 0;
	for (i = 0; i <= N && isExit == false; ++i) {// 10,000円
		int manYen = i * 10000;
		int rest = Y - manYen;
		int goNum = rest / 5000;
		if (i == 2000){
//			cout << goNum;
		}

		for (j = 0; j <= goNum && isExit == false; ++j){// 5,000円
			if (i == 2000 && j == 3){
				cout << i;
			}
			k = (rest - j * 5000) / 1000;
			if (i + j + k == N){
				isExit = true;
				goto out1;
			}
		}
	}
out1:
	if (isExit){
		cout << i << " " << j << " " << k;
	}
	else {
		cout << "-1 -1 -1";
	}



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%MOD;
        a=a*a%MOD;
        x>>=1;
    }
    return res;
}
string s;
int g(int i){
    if(i<0) return 0;
    if(i==0) return 1;
    if(i==1&&s[1]==s[0]) return 1;
    if(s[i]!=s[i-1]) return g(i-1)+1;
    if(s[i]==s[i-1]) return g(i-3)+2;
}


int main(){
    int n,m;cin>>n>>m;
    vector<vector<int> > l(m);
    for(int i=0;i<m;i++){
        int k;cin>>k;
        for(int j=0;j<k;j++){
            int s;cin>>s;
            l[i].push_back(s-1);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++) cin>>p[i];

    int ans=0;
    for(int b=0;b<(1<<n);b++){
        bool flag=true;
        for(int i=0;i<m;i++){
            int sum=0;
            for(auto sw:l[i]){
                if((b>>sw)&1) sum++;
            }
            if(sum%2!=p[i]){
                flag=false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

int h, w;
void solve() {
	cin >> h >> w;
	vector<vector<int>> v(h);
	rep(i, h) {
		rep(j, w) {
			char t; cin >> t;
			if (t == 'B') {
				v[i].push_back(j);
			}
		}
		if (v[i].size() > 2) {
			v[i] = vector<int>{ v[i][0],v[i].back() };
		}
	}
	int ans = 0;
	rep(i, h) {
		Rep(j, i + 1, h) {
			rep(k, v[i].size()) {
				rep(l, v[j].size()) {
					int dist = j - i + abs(v[i][k] - v[j][l]);
					ans = max(ans, dist);
				}
			}
		}
	}
	cout << ans << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}




Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	int N;
	cin >> N;
	cout << (800 * N) - ((N / 15) * 200) << endl;
	
	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = (int)1e5+39;
ll dp[N][3];
ll arr[N][3];

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int i;
    for(i=1;i<=n;++i){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    dp[1][0]=arr[1][0];
    dp[1][1]=arr[1][1];
    dp[1][2]=arr[1][2];

    for(i=2;i<=n;++i){
        dp[i][0]=max(max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]),dp[i-1][0]);
        dp[i][1]=max(max(dp[i-1][2]+arr[i][1],dp[i-1][0]+arr[i][1]),dp[i-1][1]);
        dp[i][2]=max(max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]),dp[i-1][2]);
    }
    ll ans = max(max(dp[n][0],dp[n][1]),dp[n][2]);
    cout<<ans;
}

Measured memory_bytes: 8308
package main

import (
  "fmt"
)

func insertionSort(a []int) {
  printSlice(a)
  for i := 1; i < len(a); i++ {
    v := a[i]
    j := i - 1
    for j >= 0 && a[j] > v {
      a[j+1] = a[j]
      j--
    }
    a[j+1] = v
    printSlice(a)
  }
}

func printSlice(s []int) {
  for i, v := range s {
    fmt.Print(v)
    if i < len(s) - 1 {
      fmt.Print(" ")
    } else {
      fmt.Println()
    }
  }
}

func main() {
  var n int
  fmt.Scanf("%d", &n)

  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scanf("%d", &a[i])
  }

  insertionSort(a)
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
    char s[10][10];
    for(int i=0;i<8;i++)cin>>s[i];

    cout<<90<<endl;
    for(int i=0;i<8;i++){
        for(int j=7;j>=0;j--)cout<<s[j][i];
        cout<<endl;
    }


    cout<<180<<endl;
    for(int i=7;i>=0;i--){
        for(int j=7;j>=0;j--)cout<<s[i][j];
        cout<<endl;
    }

    cout<<270<<endl;
    for(int i=7;i>=0;i--){
        for(int j=0;j<8;j++)cout<<s[j][i];
        cout<<endl;
    }
}

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

using namespace std;
using ll = long long;
const ll mod = 1000000007LL;

int main() {
    string l;
    cin>>l;
    int n=l.size();
    vector<vector<ll>> dp(n,vector<ll>(2,0LL));
    dp[0][1]=1;
    dp[0][0]=2;
    for(int i = 1; i < n; ++i){
        dp[i][0]=dp[i-1][0]*(l[i]=='0'?1:2);
        dp[i][0]%=mod;
        if(l[i]=='1') {
            dp[i][1]=dp[i-1][0]+dp[i-1][1]*3;
            dp[i][1]%=mod;
        }
        else {
            dp[i][1]+=dp[i-1][1]*3;
            dp[i][1]%=mod;
        }
    }
    cout<<(dp[n-1][0]+dp[n-1][1])%mod<<endl;
    return 0;
}

Measured memory_bytes: 5760
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()
	if a < b {
		a, b = b, a
	}
	fmt.Println(a + max(a-1, b))
}


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

class Solve {
private:
    using vi = std::vector<int>;
    using vvi = std::vector<vi>;
    using vb = std::vector<bool>;
    using vvb = std::vector<vb>;

    int D, W;
    vvi height;
    vvb visited;
    int calcMin(int t, int b, int l, int r)
    {
        int min{100};
        for (int i{t - 1}; i <= b + 1; i++)
            min = std::min({min, height[i][l - 1], height[i][r + 1]});
        for (int i{l - 1}; i <= r + 1; i++)
            min = std::min({min, height[t - 1][i], height[b + 1][i]});
        return min;
    }

    int calcCap(int t, int b, int l, int r, int h)
    {
        int ret{};
        for (int i{t}; i <= b; i++)
            for (int j{l}; j <= r; j++)
            {
                if (height[i][j] >= h) return -1;
                ret += h - height[i][j];
            }
        return ret;
    }
public:
    bool is_last_{};
    Solve()
    {
        scanf("%d%d", &D, &W);
        if (D == 0 && W == 0)
        {
            is_last_ = true;
            return;
        }
        height.resize(D + 2, vi(W + 2, -1));
        for (int i{1}; i <= D; i++)
            for (int j{1}; j <= W; j++)
                scanf("%d", &height[i][j]);
        int max{};
        for (int t{2}; t < D; t++)
            for (int b{t}; b < D; b++)
                for (int l{2}; l < W; l++)
                    for (int r{l}; r < W; r++)
                    {
                        int h{calcMin(t, b, l, r)};
                        max = std::max(max, calcCap(t, b, l, r, h));
                    }
        printf("%d\n", max);
    }
};

int main()
{
    while (!Solve().is_last_);

    return 0;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int ans=1;
		for(int i=2;i<=x;i++) {
			int tmp=i;
			while(tmp*i<=x) {
				tmp*=i;
				if(ans<tmp) {
					ans=tmp;
				}
			}
		}
		System.out.println(ans);
	}
}

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


int main(){
  int n,ans,i;
  cin >> n;
  int sw;
  vector<int> p(n);
  for(i=0;i<n;++i){
    cin >> p[i];
  }
  ans=0;
  for(i=0;i<n;++i){
    if(p[i]==(i+1)){
      sw=p[i];
      p[i]=p[i+1];
      p[i+1]=sw;
      ans++;
    }
  }
  cout << ans << endl;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

/////////////////////////////////////////////////////////////
ll mypow_core(ll x, int n, ll result) {
  if (n == 0) {
    return result;
  }

  if (n % 2 == 0) {
    return mypow_core(x * x, n / 2, result);
  }
  else {
    return mypow_core(x, n - 1, x * result);
  }
}

ll mypow(ll x, int n) {
  return mypow_core(x, n, 1);
}
/////////////////////////////////////////////////////////////

ll n;

ll ans;

bool check(ll next, ll target) {
  return (n % next <= target);
}

ll search(ll ok, ll ng, ll target) {
  while (abs(ok - ng) > 1) {
    ll next = (ok + ng) / 2;
    if (check(next, target)) {
      ok = next;
    }
    else {
      ng = next;
    }
  }

  if (n % ok == target) {
    return ok;
  }
  else {
    return -1LL;
  }
}

int main(void) {
  // Here your code !
  scanf("%lld", &n);

  // for (ll i = 1; i <= n; ++i) {
  //   printf("%lld: %lld - %lld\n", i, n % i, n / i);
  // }

  // TODO: cur_mod == n

  // set<ll> done;

  ans = 0;

  for (ll cur_div = 1; cur_div * cur_div <= n + 1; ++cur_div) {
    // if (done.find(cur_div) != done.end()) continue;

    ll start = n / cur_div;
    ll goal = n / (cur_div + 1);

    ll tmp = search(start, goal, cur_div);
    ans += tmp < 0 ? 0 : tmp;

    // done.insert(cur_div);

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

    // ll opposite_div = n / cur_div;
    //
    // if (done.find(opposite_div) != done.end()) continue;
    //
    // start = n / opposite_div;
    // goal = n / (opposite_div + 1);
    //
    // tmp = search(start, goal, opposite_div);
    // ans += tmp < 0 ? 0 : tmp;
    //
    // done.insert(opposite_div);
  }

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

  return 0;
}


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

const int N = 2e5+5;

int main()
{
	long long n, d, a;
	long long ans = 0, cur = 0;
	vector<pair<long long, long long>> monsters(N);
	queue<pair<long long,long long>> q; //dist , contribution to cur
	cin >> n >> d >> a;
	d *= 2;
	for(int i = 0; i < n; ++i)
		cin >> monsters[i].first >> monsters[i].second;
	sort(monsters.begin(), monsters.begin()+n);

	for(int i = 0; i < n; ++i){
		while(!q.empty()){
			if(q.front().first < monsters[i].first){
				cur -= q.front().second;
				q.pop();
			}
			else
				break;
		}
		monsters[i].second -= (cur*a);
		if(monsters[i].second > 0){
			long long contrib = ((monsters[i].second + a - 1) / a);
			ans += contrib;
			cur += contrib;
			q.push({monsters[i].first+d, contrib});
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
string S;
int A, B, C, D;



int main(void) {

	cin >> S;

	for (int k = 0; k < 8; k++) {
		int sum = S[0] - '0';
		for (int i = 1; i <= 3; i++) {
			if ((k >> (i - 1)) & 1) { sum += S[i] - '0'; }
			else { sum -= S[i] - '0'; }
		}
		if (sum == 7) {
			cout << S[0] - '0';
			for (int i = 1; i <= 3; i++) {
				if ((k >> (i - 1)) & 1) { cout << "+"; }
				else { cout << "-"; }
				cout << S[i];
			}
			cout << "=7" << endl; break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

int n, t;
int a[3030], b[3030];
pair<int, int> x[3030];
int dp[3030][7060][2];

void solve() {
	cin >> n >> t;
    rep(i, n) {
        cin >> a[i] >> b[i];
        x[i] = make_pair(a[i], b[i]);
    }
    sort(x, x + n);
    //reverse(x, x + n);
    rep(i, n + 1) {
        rep(j, 7060) {
            dp[i][j][0] = 0;
            dp[i][j][1] = 0;
        }
    }
    rep(i, n) {
        //dp[i + 1][0][1] = max(dp[i][0][1], dp[i][0][0] + x[i].sc);
        for(int j = 0; j <=t + 3010; j ++) {
            //dp[i + 1][j][1] = max(dp[i][j][1], dp[i][j][0] + x[i].sc);
            if(j < x[i].fr) {
                dp[i + 1][j][1] = dp[i][j][1];
              dp[i + 1][j][0] = dp[i][j][0];
            } else {
                dp[i + 1][j][1] = max(dp[i][j][1], dp[i][j - x[i].fr][1] + x[i].sc);
              dp[i + 1][j][0] = max(dp[i][j][0], dp[i][j - x[i].fr][0] + x[i].sc);
            }
          dp[i + 1][j][1] = max(dp[i][j][1], dp[i][j][0] + x[i].sc);
        }
    }
    int res = dp[n][t - 1][1];
    for(int j = 0; j <= t - 1; ++j) {
        res = max(res, dp[n][j][1]);
    }
  for(int j = 0; j <= t; ++j) {
    res = max(res, dp[n][j][0]);
  }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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


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

 int answer = 0;
for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
        for(int k=1;k<=n;k++){
            answer+=__gcd(i,__gcd(j,k));

        }
    }
}

cout<<answer;
    return 0;
}


Measured memory_bytes: 3628