akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
    string a;
    string f,b;
    int sum = 1;
    cin >> a;

    if(a.length()%2 == 0){
        cout<< "No"<<endl;
        return 0;
    }

    f = a.substr(0, (a.length())/2);
    b = a.substr((a.length())/2 + 1, a.length());
   

    if(!f.compare(b)){
        cout<< "Yes"<<endl;
        return 0;
    }


    cout<< "No"<<endl;
    

    return 0;
}

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

int main() {
  int N, K, a = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x < K - x) {a += 2 * x;}
    else {a += 2 * (K - x);}
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long i,j,k,s=0,p,ss=5555555,q,r;
	string t,l;
	cin>>t>>l;
	q=t.size();
	r=l.size();
	for(i=0;i<=(q-r);i++)
	{
		s=0;
		p=i;
		for(j=0;j<r;j++)
		{
			if (t[p]!=l[j])s++;
			p++;
		}
		if (s<ss)ss=s;
	}
	cout<<ss;
}

Measured memory_bytes: 3624
L = [
    0,
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]
K = int(input())
print(L[K])


Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s,t;
    cin >> s >> t;
    REP(i,0,s.size()) if (s[i] != t[i]) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

vector<int> verdes,vermelhas,incolores,vazio;
vector<vector<int>> DP;


int main(){
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	for (int i = 0; i < a; ++i)
	{
		int val; 
		cin >> val;
		verdes.push_back(val);
	}
	for (int i = 0; i < b; ++i)
	{
		int val; 
		cin >> val;
		vermelhas.push_back(val);
	}
	for (int i = 0; i < c; ++i)
	{
		int val; 
		cin >> val;
		incolores.push_back(val);
	}
	sort(verdes.begin(),verdes.end());
	sort(vermelhas.begin(),vermelhas.end());
	sort(incolores.begin(),incolores.end());
	int ponteiro1=x,ponteiro2=y,ponteiro3=0;
	bool quebraVermelha=false,quebraVerde=false;
	while(verdes[a-ponteiro1]<incolores[c-ponteiro3-1]||vermelhas[b-ponteiro2]<incolores[c-ponteiro3-1]){
		if(verdes[a-ponteiro1]<vermelhas[b-ponteiro2]){
			ponteiro1-=1;
		}else{
			ponteiro2-=1;
		}
		if(ponteiro1<0){
		    ponteiro1=0;
		    quebraVerde=true;
		    break;
		}
		if(ponteiro2<0){
		    ponteiro2=0;
		    quebraVermelha=true;
		    break;
		}
		ponteiro3+=1;
		if(ponteiro3==c){
		    break;
		}
		
	}
	if(quebraVerde){
	    while(vermelhas[b-ponteiro2]<incolores[c-ponteiro3-1]){
	        ponteiro2-=1;
    	    if(ponteiro2<0){
    		    ponteiro2=0;
    		    break;
		    }
		    ponteiro3+=1;
		    if(ponteiro3==c){
    		    break;
    		}
	    }
	}else if(quebraVermelha){
	    while(verdes[a-ponteiro1]<incolores[c-ponteiro3-1]){
	        ponteiro1-=1;
    	    if(ponteiro1<0){
    		    ponteiro1=0;
    		    break;
		    }
		    ponteiro3+=1;
		    if(ponteiro3==c){
    		    break;
    		}
	    }
	}
	long long int total=0;
	for (int i = 1; i <= ponteiro1; ++i)
	{
		total+=verdes[a-i];
	}
	for (int i = 1; i <= ponteiro2; ++i)
	{
		total+=vermelhas[b-i];
	}
	for (int i = 1; i <= ponteiro3; ++i)
	{
		total+=incolores[c-i];
	}
	cout << total;
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
const long long INF = 1LL << 60;
using namespace std;

int n;
ll dp[100010][3];
ll a[100010][3];

int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >>a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k)continue;
				dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i][k]);
			}
		}
	}
	ll ans=0;
	for(int i=0;i<3;i++){
		ans=max(ans,dp[n][i]);
	}
	cout << ans <<endl;
}


Measured memory_bytes: 4992
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Data.List
import Data.Char (digitToInt)
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust, fromMaybe)
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Set as S


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

readIntBC :: IO (Int, BC.ByteString)
readIntBC = do
    [a, b] <- BC.words <$> BC.getLine
    return (fst . fromJust . BC.readInt $ a, b)

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

fastPowerMod :: Int -> Int -> Int -> Int
fastPowerMod b 0 _ = 1
fastPowerMod b 1 modnum = b `mod` modnum
fastPowerMod b n modnum
            | even n = (fastPowerMod b (n `div` 2) modnum ^ 2) `mod` modnum
            | otherwise = (fastPowerMod b (n - 1) modnum * b) `mod` modnum


solve :: [(Int, BC.ByteString)] -> String
solve submits = let
    initial = (M.empty, S.empty, 0) -- wa count, ac, wa
    go (waMap, acSet, waCount) (qnum, "WA") = ((M.alter (\v -> Just $ (fromMaybe 0 v) + 1) qnum waMap), acSet, waCount)
    go (waMap, acSet, waCount) (qnum, "AC")
        | S.member qnum acSet = (waMap, acSet, waCount)
        | otherwise = (waMap, S.insert qnum acSet, waCount + M.findWithDefault 0 qnum waMap)
    (_, finalACSet, waCount) = foldl' go initial submits
    acCount = S.size finalACSet
    in
    show acCount ++ " " ++ show waCount
main = do
    (n,m ) <- readTuple2
    submits <- replicateM m readIntBC
    putStrLn $ solve submits



Measured memory_bytes: 88444
// time-limit: 2000
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cout << coutc << e;
  ((cout << " " << r), ..., (cout << endc << endl));
}
#else
#define debug(...)
#endif

int sign(li x) { return x < 0 ? -1 : x > 0; }

//         a / b
li ceil(li a, li b) {
  if (sign(a) == sign(b) && a % b) return a / b + 1;
  else return a / b;
}

void _main(int tc) {
    int a, b;
    cin >> a >> b;

    // b = a + (a - 1) * X
    // X = (b - a) / (a - 1)
    // is ceiling because we need to assure that with X pipes we complete "b - a" lines.
    // we add one because after fullfilling "b - a" we still need to complete with "a" lines.
    cout << ceil(b - a, a - 1) + 1 << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}


Measured memory_bytes: 3652
fun main(args: Array<String>) {
  val (H, N) = readInts()
  val AB = (1..N).map { readInts() }

  val dp = Array(H + 1) { Int.MAX_VALUE / 2 }
  dp[H] = 0
  for (i in H downTo 0) {
    for (j in 0 until N) {
      val (A, B) = AB[j]
      // 魔力 B で A の攻撃
      val v = dp[i] // 現在使用している魔力
      val hp = Math.max(i - A, 0) // 攻撃後の残り体力, 0 以下にはならない
      dp[hp] = Math.min(dp[hp], v + B)
    }
  }

  println(dp[0])
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 75172
#include <iostream>
#include <vector>

using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<int> a, b;

    for (int i=0; i < n - 1; i++)
    {
        int val;
        cin >> val;
        b.push_back(val);
    }

    a.push_back(b[0]);
    for (int i=0; i < n - 1; i++)
    {
        a.push_back(min(b[i], b[i+1]));
    }
    a.push_back(b[b.size() - 1]);

    int s = 0;
    for (auto e: a)
    {
        s += e;
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=1e9+7;
map<int,int> Ref;
int n,i,x,a[N],b[N],c[N],d[N],pp,ans,y,fa[N],tt,act[N];
int get(int x)
{
	if (fa[x]==x) return x;
	return fa[x]=get(fa[x]);
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n)
	{
		scanf("%d",a+i);
		x^=a[i];
	}
	a[n+1]=x;x=0;
	fo(i,1,n) 
	{
		scanf("%d",b+i);
		x^=b[i];
	}
	b[++n]=x;
	fo(i,1,n) c[i]=a[i],d[i]=b[i];
	sort(c+1,c+1+n);
	sort(d+1,d+1+n);
	pp=1;
	fo(i,1,n) if (c[i]!=d[i]) break;
	if (i<=n)
		printf("-1\n");
	else
	{
		c[0]=-1;
		fo(i,1,n)
		{
			if (c[i]!=c[i-1]) tt++;
			Ref[c[i]]=tt;
		}
		fo(i,1,tt) fa[i]=i;
		fo(i,1,n)
			if (a[i]!=b[i]||i==n)
			{
				ans+=(i<n);
				act[Ref[a[i]]]=act[Ref[b[i]]]=1;
				fa[get(Ref[a[i]])]=get(Ref[b[i]]);
			}
		if (ans)
		{
			fo(i,1,tt) if (act[i]&&fa[i]==i)
				ans++;
			ans--;
		}	
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 21248
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			char c[]=in.next().toCharArray();
			int ans=0;
			int i;
			for(i=0;i<c.length-1;i++)
			{
				if(f(c[i])>=f(c[i+1]))
					ans+=f(c[i]);
				else
				{
					ans+=f(c[i+1])-f(c[i]);
					i++;
				}
			}
			if(i==c.length-1)
				ans+=f(c[i]);
			System.out.println(ans);
		}
	}
	public static int f(char c)
	{
		return 
				c=='I'?1:
				c=='V'?5:
				c=='X'?10:
				c=='L'?50:
				c=='C'?100:
				c=='D'?500:1000;
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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;
}

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

int main()
{
    ll n;
    cin >> n;
    ll a;
    ll bai4 = 0, bai2 = 0, denai = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a % 4 == 0)
        {
            bai4++;
        }
        else if (a % 2 == 0)
        {
            bai2++;
        }
        else
        {
            denai++;
        }
    }
    if (n % 2)
    {
        if (bai2)
        {
            if (bai4 >= denai)
            {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            if (bai4 + 1 >= denai)
            {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
    }
    else
    {
        if (bai4 >= denai)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <numeric>
#include <unordered_map>
using namespace std;
int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	else return -1;
}
int each_sum(int n) {
	int sum = 0;
	string s = to_string(n);
	for (int i = 0; i < s.size(); i++) {
		sum += ctoi(s[i]);
	}
	return sum;
}
int main() {
	int n, max, min, sum = 0;
	cin >> n >> min >> max;
	for (int i = 1; i <= n; ++i) {
		if (each_sum(i) >= min&&each_sum(i) <= max) {
			sum += i;
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as C8

type Pair = (Int, Int)

main :: IO ()
main = do
  [n,m] <- readInts
  ps <- sortOn fst <$> replicateM n readPair
  print $ solve m ps
 
solve :: Int -> [Pair] -> Int
solve m = fst . foldl' f e
  where
    e = (0,0)
    f (!s,!n) (a,b)
      | n == m = (s,n)
      | c > m = (s+a*(m-n),m) -- until ((m==).snd) (\(!s,!n) -> (s+a,n+1)) (s,n)
      | otherwise = (s+a*b, c)
      where
        c = n+b

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

readPair :: IO Pair
readPair = do
  [x,y] <- readInts
  return (x,y)

Measured memory_bytes: 56700
#include<bits/stdc++.h>
using namespace std;
#define mo 924844033
int n,k;
long long ans;
long long jc[2005],g[2005],h[2005],f[2005][2005][2];
void work() {
	jc[0]=1;
	for(int i=1;i<=n;i++) jc[i]=jc[i-1]*i%mo;
	for(int i=0;i<=n;i++) f[i][0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mo,f[i][j][1]=f[i-1][j-1][0];
	g[0]=1;
	for(int i=1;i<=k;i++)
	{
		int sz=(n-i)/k;
		for(int j=n;j>=0;j--)
			for(int l=1;l<=sz;l++) g[j]=(g[j]+g[j-l]*(f[sz][l][0]+f[sz][l][1])%mo)%mo;
		for(int j=n;j>=0;j--)
			for(int l=1;l<=sz;l++) g[j]=(g[j]+g[j-l]*(f[sz][l][0]+f[sz][l][1])%mo)%mo;
	}
	for(int i=0;i<=n;i++) h[i]=jc[n-i]*g[i]%mo,ans=(ans+((i&1)?-h[i]:h[i]))%mo;
	ans=(ans%mo+mo)%mo;
	cout<<ans<<endl;
}
int main()
{
	//freopen("1.in","r",stdin);
	cin>>n>>k;
	work();
	return 0;
}

Measured memory_bytes: 62976
/**
	If you only do what you can do, 
	You will never be more than you are now!
	----------------------------------------
	We must all suffer from one of two pains: the pain of discipline or the pain of regret. 
	The difference is discipline weighs grams while regret weighs tons.
**/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
 
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll
 
const int N = 200;
 
int n, x[N], y[N], h[N], pos;
 
int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	fo(i, 1, n, 1) {
		cin >> x[i] >> y[i] >> h[i];
		if(h[i] >= 1) pos = i;
	}	
	fo(xc, 0, 100, 1) {
		fo(yc, 0, 100, 1) {
			int hc = h[pos] + abs(x[pos] - xc) + abs(y[pos] - yc);
			bool ok = 1;
			fo(i, 1, n, 1) {
				if(h[i] != max(hc - abs(x[i] - xc) - abs(y[i] - yc), 0)) {
					ok = 0;
					break;
				}	
			}
			if(ok) {
				cout << xc <<' '<< yc <<' '<< hc <<'\n';
				return 0;
			} 
		}
	}
	while(1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(char c : s) if(c == '2') ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

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

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    XY = LIR(N)

    Z = sorted([x+y for x, y in XY])
    W = sorted([x-y for x, y in XY])
    print(max(Z[-1] - Z[0], W[-1] - W[0]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 124208
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()


int n, m;
vector<pair<int, vector<int>>> c(10);
bool visited[10] = {false};

int dfs(int x, int len){
    if(++len >= n)return 1;
    visited[x] = true;
    int path = 0;
    rep(i, c[x].second.size()){
        int pos = c[x].second[i];
        if(visited[pos])continue;
        path  += dfs(pos,  len); 
    }
    visited[x] = false;
    return path;
}
int main(){
    
    cin >> n >> m;
    int a[m], b[m];
    rep(i, m){
        cin >> a[i] >> b[i];
        c[a[i]].second.push_back(b[i]);
        c[b[i]].second.push_back(a[i]);
    }

    cout << dfs(1, 0);


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int n;
int a[2][105];

int dfs(int x, int y){
    if(x == 1 && y == n - 1)    return a[x][y];
    int res = a[x][y];
    int foo = 0, bar = 0;
    if(x + 1 < 2)   foo = dfs(x + 1, y);
    if(y + 1 < n)   bar = dfs(x, y + 1);
    res += max(foo, bar);
    return res;
}

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

    cin >> n;
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            cin >> a[i][j];
        }
    }
    cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 256
// @niwatorip
// 多分一番わかりやすいのは実際1回ずつに減らしていく方法
// か[A/D]と[C/B]の比較([]はガウス記号)


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  for(int i=0;i<201;i++){ //攻撃の回数は最大で100回ずつ(なのでiはその合計値(=200)より大きくしなきゃいけない
    if(i%2==0){
        if(C-(i/2)*B<=0){
        //高橋くんが先攻、iは0からなのでi == 0の時はこっちが攻撃する必要がある
        //(元のやつは逆だった)
        //攻撃回数はi回ではなく(i/2)回
        cout<<"Yes"<<endl;
        break;
      }
      /*else{
        continue;
      }
      ↑何もしないならelse節は必要ない*/ 
    else{				
      // 青木くんの攻撃
      if(A-(i/2)*D<=0){
        cout<<"No"<<endl;
        break;
      }
     /*else{
       continue;
     }*/
    }
   }
}
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
//#include <fstream>
#include <vector>
#include <math.h>
#include <iomanip>
#include <queue>
 
using namespace std;
 
/********** TEMPLATE STARTS HERE ***********/
 
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define FR(i, l, r) for(int i = (l); i <= (r); i++)
#define gcd __gcd 
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <pll> vll;
 
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
 
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
//template <typename T> inline void out(T x) { cout << x; }
 
/*********** TEMPLATE ENDS HERE *************/

const int N = 2e5 + 7;

ll n, a[N];
vector <ll> v;
ll fenwick[N];

void update(ll x, ll v)
{
	x++;
	for(; x <= 2 * n; x += x & (-x)) 
		fenwick[x] += v;
}

ll sum(ll x)
{
	ll res = 0;
	x++;
	for(; x; x -= x & (-x)) 
		res += fenwick[x];
	return res;
}

bool OK(ll x)
{
	v.clear();
	ll total = 0, ans = 0;
	SET(fenwick, 0);
	total = 0;
	for(ll i = 0; i < n; i++)
	{
		total += ((a[i] >= x) ? 1 : -1);
		ans += sum(total + n) + ((total >= 0) ? 1 : 0);
		update(total + n, 1);
	}
	return ans >= ( (n * (n + 1)) / 2 ) / 2 ;
}

int main()
{
	IOS
	cin >> n; 
	ll l = LINF, r = 0;
	for(ll i = 0; i < n; i++)
	{
		cin >> a[i];
		l = min(l, a[i]);
		r = max(r, a[i]);
	} 
	r = r + 1;
	while(l < r - 1)
	{
		ll mid = ((l + r) / 2);
		
		if(OK(mid))
			l = mid;
		else 
			r = mid;
	}
	cout << l;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int[] right = new int[S.length()+1];
        int[] left = new int[S.length()+1];
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == '<') {
                right[i+1] = right[i]+1;
            } 
            if (S.charAt(S.length()-1-i) == '>') {
                left[S.length()-1-i] = left[S.length()-i]+1;
            }
        }
        long ans = 0;
        for (int i = 0; i < right.length; i++) {
            ans += Math.max(right[i], left[i]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 46404
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# 同じ桁に1が2回現れたらダメ
# 現在のビット列を持ち、同じ桁に1が2回現れない限り延長していく尺取り法

right = 0
xor = 0 # 現在のビット列
ans = 0

def isOk(x, v):
  while x and v:
    if (x & 1) and (v & 1):
      return False
    x >>= 1
    v >>= 1
  return True

for left in range(N):
  while right < N and isOk(xor,A[right]):
    # 同じ桁に1が2回現れないことをチェック
    xor ^= A[right]
    right += 1
      
  ans += (right - left)
  
  if right == left:
    right += 1
  else:
    xor ^= A[left]
  
print(ans)


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{

    int x, y, z;
    cin >> x >> y >> z;
    int ans = 0;
    if (x < y)
    {
        cout << 0 << endl;
        return 0;
    }
    while (true)
    {
        if (x < z + y)
        {
            break;
        }
        x -= z + y;
        ans++;
    }
    if (x < z)
    {
        ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int x;
  cin>>x;
  if(x == 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <random>
#include <limits>
#include <string>
#include <sstream>

#include <cassert>
#include <cmath>
#include <ctime>

#pragma comment(linker, "/STACK:200000000")

using namespace std;

void dfs (const vector<vector<int>> &gr, vector<int> &dist, int v, int d = 0)
{
    if (dist[v] != -1)
        return;

    dist[v] = d++;

    for (auto it : gr[v])
        dfs (gr, dist, it, d);
}

int far (const vector<vector<int>> &gr, int v)
{
    vector<int> dist (gr.size (), -1);

    dfs (gr, dist, v);

    return max_element (dist.begin (), dist.end ()) - dist.begin ();
}

void ord (vector<vector<int>> &gr, int v)
{
    for (auto it : gr[v])
    {
        gr[it].erase (find (gr[it].begin (), gr[it].end (), v));

        ord (gr, it);
    }
}

int cnt (const vector<vector<int>> &gr, vector<int> &siz, int v)
{
    siz[v] = 1;

    for (auto it : gr[v])
        siz[v] += cnt (gr, siz, it);

    return siz[v];
}

vector<int> build (const vector<int> &sz)
{
    int cur = 1;
    vector<int> ans;

    for (auto it : sz)
    {
        for (int i = 0; i < it; i++)
            ans.push_back (cur + i + 1);
        ans.push_back (cur);
        cur += it + 1;
    }

    return ans;
}

vector<int> subsolve (vector<vector<int>> gr, int v)
{
    ord (gr, v);

    vector<int> siz (gr.size ());

    cnt (gr, siz, v);

    vector<int> nxt (gr.size (), -1);

    for (int i = 0; i < gr.size (); i++)
    {
        int big = 0;

        for (auto it : gr[i])
            if (siz[it] > 1)
            {
                big++;
                nxt[i] = it;
            }

        if (big > 1)
            return {-1};
    }

    vector<int> sz = {(int)gr[v].size ()};

    int cur = v;

    while (nxt[cur] != -1)
    {
        sz.back ()--;

        cur = nxt[cur];
        sz.push_back (gr[cur].size ());
    }

    auto ans = build (sz);

    assert (ans.size () == gr.size ());

    swap (ans.back (), ans[ans.size () - 2]);

    return ans;
}

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
    int n;

    cin >> n;

    vector<vector<int>> gr (n);

    for (int i = 1; i < gr.size (); i++)
    {
        int a, b;

        cin >> a >> b;
        a--;
        b--;

        gr[a].push_back (b);
        gr[b].push_back (a);
    }

    int v = far (gr, 0);
    int w = far (gr, v);

    //cerr << v << '\t' << w << endl;

    auto a1 = subsolve (gr, v);
    auto a2 = subsolve (gr, w);

    auto ans = min (a1, a2);

    assert (ans != vector<int>{-1} ||
        (a1 == vector<int>{-1} &&
         a2 == vector<int>{-1}));

    for (auto it : ans)
        cout << it << ' ';
    cout << endl;
}

int main ()
{
    ios_base::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);

#ifdef LOCAL
    ifstream fin ("input.txt");

    solve (fin);

    cout << "clock: " << clock () << endl;
#else
    solve ();
#endif // LOCAL

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int maxN = 5e2 + 5;
const ll INF = 1ll<<60;
int n;
int a[maxN];
int main()
{

	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int ans = 0;
	for(int i=1;i<n;i++)
		ans += a[i];
	if(ans > a[n])
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

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

int main() {
	int N; cin >> N;
	vector<pair<int, int>> R(N);
	for (auto& i : R) { int a, b; cin >> a >> b; i = {a, a+b}; }
	sort(R.begin(), R.end());
	vector<int> V(N+1,1), f(N);
	for (int i = N-1; i >= 0; i--) {
		int &l = f[i] = i+1;
		while (l < N && R[l].first < R[i].second) l = f[l];
		V[i]=(V[i+1]+V[l])%998244353;
	}
	cout << V[0] << '\n';
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	ll a, b, c, n;
	string s;
	cin >> a >> b;
	if (a <= b) cout << a << endl;
	else cout << a - 1 << endl;
	return 0;
}

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

using namespace std;

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

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  int ma = max(h, w);
  cout << (n - 1) / ma + 1 << endl;

}


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

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

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

    int d[N];

    for(int i  = 0; i < N; i++){
        cin >> d[i];
    }

    sort(d, d + N);
    
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}


Measured memory_bytes: 640
n, k = [int(x) for x in input().split()]
a_list = [0] + [int(x) for x in input().split()]

ci = 1
temp_dict = {1: 0}
temp_list = [1]
for i in range(1, k + 1):
    temp = a_list[ci]
    if temp in temp_dict:
        ci = temp_list[(k - i) % (i - temp_dict[temp]) + temp_dict[temp]]
        break
    temp_dict[temp] = i
    temp_list.append(temp)
    ci = temp
print(ci)

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

int main(){
  string s;
  cin >> s;
  ll id = s.length() - 1;
  while(id > 0){
    if(id >= 4 && s.substr(id - 4, 5) == "dream"){
      id -= 5;
    }else if(id >= 4 && s.substr(id-4,5) == "erase"){
      id -= 5;
    }else if(id >= 5 && s.substr(id - 5, 6) == "eraser"){
      id -= 6;
    }else if(id >= 6 && s.substr(id-6, 7) == "dreamer"){
      id -= 7;
    }else{
      cout << "NO" << endl;
      return 0;
    }

  }

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



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

bool isRange(int h, int w, int H, int W){
  if (0<=h && h<H && 0<=w && w<W){
    return true;
  }else{
    return false;
  }
}

int main() {

  int H, W;
  scanf("%d %d", &H, &W);

  int Sh, Sw;
  scanf("%d %d", &Sh, &Sw);
  Sh--;
  Sw--;

  int Eh, Ew;
  scanf("%d %d", &Eh, &Ew);  
  Eh--;
  Ew--;

  // vector<vector<char>> v(H, vector<char>(W));
  int INF = H*W+1;
  vector<string> v(H);
  vector<vector<int>> cost(H, vector<int>(W, INF));
  vector<vector<int>> status(H, vector<int>(W));

  for (int i=0;i<H;i++){
    cin >> v[i];
    // for (int j=0;j<W;j++){
    //   scanf("%c\n", &v[i][j]);
    // }
  }

  deque<pair<int, int>> dq;
  
  // 始点
  pair<int, int> p_back(Sh, Sw);
  dq.push_back(p_back);

  // コスト・状態
  cost[Sh][Sw]=0;
  status[Sh][Sw]=0;


  int h, w;
  pair<int, int> p;
  while (!dq.empty()){

    p = dq.front(); dq.pop_front();
    h = p.first;
    w = p.second;
    status[h][w]=1;
    
    // printf("%d %d\n", h, w);
    // for (int i=0;i<H;i++){
    //   for (int j=0;j<W;j++){
    //     printf("%c", cost[i][j]==-1?'x':cost[i][j]+'0');
    //   }
    //   printf("\n");
    // }

    for(int i=-2;i<3;i++){
      for(int j=-2;j<3;j++){

        if(isRange(h+i, w+j, H, W)){
          
          if(status[h+i][w+j]==0){
            
            if(v[h+i][w+j]=='.'){

              p.first = h+i;
              p.second = w+j;

              if( abs(i)+abs(j)==1 ){
                cost[h+i][w+j] = min(cost[h][w],cost[h+i][w+j]);
                dq.push_front(p);
              }else{
                cost[h+i][w+j] = min(cost[h][w]+1,cost[h+i][w+j]);
                dq.push_back(p);
              }
            
            }else{
              status[h+i][w+j]=1;
            }

          }          
        }

      } 
    }


  }

  if(cost[Eh][Ew] == INF){
    printf("-1\n");
  }else{
    printf("%d\n", cost[Eh][Ew]);
  }

  
  return 0;
}



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

lst = [0] * N
k = 1
cnt = 0
for j in range(10*N):
  lst[k-1] += 1
  k = A[k-1]
num = len(list(filter(lambda x:x>=1,lst)))
k = 1
first = []
loop = []
for j in range(num):
  if lst[k-1] == 1:
    first.append(k)
  elif lst[k-1] > 1:
    loop.append(k)
  k = A[k-1]
if K < len(first):
  print(first[K])
else:
  K -= len(first)
  print(loop[K%len(loop)])

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

int main() {
  int pack_num, truck_num;
  cin >> pack_num >> truck_num;

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

  int simu_load = ceil(total_weight / (float)truck_num);

  while (true) {
    bool available = false;
    int pack_index = 0;
    int weight = weights[pack_index];
    for (int i = 0; i < truck_num; i++) {
      int load = simu_load;
      while (load >= weight) {
        load -= weight;
        pack_index++;
        if (pack_index == pack_num) {
          available = true;
          break;
        }
        weight = weights[pack_index];
      }
      if (available) break;
    }
    if (!available) {
      simu_load++;
    } else {
      break;
    }
  }

  cout << simu_load << endl;
  return 0;
}


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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif

int main(){
	int n;
	cin>>n;
	int a[4];
	cin>>a[0]>>a[1]>>a[2]>>a[3];

	int minval=999999999;

	int x[4],y[4];
	for(int i=1;i<=n;i++){
		rep(j,4){
			x[j]=(a[j]-1)%i;
			y[j]=(a[j]-1)/i;
		}
		int val=abs(x[0]-x[1])+abs(y[0]-y[1]) + abs(x[2]-x[3])+abs(y[2]-y[3]);
		if(val<minval){
			minval=val;
		}

	}
	cout<<minval<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>
int gcd(x,y){
  if (y==0){
    return x;
  }else{
    return gcd(y,x%y);
  }
}

int main()
{
  int x,n,i,j,g;
  int count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    g=1;
    for(j=1;j<=sqrt(x);j++){
      int m=gcd(j,x);
      if (m>g){
        g=m;
        break;
      }
    }
    if (g==1){
      count++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 596
// Isaunoya
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
inline int read() {
  register int x = 0 , f = 1 ;
  register char c = getchar() ;
  for( ; ! isdigit(c) ; c = getchar()) if(c == '-') f = -1 ;
  for( ; isdigit(c) ; c = getchar()) x = (x << 1) + (x << 3) + (c & 15) ;
  return x * f ;
}
template < class T > inline bool cmax(T & x , T y) {
  return x > y ? 1 : x = y , 0 ;
}
template < class T > inline bool cmin(T & x , T y) {
  return x < y ? 1 : x = y , 0 ;
}
const int MAXN = 1e6 + 10 ;
const int mod7 = 1e9 + 7 ;
const int mod9 = 1e9 + 9 ;
const int mod = 998244353 ;
inline int QP(int x , int y , int Mod){ int ans = 1 ;
  for( ; y ; y >>= 1 , x = (x * x) % Mod)
    if(y & 1) ans = (ans * x) % Mod ;
  return ans ;
}
vector < int > v ;
inline void io() {
  ios :: sync_with_stdio(false) ;
  cin.tie(0) , cout.tie(0) ;
}
#define int long long
#define MAXN 100005
string s;
int t,n,k;
bool fl = 1;
int a[MAXN],nn;
signed main() {
	cin >> s >> k;
	n = s.size();
	for(int i = 1; i < n; i ++)
		if(s[i] != s[0]) {
			fl = 0;
		}
	if(fl == 1) {
		cout<<k*n/2;
		return 0;
	}
	for(int i = 0; i < n; i ++)
		if(i == 0 || s[i] != s[i-1]) { nn ++; a[nn] = 1;} 
		else { a[nn] ++; }
	int ans = 0;
	if(s[0] == s[n-1]) {
		for(int i = 2; i < nn; i ++)
			ans += a[i]/2*k;
		ans += a[1]/2 + a[nn]/2 + (a[1]+a[nn])/2*(k-1);
	} else {
		for(int i = 1; i <= nn; i ++)
			ans += a[i] >> 1 ;;
		ans *= k;
	}
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main{
	static void dump(String s){
		System.out.println(s);
	}
	public static void main(String[] args){
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		for(int i=0;i<n;i++){
			BigInteger a=scanner.nextBigInteger();
			BigInteger b=scanner.nextBigInteger();
			BigInteger c=a.add(b);
			String res=c.toString();
			if(res.length()>80)
				dump("overflow");
			else
				dump(res);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<60
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

struct UnionFind{
    vl p;
    vl rank;

    UnionFind(ll n){
        rank.resize(n,0);
        p.resize(n,0);
        rep(i,n){
            p[i] = i;
            rank[i] = 0;
        }
    }

    ll find(ll x){
        if(x != p[x]) p[x] = find(p[x]);
        return p[x];
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] > rank[y]){
            p[y] = x; 
        }else{
            p[x] = y;
            if(rank[x] == rank[y]) rank[y]++;
        }
    }
};


int main(){
    ll n,k,l; cin >> n >> k >> l;
    UnionFind road(n), train(n);
    rep(i,k){
        ll p,q; cin >> p >> q;
        p--; q--;
        road.unite(p,q);
    }
    rep(i,l){
        ll r,s; cin >> r >> s;
        r--; s--;
        train.unite(r,s);
    }
    vpl v(n);
    map<P,ll> mp;
    rep(i,n){
        v[i].first = road.find(i);
        v[i].second = train.find(i);
        mp[v[i]]++;
    }
    rep(i,n){
        cout << mp[v[i]] << " ";
    }
}

Measured memory_bytes: 21120
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0;
    rep(i, 1, n){
        ans += a[i] - a[i - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<int,bool> F;
int main()
{
	int a,b,k;
	scanf("%d%d%d",&a,&b,&k);
	for(int i=0;i<k;i++)
	{
		if(a+i>b) break;
		printf("%d\n",a+i),F[a+i]=true;
	}
	for(int i=k-1;i>=0;i--)
	{
		if(F[b-i] || b-i<a) continue;
		printf("%d\n",b-i);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L, Edges& matching) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  return match;
}

int a[1000] , b[1000];
int main(){
	int n,m;
	
	while(cin >> n >> m && n){
		Edges hoge;
		Graph g(n+m);
		for(int i = 0 ; i < n ; i++) cin >> a[i];
		for(int j = 0 ; j < m ; j++) cin >> b[j];
		for(int i = 0 ; i < n ; i++)
			for(int j = 0 ; j < m ; j++)
				if(__gcd(a[i],b[j]) > 1){
					//hoge.push_back(Edge(i,j,1));
					g[i].push_back(Edge(i,n+j,1));
					g[n+j].push_back(Edge(n+j,i,1));
				}
		cout << bipartiteMatching(g,n,hoge) << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define MP make_pair
#define int ll int

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
const int MAX = 1e4 + 5;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int h,w,n;
    cin>>h>>w>>n;
    if(h<w)swap(h,w);
    cout<<(n-1)/h+1<<endl;
}


return 0;
}





Measured memory_bytes: 256