akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,C;
    cin >> N >> C;
    vector<vector<int>>D(C,vector<int>(C));
    for(int i = 0; i < C; i++) {
        for(int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }
    vector<vector<int>>c(N,vector<int>(N));
    vector<vector<int>>cnt(3,vector<int>(C));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            cin >> c[i][j];
            cnt[(i+j+2)%3][c[i][j]-1]++;
        }
    }
    int ans = INF;
    for(int i = 0; i < C; i++) {
        for(int j = 0; j < C; j++) {
            for(int k = 0; k < C; k++) {
                if(i == j || i == k || j == k) {
                    continue;
                }
                int res = 0;
                for(int l = 0; l < 3; l++) {
                    for(int m = 0; m < C; m++) {
                        if(l == 0) {
                            res += cnt[l][m]*D[m][i];
                        }
                        if(l == 1) {
                            res += cnt[l][m]*D[m][j];
                        }
                        if(l == 2) {
                            res += cnt[l][m]*D[m][k];
                        }
                    }
                }
                ans = min(ans,res);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
inline int in() { char ch = getchar();int x = 0, f = 1;while (ch<'0' || ch>'9') { if (ch == '-')f = -1;ch = getchar(); }while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0';ch = getchar(); }return x * f; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 4;
int fa[N], a[N];
int find(int x)
{
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}
int num[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n, m;
	while (cin >> n >> m)
	{
		f(i, 0, n)fa[i] = i;
		int x, y;
		f(i, 1, m)
		{
			x = in(), y = in();
			int fx = find(x), fy = find(y);
			if (fx != fy)fa[fx] = fy;
		}
		f(i, 1, n)num[find(i)]++;
		int mx = 0;
		f(i, 1, n)
		{
			mx = max(mx, num[i]);
		}
		cout << mx << endl;
	}
	return 0;
}

Measured memory_bytes: 10560
//ALDS1_1
//ALDSC_1
#include<iostream>
using namespace std;

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

	return gcd(b,a%b);
}
int main(){
	int a,b;
	cin>>a>>b;
	cout<<gcd(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;


int main() {

	double R;
	cin >> R;
	cout << 2*R * M_PI << endl;



}

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

using namespace std;

int main(void)
{
    int N, M, sum = 0;

    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;

    for (int i = 0; i < M; i++)
    {
        int P, X;
        cin >> P;
        cin >> X;
        cout << sum - T[P - 1] + X << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static long N,M;

        public static void Input()
        {
            var cin = new Solve();

            var input = cin.SplitReaderL();
            N = input[0];
            M = input[1];
           
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            long ans = 0;
            for(var i = 1; i <= Math.Sqrt(M); i++)
            {
                if (M % i == 0)
                {
                    if (M / i >= N) { ans = Math.Max(ans, i); }
                    if (i >= N) { ans = Math.Max(ans, M / i); }
                }
            }

            Console.WriteLine(ans);

            
            


            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }
}

    



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

int main() {
	int n;
	cin >> n;
	vector<pair<int,int>>imp(n-1);
	for (int i = 0; i < n-1; i++) {
		cin >> imp.at(i).first >> imp.at(i).second;
		imp.at(i).first--;
		imp.at(i).second--;
	}
	map<pair<int,int>,int>imps;
	for (int i = 0; i < n - 1; i++)imps.insert({ imp.at(i),0 });
	vector<vector<int>>graph(n, vector<int>(0));
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		x = imp.at(i).first;
		y = imp.at(i).second;
		graph.at(x).push_back(y);
		graph.at(y).push_back(x);
	}
	vector<int>parent(n, -1);
	queue<int>search;
	search.push(0);
	parent.at(0) = 0;
	while (search.size() > 0) {
		int a = search.front();
		vector<int> b = graph.at(a);
		for (int i = 0; i < b.size(); i++) {
			if (parent.at(b.at(i)) == -1) {
				parent.at(b.at(i)) = a;
				search.push(b.at(i));
			}
		}
		search.pop();
	}
	search.push(0);
	int mx = 0;
	while (search.size() > 0) {
		int a = search.front();
		vector<int> b = graph.at(a);
		set<int>forbid;
		if (a != 0)forbid.insert(imps.at({ parent.at(a),a }));
		int tmp = 1;
		for (int i = 0; i < b.size(); i++) {
			pair<int, int> x = { a,b.at(i) };
			if (x.first > x.second)swap(x.first, x.second);
			while (true) {
				if (forbid.count(tmp))tmp++;
				else break;
			}
			if (imps.at(x) == 0) {
				imps.at(x) = tmp;
				tmp++;
				search.push(b.at(i));
			}
		}
		mx = max(mx, tmp);
		search.pop();
	}
	cout << mx-1 << endl;
	for (int i = 0; i < n - 1; i++) {
		cout << imps.at(imp.at(i)) << endl;
	}
}

Measured memory_bytes: 15956
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;

class Dice {
    public:
        int s[6], tmp;
        Dice(int array[6]){
            s[0] = array[0];
            s[1] = array[1];
            s[2] = array[2];
            s[3] = array[3];
            s[4] = array[4];
            s[5] = array[5];
        }
        
        void N(){
            tmp = s[0];
            s[0] = s[1];
            s[1] = s[5];
            s[5] = s[4];
            s[4] = tmp;
        }   
        void E(){
            tmp = s[0];
            s[0] = s[3];
            s[3] = s[5];
            s[5] = s[2];
            s[2] = tmp;
            
        }
        void W(){
            tmp = s[0];
            s[0] = s[2];
            s[2] = s[5];
            s[5] = s[3];
            s[3] = tmp;
        }
        void S(){
            tmp = s[0];
            s[0] = s[4];
            s[4] = s[5];
            s[5] = s[1];
            s[1] = tmp;
        }
        int show_top(){
            return s[0];
        }
        
        int show_right(int num1, int num2){
            if(s[5] == num1) {
                N();
                N();
            }
            else if(s[1] == num1) N();
            else if(s[2] == num1) W();
            else if(s[3] == num1) E();
            else if(s[4] == num1) S();
            if(s[1] == num2) return s[2];
            else if(s[2] == num2) return s[4];
            else if(s[4] == num2) return s[3];
            else if(s[3] == num2) return s[1];
        }
};

int main(void){
    int nums[6];
    for(int i = 0; i < 6; i++){
        cin >> nums[i];
    }
    int N,num1, num2;
    cin >> N;
    for(int i = 0; i < N ;i++){
        cin >> num1 >> num2;
        Dice dice(nums);
        cout << dice.show_right(num1, num2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;

typedef long long ll;
ll a[maxn];
const int mod = 1e9+7;
int ans;
void search(int sum) {

    if(sum < 3) {
        if(sum == 0) {
            ans ++;   
        }
        return;
    }
    for(int i = 3;i <= sum;i ++) {
        search(sum - i);
    }
}
int main() {
    int S;
    cin>>S;
    a[1] = 0;
    a[2] = 0;
    a[3] = 1;
    a[4] = 1;
    a[5] = 1;
    for(int i = 6;i <= S;i ++){
        a[i] = (a[i-1] + a[i-3])%mod;
    }
    cout<<a[S]<<endl;
    return 0;
}



Measured memory_bytes: 3524
unittest
{
	assert( [ "?ABC" ].parse.expand.solve == 4 );		// 追加ケース
	assert( [ "ABC?" ].parse.expand.solve == 4 );		// 追加ケース
	
	assert( [ "A??C" ].parse.expand.solve == 8 );
	assert( [ "ABCBC" ].parse.expand.solve == 3 );
	assert( [ "????C?????B??????A???????" ].parse.expand.solve == 979596887 );
}

import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	const MOD = 10L ^^ 9 + 7;
	
	auto dp = new long[][]( 4 + 1, s.length + 1 );
	dp[ 0 ][ 0 ] = 1;
	for( auto ci = 0L, c = 'A'; ci + 1 < dp.length; ci++, c++ )
	{
		for( auto si = 0L; si + 1 < dp[ ci ].length; si++ )
		{
			if( s[ si ] == c )
			{
				dp[ ci     ][ si + 1 ] += dp[ ci ][ si ];		// cを選択しないパターン
				dp[ ci + 1 ][ si + 1 ] += dp[ ci ][ si ];		// cを選択するパターン
			}
			else if( s[ si ] == '?' )
			{
				dp[ ci     ][ si + 1 ] += dp[ ci ][ si ] * 3;		// cを選択しないパターン（ここまでのパターン×3通りになる）
				dp[ ci + 1 ][ si + 1 ] += dp[ ci ][ si ];			// cを選択するパターン
			}
			else
			{
				dp[ ci     ][ si + 1 ] += dp[ ci ][ si ];		// cを選択しないパターン（cが無かったパターン）
			}
			dp[ ci     ][ si + 1 ] %= MOD;
			dp[ ci + 1 ][ si + 1 ] %= MOD;
		}
	}
	
	return dp[ 3 ][ $ - 1 ];
}


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

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [n, k] <- readIntegerList
  let m = n `mod` k
  print $ min m (k - m)


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

int hc[300010],wc[300010];

signed main(){
    using P=pair<int,int>;
    set<P> st;
    int h,w,m;cin>>h>>w>>m;
    rep(_,m){
        int i,j;cin>>i>>j;
        i--,j--;
        hc[i]++;
        wc[j]++;
        st.insert(P(i,j));
    }

    vector<P> vh,vw;
    rep(i,h)vh.push_back(P(hc[i],i));
    rep(j,w)vw.push_back(P(wc[j],j));
    sort(ALL(vh));
    sort(ALL(vw));
    reverse(ALL(vh));
    reverse(ALL(vw));

    int hi=vh[0].first+vw[0].first-(st.count(P(vh[0].second,vw[0].second)));
    if(st.count(P(vh[0].second,vw[0].second))==0){
        cout<<hi<<endl;
        return 0;
    }
    int res=hi;
    rep(i,(int)vh.size()){
        rep(j,(int)vw.size()){
            if(vh[i].first+vw[j].first<hi) break;
            int tmp=vh[i].first+vw[j].first;
            if(st.count(P(vh[i].second,vw[j].second)))tmp--;
            chmax(res,tmp);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 28016
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

ll par[100000]; // par[i]... iの親
ll mem[100000]; // iの(自分も含めた) 子の構成島数

ll root(ll x) {
    // 自身が親と同一の時まで再帰的にrootをたどる
    if(par[x]==x) return x;
    else {
      return root(par[x]);
    }
}

void unite(ll x, ll y) {
  ll rx = root(x);
  ll ry = root(y);
  if(rx==ry) return;
  else {
    if(rx<ry) {
      ll tmp = rx;
      rx = ry;
      ry = tmp;
    }
    mem[ry] += mem[rx];
    par[rx] = ry;
    return;
  }
}

int main() {
  ull N, M;
  cin >> N >> M;
  ull A[M], B[M];
  rep(i, M) {
    ull a, b;
    cin >> a >> b;
    A[i] = a-1;
    B[i] = b-1;
  }

  /* Uion-find というデータ構造を使えば処理時間を短縮できるらしい */
  // cf. https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396
  // cf. https://atc001.contest.atcoder.jp/tasks/unionfind_a

  rep(i, N) par[i] = i; // 最初は全て自分が親
  rep(i, N) mem[i] = 1;

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

  ull ans[M]; // ans
  ans[M-1] = N*(N-1)/2; // 全ての橋が崩壊した時の不便さ
  for(ll i=M-1; i>0; i--) {
    ll ra = root(A[i]);
    ll rb = root(B[i]);
    if(ra==rb) ans[i-1] = ans[i];
    else {
      ans[i-1] = ans[i] - mem[ra]*mem[rb];
      // cout << "log:" << ans[i-1] << endl;
      // cout << "A, B " << A[i] << ' ' << B[i] << endl;
      // cout << "rA, rB " << root(A[i]) << ' ' << root(B[i]) << endl;
      // cout << "mrA, mrB " << mem[root(A[i])] << ' ' << mem[root(B[i])] << endl;
      unite(rb, ra);
    }
  }

  rep(i, M) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 5248
def P(s):
 i,R,P,*L=[0]*29
 while i<D:t=I[i+D][0]-1;P+=s-(i+1-L[t])*C[t];R+=I[i][t]-P;i+=1;L[t]=i
 return R
(D,),C,*I=[[*map(int,t.split())]for t in open(0)]
for d,q in I[D-~D:]:I[d-1+D][0]=q;print(P(sum(C)))

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

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

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,cnt=1,flg;
	int n;
	int fo[10]={1,4,16,64,256,1024,4096,16384,65536,262144};
	while(1) {
		cin>>n;
		flg=0;
		if(n==-1) break;
		for(i=9;i>=0;i--) {
			if(n==0&&flg==0) {
				cout<<"0";
				break;
			}
			if(n/fo[i]>0&&n!=0) {
				cout<<n/fo[i];
				n=n%fo[i];
				flg=1;
			}
			else if(flg==1) cout<<"0";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2972
#include<stdio.h>
int main(void)
{
    int h=0,m=0,s=0;
    scanf("%d",&s);
    m=s/60;
    s%=60;
    h=m/60;
    m%=60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  uint64_t x,y;
  while(true){
      cin >> x >> y;
      if(x==0&&y==0) break;
      
      if(x<y) cout << x << " " << y << endl;
      else cout << y << " " << x << endl;
      
      if(cin.eof()) break;
  }
 
  return 0;
}


Measured memory_bytes: 3016
#include <stdio.h>
#include <string.h>
int main()
{
	char a[11];
	scanf("%s",&a);
	char b[11];
	scanf("%s",&b);
	char c[11];
	scanf("%s",&c);
	int lengtha=strlen(a);
	int lengthb=strlen(b);
	
	if(a[lengtha-1]==b[0]&&b[lengthb-1]==c[0]){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 1632
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fs first
#define sc second
#define mk make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9+1;
const ll LINF = 1e17;
const int MAKS = 300100;
int x;
ld a, b;
int main(){
	cin >> a >> b;
	int x = ceil((b-1)/(a-1));
	cout << x;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC002
{
    public class C
    {
        private void Run()
        {
            var input = Console.ReadLine().Trim().Split();
            var N = int.Parse(input[0]);
            var L = long.Parse(input[1]);
            var A = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();

            var total = A.Sum();
            var result = new List<long>();

            var lastIndex = -1;
            for (int i = 0; i < N - 1; i++)
            {
                if (A[i] + A[i + 1] >= L)
                {
                    lastIndex = i;
                    break;
                }
            }
            if (lastIndex < 0) { Console.WriteLine("Impossible"); }
            else
            {
                Console.WriteLine("Possible");

                for (int i = 0; i < lastIndex; i++)
                {
                    Console.WriteLine(i + 1);
                }
                for (int i = N - 1; i - 1 > lastIndex; i--)
                {
                    Console.WriteLine(i);
                }
                Console.WriteLine(lastIndex + 1);
            }
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new C().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 19800
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>
 
#define REP(i, n) for (int i=0;i<int(n);++i)
#define REPV(i, v, n) for (int i=0,tmp=v;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
 
using namespace std;
 
typedef unsigned char byte;
 
byte mask[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
#define tget(i) !!(t[(i)>>3]&mask[(i)&7])
#define tset(i, b) t[(i)>>3]=(b) ? (mask[(i)&7]|t[(i)>>3]) : ((~mask[(i)&7])&t[(i)>>3])
#define chr(i) (cs==sizeof(int)?((int*)s)[i]:((byte *)s)[i])
#define isLMS(i) (i>0 && tget(i) && !tget(i-1))
 
void getBuckets(byte *s, int *bkt, int n, int K, int cs, bool end=true){
  fill(bkt, bkt + K + 1, 0);
  REP(i,n)bkt[chr(i)]++;
  REPV(i, 0, K+1)tmp += bkt[i], bkt[i] = end ? tmp : tmp - bkt[i];
}
 
void induceSAl(byte *t, int *SA, byte *s, int *bkt, int n, int K, int cs, bool end=false){
  getBuckets(s, bkt, n, K, cs, end);
  REP(i,n)if(SA[i]>0 && !tget(SA[i]-1)) SA[ bkt[chr(SA[i]-1)]++ ] = SA[i]-1;
}
 
void induceSAs(byte *t, int *SA, byte *s, int *bkt, int n, int K, int cs, bool end=true){
  getBuckets(s, bkt, n, K, cs, end);
  DWN(i,n,0)if(SA[i]>0 && tget(SA[i]-1))SA[--bkt[chr(SA[i]-1)]] = SA[i]-1;
}
 
void SA_IS(byte *s, int *SA, int n, int K=128, int cs=1) {
  byte t[(n >> 3) + 1];
  int bkt[K + 1],n1=0,name=0;
   
  tset(n-2, 0), tset(n-1, 1);
  DWN(i,n-2,0)tset(i, (chr(i)<chr(i+1) || (chr(i)==chr(i+1) && tget(i+1))));
  getBuckets(s, bkt, n, K, cs);
  fill(SA, SA+n, -1);
  FOR(i,1,n)if(isLMS(i))SA[--bkt[chr(i)]] = i;
 
  induceSAl(t, SA, s, bkt, n, K, cs);
  induceSAs(t, SA, s, bkt, n, K, cs);
   
  REP(i,n)if(isLMS(SA[i]))SA[n1++] = SA[i];
  fill(SA + n1, SA + n, -1);
 
  REPV(i,-1,n1){
    int pos = SA[i], diff = false;
    for(int d = 0; d < n && !diff; d++){
      diff = chr(pos+d) != chr(tmp+d) || tget(pos+d) != tget(tmp+d);
      if(!diff && d && (isLMS(pos+d) || isLMS(tmp+d)))break;
    }
    if(diff)name++,tmp=pos;
    SA[ n1 + ((pos - (pos & 1)) >> 1) ] = name - 1;
  }
  int *s1 = SA + n - n1;
  for(int i=n-1,j=n-1;i>=n1;i--)if(SA[i]>=0)SA[j--]=SA[i];
  if(name < n1)SA_IS((byte*)s1, SA, n1, name - 1, sizeof(int));
  else REP(i,n1)SA[s1[i]]=i;
   
  getBuckets(s, bkt, n, K, cs);
  for(int i = 1, j = 0; i < n; i++)if(isLMS(i))s1[j++] = i;
  REP(i,n1)SA[i]=s1[SA[i]];
  fill(SA + n1, SA + n, -1);
 
  DWN(i,n1,0){
    int tmp = SA[i];
    SA[i] = -1, SA[--bkt[chr(tmp)]] = tmp;
  }
  induceSAl(t, SA, s, bkt, n, K, cs);
  induceSAs(t, SA, s, bkt, n, K, cs);
}
 
const int maxn = 1000001;
int n,sa[maxn];
 
bool contain(string S, int *sa, string T){
  int a = 0, b = S.length();
  while( b - a > 1 ){
    int c = (a + b ) / 2;
    if ( S.compare(sa[c], T.length(), T) < 0 ) a = c;
    else b = c;
  }
  return S.compare(sa[b], T.length(), T) == 0;
}
 
char a[maxn],b[maxn];
 
int main(void){
  int q;
  scanf("%s", a);
  string s = string(a);
  SA_IS((byte*) s.c_str(), sa, s.size()+1);
 
  scanf("%d", &q);
  while(q--){
    scanf("%s", b);
    if(contain(s, sa, string(b))) printf("1\n");
    else printf("0\n");
  }
 
  return 0;
}

Measured memory_bytes: 7900
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

public class Main {

	void submit() {
		int n = nextInt();
		int k = n * (n - 1) / 2 - n / 2;

		out.println(k);
		int badSum = n + (1 - n % 2);

		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (i + j != badSum) {
					out.println(i + " " + j);
				}
			}
		}
	}

	void test() {

	}

	void stress() {
		for (int tst = 0;; tst++) {
			if (false) {
				throw new AssertionError();
			}
			System.err.println(tst);
		}
	}

	Main() throws IOException {
		is = System.in;
		out = new PrintWriter(System.out);
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();
	static final int C = 5;

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	private InputStream is;
	PrintWriter out;

	private byte[] buf = new byte[1 << 14];
	private int bufSz = 0, bufPtr = 0;

	private int readByte() {
		if (bufSz == -1)
			throw new RuntimeException("Reading past EOF");
		if (bufPtr >= bufSz) {
			bufPtr = 0;
			try {
				bufSz = is.read(buf);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			if (bufSz <= 0)
				return -1;
		}
		return buf[bufPtr++];
	}

	private boolean isTrash(int c) {
		return c < 33 || c > 126;
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isTrash(b))
			;
		return b;
	}

	String nextToken() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	String nextString() {
		int b = readByte();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b) || b == ' ') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	char nextChar() {
		return (char) skip();
	}

	int nextInt() {
		int ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}

	long nextLong() {
		long ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 21716
import java.util.*;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int[] ary = new int[3];
    	ary[0]=sc.nextInt();
    	ary[1]=sc.nextInt();
    	ary[2]=sc.nextInt();
    	Arrays.sort(ary);
    	System.out.println(ary[0]+" "+ary[1]+" "+ary[2]);
    }
}


Measured memory_bytes: 26136
n, a, b, c = map(int, input().split())

keep = False

answer = []

miss = False

for i in range(n):
    s = input()

    if keep:
        if kept == "AB":
            if s == "AB":
                a += 1
                b -= 1
                answer.append('A')
            elif s == "AC":
                a += 1
                b -= 1
                answer.append('A')
            elif s == "BC":
                a -= 1
                b += 1
                answer.append('B')
        if kept == "AC":
            if s == "AB":
                a += 1
                c -= 1
                answer.append('A')
            elif s == "AC":
                a += 1
                c -= 1
                answer.append('A')
            elif s == "BC":
                a -= 1
                c += 1
                answer.append('C')
        if kept == "BC":
            if s == "AB":
                b += 1
                c -= 1
                answer.append('B')
            elif s == "AC":
                b -= 1
                c += 1
                answer.append('C')
            elif s == "BC":
                b += 1
                c -= 1
                answer.append('B')

    keep = False

    if s == "AB":
        if a == b:
            if a == 1:
                keep = True
                kept = "AB"
            else:
                a += 1
                b -= 1
                answer.append('A')
        else:
            if a > b:
                a -= 1
                b += 1
                answer.append('B')
            else:
                a += 1
                b -= 1
                answer.append('A')

    elif s == "AC":
        if a == c:
            if a == 1:
                keep = True
                kept = "AC"
            else:
                a += 1
                c -= 1
                answer.append('A')
        else:
            if a > c:
                a -= 1
                c += 1
                answer.append('C')
            else:
                a += 1
                c -= 1
                answer.append('A')
    elif s == "BC":
        if b == c:
            if b == 1:
                keep = True
                kept = "BC"
            else:
                b += 1
                c -= 1
                answer.append('B')
        else:
            if b > c:
                b -= 1
                c += 1
                answer.append('C')
            else:
                b += 1
                c -= 1
                answer.append('B')

    if a < 0 or b < 0 or c < 0:
        miss = True
        break

    if keep and i == (n-1):
        if kept == "AB":
            answer.append('A')
        elif kept == "AC":
            answer.append('A')
        elif kept == "BC":
            answer.append('B')

if miss:
    print("No")
else:
    print("Yes")
    for ans in answer:
        print(ans)


Measured memory_bytes: 9880
n,m = map(int,input().split())	
s=[1 for _ in range(n+2)]
for _ in range(m):
    s[int(input())+1]=0
mod=1000000007
num=[0 for _ in range(n+2)]
num[0]=num[1]=1
for i in range(n):
    if num[2]==2:
        num[2]=1
    num[i+2]=(num[i+1]*s[i+1]+num[i]*s[i])%mod

if num[2]==2:
    num[2]=1
print(num[n+1])





Measured memory_bytes: 7844
// Vicfred
// https://atcoder.jp/contests/abc159/tasks/abc159_a
// math
import std.stdio;

int gauss(int n) {
    return n*(n-1)/2;
}

void main() {
    int n, m;
    readf("%s %s\n", &n, &m);

    int ans = gauss(n) + gauss(m);

    ans.writeln;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    int N;
    string S, a, b;
    cin >> N >> S;

    if(N % 2 == 0) {
        a = S.substr(0, N / 2);
        b = S.substr(N / 2, N / 2);
        if(a == b) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    cnt = 0
    for et in t:
        sc = s.copy()
        sc.append(et)
        i = 0

        while sc[i] != et:
            i += 1

        if i < n:
            cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()



Measured memory_bytes: 6556
#include <cstdio>
#include <utility>
#include <vector>
#include <string>
#include <queue>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

struct point {int x, y;};
typedef vector<string> map;

int distance(point s, point e) {
	return abs(e.x - s.x) + abs(e.y - s.y);
}

int walk(point s, point e, map m) {
	struct node {
		int g, h, f;
		point p;
		bool operator < (const node &a) const {
			return f > a.f;
		};
	};
	priority_queue<node> q;
	static point d[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

	int sd = distance(s, e);
	q.push({0, sd, sd, s});

	while (!q.empty()) {
		node n = q.top();
		q.pop();
		if (!n.h) {
			return n.g;
		}
		m[n.p.y][n.p.x] = '#';
		for (auto p: d) {
			p.x += n.p.x;
			p.y += n.p.y;
			if (p.x >= 0 && p.x < (int) m[0].size()
				&& p.y >= 0 && p.y < (int) m.size()) {
				char &c = m[p.y][p.x];
				if (c == '.') {
					int g = n.g + 1, h = distance(p, e);
					q.push({g, h, g + h, p});
				}
			}
		}
	}
	return 0;
}


int main() {
	int h = in(), w = in(), d = 0, n = in();
	vector<string> m(h);
	vector<point> p(n);
	point s;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c = gcu();
			if (isdigit(c)) {
				p[c - '0' - 1] = {j, i};
				c = '.';
			} else if (c == 'S') {
				s = {j, i};
				c = '.';
			}
			m[i].push_back(c);
		}
		gcu();
	}
	for (auto t: p) {
		d += walk(s, t, m);
		s = t;
	}
	out(d, '\n');
}


Measured memory_bytes: 5492
class Mint:
    MOD = 1000000007  # Must be a prime
    CACHE_FACTORIALS = [1, 1]

    def __init__(self, v):
        if self.__isally(v):
            self.v = v.v % self.MOD
        else:
            self.v = v % self.MOD

    @property
    def inv(self):
        return Mint(self.__minv(self.v))

    @classmethod
    def factorial(cls, v):
        for i in range(len(cls.CACHE_FACTORIALS), int(v) + 1):
            cls.CACHE_FACTORIALS.append(cls.CACHE_FACTORIALS[-1] * i % cls.MOD)
        return Mint(cls.CACHE_FACTORIALS[int(v)])

    @classmethod
    def perm(cls, n, r):
        if n < r or r < 0:
            return 0
        return cls.factorial(n) // cls.factorial(n - r)

    @classmethod
    def comb(cls, n, r):
        if n < r or r < 0:
            return 0
        return cls.perm(n, r) // cls.factorial(r)

    @classmethod
    def __isally(cls, v) -> bool:
        return isinstance(v, cls)

    @classmethod
    def __minv(cls, v) -> int:
        return pow(v, cls.MOD - 2, cls.MOD)

    @classmethod
    def __mpow(cls, v, w) -> int:
        return pow(v, w, cls.MOD)

    def __str__(self):
        return str(self.v)
    __repr__ = __str__

    def __int__(self):
        return self.v

    def __eq__(self, w):
        return self.v == w.v if self.__isally(w) else self.v == w

    def __add__(self, w):
        return Mint(self.v + w.v) if self.__isally(w) else Mint(self.v + w)
    __radd__ = __add__

    def __sub__(self, w):
        return Mint(self.v - w.v) if self.__isally(w) else Mint(self.v - w)

    def __rsub__(self, u):
        return Mint(u.v - self.v) if self.__isally(u) else Mint(u - self.v)

    def __mul__(self, w):
        return Mint(self.v * w.v) if self.__isally(w) else Mint(self.v * w)
    __rmul__ = __mul__

    def __floordiv__(self, w):
        return Mint(self.v * self.__minv(w.v)) if self.__isally(w) else \
            Mint(self.v * self.__minv(w))

    def __rfloordiv__(self, u):
        return Mint(u.v * self.__minv(self.v)) if self.__isally(u) else \
            Mint(u * self.__minv(self.v))

    def __pow__(self, w):
        return Mint(self.__mpow(self.v, w.v)) if self.__isally(w) else \
            Mint(self.__mpow(self.v, w))

    def __rpow__(self, u):
        return Mint(self.__mpow(u.v, self.v)) if self.__isally(u) else \
            Mint(self.__mpow(u, self.v))


N = int(input())
S1 = input()
S2 = input()
if S1[0] == S2[0]:
    ans = Mint(3)
    j = 1
else:
    ans = Mint(6)
    j = 2
while j < N:
    a = S1[j] == S2[j]
    b = S1[j-1] == S2[j-1]
    if a:
        ans *= 2 if b else 1
        j += 1
    else:
        ans *= 2 if b else 3
        j += 2

print(ans)


Measured memory_bytes: 3192
using System;
using System.Linq;
using System.Text;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32 (Console.ReadLine ());
            int[] Ai = Array.ConvertAll<string, int> (Console.ReadLine ().Split (), int.Parse);
            int[] answer = new int[N + 1];
            for (var i = 0; i < Ai.Length; i++) {
                answer[Ai[i]]++;
            }
            //StringBuilder builder = new StringBuilder (answer.Length);
            for (var i = 1; i < answer.Length; i++) {
                Console.WriteLine (answer[i]);
                //builder.Append (answer[i].ToString() + "\n");
            }
            //Console.Write (builder.ToString ());
        }
    }
}


Measured memory_bytes: 43068
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string S = Console.ReadLine();
		string T = Console.ReadLine();
		long ans = 99999999;
		for(var i=0;i<=S.Length-T.Length;i++){
			long ct = 0;
			for(var j=0;j<T.Length;j++){
				if(S.Substring(i+j,1)!=T.Substring(j,1)){
					ct++;
				}
			}
			ans = Math.Min(ct,ans);
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 21644
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string str;
  cin >> str;
  int s1 =0, s2 = 0;
  char c;
  for(int i =0 ;i<str.size();i++){
    if(i&1)
      c = '1';
   else
     c='0';
    if(str[i]!=c)
      	s1++;
   	if(str[i]==c)
      	s2++;
  }
  cout<<min(s1,s2);
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		long bisket = 1;

		if (B - A <= 2)  {
			bisket += K;
			System.out.println(bisket);
			return;
		}

		for (int i = 1; i <= K; i++) {
			//残り2回以上操作ができる かつ ビスケットがA枚以上ある
			if (K - i >= 1 && bisket >= A) {
				i++;
				bisket = bisket - A + B;
			} else {
				bisket++;
			}
		}
		System.out.println(bisket);
	}
}

Measured memory_bytes: 23764
M, D = gets.split.map(&:to_i)

def is_ok(m, d1, d10)
  d1 >= 2 && d10 >= 2 && d1 * d10 == m
end

ans = 0
(1..M).each do |m|
  (1..D).each do |d|
    d1 = d % 10
    d10 = d / 10
    ans += 1 if is_ok(m, d1, d10)
  end
end
puts ans


Measured memory_bytes: 1788
object Main{
  def main(args: Array[String]){
      	val ct = io.StdIn.readLine().trim().toInt
		val nums = io.StdIn.readLine().split(" ").map(_ .toInt)
      println(solve(ct, nums).toString.trim());
  }
  def solve(ct :Int,nums:Array[Int]):Int ={
    val soretedNms = nums.sorted
    soretedNms((ct/2) )  - soretedNms(ct/2 - 1 )
  }
}

Measured memory_bytes: 42892
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        for(int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }
        long[] Kbin = new long[40];
        for(int i = 0; K > 0; i++) {
            Kbin[i] = K & 1;
            K >>= 1;
        }
        long[] Abin_one = new long[40];
        for(int i = 0; i < N; i++) {
            long tmp = A[i];
            for(int j = 0; tmp > 0; j++) {
                Abin_one[j] += tmp & 1;
                tmp >>= 1;
            }
        }
        long[] Xbin = new long[40];
        for(int i = 0; i < 40; i++) {
            if(Abin_one[i] >= N - Abin_one[i]) Xbin[i] = 0;
            else Xbin[i] = 1;
        }
        for(int i = 39; i >= 0; i--){
			if(Kbin[i] == 1 && Xbin[i] == 0) break;
			if(Kbin[i] == 0 && Xbin[i] == 1) Xbin[i] = 0;
        }
        long ans = 0;
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < 40; j++) {
                ans += (Xbin[j] ^ ((A[i] >> j) & 1)) << j;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64556
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int A = nextInt();
      int B = nextInt();
      int H = nextInt();
      myout((A + B) * H / 2);
	}
	//Method addition frame start


  
	//Method addition frame end
}


Measured memory_bytes: 32788
#include<stdio.h>
int minc(long a,long b){
if(a>b)return b;
  else return a;
}
int main(void){
  long l,r;
  scanf("%ld%ld",&l,&r);
 int  min=2020;
 r=minc(r,l+4038);
  for(long i=l;i<=r;i++){
    for(long j=l;j<=r;j++){
      if(j==i)continue;
      if(i*j%2019<min)min=i*j%2019;
    }
  }
  printf("%d",min);
  return 0;
}
    

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

int main(int argc, char *argv[])
{
    int a, b;
    vector<tuple<int, int>> tv;

    while (1)
    {
        cin >> a >> b;
        if (a == 0 && b == 0)
            break;
        tv.push_back(tuple<int, int>(a, b));
    }

    for (tuple<int, int> t : tv)
    {
        for (int i = 0; i < get<0>(t); i++)
        {
            if (i == 0 || i == get<0>(t) - 1)
            {
                for (int j = 0; j < get<1>(t); j++)
                {
                    cout << "#";
                }
            }
            else
            {
                cout << "#";
                for (int j = 1; j < get<1>(t) - 1; j++)
                {
                    cout << ".";
                }
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    vector<ll> seq(N);

    REP(i,0,N){
        cin >> seq[i];
    }

    ll now,cnt=0,maxi=0;
    REP(i,0,N){
        if(i==0){
            now=seq[0];
            continue;
        }
        if(now<seq[i]){
            maxi=max(maxi,cnt);
            cnt=0;
        }else{
            cnt++;
        }
        now=seq[i];
    }
    maxi=max(maxi,cnt);
    P(maxi);
}

Measured memory_bytes: 1024
N = int(input())
A = []
first = 0
second = 0
for i in range(N):
    x = int(input())
    if x > first:
        first = x
    elif x >= second:
        second = x
    A.append(x)
for i in range(N):
    if A[i] == first:
        print(second)
    else:
        print(first)




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

const int maxn = 5050, P = 1000000007;
int n, m, f[maxn][maxn];

int main() {
    scanf("%d %d", &n, &m);
    fill(f[0] + 1, f[0] + m + 1, 1);
    for (int i = 1; i <= n; i++) {
        int sum = 0;
        for (int j = 1; j <= m; j++) {
            f[i][j] = (1LL * (j + 1) * f[i - 1][j] + sum) % P;
            sum = (2LL * sum + 1LL * j * f[i - 1][j]) % P;
        }
    }
    printf("%d\n", f[n][m]);
    return 0;
}

Measured memory_bytes: 102312
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

static const int N = 100;

int main() {
    int M[N][N];
    int n, u, k, v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) {
                cout << " ";
            }
            cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3116