akhauriyash/Code-Regression huggingface dataset:
#define ll long long int
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

//using namespace __gnu_pbds;

#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)2e5 + 2;

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

//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }

//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}

void solve()
{
    ll a , b , m;
    cin >> a >> b >> m;
    ll arr[a] , brr[b];
    ll ans = 0,mn = inf, mn2 = inf;
    for(ll i = 0 ; i < a ;i ++)
    {cin >> arr[i] ; if(mn > arr[i])mn = arr[i];}
    for(ll i = 0; i < b ; i ++)
    {cin >> brr[i];if(mn2 > brr[i])mn2 = brr[i];}
    ans = mn + mn2;
    while(m --)
    {
        ll x ;
        cin >> a >> b >> x;
        ll t = arr[a - 1] + brr[b - 1] - x;
        if(t < ans)
            ans = t;
    }
    print(ans);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


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

int main(){
    int n,A,B,C; cin >> n >> A >> B >> C;
    map<char,int> mp;
    mp['A'] = A; mp['B'] = B; mp['C'] = C;
    vector<char> ans(n);
    vector<string> sn(n);
    rep(i,n) cin >> sn[i];
    rep(i,n){
        string s = sn[i];
        char s0 = s[0];
        char s1 = s[1];

        if(mp[s0]==0 && mp[s1]==0){
            cout << "No" << endl;
            return 0;;
        }
        else if(mp[s0]==0){
            mp[s0]++; mp[s1]--;
            ans[i] = s0;
        }
        else if(mp[s1]==0){
            mp[s1]++; mp[s0]--;
            ans[i] = s1;
        }
        else if(i==n-1){
            ans[i] = s0;
        }
        else if(sn[i+1][0]==s0 || sn[i+1][1]==s0){
            mp[s0]++; mp[s1]--;
            ans[i] = s0;
        }
        else{
            mp[s0]--; mp[s1]++;
            ans[i] = s1;
        }
    }
    cout << "Yes" << endl;
    rep(i,n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6424
N,M = map(int,input().split())
A = [ int(a) // 2 for a in input().split()]
from math import ceil
from fractions import gcd
def main():
    x = 1
    check = set()
    for a in A:
        tmp = 0
        if a%2 == 0:
            tmpa = a
            while tmpa%2 ==0 :
                tmpa //= 2
                tmp += 1
        check.add(tmp)
        if len(check) > 1:
            print(0)
            return
        if x%a != 0:
            x *= a // gcd(a,x)
    print(ceil((M // x)/2))
    return

if __name__ == "__main__":
    main()

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;

int main(){
    int k,x;
    cin >> k >> x;
    if(k * 500 >= x){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i=0;i<N-1;i++){
    int A;
    cin >> A;
    num.at(A-1)++;
  }
  for(int i=0;i<N;i++){
    cout << num.at(i) << endl;
  }
}

Measured memory_bytes: 4048
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}
/*

*/


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

void solve() 
{
    int a,b,c,k;cin>>a>>b>>c>>k;
    int cnt=0;
    while(a>=b&&cnt<k)b*=2,cnt++;
    while(b>=c&&cnt<k)c*=2,cnt++;
    cout<<(a<b&&b<c?"Yes":"No")<<endl;
}

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans;
string s[10005];
int a,b,ab,d;
int main(void){
	int n; cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=0;j<s[i].size()-1;j++){
			if(s[i][j]=='A'&&s[i][j+1]=='B'){
				ab++;
			}
		}
		if(s[i][0]=='B'){
			b++;
		}
		if(s[i][s[i].size()-1]=='A'){
			a++;
		}
		if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A'){
			d++;
		}
	}
	int A=a-d,B=b-d;
	if(d==0){
		cout<<ab+min(a,b)<<endl;
		return 0;
	}
	ans=ab+d-1;
	if(A>0){
		ans++;
		A--;
	}
	if(B>0){
		ans++;
		B--;
	}
	ans=ans+min(A,B);
	cout<<ans<<endl;
	
	
}


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

int main(){
	int n, c;
	cin >> n >> c;
	vector<vector<int>> d = vector<vector<int>>(c, vector<int>(c, 0));
	for (int i = 0; i < c; ++i) {
		for (int j = 0; j < c; ++j) {
			int dij;
			cin >> dij;
			d[i][j] = dij;
		}
	}
	vector<vector<int>> cmap = vector<vector<int>>(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int cij;
			cin >> cij;
			cij--;
			cmap[i][j] = cij;
		}
	}
	vector<vector<int>> result = vector<vector<int>>(3, vector<int>(c,0));
	for(int ct =0;ct<c;++ct){
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				int line = (i + j) % 3;
				int cc = cmap[i][j];
				if(cc!=ct)
					result[line][ct] += d[cc][ct];
			}
		}
	}
	int best = 500*500*1000+1;
	for (int call = 0; call < c*c*c; call++) {
		int c1 = call % c;
		int c2 = (call / c) % c;
		int c3 = (call / c / c) % c;
		if (c1 == c2 || c2 == c3 || c3 == c1) continue;
		best = min(best, result[0][c1] + result[1][c2] + result[2][c3]);
	}
	cout << best << endl;
	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  rep(i, N) cin >> H.at(i);

  vector<bool> res(N, true);
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    A--; B--;
    if (H.at(A) > H.at(B)) {
      res.at(B) = false;
    } else if (H.at(A) == H.at(B)) {
      res.at(A) = false;
      res.at(B) = false;
    } else {
      res.at(A) = false;
    }
  }

  int ans = 0;
  rep(i, N) {
    if (res.at(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3776
import java.awt.Point;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Point>[] edge = new ArrayList[N];
		for(int i = 0; i < N; i++)
		    edge[i] = new ArrayList<>();
		for (int i = 0; i < N-1; i++) {
		    int a = sc.nextInt()-1;
		    int b = sc.nextInt()-1;
		    int c = sc.nextInt();
		    edge[a].add(new Point (b, c));
		    edge[b].add(new Point (a, c));
		}
		int Q = sc.nextInt();
		int K = sc.nextInt()-1;
		long[] d = new long[N];
		boolean[] used = new boolean[N];
		used[K] = true;
		Queue<Integer> q = new ArrayDeque<>();
		q.offer(K);
		while(q.size() > 0) {
			int x = q.poll();
			for(Point y : edge[x]) {
				if(!used[y.x]) {
					q.offer(y.x);
					d[y.x] = d[x] + y.y;
					used[y.x]= true; 
				}
			}
		}
		for(int i = 0; i < Q; i++)
			System.out.println(d[sc.nextInt()-1] + d[sc.nextInt()-1]);
	}

}

Measured memory_bytes: 182984
#include<cstdio>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 100000;
const int MAX_V = 1000000000;

int N;
int X[MAX_N];
int L[MAX_N];

void input(){
    scanf("%d",&N);
    for(int i = 0; i < N; i++){
        scanf("%d%d", X + i, L + i);
    }
}

P ps[MAX_N];

int solve(){
    for(int i = 0; i < N; i++){
        ps[i] = P(X[i] + L[i], X[i] - L[i]);
    }
    sort(ps,ps+N);
    int cur = -MAX_V;
    int ans = 0;
    for(int i=0;i<N;i++){
        if(cur <= ps[i].second){
            ans++;
            cur = ps[i].first;
        }
    }
    return ans;
}

int main(){
    input();
    int ans = solve();
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int n=sc.nextInt();
		int c=0;
		for(int i=0; i<n; i++) {
			c += sc.nextInt();
		}
		if(c>=h) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H+2,vector<char>(W+2));
  for(int i=0; i<H+2; i++){
    S.at(i).at(0)='.';
    S.at(i).at(W+1)='.';
  }
  for(int i=0; i<W+2; i++){
    S.at(0).at(i)='.';
    S.at(H+1).at(i)='.';
  }
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      cin >> S.at(i).at(j);
    }
  }
  bool a=1;
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      if(S.at(i).at(j)=='#'){
        if(S.at(i-1).at(j)=='.'&&S.at(i+1).at(j)=='.'&&S.at(i).at(j-1)=='.'&&S.at(i).at(j+1)=='.'){
          a=0;
        }
      }
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
vector<ll> vec;

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N+1);

    REP(i, N)
    cin >> A.at(i);
    A.at(N) = 0;

    sort(A.begin(), A.end()); //個数を数えるためにソート

    ll tmp = 1;
    REP(i, N )
    {
        if (A.at(i) == A.at(i + 1))
        {
            tmp++;
            if (i == N - 1)
            {
                vec.push_back(tmp); //vector のvecに配列Aの個数を入れている
            }
        }
        else
        {
            vec.push_back(tmp);
            tmp = 1;
        }
    }

    sort(vec.begin(), vec.end()); //小さい順にソート
    reverse(vec.begin(), vec.end());
    //cout << vec.size() << endl;

    if (vec.size() <= K) //vec.sizeが種類数なのでK以下なら書き換える必要なし
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = 0;
        REP(i, K) //個数が少ないものから足し合わせる
        {
            ans += vec.at(i);
        }
        cout << N-ans << endl;
    }
}


Measured memory_bytes: 3956
import sys
import fractions

def input(): return sys.stdin.readline().strip()
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    T = [Z() for _ in range(N)]
    ans = T[0]
    for i in range(1, N):
        g = fractions.gcd(ans, T[i])
        ans *= T[i]
        ans //= g
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..


int main(void) {
  ll n, p;
  cin >> n >> p;



  ll ans = 1;

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

  for (ll i = 2; i * i <= p; i++) {
    
    ll cnt = 0;
    while (p % i == 0) {
      
      cnt++;
      p /= i;
      
      
    }
    if (cnt >= n) {
      ans *= (ll) pow(i, cnt / n);
    }
    
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

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

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int b,f,r,v;
	int a[4][3][10] = {};
	for(int i=0;i<n;i++){
		cin >> b >> f >> r >> v;
		a[b-1][f-1][r-1] += v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++) cout << " " << a[i][j][k];
			cout << endl;
		}
		if(i!=3) cout << "####################" << endl;
	}
}

Measured memory_bytes: 1160
open System
let x = stdin.ReadLine() |> int

let isPrime n =
    match n with
    | _ when n > 3 && (n % 2 = 0 || n % 3 = 0) -> false
    | _ ->
        let maxDiv = int(System.Math.Sqrt(float n)) + 1
        let rec f d i = 
            if d > maxDiv then 
                true
            else
                if n % d = 0 then 
                    false
                else
                    f (d + i) (6 - i)     
        f 5 2

let rec p n = 
 match n with
 |s when isPrime s -> s
 |t -> p (t + 1)

p x
|>stdout.WriteLine

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>

using namespace std;

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  cout << min(A,B)+min(C,D) << endl;
  
  return 0;
}

Measured memory_bytes: 256
T = int(input())

def f(N, A, B, C, D):
  if N == 0:
    return 0
  elif N == 1:
    return D
  elif N in data:
    return data[N]
  else:
    cost = min(
      D * N,
      D * abs(N - (N // 2) * 2) + A + f(N//2, A, B, C, D),
      D * abs(N - ((N + 1)// 2) * 2) + A + f((N + 1)// 2, A, B, C, D),
      D * abs(N - (N // 3) * 3) + B + f(N//3, A, B, C, D),
      D * abs(N - ((N + (N % 3)) // 3) * 3) + B + f((N + (N % 3)) // 3, A, B, C, D),
      D * abs(N - (N // 5) * 5) + C + f(N//5, A, B, C, D),
      D * abs(N - ((N + (N % 5)) // 5) * 5) + C + f((N + (N % 5))//5, A, B, C, D)
    )
    data[N] = cost
    return cost
  
for _ in range(T):
  N, A, B, C, D = list(map(int, input().split()))
  data = {}
  print(f(N, A, B, C, D))
  

Measured memory_bytes: 10868
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>


#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;


signed main(){
	IOS;

	string s;
	cin >> s;
	
	reverse(s.begin(), s.end());
	int size = s.size();
	map<int, int> mm;
	mm[0] = 1;
	int t = 0;
	ll res = 0;
	int carpan = 1;
	for (int i = 0; i < size; i++){
		int cur = s[i] - '0';
		
		t =(t+ cur * carpan )%2019;
		
	
		res+=mm[t];
		mm[t]++;
		carpan = (carpan *10)%2019;
	}
	
	cout << res ;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 2e5+4;
int a[MAXN];
 
int main() {
    int k,n;
    cin>>k>>n;
 
    int maxx = 0;
    cin>>a[0];
    for (int i=1; i<n; i++) {
        cin>>a[i];
        maxx = max(maxx, a[i]-a[i-1]);
    }
    maxx = max(maxx, k+a[0]-a[n-1]);
 
    cout << k - maxx << endl;
 
    return 0;
}

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

T,X = inpl()
print(T/X)


Measured memory_bytes: 4200
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int K,A,B;
	scanf("%d %d %d",&K,&A,&B);

	for(int i = A; i <= B; i++){
		if(i%K == 0){

			printf("OK\n");
			return 0;
		}
	}

	printf("NG\n");

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli m, r,i,j,n,x;
    cin>>n>>m;
    int a[m];
    lli c=0;
    for(i=0;i<m;i++){
        cin>>a[i];
        c=c+a[i];
    }
    if(c>n){
        cout<<"-1";
    }
    else{
        cout<<n-c;
    }
}


Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    long x,a,b; cin >> x >> a >> b;
    if(abs(x-a)>abs(x-b)) pr("B");
    else pr("A");
}



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int modPow(int a, int n) {
  int res = 1;
  while(n > 0) {
    if(n&1) res = res*a%mod;
    a = a*a%mod;
    n >>= 1;
  }
  return res;
}

int modInv(int a) {
  return modPow(a, mod-2);
}

int modComb(int n, int r) {
  static int fact[2002], invfact[2002];
  if(fact[0] == 0) {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < 2002; ++i) {
      fact[i] = fact[i-1]*i%mod;
      invfact[i] = modInv(fact[i]);
    }
  }
  if(r < 0 || n < r) return 0;
  return fact[n]*invfact[r]%mod*invfact[n-r]%mod;
}

struct UnionFind {
  vector<int> data;
  UnionFind(int n):data(n, -1){}
  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  struct edge {
    int u, v, w;
    edge(){}
    edge(int u, int v, int w):u(u), v(v), w(w){}
    bool operator < (const edge& e) const {
      return w < e.w;
    }
  };

  int n, m, x;
  cin >> n >> m >> x;
  vector<edge> es;
  rep(i, m) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    es.emplace_back(u, v, w);
  }
  sort(all(es));

  int cnt = 0;
  int cnt_no = 0;
  rep(i, m) {
    UnionFind uf(n);
    int sum = es[i].w;
    uf.unite(es[i].u, es[i].v);
    rep(j, m) {
      edge e = es[j];
      if(!uf.same(e.u, e.v)) {
	uf.unite(e.u, e.v);
	sum += e.w;
      }
    }
    if(sum == x) ++cnt;
    else if(sum < x) ++cnt_no;
  }

  int ans = 0;
  if(cnt == 0) ans = 0;
  else if(cnt_no == 0) ans = (modPow(2, cnt)+mod-2)%mod*modPow(2, m-cnt-cnt_no)%mod;
  else ans =((modPow(2, cnt)+mod-2)%mod*modPow(2, m-cnt-cnt_no)%mod*2%mod+modPow(2, m-cnt-cnt_no)%mod*2%mod)%mod;

  cout << ans << endl;

  return 0;
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a,s=0LL;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		s+=a-1LL;
	}
	cout<<s<<endl;
	return 0;
}


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

int main(){
 int a,b;
 cin >> a >> b;
 if((a + b) % 2 == 1){
  cout << int((a + b)/2) + 1 << endl; 
 }else{
  cout << (a + b)/2 << endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
int main() {
     int n;
       cin >> n;
       vector<map<char,int>> d(n);
       rep(i,0,n){
           string s;
           cin >> s;
           rep(j,0,s.size()){
               d[i][s[j]]++;
           }
       }
       map<char,int> m = d[0];
       for(auto x:m){
           char k = x.first;
           rep(i,0,n) m[k] = min(m[k],d[i][k]);
       }
       for(auto x:m){
           rep(i,0,x.second) cout << x.first;
       }
       cout << endl;
}



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

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

    int mx=(n-1)*(n-2)/2;
    if ( k>mx ) {
        puts("-1");
        return 0;
    }
    vector<pair<int,int>> e;
    // star
    for ( int i=2; i<=n; i++ ) {
        e.emplace_back(1,i);
    }

    int total=mx;
    for ( int i=2; i<=n; i++ ) {
        for ( int j=i+1; j<=n; j++ ) {
            if ( total>k ) {
                e.emplace_back(i,j);
                total--;
            } 
        }
    }
    cout << e.size() << '\n';
    for ( int i=0; i<e.size(); i++ ) {
        cout << e[i].first << ' ' << e[i].second << '\n';
    }
    return 0;
}

Measured memory_bytes: 384
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */

    int n = sc.nextInt();
    int fstMax = Integer.MIN_VALUE;
    int scdMax = Integer.MIN_VALUE;

    int a[] = new int[n];

    for (int i = 0; i < n; i++) {
      int val = sc.nextInt();
      a[i] = val;

      if (val >= fstMax) {
        scdMax = fstMax;
        fstMax = val;
      } else if (val >= scdMax) {
        scdMax = val;
      }
    }

    for (int i = 0; i < n; i++) {
      if (a[i] != fstMax) {
        os.println(fstMax);
      } else {
        os.println(scdMax);
      }
    }
  }
}

Measured memory_bytes: 105600
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;
int main() {
    int r;
    cin >> r;
    cout << 2*r*3.14159;
    return 0;
}

Measured memory_bytes: 3764
/*-- ILSH  --*/

// Multipoll evaluation + Divide and Conquer
// Time ( Iterative ) < Time ( Recursive )

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double ld;

#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll > 
#define len length 
#define fi first
#define se second
#define dt cout<<"HEre\n";
#define sz(x) (ll)x.size()
const ll inf=1e18+1e17;
const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

int brr[10]={0};
bool check( int n){
	while ( n!=0){
		if ( brr[n%10]==1)
			return false;
		n/=10;
	}
	return true;
}
void solve(){
	int n;
	cin>>n;
	int k;
	cin>>k;
	for ( int i=0;i<k;i++){
		int aa;
		cin>>aa;
		brr[aa]=1;
	}
	for ( int i=n;;i++){
		if ( check(i)){
			cout<<i<<'\n';
			return;
		}
	}
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
    //	cout << clock() / double(CLOCKS_PER_SEC) << endl;
}


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

int main() {
  int n;
  float x, ans; ans = 0.0;
  string s;
  cin >> n;

  rep(i, n) {
    cin >> x >> s;
    if (s == "BTC")
      ans += x*380000.0;
    else 
      ans += x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# できなかった
# nコのコマでmコの地点を訪れる
# 指定された地点のみをスタート地点と考えて問題ない
# 右にのみ進むと考えて問題ない
# nコの範囲に分け、その合計幅の最小値を求める
# ※訪れていないN-1コの開区間を最大化すれば良い！！！
import math
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
if n>=m:
    print(0)
else:
    dimX=[x[i]-x[i-1]for i in range(1,m)]
    # print(x,dimX)
    dimX.sort(key=lambda x:-x)
    ans=x[-1]-x[0]
    for i in range(n-1):
        ans-=dimX[i]
    print(ans)


Measured memory_bytes: 13576
#include<stdio.h>

int main(){

  int N1,N2,i,j,key,count=0;

  scanf("%d", &N1);
  int A[N1];
  for(i=0;i<N1;i++)scanf("%d",&A[i]);
  scanf("%d", &N2);
  int B[N2];
  for(i=0;i<N2;i++)scanf("%d",&B[i]);

  for(i = 0 ; i< N2 ; i++){
    j = 0;
    key = B[i];
    while(1){
      if(j == N1)break;
      if(A[j] == key){
	count++;
	break;
      }
      j++;
    }
  }

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

  return 0;
}




Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
     ///"In the name of Allah,most gracious and most merciful"///

        ll i,j,x,y,z,count=0,sum=0,n;
        string s;
        cin>>s;
        for(i=0;i<s.size();i++)
        {
            ll k=s[i]-'0';
            sum+=k;

        }
        if(sum%9==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;


    return 0;
}




Measured memory_bytes: 3720
#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 int
#define endl "\n"
#define db(x) cout<<#x<<" ->"<<x<<endl
#define db2(x,y) cout<<#x<<"->"<<x<<", "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define db4(w,x,y,z) cout<<#w <<" -> " << w << " , " << #x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++) { cout<<*it<<" "; } cout<< endl
#define IN freopen("input.txt","r",stdin)
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = (int)2e5+4;

ll dp[N][5];
int n , ara[N];
const ll inf = (ll)1e18;

ll solve(int at , int fl){
    if( at >= n){
        if( n % 2 && fl > 1){ return -inf ; }
        return 0;
    }
    ll &ret = dp[at][fl];
    if(ret!=-1){ return ret ;}
    ret = -inf;
    ret = max(ret,ara[at] + solve(at+2,fl));
    if(fl > 0){
        ret = max(ret,solve(at+1,fl-1));
    }
    return ret;
}

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> ara[i];
    }
    int lagbe = n / 2;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < 3; j++){ dp[i][j] = -1 ; }
    }
    cout << solve(0, 1 + (n%2) ) << endl;;

    return 0;
}


Measured memory_bytes: 18484
//Tue Dec 22 22:01:34 JST 2009
#include<cstdio>
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false
int gx,gy;

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//©ªÌOÈOÌâÂÆÂÈªÁÄ¢éÌÅ¾ßB
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//©ªÆOÌâÂÆÂÈªÁÄ¢éÌÅ¨
    return false;
  }
  
  bool make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	if ( x[0]==gx && y[0]==gy)return true;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return false;
    }

    //don't move
    
    if (can_good_pos(now) ){
      if (make_next(now+1,Q,S,CANMOVE,NG))return true;
    }

    if ( flag == CANNOTMOVE)return false;//OÌª®¢Ä½ç©ªÍ®¯È¢

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];



      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	if (make_next(now+1,Q,S,CANNOTMOVE,NG))return true;//©ªª®¢½çÌÍ®¯È¢B
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
    return false;
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
    if (20<now.cnt+(max(now.x[0],dx)-min(now.x[0],dy)+max(now.y[0],dy)-min(now.y[0],dy))/2)continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    if ( now.make_next(0,Q,S,CANMOVE,NG))return now.cnt;
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(scanf("%d",&n)!=-1 && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)scanf("%d%d",&ini.x[i],&ini.y[i]);
    scanf("%d",&m);
    rep(i,m){
      int f,s;
      scanf("%d%d",&f,&s);
      NG.insert(mp(f,s));
    }
    scanf("%d%d",&dx,&dy);
    gx=dx;gy=dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

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

int main(){
  string s,t;cin>>s>>t;
  int n=s.size();
  REP(i,n){
    if(s==t){
      cout<<"Yes";
      return 0;
    }
    char tmp=s.at(0);
    REP(j,n-1) s.at(j)=s.at(j+1);
    s.at(n-1)=tmp;
  }
  cout<<"No";
}

Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
point=0
l=[0]*n
for i in range(k):
  if t[i]=='r':
    point+=p
  elif t[i]=='s':
    point+=r
  else:
    point+=s
  l[i]=1
for i in range(k,n):
  if t[i]==t[i-k] and l[i-k]==1:
    continue
  if t[i]=='r':
    point+=p
  elif t[i]=='s':
    point+=r
  else:
    point+=s
  l[i]=1
print(point)

Measured memory_bytes: 4212
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] strs = sc.next().split("");
        String before = "0";
        int cnt0 = count(strs, "0");
        int cnt1 = count(strs, "1");

        if (cnt0 > cnt1) {
            System.out.println(cnt1);
        } else {
            System.out.println(cnt0);
        }

    }

    private static int count(String[] strs, String before) {
        int cnt = 0;
        for (String str : strs) {
            if (before.equals(str)) {
                cnt++;
                if (str.equals("0")) {
                    before = "1";
                } else {
                    before = "0";
                }
            } else {
                before = str;
            }
        }
        return cnt;
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll MRINF = 5000000000000000;

int main() {

    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());

    cout << A[2]-A[0] << endl;
    
  
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3592
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int h = saori.saori_hayami();
		int w = saori.saori_hayami();
		int n = saori.saori_hayami();
		int num = Math.max(h, w);
		if(n%num == 0){
			System.out.println((int)n/num);
		} else {
			System.out.println((int)n/num+1);
		}

		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22612
import heapq


def dijkstra(K):
    c_l = [float('inf')] * N
    c_l[K] = 0
    hq = [(0, K)]
    while hq:
        u = heapq.heappop(hq)[1]
        for nv, c in adj_list[u]:
            if c_l[nv] > c_l[u] + c:
                c_l[nv] = c_l[u] + c
                heapq.heappush(hq, (c_l[u] + c, nv))
    return c_l


N = int(input())
adj_list = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj_list[a].append((b, c))
    adj_list[b].append((a, c))

Q, K = map(int, input().split())
c_l = dijkstra(K - 1)

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(c_l[x] + c_l[y])


Measured memory_bytes: 49436
#include <stdio.h>
#define MAXSIZE 10

int main(void){
    int n, p[MAXSIZE], max_price = 0, sum_value = 0, half_flag = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &p[i]);
        if(p[i] > max_price){
            max_price = p[i];
        }
    }

    for(int i = 0; i < n; i++){
        if(p[i] == max_price && half_flag == 0){
            sum_value += p[i] / 2;
            half_flag = 1;
        }else{
            sum_value += p[i];
        }
    }
    printf("%d\n", sum_value);
    return 0;
}

Measured memory_bytes: 128
def dist(s1,s2):
  return abs(s1[1]-s2[1]) + abs(s1[2]-s2[2])

N=int(input())
now = (0,0,0)
for i in range(N):
  next_ = list(map(int,input().split()))
  if dist(now,next_)<=next_[0]-now[0] and dist(now,next_) % 2 == (next_[0]-now[0])%2:
    now = next_
    continue
  else:
    print('No')
    exit()
print('Yes')

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

#include <map>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> mp;
    rep(i, N) cin >> A[i];

    ll ans = 0;
    rep(j, N) {
        ans += mp[j - A[j]];
        mp[A[j] + j]++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 21044
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

template <typename T>
struct SegTree {
	T init_val;
	int n;
	vector<T> dat;
	
	SegTree() = default;
	SegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(n * 2 - 1, init_val);
	}
	
	void update(int i, T x) {
		i += n - 1;
		dat[i] = min(dat[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	
	void set(int i, T x) {
		dat[i + n - 1] = x;
		update(i, x);
	}
	
	// 探索範囲[a,b), 現在見ているkノード[l,r)
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return min( query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r) );
	}
};

int N, K;
int H[300], h[300];
SegTree<ll> dp[301][301];


int main() {
	cin >> N;
	K = 0;
	REP(i, N) scanf("%d", H + i);
	
	vector<int> cx(N);
	REP(i, N) cx[i] = H[i];
	cx.push_back(0);
	sort(ALL(cx));
	cx.erase(unique(ALL(cx)), cx.end());
	
	REP(i, N) h[i] = lower_bound(ALL(cx), H[i]) - cx.begin();
	
	REP(i, N + 1) REP(j, K + 1) dp[i][j] = SegTree<ll>(N + 1, longINF);
	
	dp[0][0].update(0, 0);
	FOR(i, 1, N + 1) {
		REP(j, K + 1) {
			ll mn = longINF;
			if (i) {
				REP(k, N + 1) chmin(mn, dp[i - 1][j].query(k, k + 1) + max(cx[h[i - 1]] - cx[k], 0));
				if (j < K) dp[i][j + 1].update(h[i - 1], mn);
			}
			
			REP(k, N + 1) { // i番目までで合計j回変更し直前の高さがcx[k]
				// min(>=k)採用
				if (i && j) dp[i][j].update(k, dp[i - 1][j - 1].query(k, N + 1));
				
				// 下から伸ばす
				if (k) dp[i][j].update(k, dp[i][j].query(k - 1, k) + cx[k] - cx[k - 1]);
				
			}
			dp[i][j].update(h[i - 1], mn);
		}
	}
	
	ll ans = longINF;
	REP(j, K + 1) chmin(ans, dp[N][j].query(0, N + 1));
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3968
n, a, b = input(), map(int, raw_input().split()), map(int, raw_input().split())
c = [a[i] - b[i] for i in xrange(n)]
print 'Yes' if sum([-x / 2 for x in c if x < 0]) >= sum([x for x in c if x > 0]) else 'No'


Measured memory_bytes: 3972
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main {

	final int INF=1<<30;
	int adjacent[][];
	Scanner sc;
	int n;
	
	int solve(){
		int cost=0;
		Set<Integer> vertex=new HashSet<Integer>();
		vertex.add(0);
		
		for(int h=0;h<n;++h){
			int min=INF,e=0;
			for(int v:vertex){
				for(int i=0;i<n;++i){
					if(vertex.contains(i))continue;
					if(adjacent[v][i]<min){
						min=adjacent[v][i];
						e=i;
					}			
				}
			}
			if(min<INF){
				vertex.add(e);
				cost+=min/100-1;	
			}
		}
		return cost;
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in).useDelimiter("\\s*,\\s*|\n");
		
		while((n=ni())!=0){
			adjacent=new int[n][n];
			for(int i=0;i<n;++i){Arrays.fill(adjacent[i],INF);}
			int m=ni();
			for(int i=0;i<m;++i){
				int a=ni(),b=ni(),d=ni();
				adjacent[a][b]=adjacent[b][a]=d;
			}
			System.out.println(solve());
		}
	}

	public static void main(String[] args) {
			new Main().io();
	}
}

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

using namespace std;

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

const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(void) {
	int N;
	cin >> N;
	map<string,int> id;
	vector<int> x(N);
	for(int i=0;i<N;i++){
		string a;
		cin >> a >> x[i];
		id[a] = i;
	}
	UnionFind uf(N+1);

	int M;
	cin >> M;
	
	for(int i=0;i<M;i++){
		string s,t;
		cin >> s >> t;
		uf.unionSet(id[s],id[t]);
	}

	vector<int> cost(N);
	for(int i=0;i<N;i++)cost[i] = x[i];
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i == j)continue;
			if(uf.findSet(i,j)){
				cost[i] = min(cost[i],x[j]);
			}
		}
	}
	ll ans = 0;
	for(int i=0;i<N;i++){
		ans += cost[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1844