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

const int N = 2005;

int H, W, h[N], stk[N], top, ans;
char s[N][N];

bool Judge (int x, int y) {
	return x > 1 & y > 1 && (((s[x][y] == '#') + (s[x - 1][y] == '#') + (s[x][y - 1] == '#') + (s[x - 1][y - 1] == '#')) & 1);
}

void Max (int &x, int y) { if (x < y) x = y; }

int main () {
	scanf("%d%d", &H, &W);
	for (int i = 1; i <= H; ++i) scanf("%s", s[i] + 1);
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			++h[j];
			if (j < W && Judge(i, j + 1)) h[j] = 1;
			while (top && h[stk[top]] >= h[j]) {
				Max(ans, h[stk[top]] * (j - stk[top - 1]));
				--top;
			}
			stk[++top] = j;
		}
		while (top) Max(ans, h[stk[top]] * (W - stk[top - 1])), --top;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4224
pat = ["A", "C", "G", "T"]

s = input()

left = right = 0
ans = 0

while left < len(s):
    right = left
    while right < len(s) and s[right] in pat:
        right += 1

    ans = max(ans, right - left)

    left = right + 1

print(ans)


Measured memory_bytes: 2940
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,a,b,l,r,num;

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

bool check(int x){
	int y=max(0,(x-1)/num);
	int resa=a-x,resb=b-y;
	return resb<=1ll*(resa+1)*num;
}

int main(){
	for (int T=read();T;T--){
		a=read(),b=read(),l=read(),r=read();
		num=ceil(1.0*max(a,b)/(min(a,b)+1));
		int _l=0,_r=a,numa=-1;
		while (_l<=_r){
			int mid=(_l+_r)>>1;
			if (check(mid)) _l=mid+1,numa=mid;
			else _r=mid-1;
		}
		int numb=max(0,(numa-1)/num),pos=numa+numb;
		int resa=a-numa,resb=b-numb;
		if (r<=pos){
			for (int i=l;i<=r;i++) putchar(i%(num+1)?'A':'B');
		}
		else if (l<=pos&&r>pos){
			for (int i=l;i<=pos;i++) putchar(i%(num+1)?'A':'B');
			for (int i=pos+1;i<=r;i++){
				bool flag=(resb<=1ll*resa*num);
				putchar(flag?(--resa,'A'):(--resb,'B'));
			}
		}
		else{
			int tmpb=resb-resa*num;
			if (l<=pos+tmpb) resb-=l-pos-1;
			else{
				resb-=tmpb;
				int x=(l-pos-tmpb-1)/(num+1);
				resa-=x,resb-=x*num;
				int y=l-pos-tmpb-1-x*(num+1);
				if (y) --resa,--y;
				resb-=y;
			}
			for (int i=l;i<=r;i++){
				bool flag=(resb<=1ll*resa*num);
				putchar(flag?(--resa,'A'):(--resb,'B'));
			}
		}
		puts("");
	}
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    ll N; cin >> N;

    for(ll i = 0; i < N; i++){
        ll t = 0; cin >> t;
        vec.push_back(t);
    }

    vector<ll > a(N, 0);
    for(ll i = 1; i < N; i++){
        a[i] += vec[i-1] + a[i-1];
       //cout << a[i] << endl;
    }
    vector<ll > b(N, 0);
    for(ll i = N-2; i >= 0; i--){
        b[i] += vec[i+1] + b[i+1];
        //cout << b[i] << endl;
    }

    ll ans = 1145141919191919;
    for(ll i = 1; i < N; i++){
        //cout << a[i] << " " << b[i-1] << endl;
        ans = min(ans, abs(a[i] - b[i-1]) );
    }

    cout << ans << endl;
    

}

Measured memory_bytes: 5104
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 1000010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

int n, h, d;
ll f[maxn], s[maxn], fac[maxn], sum = 0;
const ll p = 1e9 + 7;
template <class T> void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
int main() {
  cin >> n >> h >> d, f[0] = s[0] = fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
  for (int i = 1; i <= n; i++) {
    sum = (sum + fac[i]) % p;
  }
  for (int i = 1; i <= h; i++) {
    f[i] = (s[i - 1] - (i > d ? s[i - d - 1] : 0) + p) % p * (i == h ? fac[n] : sum) % p;
    s[i] = (s[i - 1] + f[i]) % p;
  }
  cout << f[h] << endl;
  return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    string t_tmp; cin >> t_tmp;
    int n = t_tmp.size();
    string t_1 = t_tmp;
    if (t_1[n-1] == '?') t_1[n-1] = 'D';
    for (int i = n-2; i >= 0; i--) {
        if (t_1[i] != '?') continue;
        if (t_1[i+1] == 'D') t_1[i] = 'P';
        else if (t_1[i+1] == 'P') t_1[i] = 'D';
    }
    int ct_1 = 0;
    rep(i,n) {
        if (t_1[i] == 'D') ct_1++;
        if (t_1[i] == 'P' && t_1[i+1] == 'D' && i != n-1) ct_1++;
    }
    string t_2 = t_tmp;
    if (t_2[0] == '?') t_2[0] = 'D';
    for (int i = 1; i < n; i++) {
        if (t_2[i] != '?') continue;
        if (t_2[i-1] == 'P') t_2[i] = 'D';
        else if (t_2[i-1] == 'D') t_2[i] = 'D';
    }
    int ct_2 = 0;
    rep(i,n) {
        if (t_2[i] == 'D') ct_2++;
        if (t_2[i] == 'P' && t_2[i+1] == 'D' && i != n-1) ct_2++;
    } 
    if (ct_1 < ct_2) cout << t_2 << endl;
    else cout << t_1 << endl;
}

Measured memory_bytes: 3884
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int s,c;
signed main()
{
    scanf("%lld%lld",&s,&c);
    if(c<=s*2)
        printf("%lld\n",min(c/2,s));
    else
        printf("%lld\n",s+(c-s*2)/4);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double

int ans=0,c=0;

int32_t main()
{
	IOS
	int n,k;cin>>n>>k;
	vector<int>H(n+10),dp(n+10,1e15);
	for(int i=1;i<=n;i++)cin>>H[i];
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>=max(i-k,1LL);j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(H[i]-H[j]));
		}
	}
	cout<<dp[n]<<endl;
		
}
			
	
	
	
	
	

	

	

	
		


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

using namespace std;

int main() {
	int a,b,dif,num = 0;
	cin >> a >> b;
	dif = b - a;
	for (int i = 1; i <= dif; ++i)
	{
		num+= i;
	}
	int ans = num - b;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;




int main(){
    int k,x;
    int lhashi=-(1+10e+6);
    int rhashi=1+10e+6;
    
    cin >> k >> x;
    lhashi=max(lhashi,x-k+1);
    rhashi=min(rhashi,x+k-1);
    
    int d=rhashi-lhashi+1;
    
    for(int i=0;i<d;i++){
        cout << lhashi+i << " "  ;
    }
}




Measured memory_bytes: 764
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next()) - 1;
		sc.close();
		long yono = 0;
		for(int i = 1 ; i <= n ; i++){
			yono += n / i;
		}
		ou.println(yono);
		ou.flush();
	}
}

Measured memory_bytes: 35732
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getArgs() [][]string {
    args := [][]string{}
    var line string
    for ;sc.Scan(); {
        line = sc.Text()
        split := strings.Split(line, " ")
        args = append(args, split)
    }
    return args
}

func main() {
	args := getArgs()
	T,_ := strconv.Atoi(args[0][1])
	
	var flag_foundroute bool
	c_best := 1001
	
	for _, arg := range args[1:] {
	    c,_ := strconv.Atoi(arg[0])
	    t,_ := strconv.Atoi(arg[1])
	    if t<=T && c < c_best{
	        c_best = c
	        flag_foundroute = true
	    }
	}
	if !flag_foundroute {
	    fmt.Println("TLE")
	} else {
	    fmt.Println(c_best)
	}
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define debug(a) cout << a << "\n";

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;	cin >> s;
	int sS = s.size();
	int cT = 0;
	bool ac = true;
	
	if(s[0] != 'A') ac = false;
	REP(i, sS){
		if(2 <= i and i <= (sS-2)){
			if(s[i] == 'C') cT++;
		}else{
			if(i > 0 and isupper(s[i])) ac = false;
		}
	}
	if(cT != 1) ac = false;
	if(ac == true){
		cout << "AC" << "\n";
	}else{
		cout << "WA" << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(int(input()) for _ in range(N))
A.sort()
count = 0
test = -1
stack = 0
for i in range(N):
    if test != A[i]:
        count += 1
        stack = 1
        test = A[i]
    else:
        if stack == 1:
            count = count - 1
            stack = 0
        else:
            stack = 1
            count += 1
print(count)


Measured memory_bytes: 7400
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

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

        bool flag=false;
        FOR(i,1,N.size()){
                if(N[i]!='9'){
                        flag=true;
                }
        }

        int ret = 0;
        if (flag) {
                ret += N[0]-'0'-1;
                FOR(i,1,N.size()){
                        ret += 9;
                }
        } else {
                FOR(i,0,N.size()){
                        ret += N[i]-'0';
                }

        }
        cout<<ret<<endl;




}


Measured memory_bytes: 256
s=str(input())
n = len(s)
dev1 = s[0:(n-1)//2]
dev2 = s[(n+3)//2 - 1:n]
if dev1 == dev1[::-1] and dev2 == dev2[::-1] and s == s[::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int d, c; cin >> d >> c;
	cout << d*c << endl;

	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<vector>
std::vector<int> vec;
int x;
int n=1;
int main(){
	do{
		std::cin>>x;
		vec.push_back(x);
	}while(x!=0);
	for(auto l:vec){
		if(l!=0)std::cout<<"Case "<<n<<": "<<l<<std::endl;
		++n;
	}
	return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  // map<string, int> m;
  vector<string> hoge(n);
  string tmp;
  rep_i(i, n){
    // cin >> tmp;
    // hoge.push_back(tmp);
    // auto it = m.find(tmp);
    // if(it != m.end()){
    //   m[tmp] += 1;
    // }else{
    //   m[tmp] = 1;
    // }
    cin >> hoge[i];
  }
  sort_v(hoge);
  int max_c = 0;
  string pre;
  pre = hoge[0];
  int c = 1;
  for (int i = 1; i < hoge.size(); i++){
    if(hoge[i] == pre){
      c += 1;
      if(i == n - 1){
        if(max_c <= c){
          max_c = c;
        }
      }
    }else{
      if(max_c <= c){
        max_c = c;
      }
      c = 1;
    }
    pre = hoge[i];
  }
  // cout << max_c << endl;
  vector<string> fuga;
  pre = hoge[0];
  c = 1;
  // debug_vs(hoge);
  // cout << endl;
  for (int i = 1; i < hoge.size(); i++){
    if(hoge[i] == pre){
      c += 1;
      if(i == n - 1){
        if(c == max_c){
          fuga.push_back(hoge[i - 1]);
        }
      }
    }else{
      if(c == max_c){
        fuga.push_back(hoge[i - 1]);
      }
      if(i == n - 1){
        if(c == max_c){
          fuga.push_back(hoge[i]);
        }
      }
      c = 1;
    }
    pre = hoge[i];
  }
  sort_v(fuga);
  for (int i = 0; i < fuga.size(); i++){
    cout << fuga[i] << endl;
  }
  
  // sort_v(hoge);
  // hoge.erase(std::unique(hoge.begin(), hoge.end()), hoge.end());
  // // sort(m.begin(), m.end());
  // for (int i = 0; i < hoge.size(); i++){
  //   cout << hoge[i] << endl;
  //   cout << m[hoge[i]] << endl;
  // }
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

int a,b,k;

int main()
{
    cin>>k>>a>>b;
    if(a%k==0){
        cout<<"OK"<<endl;
        return 0;
    }
    int c=a/k*k+k;
    
    

    if(c<=b){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }

    return 0;

}




Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

string inp;
string number;

string del_space(string s)
{
	size_t pos;
	while ((pos = s.find_first_of(" ")) != string::npos) s.erase(pos, 1);
	return s;
}

string created_num = "00000000";
stack<int> st;

bool solve(void)
{
	int c = 0;
	while (created_num[c] != '\0')
	{
		if (created_num[c] >= '0' && created_num[c] <= '9')
		{
			st.push(created_num[c] - '0');
		} else {
			int a, b;
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			if (created_num[c] == '+')
			{
				st.push(b + a);
			} else if (created_num[c] == '-') {
				st.push(b - a);
			} else if (created_num[c] == '*') {
				st.push(b * a);
			}
		}
		c++;
	}
	int ans = st.top();
	if (ans == 10) return true;
	else return false;
}

bool make_rpn(int num, int exp, bool first = false)
{
	static int isused[4] = {0, 0, 0, 0};
	if (first)
	{
		isused[0] = 0;
		isused[1] = 0;
		isused[2] = 0;
		isused[3] = 0;
	}
	int i;

	if (num + exp == 7)
	{
		created_num[7] = '\0';
		//cout << created_num << endl;
		if (solve())
		{
			return true;
		}
	} else {
		if (num - exp >= 2)
		{
			created_num[num + exp] = '+';
			if (make_rpn(num, exp + 1)) return true;
			created_num[num + exp] = '-';
			if (make_rpn(num, exp + 1)) return true;
			created_num[num + exp] = '*';
			if (make_rpn(num, exp + 1)) return true;
		}
		if (num <= 3)
		{
			for (i=0; i<4; i++)
			{
				if (isused[i] == 0)
				{
					isused[i] = 1;
					created_num[num + exp] = number[i];
					if (make_rpn(num + 1, exp)) return true;
					isused[i] = 0;
				}
			}
		}
	}
	return false;
}

stack<string> st2;

string get_tyuuchi()
{
	while (!st2.empty()) st2.pop();

	for (int i=0; i<created_num.length(); i++)
	{
		string cs = created_num.substr(i, 1);
		char c = created_num[i];

		string a, b;

		if ('0' <= c && c <= '9')
		{
			st2.push(cs);
		} else {
			switch (c)
			{
			case '+':
				a = st2.top(); st2.pop();
				b = st2.top(); st2.pop();
				st2.push("(" + b + "+" + a + ")");
				break;
			case '-':
				a = st2.top(); st2.pop();
				b = st2.top(); st2.pop();
				st2.push("(" + b + "-" + a + ")");
				break;
			case '*':
				a = st2.top(); st2.pop();
				b = st2.top(); st2.pop();
				st2.push("(" + b + "*" + a + ")");
				break;
			}
		}
	}

	return st2.top();
}

int main()
{
	while (getline(cin, inp))
	{
		number = del_space(inp);
		if (number == "0000") break;
		created_num = "00000000";
		if (make_rpn(0, 0, true))
		{
			//cout << created_num << endl;
			cout << get_tyuuchi() << endl;
		} else {
			cout << 0 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1364
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
ans = ""
for i in range(len(s)):
    if s[i] == '0':
        ans += '0'
    elif s[i] == '1':
        ans += '1'
    else:
        ans = ans[:-1]
print(ans)


Measured memory_bytes: 10204
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;

struct mouse{
	int y, x, dis;
	mouse(){
		y = x = dis = 0;
	}
};

char stage[1000][1000];
int ng[1000][1000] = {};
int main(){
	int h, w, n;
	mouse s;
	cin >> h >> w >> n;
	for (int i = 0; i < h; i++){
		cin >> stage[i];
		for (int j = 0; j < w; j++){
			if (stage[i][j] == 'S'){
				s.y = i;
				s.x = j;
			}
			else if (stage[i][j] != 'X' && stage[i][j] != '.'){
				stage[i][j] -= '0';
			}
		}
	}

	int ny, nx;
	int situ_y[4] = { -1, 0, 1, 0 }, situ_x[4] = { 0, 1, 0, -1 };
	for (int target = 1; target <= n; target++){
		queue<mouse> mickey;
		mouse m_c;
		for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)ng[i][j] = 0;
		mickey.push(s);
		while (1){
			m_c = mickey.front();
			if (stage[m_c.y][m_c.x] == target){
				s = m_c;
				break;
			}
			if ((m_c.dis != 0 && ng[m_c.y][m_c.x] >= 4)
				|| stage[m_c.y][m_c.x] == 'X'){
				mickey.pop();
				continue;
			}
			ng[m_c.y][m_c.x]++;
			for (int i = 0; i < 4; i++){
				m_c = mickey.front();
				ny = m_c.y + situ_y[i];
				nx = m_c.x + situ_x[i];
				if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
				m_c.y = ny;
				m_c.x = nx;
				m_c.dis++;
				mickey.push(m_c);
			}
			mickey.pop();
		}
	}
	printf("%d\n", s.dis);
	return 0;
}

Measured memory_bytes: 6084
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

map<char, int> val = {{'0', 0}, {'1', (1<<16)-1}, {'a', 43690}, {'b', 52428}, {'c', 61680}, {'d', 65280}};

int expr(string &s, int &i){
    if(s[i] == '-'){
        ++i;
        int tmp = expr(s, i);
        return ((1<<16) - 1) ^ tmp;
    }
    else if(s[i] == '('){
        ++i;
        int lhs = expr(s, i);
        char op = s[i];
        ++i;
        int rhs = expr(s, i);
        ++i;
        return (op == '^' ? lhs ^ rhs : lhs & rhs);
    }
    else{
        int ret = val[s[i]];
        ++i;
        return ret;
    }
}

int len[1<<16];

void solve(string &s){
    int i = 0;
    int S = expr(s, i);
    printf("%d\n", len[S]);
}

int main(){
    fill(len, len + (1<<16), mod);
    queue<pii> que;
    for(auto p: val){
        len[p.se] = 1;
        que.emplace(p.se, 1);
    }
    while(!que.empty()){
        int S, tl;
        tie(S, tl) = que.front();
        que.pop();
        if(len[S] < tl) continue;
        if(chmin(len[((1<<16) - 1) ^ S], tl + 1)){
            que.emplace(((1<<16) - 1) ^ S, tl + 1);
        }
        rep(T, 1<<16)if(len[T] < mod){
            if(chmin(len[T ^ S], tl + len[T] + 3)){
                que.emplace(T ^ S, len[T ^ S]);
            }
            if(chmin(len[T & S], len[S] + len[T] + 3)){
                que.emplace(T & S, len[T & S]);
            }
        }
    }

    string s;
    while(cin >> s && s != "."){
        solve(s);
    }
}


Measured memory_bytes: 5856
H, W = map(int, input().split())
large_n = 100000000

C_mat = []
for i in range(10):
    C_mat.append(list(map(int, input().split())))

A_mat = []
for i in range(H):
    A_mat.append(list(map(int, input().split())))
    



for k in range(10):
    for i in range(10):
        for j in range(10):
            C_mat[i][j] = min(C_mat[i][j], C_mat[i][k]+ C_mat[k][j])
            
            
            
            
ans = 0
for i in range(H):
    for j in range(W):
        if A_mat[i][j] != -1:
            ans += C_mat[A_mat[i][j]][1]
            
print(ans)

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

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

  for (int i = 0; i < N ; i++){
    string S;
    cin >> S;
    
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    
    if (i ==  N-1){
      cout << "Three" << endl;
    }
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	//入力
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	//食べられたチョコの総数
	int total_eaten = 0;
	for (int i = 0; i < N; i++) {
		total_eaten += (D - 1) / A[i] + 1;
	}

	cout << total_eaten + X;

	return 0;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    if (A >= 13)
    {
        OUT(B);
    }
    else if (A >= 6)
    {
        OUT(B / 2);
    }
    else
    {
        OUT(0);
    }
}

Measured memory_bytes: 256
using System;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            int n = int.Parse(Console.ReadLine());

            //深さ優先検索
            dfs("", 'a', n);
            
        }

        static void dfs(string s, char mx,int n)
        {
            if(s.Length == n)
                Console.WriteLine(s);
            else
            {
                for(char c ='a' ; c <=mx;c++)
                    dfs(s + c,(c == mx) ? (char)(mx + 1) : mx, n);
            }
        }
        
    }

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

using namespace std;

//Author: Ezio Sam

/* Shorthands */

#define ll long long

#define pb push_back 

#define mp make_pair

#define sp " "

#define fi first

#define sn second 

/* STL */

#define vi vector<int>v

#define pii pair<int,int>

#define pll pair<ll,ll>

#define mem(a, n) memset(a, n, sizeof(a));

#define all(x) x.begin(),x.end()

#define sz(x) (int)x.size()

/* loops */

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

#define fn(i,n) for(i=1;i<=n;i++)

#define fa(i,a,n) for(i=a;i<=n;i++)

/* inputs */

#define si(n)               scanf("%d", &n)

#define sl(n)               scanf("%lld", &n)

#define sii(a, b)           scanf("%d %d", &a, &b)

#define sll(a, b)           scanf("%lld %lld", &a, &b)

#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)

#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)

#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)

#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

   

#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);

#define debugg(something)   cout<<#something<<" - "<<something<<"\n";         

int main()

{

	string s;	string t;

	int i;

	cin>>s>>t;

	

	fr(i, sz(s)){

		if(t[i]!=s[i]){

		cout<<"No"<<endl ;

		return 0;

		}

	}

    cout <<"Yes"<<endl ;

   return 0;

}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <vector>
#define llint long long

using namespace std;

llint m;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> m;
	llint sum = 0, cnt = 0;
	llint d, c;
	for(int i = 1; i <= m; i++){
		cin >> d >> c;
		sum += d * c;
		cnt += c;
	}
	llint ans = cnt-1;
	ans += (sum-9+8)/9;
	cout << ans << endl;
	
	return 0;
}

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

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

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



int main() 
{
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    double ans = 0.0;
    sort(v.begin(), v.end());
    for (int i = 2; i < n;i++)
    {
        ans += v[i] / pow(2, n-i);
    }
    cout << ans + (v[0] + v[1]) / pow(2, n - 1) << endl;
    return 0;
}



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

int main(){
    char a[2][3];
    int i,j,l=1;
    for(i=0;i<2;i++)
        for(j=0;j<3;j++) cin>>a[i][j];
            
    for(i=0;i<3;i++){
        if(a[0][i]!=a[1][2-i]){
            l=0;
            break;
        }
    }
    if(l==1) cout<<"YES";
    else cout<<"NO";
	return 0;
}

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

using namespace std;

int main()
{
	int N, A, B;
	int count = 0, o_count = 0;
	string S, ans = "";
	cin >> N >> A >> B >> S;

	for (int i = 0; i < S.size(); i++)
	{
		switch (S[i])
		{
		case 'a':
			if (count < A + B)
			{
				ans += "Yes\n";
				count++;
			}
			else
				ans += "No\n";
			break;
		case 'b':
			if (count < A + B && o_count < B)
			{
				ans += "Yes\n";
				count++;
				o_count++;
			}
			else
				ans += "No\n";
			break;
		case 'c':
			ans += "No\n";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

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


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

		int i = a;
		bool f = false;
		for (; i <= b; i++) {
			if (i%k == 0) {
				cout << "OK\n";
				f = true;
				break;
			}
		}
		if (f != true)cout << "NG\n";

	return 0;
}

Measured memory_bytes: 3640
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

s = input()
ans = ""
for i in range(len(s)):
    if i%2 == 0:
        ans += s[i]
print(ans)

Measured memory_bytes: 3548
a,b=map(int,input().split())
l=[0]*999
for i in range(1,1000):
    l[i-1]=(i*(i+1)//2)
#print(l)
for i in range(998):
    if (b-a)==l[i+1]-l[i]:
        ans=l[i]-a
print(ans)

Measured memory_bytes: 3060
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: usize
    };

    let x = d * 2 + 1;

    if n % x == 0 {
        println!("{}", n / x);
    } else {
        println!("{}", n / x + 1);
    }
}


Measured memory_bytes: 2172
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        const int max = 8;
        static bool[,] graph = new bool[max, max];
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1];

            for (var i = 0; i < M; i++)
            {
                var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
                graph[t[0] - 1, t[1] - 1] = graph[t[1] - 1, t[0] - 1] = true;
            }

            var visited = new bool[N];
            for (var i = 0; i < N; i++) visited[i] = false;

            visited[0] = true;
            Console.WriteLine(Dfs(0, N, visited));
        }

        static int Dfs(int v, int N, bool[] visited)
        {
            var allVisited = visited.Any(z => !z) ? false : true;
            if (allVisited) return 1;

            var ret = 0;

            for (var i = 0; i < N; i++)
            {
                if (!graph[v, i]) continue;
                if (visited[i]) continue;

                visited[i] = true;
                ret += Dfs(i, N, visited);
                visited[i] = false;
            }

            return ret;
        }
    }
}


Measured memory_bytes: 13396
n=int(input())
a=list(map(int,input().split()))

s=sum(a)

res=list()
res.append(s-2*sum([a[(2*j+1)] for j in range(int((n-1)/2))]))

for i in range(1,n):
    res.append(2*a[i-1] - res[i-1])

print(' '.join(map(str,res)))

Measured memory_bytes: 19096
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,x,l,d=0,i=0;
    cin>>n>>x;
    for(i;i<n;i++) {
        cin>>l;
        d+=l;
        if(d>x)break;
    }
    cout << i+1 <<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}



const int N=2e5+5;
vector<int> v[N],vis(N);


int dfs(int node)
{
    vis[node]=1;
    int x=1;
    for(auto i:v[node])
    {
        if(!vis[i])
            x+=dfs(i);
    }
    return x;
}

void solve()
{
    int n,m,x,y;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i])
            continue;
        int x=dfs(i);
        ans=max(ans,x);
    }
    cout<<ans<<endl;

}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 21932
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A)

if B[-1] == B[-2]:
    for i in range(N):
        print(B[-1])
else:
    for a in A:
        if a == B[-1]:
            print(B[-2])
        else:
            print(B[-1])

Measured memory_bytes: 14112
package main

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	m := 1000
	rem := x
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		m = min(m, a)
		rem -= a
	}
	ans := n + rem/m
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	cin >> N;
	vector<ll>A(N);
	rep(i, N)cin >> A[i];
	cin >> Q;
	rep(i, Q) {
		ll k;
		cin >> k;
		vector<ll>::iterator a=lower_bound(A.begin(), A.end(), k);
		cout << distance(A.begin(),a)  << endl;
	}
	return 0;
}





Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int n,c,a = 1,mx=0;

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

	cin >> n;
	
	while (n) {
		int tmp = n;
		c = 0;
		while (tmp) {
			if (tmp % 2 == 0) {
				c++;
			}
			
			tmp = tmp / 2;
		}

		if (c > mx) {
			a = n;
			mx = c;
		}
		n--;
	}
	cout << a << endl;

}


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

#define MAX (2000000)

int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }

void print(int A[], int H)
{
	for (int i = 1; i <= H; i++)
	{
		cout << "node " << i << ": ";
		cout << "key = " << A[i] << ", ";
		if (parent(i) >= 1)
			cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H)
			cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H)
			cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
}

void maxHeapify(int A[], int i, int H)
{
	int l = left(i);
	int r = right(i);
	int largest;
	// 左の子、自分、右の子で最大を選ぶ
	if (l <= H && A[l] > A[i])
		largest = l;
	else
		largest = i;
	if (r <= H && A[r] > A[largest])
		largest = r;

	if (largest != i)
	{
		swap(A[i], A[largest]);
		maxHeapify(A, largest, H);
	}
}

void buildMaxHeap(int A[], int H)
{
	for (int i = H / 2; i > 0; i--)
		maxHeapify(A, i, H);
}

int main()
{
	int A[MAX+1];
	int H;

	cin >> H;
	for (int i = 1; i <= H; i++)
	{
		cin >> A[i];
	}

	buildMaxHeap(A, H);

	for (int i = 1; i <= H; i++)
	{
		cout << " " << A[i];
	}
	cout << endl;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a%b);}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x; cin >> x;
    cout << lcm(360,x)/x << endl;
}

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

using namespace std;

struct sushi_t {
  int d;
  int t;
};

static int n, k;
static std::array<sushi_t, 100000> sushis{};
static std::array<int, 100001> worstSushis{0};

int64_t solve() {
  int64_t ret0 = 0;
  int64_t nn = 0;
  std::vector<int> replaceables{};
  int i = 0;
  for (; i < k; ++i) {
    const auto& s = sushis[i];
    int const prev = worstSushis[s.t];
    worstSushis[s.t] = i + 1;
    ret0 += int64_t(s.d);
    if (prev <= 0) {
      nn++;
    } else {
      replaceables.push_back(i);
    }
  }
  int64_t ret = ret0 + nn * nn;
  std::vector<int> replacements{};
  for (; i < n; ++i) {
    const auto& s = sushis[i];
    int const prev = worstSushis[s.t];
    worstSushis[s.t] = i + 1;
    if (prev <= 0) {
      replacements.push_back(i);
    }
  }

  int replaceableIdx = replaceables.size() - 1;
  int replacementIdx = 0;
  for (++nn;
       nn <= k && replaceableIdx >= 0 && replacementIdx < replacements.size();
       ++nn, --replaceableIdx, ++replacementIdx) {
    ret0 -= int64_t(sushis[replaceables[replaceableIdx]].d);
    ret0 += int64_t(sushis[replacements[replacementIdx]].d);
    if (ret0 + int64_t(k) * int64_t(k) <= ret) {
      break;
    }
    ret = std::max(ret0 + nn * nn, ret);
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    auto& s = sushis[i];
    std::cin >> s.t >> s.d;
    s.t--;
  }
  std::sort(sushis.begin(), sushis.begin() + n,
            [](const auto& lhs, const auto& rhs) { return lhs.d > rhs.d; });
  std::cout << solve() << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<pll,ll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define piii pair<pii, int>
#define pb push_back
const ll llinf = 2e18 + 7;
const int inf = 2e9 + 7;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 1;
const ll M = 1e3 + 5;
const ld pi = 3.14159265358979; 
void solve() {
    ll a;
    cin>>a;
    ll ans = a + a*a + a*a*a;
    cout<<ans;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    
    // cin>>t;
    while(t--) {
        solve();
        cout<<"\n";
    }
    return 0; 

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
int main(){string a; cin>>a;if(a.length()%2==1)cout<<"No";else{int k;rep(i,a.length()){k=0;if(i%2==1){if(a[i-1]!='h')break;}else{if(a[i-1]!='i')break;}k=1;}cout<<(k?"Yes":"No");}}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

// g = gcd(a, b), (x, y) satisfies ax + by = gcd(a, b)
template <typename T>
T extgcd(T a, T b, T &x, T &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    T d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

int main()
{
    int a, b, x, y;
    cin >> a >> b;
    int d = extgcd(a, b, x, y);
    cout << x << " " << y << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cmath>
using namespace std;
int n, l, s, mn=1e9, t, mi;
int main() {
	cin>>n>>l;
	for(int i=l; i<n+l; i++) {
		s += i;
		t = abs(i);
		if(t < mn) mn = t, mi = i;
	}
	cout<<s - mi;
	return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [a, b, c] <- getIntList
  putStrLn $ if (c - a - b) > 0 && 4 * a * b < (c - a - b) ^ 2
             then "Yes"
             else "No"

Measured memory_bytes: 380
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	LL hs[n], maxH = 0, ans = 0;
	rep(i, 0, n) {
		hs[i] = scanLong();
		if(i == 0)	maxH = hs[i];
		else	maxH = max(maxH, hs[i]);
		if(hs[i] == maxH)	ans++;
	}
	pll(ans); nl;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
xi = list(map(int, input().split()))
xi.append(x)
xi.sort()
d = [xi[i+1]-xi[i] for i in range(n)]

import fractions
from functools import reduce

def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)

print(gcd_list(d))

Measured memory_bytes: 14252
s = input().split(" ");
w = int(s[0]);
h = int(s[1]);
x = int(s[2]);
y = int(s[3]);

if x == w/2 and y == h/2 :
	bunkatu = 1;
else :
	bunkatu = 0;

print(w*h/2,bunkatu)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  ll ans = 0;
  ans += n / 25;
  n %= 25;
  ans += n / 10;
  n %= 10;
  ans += n / 5;
  n %= 5;
  ans += n;
  cout << ans <<endl;

  return 0;
}




Measured memory_bytes: 3184
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

K = int(input())


lines = defaultdict(set)
for i in range(K-1):
	lines[i].add((i+1,1))
lines[K-1].add((0,1))

for s in range(K):
	t = s*10 % K
	if s != t:
		lines[s].add((t,0))

def search (s,w_0): #s->t
	global weight
	global q

	for line in list(lines[s]):
		t = line[0]
		w = w_0 + line[1]
		if weight[t] > w:
			heapq.heappush(q, [w,t])
			weight[t] = w

s = 1
weight = [INF]*K
weight[s] = 0
q = [[0,s]]
heapq.heapify(q)
while q:
	w,n = heapq.heappop(q)
	search(n,w)

print(weight[0]+1)


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

int N, M;
vector<vector<int>> graph;
vector<vector<int>> dist;

int main(){
    cin >> N >> M;
    graph.resize(N,vector<int>());
    dist.resize(N, vector<int>(3, 1e9));
    for(int i=0; i<M; i++){
        int u, v;  cin >> u >> v;
        graph[u-1].push_back(v-1);
    }
    int S, T;  cin >> S >> T;
    S--;  T--;
    dist[S][0] = 0;
    queue<pair<int,int>> que;
    que.push({S,0});
    while(!que.empty()){
        int u = que.front().first;
        int d = que.front().second;
        que.pop();
        for(int v:graph[u]){
            if(dist[v][(d+1)%3] > dist[u][d] + 1){
                dist[v][(d+1)%3] = dist[u][d] + 1;
                que.push({v, (d+1)%3});
            }
        }
    }

    if(dist[T][0] != 1e9){
        cout << dist[T][0]/3 << endl;
    }else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 11136