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

using namespace std;
#define X first
#define Y second
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl;
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=5005;
int n,m,x,top[205],pos[205][MAXN];
ll val[205][MAXN],sum[MAXN],d[MAXN],res;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=2;i<=n;i++)
		scanf("%d",&x),d[i]=d[i-1]+x;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&x);
			for(;top[j]&&val[j][top[j]]<=x;top[j]--)
				sum[pos[j][top[j]]]-=val[j][top[j]],
				sum[pos[j][top[j]-1]]+=val[j][top[j]];
			sum[pos[j][top[j]]]-=x;sum[i]+=x;
			pos[j][++top[j]]=i;val[j][top[j]]=x;
		}
		ll tmp=0;
		for(int j=i;j;j--)
			tmp+=sum[j],res=max(res,tmp-(d[i]-d[j]));
	}
	printf("%lld",res);
	return 0;
}

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



int main() {
    int k;
    cin >> k;
    if(k < 10) {
        cout << k;
    }
    else {    
        k++;
        set<long long> st; 
        vector<long long> cur;
        for(int i = 0; i < 10; i++) {
            st.insert(i);
            cur.push_back(i);
        }
        long long power = 1;
        for(int i = 0; i < 12; i++) {
            vector<long long> tmp;
            for(auto it : cur) {
                long long top = it / power % 10LL;
                for(long long k = -1; k <= 1; k++) {
                    if(top + k >= 0 && top + k <= 9) {
                        tmp.push_back((top + k) * 10LL * power + it);
                    }
                }
            }
            for(auto it : tmp) st.insert(it);
            cur = tmp;
            //cout << power * 10 << " " << st.size() << '\n';
            if(st.size() >= k) {
                for(auto it : st) {
                    //cout << it << '\n';
                    k--;
                    if(k == 0) {
                        cout << it << '\n';
                        break;
                    }
                }
                break;
            } 
            power = power * 10LL;
        }
    }
    return 0;
}

Measured memory_bytes: 12104
import Data.List
main=do
 [n,p]<-map read.words<$>getLine
 s<-map(\c->fromEnum c-48).reverse<$>getLine
 let a=group$sort$0:(f 0 1 s p)
 print$sum$if 10`mod`p==0 then(map(\(c,i)->if c`mod`p==0 then i else 0)$zip(reverse s)[1..])else map(\l->(length l)*(-1+length l)`div`2)a
f w k[]p=[]
f w k(c:s)p=t:f t(k*10`mod`p)s p where t=(w+k*c)`mod`p

Measured memory_bytes: 30972
#include "stdio.h"
#include "string"
#include "iostream"

using namespace std;

int main(){
    int n;
    string a, b, output;

    cin >> n;
    cin >> a >> b;

    for(int i = 0; i< n; i++){
        output += string(1, a[i]) + string(1, b[i]);
    }
    cout << output << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}
int dp[100100];
int dfs(whei(int)&G, int v){
	if (dp[v] != -1)return dp[v];
	int s = 0;
	for (auto x : G[v])s = max(s, dfs(G, x)+1);
	return dp[v] = s;
}

int main() {
	int n, m;
	cin >> n >> m;
	whei(int) dp(n, hei(int)(m,0));
	whei(char) a(n, hei(char)(m));
	rep(i, 0, n)rep(j, 0, m)cin >> a[i][j];
	rep(i, 0, n) {
		if (a[i][0] == '#')break;
		dp[i][0] = 1;
	}
	rep(i, 0, m) {
		if (a[0][i] == '#')break;
		dp[0][i] = 1;
	}
	rep(i, 1, n) {
		rep(j, 1, m) {
			if (a[i - 1][j] == '.')dp[i][j] += dp[i - 1][j];
			if (a[i][j - 1] == '.')dp[i][j] += dp[i][j - 1];
			dp[i][j] %= mod;
		}
	}
	cout << dp[n - 1][m - 1] << endl;
	return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
#include<string.h>
#include<math.h>


int main() {
	
	int N;
	int P[300000];
	int j = 0;
	int flag = 0;
	int ans = 0;
	int P_Low = 0;

	scanf("%d", &N);

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

	P_Low = P[0];

	for (int i = 0; i < N; i++) {

		if (P[i] <= P_Low) {
			ans += 1;
            P_Low = P[i]; 
		}
		
		

	}

	printf("%d", ans);

	return 0;
	
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  string a;
  cin>>a;
  ll b=a.size();
  for(ll i=0;i<(b-1)/2+1;i++){
    if(a.at(2*i)=='L'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(ll i=0;i<b/2;i++){
    if(a.at(2*i+1)=='R'){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
  
  
  
      
                        
                        
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;

ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return (a/gcd(a,b)*b); }

int main() {
  ll A, B, C, D; cin >> A >> B >> C >> D; A--;
  ll sumc = A - A/C - A/D + A/lcm(C,D);
  ll sumd = B - B/C - B/D + B/lcm(C,D);
  ll result = sumd - sumc;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

ans = 0
f1 = min(a[0], b[0])
f = [[f1, min(a[1], b[0]-f1)]]
for i in range(1,n):
    f_tmp = min(a[i]-f[i-1][1], b[i])
    f.append([f_tmp, min(a[i+1], b[i]-f_tmp)])
for f_i in f:
    ans += f_i[0]+f_i[1]
print(ans)


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

int main()
{
	vector<int> A(3);

	cin >> A[0] >> A[1] >> A[2];

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

	cout << A[2] * 10 + A[1] + A[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,ans=0;
cin>>n;
int a[n+2];
for(i=0;i<n;i++)
{
cin>>a[i];

}
sort(a,a+n);
//cout<<a[n-1];
ans=a[n-1]-a[0];
cout<<ans<<endl;

}


Measured memory_bytes: 256
// At Coder :: Beginner Contest 178 :: D - Redistribution 
// https://atcoder.jp/contests/abc178/tasks/abc178_d

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const ll MOD{1000000007};

ll solve(ll S) {
    if (S < 3) {
        return 0LL;
    }

    vector<ll> A(S+1, 1);
    A[0] = A[1] = A[2] = 0;
    for (ll i{3}; i <= S; ++i) {
        for (ll k{3}; i - k >= 0; k++) {
            A[i] = A[i-k] + A[i] % MOD;
        }
    }
    return A[S];
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll S;
    cin >> S;
    cout << solve(S) << endl;
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3652
// WeirdBugsButOkay

#include <bits/stdc++.h>
 
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 
using namespace std;

ll pow3(ll a,ll b,ll m=1000000007)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

void solve()
{
    ll n,x,y;
    cin>>n>>x>>y;
    ll ans[n]={0};
    for(ll i=1;i<n+1;i++)
    {
        for(ll j=i+1;j<n+1;j++)
        {
            ll dis=min({j-i,abs(i-x)+1+abs(j-y),abs(j-x)+1+abs(i-y)});
            //cout<<i<<" "<<j<<" "<<dis<<endl;
            ans[dis]++;
        }
    }
    for(ll i=1;i<n;i++)
        cout<<ans[i]<<endl;
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q=1;
    //cin>>q;
    for(ll i=0;i<q;i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
package main
import "fmt"
func main(){
    // Your code here!
    var a int
    var b int
    var c int
    fmt.Scanf("%v%v%v", &a, &b, &c)
    if a < b && b < c {
        fmt.Println("Yes")
    }else {
        fmt.Println("No")
    }
}


Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int ans = 0,now = 1;
    rep(i,n){
        if(a[i] != now)ans++;
        else now++;
    }
    if(now != 1)cout<<ans<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int ans = 0;
		for (int i = 0; i < str.length(); i++) {
			String st = str.substring(i,i+1);
			if (st.equals("1")) {
				ans++;
			}
		}
		System.out.print(ans);
	}
} 


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,ans;
  int a[100005];
  cin>>n>>k;
  for(int i=0; i<n; i++){
    cin>>a[i];
  }

  sort(a,a+n);
  ans=a[k-1]-a[0];
  for(int i=1; i<=n-k; i++){
    if(ans>a[i+k-1]-a[i]){
      ans=a[i+k-1]-a[i];
    }
  }
  cout<<ans<<'\n';
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans = 0, c0, c1;
	string s;

	cin >> n >> s;
	n = s.length();
	vector<long long> b(n + 2, 0), w(n + 2, 0);
	for (i = 1; i <= n; i++) {
		b[i] = b[i - 1];
		if (s[i - 1] == '#') b[i]++;
	}
	for (i = n; i >= 1; i--) {
		w[i] = w[i + 1];
		if (s[i - 1] == '.') w[i]++;
	}

	ans = n * 3;
	for (i = 1; i <= n + 1; i++) {
		ans = min(ans, b[i - 1] + w[i]);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3956
n,a,b=map(int,input().split())
l=list(range(1,n+1))
ans_sum=0
for i in l:
    ans=0
    i_str=str(i)
    for j in i_str:
        ans+=int(j)
    if a<=ans<=b:
        ans_sum+=i
print(ans_sum)
        

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

int main(){
   string s; cin >> s;
   int bucket[26] = {0};

   for(int i=0; i<s.size(); i++) {
      int tmp = s[i] - 'a';
      bucket[tmp] = 1;
   }

   for(int i =0; i < 26; i++) {
      if (bucket[i] != 1) {
         printf("%c\n", i + 97);
         return 0;
      }
   }
   cout << "None" << endl;
   return 0;
}


Measured memory_bytes: 512
function Main(input) {
  input = input.split("\n");
  let target = parseInt(input[0].split(" ")[0]);
  let zerocheck = parseInt(input[0].split(" ")[1]);
  if (zerocheck == 0) {
    console.log(target);
  } else {
    let str = input[1].split(" ");
    for (let i = 0; i < str.length; i++) {
      let num = parseInt(str[i]);
      str[i] = target - num;
    }
    for (let ite = 0; ite <= 100; ite++) {
      const isp = str.indexOf(ite);//小さい方
      const isn = str.indexOf(-ite);//大きい方
      if (isp == -1) {
        console.log(target - ite);
        break;
      }
      if (isn == -1) {
        console.log(target + ite);
        break;
      }
    }
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

#define ll long long
#define fi first
#define se second
const int N=2e6+1;
int n,k;
ll a[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	string s;
	cin >> s;
	
	ll int cnt = 0;
	ll int ans = 0;
		for(int i = 0; i < s.size(); ++i)
		{
			if(s[i] == 'S') cnt = 0;
			else
				cnt++;
			
		ans = max(ans, cnt);
			
		}
		
	cout << ans << "\n";
			
}


Measured memory_bytes: 3584
use std::io::*;

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

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

fn main() {
    let v = read_vec::<i64>();
    let d = v[0] + v[1] - v[2] - v[3];
    let ans = if d > 0 {
        "Left"
    } else if d == 0 {
        "Balanced"
    } else {
        "Right"
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

void cnt(ll x,int n,ll pt){
    //cout<<" "<<x<<" "<<n<<" "<<pt<<endl;
    ll a = pow(2,n+2)-3,b = pow(2,n+1)-1; 
    if(x==1) {cout<<pt <<endl;return;}
    if(x==a) {cout<<pt + b;return;}
    if(x==a/2+1){cout<< pt+b/2+1;return;}

    if(n>1){
        if(x>a/2+1&&x>1){
            cnt(x-(a/2+1),n-1,pt+b/2+1);
        }
        if(x<a/2+1&&x>1){
            cnt(x-1,n-1,pt);
        }
    }
    else{ 
        cout<<pt+x-1<<endl;
        return;
    }
}


int main(){
    int n; cin>>n;
    ll x;cin>>x;
    cnt(x,n,0);
    return 0;
}

Measured memory_bytes: 256
Q = 10**9+7
def main():
    N, K = map( int, input().split())
    ANS = [0]*(K+1)
    for x in range(K,0,-1):
        ans = pow(K//x,N,Q)
        for i in range(2, K+1):
            if x*i > K:
                break
            ans -= ANS[x*i]
        ANS[x] = ans%Q
    print( sum( [ANS[i]*i%Q for i in range(K+1)])%Q)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 15192
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int a , b , c ,times;
    cin>>a>>b>>c>>times;
    int max_ = max(a,max(b,c));
    cout<<(pow(2,times)-1)*max_ + b + a +c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9;
const long double PI=acos(-1);

int a[11][11];

void solve(int T){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int j=i%10;
        int k=i;
        while(k>=10){
            k/=10;
        }
        a[k][j]++;
    }
    int ans=0;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            ans+=a[i][j]*a[j][i];
        }
    }
    cout<<ans<<"\n";
}

int main() {
    //fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


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

int main()
{
    string s;
    stack<int> st;

    for (; cin >> s;) {
        if (s == "+" || s == "-" || s == "*") {
            int a = st.top(); st.pop();
            int b = st.top(); st.pop();
            if (s == "+") st.push(b + a);
            if (s == "-") st.push(b - a);
            if (s == "*") st.push(b * a);
        }
        else st.push(stoi(s));
    }

    cout << st.top() << endl;

    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll n, ans;
VLL a;
map<ll, ll> mp;

int main()
{
    cin>>n;
    a.resize(n);
    REP(i,n) {
        cin>>a[i];
        ans += mp[a[i] - i];
        mp[- i - a[i]]++;
    }

	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 27300
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b);
#define chmin(a, b) (a)=min(a, b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  string s;
  cin >> s;
  ll N=s.size();
  ll dp[MAX*2][3]={};
  
  s="#"+s;
  dp[1][1]=1;
  dp[2][1]=(s[1]==s[2]) ? 0 : 2;
  dp[2][2]=1;
  for(i=1; i<=N; i++) {
    if(i>=2 && s.substr(i-1, 2)!=s.substr(i+1, 2))
      chmax(dp[i+2][2], dp[i][2]+1);
    if(s.substr(i, 1)!=s.substr(i+1, 1))
      chmax(dp[i+1][1], dp[i][1]+1);
    
    chmax(dp[i+1][1], dp[i][2]+1);
    chmax(dp[i+2][2], dp[i][1]+1);
  }
  
  
  pt(max(dp[N][1], dp[N][2]));
  
}





Measured memory_bytes: 5508
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  cout << N + N*N + N*N*N << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define rrep(i, n) for (int i = n-1; i >= 0; i--)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
#define lloop(i, a, b) for(ll i = a; i < (b); i++)
#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int n, k;
vi arr;
bool check(int x) {
	ll total = 0;
	rep(i, n) total += (arr[i]+x-1)/x - 1;
	return (total <= k);
}

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> k;
	arr.resize(n);
	rep(i, n) cin >> arr[i];
	int l = 0, r = 1000000001;
	while (r > l+1) {
		int m = (l+r)/2;
		if (check(m)) r = m;
		else l = m;
	}
	cout << r << endl;
	
	// you should actually read the stuff at the bottom
}
/* stuff you should look for
 * int overflow, array bounds
 * special cases (n=1?)
 * do smth instead of nothing and stay organized
 * WRITE STUFF DOWN
 * also remember to clear global variables on multitest problems
 */
// benq please don't sue me


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var ans = 0;
            if (K == 1) ans = 0;
            else
            {
                ans = N - (K - 1) - 1;
            }            

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main() {
  
  int N; cin >> N;
  
  vector<int64_t> vecA(N);
  
  for (int i = 0; i < N; i++) cin >> vecA[i];
  
  vector<int64_t> vecB(N);
  
  for (int i = 0; i < N; i++) cin >> vecB[i];
  
  int64_t sum = 0;
  
  for (int i = 0; i < N; i++) {
    
    int64_t tmpA = vecA[i], tmpB = vecB[i];
    
    if (tmpA < tmpB) sum += (tmpB - tmpA) / 2;
    
    if (tmpB < tmpA) sum -= tmpA - tmpB;
    
  }
  
  if (sum < 0) cout << "No" << endl;
  
  else cout << "Yes" << endl;
  
}

Measured memory_bytes: 3776
N, M = map(int, input().split())
X = [0]*M
for i in range(M):
  A, *B= map(int, input().split())
  X[i] = B
p = list(map(int, input().split()))
onoff =[0]*M
count = 0
for i in range(2**N):
    for j in range(N):
        if (i>>j) & 1:
            for k in range(M):
                if j+1 in X[k]:
                    onoff[k] += 1
    flag = 1
    for i in range(M):
        if onoff[i] % 2 != p[i]:
            flag = 0
    if flag:
        count += 1
    onoff = [0]*M
print(count)
    
  


Measured memory_bytes: 42352
#include<iostream>

using namespace std;

int main()
{
    int k, n;
    cin >> k >> n;
    int first, act, pre, maxD = 0;
    cin >> first;
    pre = first;
    for(int i = 1; i < n; ++i)
    {
        cin >> act;
        maxD = max(maxD, act-pre);
        pre = act;
    }
    maxD = max(maxD, k-pre+first);
    cout << (k - maxD) << endl;
    return 0;
}


Measured memory_bytes: 256
// B - An Odd Problem
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n){
        if(i%2 == 0 && a[i]%2 == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n, m;
    cin >> n >> m;
    int flag[30];
    rep(i, 30){flag[i] = 0;}
    rep(i, n){
        int km;
        cin >> km;
        rep(j, km){
            int a;
            cin >> a;
            flag[a-1]++;
        }
    }
    int count = 0;
	rep(i, m){
        if(flag[i] == n)count++;
    }
    cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    /*
    vector<int> a(n+1);
    rep(i,n) cin >> a[i+1];
    const int INF = INT_MAX;
    vector<int> cnt(n+1,INF);
    int now = 1;
    cnt[1] = 0;
    ll j = 0;
    while(j < k) {
        j++;
        now = a[now];
        if(cnt[now] != INF) {
            j += (j-cnt[now])*((k-j)/(j-cnt[now]));
        } else {
            cnt[now] = j;
        }
    }
    cout << now << endl;
    */
    //ダブリング
    const int D = 60;
    vector<vector<int>> to(D, vector<int>(n));
    //to[i][j] : jから2^i回でどこへ行くか
    rep(i,n) {
        cin >> to[0][i];to[0][i]--;
    }
    rep(i,D-1) rep(j,n) to[i+1][j] = to[i][to[i][j]];
    
    int v = 0;
    for(int i = D-1; i >= 0; i--) {
        ll l = 1ll << i;
        if(l <= k) {
            k-=l;
            v = to[i][v];
        }
    }
    cout << v+1 << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

template<class T> struct Mat {
    int r,c; vector<vector<T>> d;
    Mat(int _r, int _c) : r(_r), c(_c) {
        d.assign(r,vector<T>(c));
    }
    Mat() : Mat(0,0) {}
    Mat(const vector<vector<T>>&_d) :
    r(sz(_d)), c(sz(_d[0])) { d = _d; }

    Mat& operator+=(const Mat& m) {
        F0R(i,r) F0R(j,c) d[i][j] = (d[i][j]+m.d[i][j])%MOD;
        return *this;
    }
    Mat& operator-=(const Mat& m) {
        F0R(i,r) F0R(j,c) d[i][j] = (d[i][j]-m.d[i][j]+MOD)%MOD;
        return *this;
    }
    Mat operator*(const Mat& m) {
        assert(c == m.r); Mat x(r,m.c);
        F0R(i,r) F0R(j,c) F0R(k,m.c)
        x.d[i][k] = (x.d[i][k]+((d[i][j]*m.d[j][k])%MOD))%MOD;
        return x;
    }
    Mat operator+(const Mat& m) { return Mat(*this)+=m; }
    Mat operator-(const Mat& m) { return Mat(*this)-=m; }
    Mat& operator*=(const Mat& m) {
        return *this = (*this)*m;
    }
    friend Mat qpow(Mat m, ll p) {
        assert(m.r == m.c && p >= 0);
        Mat res(m.r,m.c); F0R(i,m.r) res.d[i][i] = 1;
        for (; p; p /= 2, m *= m) if (p&1) res *= m;
        return res;
    }
};

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll N,K; cin >> N >> K;

    Mat<ll> m(N,N);

    F0R(i,N) F0R(j,N) {
        cin >> m.d[i][j];
    }

    m = qpow(m,K);

    ll res = 0;
    F0R(i,N) F0R(j,N) res = (res+m.d[i][j])%MOD;

    cout << res << "\n";

}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

typedef long long ll;

using namespace std;

int main()
{
	ll a, b;
	cin >> a >> b ;

	ll d = a / b;
	ll r = a % b;
	double f = (double)a / (double)b;
	cout << d << " " << r << " " << fixed << f << endl;

	return 0;
}




Measured memory_bytes: 3272
#include<cstdio>
#include<iostream>


using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if (a > c && a > b) {
        ans = (c * b) / 2;
    }else if (b > a && b > c) {
        ans = (a * c) / 2;
    }else{
        ans = (a * b) / 2;
    }
    
    cout << ans << '\n';
    
}

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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
pair<int, int> a[maxi];
int n;


bool cmp(pair<int,int> x, pair<int,int> y)
{
    return x.first + x.second< y.first + y.second;
}

int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
        scanf("%d%d",&a[i].first,&a[i].second);

    sort(a+1,a+n+1, cmp);

    int ans = 1;
    int last = 1;

    for (int i=2;i<=n;i++)
        if (a[last].first + a[last].second <= a[i].first - a[i].second)
    {
        ans++;
        last = i;
    }

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


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n;cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++) cin>>d[i];
    sort(d.begin(),d.end());
    int res=1;
    for(int i=1;i<n;i++){
        if(d[i]>d[i-1]) res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n;
cin>>n;
long int k;
k= n%10;

if(k==2 || k==4 || k==5 || k==7 || k==9)
{

    cout << "hon";
}
else if(k==3)
{

    cout << "bon";
}
else cout<< "pon";

return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;
#define Nmax 100000
int main() {
	int N;
	int a;
	int start;
	int Nnum[Nmax];
	cin >> N;
	for (int i = 1; i < N+1; i++) {
		cin >> a;
		Nnum[i] = a;
	}
	int next=1;
	int count = 0;
	while (count<N) {
		next = Nnum[next];
		count++;
		if (next == 2)
			break;
	}
	if (next == 2)
		cout << count << endl;
	else
		cout << -1 << endl;

}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            if (a == 1) {
                array[b] += 1;
            }
            if (b == n) {
                array[a] += 200000;
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (array[i] > 200000 && array[i] % 200000 != 0) {
                ans = 1;
                break;
            }
        }
        if (ans == 1) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 65472
import sys
# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_left, bisect_right, insort_left, insort_right
# from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]


if __name__ == '__main__':
    h, w = wi()
    s = hs(h)
    flagli = [[0] * w for i in range(h)]
    stack = deque()
    black = 0
    white = 0
    for i in range(h):
        for j in range(w):
            if flagli[i][j] == 0:
                flagli[i][j] = 1
                white = 1 if s[i][j] == "." else 0
                black = 1 if s[i][j] == "#" else 0
                stack.append([i, j])
                while stack != deque():
                    p, q = stack.pop()
                    k = 0 if s[p][q] == "." else 1
                    for dx, dy in dd:
                        nx = q + dx;
                        ny = p + dy
                        if 0 <= nx < w and 0 <= ny < h:
                            if flagli[ny][nx] == 0:
                                if k == 0 and s[ny][nx] == "#":
                                    flagli[ny][nx] = 1
                                    stack.append([ny, nx])
                                    black += 1
                                elif k == 1 and s[ny][nx] == ".":
                                    flagli[ny][nx] = 1
                                    stack.append([ny, nx])
                                    white += 1
                ans += black * white
                black = 0
                white = 0
    print(ans)

Measured memory_bytes: 52700
#include <bits/stdc++.h>
using namespace std;
int main () {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) {
        puts("+");
    }
    else if (a * b == 15) {
        puts("*");
    }
    else {
        puts("x");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  int num = 1;
  for (int i = 0; i < N; ++i){
    if ( (num + K) < (num * 2) ){
      num += K;
    }
    else{
      num *= 2;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int x, a, b, c, d = 0;
scanf("%d", &x);
scanf("%d", &a);
scanf("%d", &b);

c = x - a;

while(c > 0){
  c = c - b;
  if(c < 0){
  break;
  }
  d = c;
}
printf("%d", d);

return (0);
}


Measured memory_bytes: 128
object Main extends App {

  import scala.io.StdIn._
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val bestInterest = Array.tabulate(1001){ _ ⇒ Int.MaxValue}
  for (i ← 0 until n) {
    val cost = readLine.trim.toInt
    if (bestInterest(cost) > i) bestInterest(cost) = i + 1
  }
  for (i ← 1 to 1000) {
    if (bestInterest(i - 1) < bestInterest(i)) bestInterest(i) = bestInterest(i - 1)
  }
  val compe = Array.tabulate(n + 1){_ ⇒ 0}
    for (_ ← 0 until m) {
      compe(bestInterest(readLine.trim.toInt)) += 1
    }
  println(
    compe.indexOf(compe.max)
  )

}



Measured memory_bytes: 44304
// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long   
int mod=1e9+7;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m; return t%m; }

const int mx=1000001;
vector<bool> prim(mx,true); 

void seive(){
    for (int p = 2;p*p<=1000001;p++) {
        if (prim[p]==true) 
            for (int i=p * p;i<=1000001;i += p) 
                prim[i] = false; 
    }
}
                
int div(int n) 
{ 
 	int total = 1; 
    for (int p = 2; p <= n; p++) { 
        if (prim[p]) { 
            int count = 0; 
            if (n%p==0) { 
                while (n%p == 0) { 
                     n=n/p; 
                     count++; 
                } 
                total *= (count + 1); 
            } 
        } 
    } 
    return total; 
} 

signed main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0); 
  
    int n;
    cin>>n;
    seive();
    int ans=0;
    for (int i=1;i<n;++i){
      ans+=floor(n-1)/i;
    }   
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3724
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int a[5], c[4];
    cin >> a[0];
    if (!a[0]) return 0;
    fill(c+1, c+4, 0);
    for (int i = 1; i < 5; i++)
      cin >> a[i];
    for (int i = 0; i < 5; i++)
      c[a[i]]++;
    int w = 0;
    if (!c[1] && c[2] && c[3])
      w = 2;
    else if (c[1] && !c[2] && c[3])
      w = 3;
    else if (c[1] && c[2] && !c[3])
      w = 1;
    if (w)
      for (int i = 0; i < 5; i++)
        cout << (a[i] == w ? 1 : 2) << endl;
    else
      for (int i = 0; i < 5; i++)
        cout << 3 << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ri register int
const int N=225;
char s[N];
int n,m,b[N][N],f[N][N][N],g[N][N][N]; 
inline bool check(ri x1,ri x2,ri y1,ri y2){
	ri s=b[x2][y2]-b[x1-1][y2]-b[x2][y1-1]+b[x1-1][y1-1];
//	printf("check %d %d %d %d %d\n",x1,x2,y1,y2,s);
	return !s||s==(x2-x1+1)*(y2-y1+1);
}
int main(){
	ri i,j,l,r,ans,now;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i){
		scanf("%s",s+1);
		for(j=1;j<=m;++j)
			b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+(s[j]=='.');
	}
	for(l=1;r<=m;++l)
		for(r=l;r<=m;++r)
			f[n+1][l][r]=n;
	for(l=1;l<=n;++l)
		for(r=l;r<=n;++r)
			g[m+1][l][r]=m;
	for(l=1;l<=m;++l)
		for(r=l;r<=m;++r)
			for(i=1;i<=n;++i){
				f[i][l][r]=max(f[i-1][l][r],i-1);
				while(f[i][l][r]+1<=n&&check(i,f[i][l][r]+1,l,r))
					++f[i][l][r];
			//	printf("f %d %d %d %d\n",i,l,r,f[i][l][r]);
			}
	for(l=1;l<=n;++l)
		for(r=l;r<=n;++r)
			for(i=1;i<=m;++i){
				g[i][l][r]=max(g[i-1][l][r],i-1);
				while(g[i][l][r]+1<=m&&check(l,r,i,g[i][l][r]+1))
					++g[i][l][r];
			}
	for(ans=0;;++ans){
	//	printf("%d %d\n",f[1][1][m],g[1][1][n]);
		if(f[1][1][m]>=n||g[1][1][n]>=m)
		//	printf("%d %d\n",f[1][1][m],g[1][1][m]);
			return printf("%d\n",ans),0;
		for(l=1;l<=m;++l)
			for(r=l;r<=m;++r){
				now=0;
				for(i=1;i<=n;++i){
					now=max(now,i-1);
					while(now+1<=n&&g[g[l][i][now+1]+1][i][now+1]>=r) // |   +1
						++now;
					f[i][l][r]=max(now,f[f[i][l][r]+1][l][r]); // __
				}
			}
		for(l=1;l<=n;++l)
			for(r=l;r<=n;++r){
				now=0;
				for(i=1;i<=m;++i){
					now=max(now,i-1);
					while(now+1<=m&&f[l][i][now+1]>=r) // __    +0
						++now; 
				//	printf("%d %d %d %d\n",l,r,i,now);
					g[i][l][r]=max(now,g[g[i][l][r]+1][l][r]); // |
				}
			}
	}
}

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

int ame(int x){
  if(x == 0)
    return x;
  
  else
    return x+ame(x-1);
}
  

int main() {
  int n,total=0;
  
  cin >> n;
  
  total = ame(n);
  
  cout << total;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int count;
	int i,j;
	int sosuu;
	int sosuulist[100000];
	while(!feof(stdin)) {
		scanf("%d",&n);
		if(feof(stdin))break;
		if(n>=2) {
			sosuulist[0]=2;
			count=1;
		} else count=0;
		for(i=3;i<=n;i+=2) {
			sosuu=1;
			for(j=0;j<count && sosuulist[j]*sosuulist[j]<=i;j++) {
				if(i%sosuulist[j]==0) {
					sosuu=0;
					break;
				}
			}
			if(sosuu) {
				sosuulist[count]=i;
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 720
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules! chmax {
    ( $ x : expr , $ y : expr ) => {
        if $x < $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => {
        if $x > $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        s: chars
    }
    let mut p = 1usize << 60;
    let mut q = 0;
    for i in 0..s.len() {
        if s[i] == 'A' {
            chmin!(p, i);
        }
        if s[i] == 'Z' {
            chmax!(q, i);
        }
    }
    println!("{}", q - p + 1);
}

Measured memory_bytes: 4352
#!/usr/bin/perl
my ($n,$k) = map { $_ - 0 } split(/\s+/,<STDIN>);
my $s = <STDIN>;

my $hn = 0;
my $g = 0;

my $c2 = substr($s,0,1);
for(my $i=0;$i<$n-1;$i++){
  my $c1 = $c2;
  $c2 = substr($s,$i+1,1);
  $hn ++ if $c1 eq $c2;
  $g ++ if $c1 ne $c2;
}

my $maxh = $hn;
if( $k * 2 <= $g ){
  $maxh += $k * 2;
} else {
  $maxh = $n - 1;
}
print "$maxh\n";

exit(0);




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

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

int main()
{
    int n;
    cin >> n;
    ll sun = 0;
    for(int i=1; i<=n; i++)
    for(int j=1; j<=n; j++)
    for(int k=1; k<=n; k++)
    {
        sun += gcd(gcd(i, j), k);
    }
    cout << sun << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using pint = pair<int, int>;

int main() {
  string w;
  cin >> w;
  vector<int> v(26, 0);
  rep(i, 0, w.size()) v[w[i] - '0' - 49]++;
  rep(i, 0, 26) {
    if (v[i] % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3600
package main

import (
	"fmt"
	"sort"
)

func main() {
	var L [3]int
	var ans string
	fmt.Scan(&L[0], &L[1], &L[2])

	sort.Ints(L[:])

	if L[0]+L[1] == L[2] {
		ans = "Yes"
	} else {
		ans = "No"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
 
using namespace std;
 
int main(){
	int n;
	cin>>n;
	unsigned long long a[n];
	long double k=0;
	int z=0;
	unsigned long long s=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<0<<endl;
			return 0;
		}
		k+=log10(a[i]);
	}
	if(k>18.1){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		s*=a[i];
		if(s>1000000000000000000){
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 4512
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
XY = np.array([lr() for _ in range(N)])
X = XY[:, 0]; Y = XY[:, 1]
diff_X = X[:, None] - X[None, :]
diff_Y = Y[:, None] - Y[None, :]
path = (diff_X ** 2 + diff_Y ** 2) ** .5
answer = path.sum() / N
print(answer)


Measured memory_bytes: 12508
#include<cstdio>
int n,k,a[1005];
int main()
{
    scanf("%d %d",&n,&k);
    a[1]=k;
    for(int i=2;i<=n;i++)
        a[i]=a[i-1]*(k-1);
    printf("%d",a[n]);
    return 0;
}

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

int main() {
   int N;
   cin>>N;
   vector<vector<int>> a(2,vector<int>(N));
   for(int i=0;i<2;i++){
      for(int j=0;j<N;j++){
         cin>>a[i][j];
      }
   }
   int maxx=0;
   int y=0;
   for(int i=0;i<N;i++){
      int x=0;
      for(int j=0;j<N;j++){
         if(i==j){
         x+=a[0][j];
         y=1;
         }
         x+=a[y][j];
      }
         y=0;
         maxx=max(maxx,x);
   }
   cout<<maxx<<endl;
   
   return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='9')cout << 1;
    else if(s[i]=='1')cout << 9;
    else cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256