akhauriyash/Code-Regression huggingface dataset:
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def main():
	a, b, c = read(); k = int(input())
	# k -= 1
	while b <= a:
		b *= 2
		k -= 1
	while c <= b:
		c *= 2; k -= 1
	print("YNeos"[k < 0::2])






if __name__ == "__main__":
	main()

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}



int main(){
  int a, b;
  cin >> a >> b;
  bool res[100][100];
  REP(i, 50) REP(j, 100) res[i][j] = false;
  FOR(i, 50, 100) REP(j, 100) res[i][j] = true;
  int cnt = 0;
  cout << 100 << " " << 100 << endl;
  REP(i, 25){
    REP(j, 50){
      if(cnt++ >= (b -1)) break;
      res[i*2+1][j*2+1] = true;
    }
  }
  cnt = 0;
  FOR(i, 25, 50){
    REP(j, 50){
      if(cnt++ >= (a - 1)) break;
      res[i*2 + 1][j*2+1] = false;
    }
  }
  REP(i, 100){
    REP(j, 100){
      if(!res[i][j]) cout << '.';
      else cout << '#';
    }
    cout << endl;
  }
} 	


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int i, n, sum=0;
    scanf("%lld", &n);
    for(i=1; i<=n; i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            sum+=i;
        }
    }
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
	// Input
	int adj_m[100][100] = { 0 };
	int n;
	cin >> n;
	int u,v,k;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			adj_m[u - 1][v - 1] = 1;
		}
	}

	// Output
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j)
				cout << " ";
			cout << adj_m[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
// In the name of Allah
// #Isart

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 400 + 10, mod = 1e9 + 7;
ll dp[MAXN][MAXN], sum[MAXN][MAXN];
int a[MAXN], b[MAXN];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, c; cin >> n >> c;
	for(int i = 0; i < n; i ++) cin >> a[i];
	for(int i = 0; i < n; i ++)	cin >> b[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i ++){
		for(int j = a[i - 1]; j <= b[i - 1]; j ++){
			ll tmp = 1;
			for(int t = 0; t <= c; t ++){
				sum[i][t] = (sum[i][t] + tmp) % mod;
				tmp = 1ll * tmp * j % mod; 
			}
		}
	}
	for(int i = 1; i <= n; i ++){
		for(int j = 0; j <= c; j ++){
			for(int t = 0; t <= j; t ++){
				dp[i][j] = (dp[i][j] + dp[i - 1][j - t] * sum[i][t] % mod) % mod;
			}
		}
	}
	cout << dp[n][c] << endl;
	return 0;	
}

Measured memory_bytes: 2816
package main

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

func main() {
	S := ReadString()
	c := make([]int, len(S))
	j := 1
	for i := 0; i < len(S)-1; i++ {
		if S[i] != 'R' {
			continue
		}
		for S[j] == 'R' || j <= i {
			j++
		}
		if (j-i)%2 == 0 {
			c[j]++
		} else {
			c[j-1]++
		}
	}
	j = len(S) - 2
	for i := len(S) - 1; i >= 1; i-- {
		if S[i] != 'L' {
			continue
		}
		for S[j] == 'L' || j >= i {
			j--
		}
		if (i-j)%2 == 0 {
			c[j]++
		} else {
			c[j+1]++
		}
	}
	for _, v := range c {
		fmt.Printf("%d ", v)
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main(){
  int n, m, i, j;
  cin >> n >> m;
  
  vector<int> A(n, 16);
  vector<int> S(m);
  vector<int> C(m);

  for(i=0; i<m; i++) cin >> S[i] >> C[i];
  int ch = 0;
  
  if (n == 1){
    if (m == 0) cout << 0 << endl;
    else {
      for(i=0; i<m; i++){
      if(A[0] != 16){
        if (A[0] != C[i]) ch = 1;
      }
      else A[0] = C[i];
    }
    if (ch == 1) cout << -1 << endl;
    else cout << A[0] << endl;
    }
  }
  
  else {
    for(i=0; i<m; i++){
    if(S[i] == 1 && C[i] == 0) ch = 1;
    else if(A[S[i]-1] != 16){
      if (A[S[i]-1] != C[i]) ch = 1;
    } 
    else A[S[i]-1] = C[i];
  }
  for(i=0; i<n; i++){
    if(i==0 && A[i] == 16) A[i] = 1; 
    else if(A[i] == 16) A[i] = 0;
  }
  
  if (ch == 1) cout << -1 << endl;
  else {
    for(i=0; i<n; i++){
      cout << A[i];
  }
    cout << endl;
}
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int h,w;
  cin >> h >> w;
  vector<vector<char>> mapp(h+2,vector<char>(w+2));
  int ct=0;
  char c;
  rep(i,0,h){
    rep(j,0,w){
      cin >> c;
      if(c=='#')ct++;
      mapp[i][j]=c;
    }
  }
  if(ct!=h+w-1) {cout<<"Impossible"<<endl;return 0;}
  int nowh=0,noww=0;
  while(!(nowh==h-1&&noww==w-1)){
    if(mapp[nowh+1][noww]=='#') {nowh++;continue;}
    if(mapp[nowh][noww+1]=='#') {noww++;continue;}
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  return 0;
}


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

using namespace std;
const int mod = 1e9 + 7;
using ll = long long;

ll f(int n) {
    ll ans = 1;
    for (ll i = 1; i <= n; ++i) {
        ans = (ans * i) % mod;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int m, n;
    cin >> m >> n;
    ll ans = abs(m - n) > 1 ? 0 : (m == n ? 2 * f(m) * f(m) : f(m) * f(n)) % mod;
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#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 int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int i,n,m,vis[N],ans=0;
vi g[N];

void dfs(int v)
{
    vis[v]=1;
    for(int u:g[v])
    {
        if(!vis[u])
            dfs(u);
    }
}

void solve()
{
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        g[x].pb(y);
        g[y].pb(x);
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
            ans++;
        }
    }
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
	int n, a;
	cin >> n >> a;
	n = n % 500;
	if (n>a) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

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

    string result;
    while (N > 0)
    {
        N--;
        result.insert(result.begin(), (N % 26) + 97);
        N /= 26;
    }

    cout << result<< "\n";

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={-1,0,1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string s;
    cin>>s;
    int n=sz(s);
    s+="...........";
    
    vector<vector<int>> dp(n+10,vector<int>(3,0));
    dp[0][1]=1;
    //dp[i][j] -> i文字目までを分割する場合の数,最後の文字列の長さはj
    rep(i,n) {
        dp[i+1][1]=max(dp[i+1][1],dp[i][2]+1);
        dp[i+2][2]=max(dp[i+2][2],dp[i][1]+1);
        if(i>0 && !(s[i-1]==s[i+1] && s[i]==s[i+2])) dp[i+2][2]=max(dp[i+2][2],dp[i][2]+1);
        if(s[i]!=s[i+1]) dp[i+1][1]=max(dp[i+1][1],dp[i][1]+1);
    }
    cout<<max(dp[n-1][1],dp[n-1][2])<<endl;
}



Measured memory_bytes: 11396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int sum_digit(int p){
        int ret = 0;
        int q = p;

        ret = q%10;
        while(q>=10){
                q = q/10;
                ret += q%10;
        }
        return ret;
}

int main(int argc, char* argv[]){
        char buf[1024]={0};
        char* p=NULL;
        int N = 0;
        int A = 0;
        int B = 0;

        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        N = atoi(p);

        p = strtok(NULL, " ");
        A = atoi(p);

        p = strtok(NULL, " ");
        B = atoi(p);

#ifdef DEBUG1
        printf("input: N=%d, A=%d, B=%d\n", N, A, B);
#endif
        long long sum=0;
        for(int i=1; i<N+1; i++){
                int v = sum_digit(i);
                if(v>=A && v<=B){ sum+=i; }
        }

        printf("%lld\n", sum);
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

using mint = modint998244353;

struct S { ll zero, one, inversion; };
using F = bool;
S op(S l, S r) { return S{l.zero + r.zero, l.one + r.one, l.inversion + r.inversion + l.one * r.zero}; }
S e() { return S{0, 0, 0}; }
S mapping(F l, S r) {
  if (!l) return r;
  return S{r.one, r.zero, r.one * r.zero - r.inversion};
}
F composition(F l, F r) { return (l && !r) || (!l && r); }
F id() { return false; }

signed main(void) {
  int n, q; cin >> n >> q;
  V<S> a(n);
  rep(i,n) {
    int x; cin >> x;
    if (x == 0) a[i] = S{1, 0, 0};
    else a[i] = S{0, 1, 0};
  }

  lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

  rep(i,q) {
    int t, l, r; cin >> t >> l >> r;
    --l;
    if (t == 1) {
      seg.apply(l, r, true);
    } else {
      pl(seg.prod(l, r).inversion)
    }
  }
  return 0;
}


Measured memory_bytes: 20400
#include <iostream>

using namespace std;


int main() {
	int x;
	int a = 0;

	cin >> x;
	if (x == 2) {
		cout << x;
		return 0;
	}
	
	for (int i = x; i < 10e5;i++) {
		a = 0;
		if (i % 2 == 0) {
			continue;
		}
		for (int j = 3; j < i; j++) {
			if (i % j == 0) {
				a = 1;
				break;
			}
		}if (a != 1) {
			cout << i << endl;
			break;
		}
	}



	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		String ans = "No";
		for(int i=0;i<=N/7;i++) {
			if((N-(i*7)) % 4 == 0) {
				ans = "Yes";
				break;
			}
		}

		out.println(ans);

		sc.close();

	}

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

}


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

int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    rep (i, n) cin >> a[i];
    vector <vector <long long>> dp(n, vector <long long> (21, 0LL));
    rep (i, n - 1) {
        if (i == 0) {
            dp[i + 1][a[i]] = 1LL;
            continue;
        }
        rep (j, 21) if (dp[i][j] != 0LL) {
            if (j + a[i] <= 20) dp[i + 1][j + a[i]] += dp[i][j];
            if (0 <= j - a[i]) dp[i + 1][j - a[i]] += dp[i][j];
        }
    }
    cout << dp[n - 1][a[n - 1]] << endl;
    return 0;
}


Measured memory_bytes: 3164
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define N 200010
#define lowbit(x) x&-x
int n,m,q,ans[N];
struct node
{
	int l,r,id;
}a[N],ask[N];

bool cmp(node a,node b){
	return a.r<b.r; 
}

int c[N];

void add(int x,int y){
	for(int i=x;i<=n;i+=lowbit(i))
		c[i]+=y;
}

int query(int x){
	int ans=0;
	for(int i=x;i;i-=lowbit(i))
		ans+=c[i];
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&q);

	for(int i=1;i<=m;i++)
		scanf("%d%d",&a[i].l,&a[i].r);

	sort(a+1,a+m+1,cmp);
	for(int i=1;i<=q;i++){
		scanf("%d%d",&ask[i].l,&ask[i].r);
		ask[i].id=i;
	}
	sort(ask+1,ask+q+1,cmp);
	int cnt=1; 
	
	for(int i=1;i<=q;i++){
		while(cnt<=m&&a[cnt].r<=ask[i].r)
			add(a[cnt++].l,1);
		ans[ask[i].id]=query(ask[i].r)-query(ask[i].l-1);
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

void self_min(ll &a, ll b) {
	a = min (a,b);
}
template <class T>
void self_max(T &a, T b) {
	a = max(a,b);
}

int main() {
	ios::sync_with_stdio(false);

	ll N, W; cin >> N >> W;

	ll grenze = 0;
	vl w(N), v(N);
	FOR(i,0,N) {
		cin >> w[i] >> v[i];
		grenze += v[i];
	}

	vvl dp(N+1, vl(grenze + 3,oo));

	FOR(i,0,N) {
		dp[i][0] = 0;
	}

	FOR(i,0,N) {
		FOR(j,0,grenze+1) {
			self_min(dp[i+1][j], dp[i][j]);
			if (j + v[i] < grenze+1) {
				self_min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
			}
		}
	}

	ll maxi = 0;
	FOR(j,0,grenze+1) {
		if ( dp[N][j] <= W) {
			self_max(maxi, j);
		}
	}
	cout << maxi << endl;
	return 0;
}


Measured memory_bytes: 80256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long k = sc.nextLong();
    long d = sc.nextLong();
    x = Math.abs(x);
    long a = x/d;
    if(k<=a){
      System.out.println(x-d*k);
      return;
    }
    long b = x%d;
    k -= a;
    if(k%2==0){
      System.out.println(b);
    }else{
      System.out.println(Math.abs(b-d));
    }
  }
}


Measured memory_bytes: 35784
/*
    author: Salam_35
    Created at :

*/

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

/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

bool cmp(const pair<int,int>&a,const pair<int,int>&b)
{
	if(a.first==b.first)
		return a.second<b.second;
	else return a.first<b.first;
}

int main()
{
	int n,s;
	cin >> s >> n;
    set<int>st;
    for (int i = -101; i <102 ; ++i)
    {
    	st.insert(i);
    }
    for (int i = 0; i < n; ++i)
    {
    	int a;
    	cin >>a;
    	if(st.count(a))st.erase(a);
    }
    int mn=100000;
    int ans=10000;
    std::vector<pair<int,int>> v;
    for(int x:st)
    {
    	v.push_back({abs(s-x),x});
    }
   	sort(ALL(v),cmp);
    cout<<v[0].second<<endl;
}
/*
 		remember:
 		ll vs int
 		array size
 		case for 1 2 3 
*/


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[])
{
	int D; cin >> D;
	if (D == 25) cout << "Christmas" << endl;
	else if (D == 24) cout << "Christmas Eve" << endl;
	else if (D == 23) cout << "Christmas Eve Eve" << endl;
	else if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)



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

#define llint long long int
#define MAX 10000000000000L

using namespace std;

int main(){
    int N, M, S;

    cin >> N >> M >> S;

    vector<int> U(M + 1), V(M + 1), A(M + 1);
    vector<llint> B(M + 1), C(N + 1), D(N + 1);

    for(int i = 1; i <= M; i ++){
        cin >> U[i] >> V[i] >> A[i] >> B[i];
    }
    for(int i = 1; i <= N; i ++){
        cin >> C[i] >> D[i];
    }
    vector<vector<int>> next(N + 1, vector<int>()), AA(N + 1, vector<int>());
    vector<vector<llint>> BB(N + 1, vector<llint>());

    for(int i = 1; i <= M; i ++){
        next[U[i]].push_back(V[i]);
        next[V[i]].push_back(U[i]);
        AA[U[i]].push_back(A[i]);
        AA[V[i]].push_back(A[i]);
        BB[U[i]].push_back(B[i]);
        BB[V[i]].push_back(B[i]);
    }
    vector<vector<llint>> min_time(N + 1, vector<llint>(2501, MAX));
    if(S >= 2500){
        min_time[1][2500] = 0;
    }else{
        min_time[1][S] = 0;
    }
    for(int i = 0; i < 4 * N; i ++){
        for(int j = 1; j <= N; j ++){
            for(int k = 0; k < next[j].size(); k ++){
                for(int l = 0; l <= 2500; l ++){
                    if(l - AA[j][k] >= 0 && min_time[next[j][k]][l - AA[j][k]] > min_time[j][l] + BB[j][k]){
                        min_time[next[j][k]][l - AA[j][k]] = min_time[j][l] + BB[j][k];
                    }
                }
            }
        }
        for(int j = 1; j <= N; j ++){
            for(int k = 0; k <= 2500; k ++){
                if(k + C[j] < 2500 && min_time[j][k + C[j]] > min_time[j][k] + D[j]){
                    min_time[j][k + C[j]] = min_time[j][k] + D[j];
                }else if(k + C[j] < 2500 >= min_time[j][2500] > min_time[j][k] + D[j]){
                    min_time[j][2500] = min_time[j][k] + D[j];
                }
            }
        }
    }
    for(int i = 2; i <= N; i ++){
        llint ans = MAX;

        for(int j = 0; j <= 2500; j ++){
            if(min_time[i][j] < ans){
                ans = min_time[i][j];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1000000000 + 7;
#define LL long long
LL N, M, K;
LL ny[200001], jc[200001];
int main(){
    cin>>N>>M>>K;
    ny[0] = ny[1] = 1;
    jc[0] = jc[1] = 1;
    for(int i = 2;i <= 200000; i++){
        ny[i] = (-1 * mod / i * ny[mod % i] % mod + mod) % mod;
        //printf("ny[%d]=%lld i*ny=%d\n", i, ny[i], 1LL * (i * ny[i]) % mod);
    }
    for(int i = 2;i <= 200000; i++){
        ny[i] = 1LL * (1LL * ny[i] * ny[i-1]) % mod;
        jc[i] = jc[i-1] * i % mod;
        //printf("ny[%d] = %lld, jc=%lld ji=%d\n", i, ny[i], jc[i], 1LL * (ny[i] * jc[i]) % mod);
    }
    LL ans = 0;
    LL C = jc[M*N-2] * ny[K-2] % mod * ny[M*N-K] % mod;
    //printf("c=%lld\n", C);
    for(LL i = 1;i <= N; i++){
        for(LL j = 1;j <= M; j++){
      //      cout<<ans<<"\n";
            (ans += ((M - j + 1) * (N - i + 1) * (N - i + M - j) / 2 % mod + (j - 1) * (N - i + 1) * (N - i) / 2 % mod + (N - i) * j * (j - 1) / 2 % mod) % mod * C % mod) %= mod;
            //printf("%lld\n", ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}



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


int main(void) {
  ll N;
  cin >> N;
  ll a[MAX];
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> a[i];
  }
  
  deque<ll> q;
  q.push_front(INF);
  for(i=0; i<N; i++) {
    
    if(a[i]<=q[0]) {
      q.push_front(a[i]);
    }else {
      ll itr=lower_bound(q.begin(), q.end(), a[i])-q.begin()-1;
      q[itr]=a[i];
    }
    
  }
  
  pt(q.size()-1);
  
}


Measured memory_bytes: 1792
def b():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10 ** 9] * (N + 1)
    dp[0] = 0
    for i in range(1, N):
        for j in range(1, K + 1):
            if i >= j:
                dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
    return dp[i]


if __name__ == '__main__':
    ans = b()
    print(ans)

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 && i % 5 == 0)continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private static void print(int[] A){
		String[] V=new String[A.length];
		for(int i=0;i<A.length;i++){
			V[i]=String.valueOf(A[i]);
		}
		System.out.println(String.join(" ",V));
	}
	
	private static void BubbleSort(int[] A){
	 int store=0;
	 for(int i = 0;i<=A.length-1;i++){
	     for(int j = A.length-1;j>=i+1;j--){
	         if(A[j] < A[j-1]){
	             int w=A[j];
	             A[j]=A[j-1];
	             A[j-1]=w;
	             store++;
	         }
	     }
	 }
	 print(A);
	 System.out.println(store);
	}
	
	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            line=br.readLine();
            line=br.readLine();
            String[] str=line.split(" ");
            int[] A=new int[str.length];
            for(int i=0;i<A.length;i++){
            	A[i]=Integer.parseInt(str[i]);
            }
            BubbleSort(A);
        }
	}
}

Measured memory_bytes: 24472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sNow = sS.Substring(0, 1);
            int iBcnt = 0;
            int iWcnt = 0;
            if (sNow == "B") { iBcnt += 1; }
            if (sNow == "W") { iWcnt += 1; }
            for (int i = 1; i < sS.Length; i++)
            {
                string sNxt = sS.Substring(i, 1);
                if (sNow != sNxt)
                {
                    sNow = sNxt;
                    if (sNow == "B") { iBcnt += 1; }
                    if (sNow == "W") { iWcnt += 1; }
                }
            }
            int iOut = iBcnt + iWcnt - 1;

            // 出力
            Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 15456
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
 
 
long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}
 
void main() {
    auto N = readln.chomp.to!int;
    auto X = new long[](N);
    auto Y = new long[](N);
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!long);
        X[i] = s[0];
        Y[i] = s[1];
    }
 
    bool line(int i, int j, int k) {
        if (X[i] == X[j]) return X[i] == X[k];
        if (Y[i] == Y[j]) return Y[i] == Y[k];
        if (X[i] == X[k]) return X[i] == X[j];
        if (Y[i] == Y[k]) return Y[i] == Y[j];
        return (Y[k] - Y[i]) * (X[j] - X[i]) == (Y[j] - Y[i]) * (X[k] - X[i]);
    }
 
    const long MOD = 998244353;
    auto used = new bool[][](N, N);
    long ans = 1 + N;
 
 
    foreach (i; 0..N) {
        foreach (j; i+1..N) {
            if (used[i][j])
                continue;
            
            long cnt = 2;
            int[] v = [i, j];
 
            foreach (k; j+1..N) {
                if (used[i][k] || !line(i, j, k))
                    continue;
                cnt += 1;
                v ~= k;
            }
 
            foreach (a; 0..v.length)
                foreach (b; a+1..v.length)
                    used[v[a]][v[b]] = true;
 
            ans += powmod(2, cnt, MOD) - cnt - 1;
            ans %= MOD;
        }
    }
 
    ans = powmod(2, N, MOD) - ans;
    ans = (ans % MOD + MOD) % MOD;
    ans.writeln;
}


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

int main()
{
    string str;
  	cin >> str;
    while(str[0] != '0')
    {
        int sum = 0;
        for(int i = 0; str[i] != '\0'; i++)
        {
            int n = str.at(i) - '0';
            sum += n;
        }
        cout << sum << endl;
      	cin >> str;
    }
}


Measured memory_bytes: 3156
#include <iostream>

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if( a<0 || b<0 || c<0 || a>100 || b>100 || c>100 ){
		cout << "error." << endl;
		return 0;
	}
	if( a<b && b<c ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3024
#include<stdio.h>

#define MAX 500001

int A[MAX];
int heap_size;


void maxHeapify(int i){
  int l,r,largest,tmp;
  l=2*i;
  r=l+1;
  if(l<=heap_size && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=heap_size && A[r]>A[largest])largest=r;
  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  int i;
  for(i=(int)(heap_size/2);i>=1;i--){
    maxHeapify(i);
  }
}



main(){
  int i;

  scanf("%d",&heap_size);
  for(i=1;i<=heap_size;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  for(i=1;i<=heap_size;i++)printf(" %d",A[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h==0&&w==0) break;
            for(int i=0;i<h;i++){
                if(i%2==0){
                for(int j=0;j<w;j++){
                    if(j%2==0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
            }else{
                for(int j=0;j<w;j++){
                    if(j%2==0){
                        System.out.print(".");
                    }else{
                        System.out.print("#");
                    }
                }

            }
                System.out.println("");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 33748
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3592
n,m=map(int,input().split())
k = [0]*m
s = [0]*m

for i in range(m):
    k[i], *s[i] = map(int,input().split())

p = list(map(int,input().split()))

ans = 0
for i in range(1 << n):
    cnt = [0]*m
    for j in range(n):
        if (i >> j) % 2 == 1:
            for a in range(m):
                if j + 1 in s[a]:
                    cnt[a] += 1
    chk = 0
    for j in range(m):
        if cnt[j] % 2 != p[j]:
            chk = 1
            break
    if chk == 0:
        ans += 1
print(ans)

Measured memory_bytes: 74084
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<pair<ll,ll>>pll(n);
  for(int i=0;i<n;i++){
    ll x,l;
    cin>>x>>l;
    pll[i]=mp(x-l,x+l);
  }
  sort(ALL(pll),greater<pair<ll,ll>>());
  ll now=llINF;
  ll ans=0;
  for(int i=0;i<n;i++){
    if(now>=pll[i].S){
      now=pll[i].F;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;

int main() {
   std::string s;
   cin >> s;
   int size = s.size();
   bool flg = false;

   if (s[0] == 'A') {
      int count = 0;
      int temp;
      for (int i = 2; i < size-1; i++ ){
         if (s[i] == 'C') {
            count++;
            temp = i;
         }
      }
      if (count == 1) {
         int small = 0;
         for (int i = 1; i < size; i++) {
            if (s[i] >= 'a' && s[i] <= 'z') {
               small++;
            }
         }
         if (small == size-2) flg = true;
      }
   }
   
   if (flg) cout << "AC" << endl;
   else cout << "WA" << endl;
   return 0;
}


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

int main(){
  int tawar[1000] = {0};
  int a, b;
  int x;
  cin >> a >> b;
  
  for ( int i = 1; i < 1000; i++ ){
    tawar[i] = tawar[i - 1] + i;
  }
  
  x = tawar[b - a] - b;
  cout << x << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int n,ans;long long t,f[233];char a[1200][2];
int main(){
	scanf("%d",&n);
	if(n&1){
			for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	if(i+j!=n) ans++;printf("%d\n",ans);
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	if(i+j!=n) 
	printf("%d %d\n",i,j); 
	}
	else {
		for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	if(i+j!=n+1) ans++;printf("%d\n",ans);
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	if(i+j!=n+1) printf("%d %d\n",i,j); 
	}

}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    int cnt=0;
    int a=0, b=0, ab=0;
    for(int i=0; i<n; i++){
        cin >> s[i];
        for(int j=0; j<s[i].size(); j++){
            if(s[i][j]=='A' && s[i][j+1]=='B'){
                cnt++;
            }
        }
        if(s[i].back()=='A' && s[i].front()=='B'){
            ab++;
        }else if(s[i].back()=='A'){
            a++;
        }else if(s[i].front()=='B'){
            b++;
        }
    }
    if(!a && !b){
        cnt += max(ab-1,0);
    }else{
        cnt += ab+min(a,b);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int n, xs[10], ys[10],
    dxs[12] = {-1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1},
    dys[12] = {-2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2};

inline bool range_check(int x, int y) {
  return 0 <= x && x <= 9 && 0 <= y && y <= 9;
}

inline bool inside(int x, int y, int k) {
  int kx = xs[k], ky = ys[k];
  return range_check(x, y) && kx-1 <= x && x <= kx+1 && ky-1 <= y && y <= ky+1;
}

bool rec(int x, int y, int k) {
  if (k == n)
    return true;
  for (int i = 0; i < 12; i++)
    if (inside(x+dxs[i], y+dys[i], k) && rec(x+dxs[i], y+dys[i], k+1))
      return true;
  return false;
}

int main() {
  for (;;) {
    int sx, sy;
    cin >> sx >> sy;
    if (!(sx || sy)) return 0;
    cin >> n;
    for (int i = 0; i < n; i++)
      cin >> xs[i] >> ys[i];
    cout << (rec(sx, sy, 0) ? "OK" : "NA")  << endl;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
#include <iomanip>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;

ll D[100000];
ll K[100000];

int main()
{
	ll  N;
	cin >> N;
	memset(K, 0, sizeof(K));

	long double sum = 1;
	for (ll i = 0; i < N; i++)
	{
		cin >> D[i];

		K[D[i]]++;
	}

	ll num = K[0];

	if (D[0] != 0)
	{
		cout << 0 << endl;
		return 0;
	}

	if (K[0] != 1)
	{
		cout << 0 << endl;
		return 0;
	}

	for (ll i = 0; i < N - 1; i++)
	{
		//sum *= (ll)((pow(K[i], K[i + 1])) % 998244353);
		for (ll j = 0; j < K[i + 1]; j++)
		{
			sum *= fmodl(K[i], 998244353);
			sum = fmodl(sum, 998244353);
		}
		//sum *= ( fmodl((pow(K[i], K[i + 1])) , 998244353));
		sum = fmodl(sum, 998244353);

		num += K[i + 1];
		if (num == N)
		{
			break;
		}
		if (sum == 0)
		{
			break;
		}
	}


	cout << (ll)fmodl(sum, 998244353) << endl;


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll h, w, n; cin >> h >> w >> n;
    ll M = max(h,w);
    ll ans = (n + M-1)/M;
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

flag = True
for i in range(n):
  if a[i]%2 == 0:
    if a[i]%3!= 0 and a[i]%5!= 0:
      flag = False
      break
if flag:
  print("APPROVED")
else:
  print("DENIED")

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

#define mp make_pair
#define pb push_back

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
    int odd = 0;
    bool oneDiv = false;
    int moreOneDiv = 0;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int k;
        cin >> k;
        if(k % 2 != 0){
            odd++;
        } else if (((k/2) % 2) != 0){
            oneDiv = true;
        } else {
            moreOneDiv++;
        }
    }
    cout << (odd + oneDiv <= moreOneDiv + 1 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//! (*'ω'*)

use std::io;

fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let a = get_line().parse::<u32>().unwrap();
    let b = get_line().parse::<u32>().unwrap();
    let h = get_line().parse::<u32>().unwrap();

    println!("{}", (a + b) * h / 2);
}


Measured memory_bytes: 380
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> P;
int b[20][20];
int h,w;
P st;
P gl;
//sの配列をtにコピーする
void cpy(int s[][20],int t[][20])
{
	for(int i=0;i<20;i++)
	{
		for(int j=0;j<20;j++)
			t[i][j]=s[i][j];
	}
}

//dfsする
int dfs(P now,int turn,vector<P> broke)
{
	int ret=1e7-1;
	//終了条件
	if(turn==11)
		return 1e7-1;
	int c[20][20];
	//盤面を構築する
	cpy(b,c);
	for(int i=0;i<broke.size();i++)
		c[broke[i].first][broke[i].second]=0;
	//上下左右に移動する
	int dx[4]={1,0,-1,0};
	int dy[4]={0,-1,0,1};
	for(int i=0;i<4;i++)
	{
		vector<P> nbroke=broke;
		int ni=now.first+dx[i];
		int nj=now.second+dy[i];
		if((ni<0 || ni>=h || nj<0 || nj>=w) || c[ni][nj]==1)
			continue;
		//進めるなら進めるところまで進む
		while(c[ni][nj]!=1)
		{
			if(c[ni][nj]==3)
				return turn;
			ni+=dx[i];
			nj+=dy[i];
			if(ni<0 || ni>=h || nj<0 || nj>=w)
				break;
		}
		if(ni<0 || ni>=h || nj<0 || nj>=w)
			continue;
		//となりが障害物ならそれを消す
		P next=P(ni-dx[i],nj-dy[i]);
		if(c[ni][nj]==1)
			nbroke.push_back(P(ni,nj));
		ret=min(dfs(next,turn+1,nbroke),ret);
	}
	return ret;
}
int main()
{
	while(1)
	{
		cin>>w>>h;
		if(h==0)
			break;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				cin>>b[i][j];
				if(b[i][j]==2)
					st=P(i,j);
				if(b[i][j]==3)
					gl=P(i,j);
			}
		}
		//cerr<<st.first<<" "<<st.second<<endl;
		//cerr<<gl.first<<" "<<gl.second<<endl;
		//dfs
		vector<P> tmp;
		int ans=dfs(st,1,tmp);
		if(ans==1e7-1)
			ans=-1;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3036
s = input().strip()
t = input().strip()
LS, LT = len(s), len(t)
dp = [[0]*(LT+1) for _ in range(LS+1)]
dp2 = [[(0, 0)]*(LT+1) for _ in range(LS+1)]
for i in range(LS):
    for j in range(LT):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
            dp2[i+1][j+1] = (i, j)
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
            if dp[i][j+1] > dp[i+1][j]:
                dp2[i+1][j+1] = (i, j+1)
            else:
                dp2[i+1][j+1] = (i+1, j)
bb = []
a, b = (LS, LT)
while a > 0 and b > 0:
    if s[a-1] == t[b-1]:
        bb.append(s[a-1])
    a, b = dp2[a][b]

print("".join(bb[::-1]))



Measured memory_bytes: 376584
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int[] a = sc.nextIntArray(n);

		Arrays.sort(a);
		int prev = 0, count = 0;
		for (int i = 1; i < n; i++) {
			if (a[prev] == a[i]) {
				continue;
			} else {
				if ((i - prev) % 2 == 1) count++;
				prev = i;
			}
		}
		if ((n - prev) % 2 == 1) count++;

		out.println(count);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

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

signed main(){
  int n, h, amax=0, b[100000], ans=0;

  cin >> n >> h;

  int a;
  for(int i=0; i<n; ++i){
    cin >> a >> b[i];
    amax = max(amax, a);
  }

  sort(b, b+n, greater<int>());

  for(int i=0; i<n && h > 0 && b[i] >= amax; ++i){
    h -= b[i];
    ++ans;
  }

  if(h > 0) ans += (h + (amax - 1)) / amax;

  cout << ans << endl;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e18)

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

void Main(){
  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  int n = N - 1;
  for(; n >= 0; n -= 2){
    cout << a[n] << " ";
  }
  if(n == -1) n = 0;
  if(n == -2) n = 1;
  for(; n < N; n += 2){
    cout << a[n] << " ";
  }
  cout << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 2944
N = int(input())
dict_s = {}
for var in range(N):
    s = input()
    if s in dict_s:
        dict_s[s] += 1
    else:
        dict_s[s] = 1
M = int(input())
for var in range(M):
    t = input()
    if t in dict_s:
        dict_s[t] -= 1
dict_s[''] = 0
print (max(dict_s.values()))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,k,sum=0;
  cin>>n>>k;
  long long int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  sort(arr,arr+n);
  for(int i=0;i<k;i++)
    sum+=arr[i];
  cout<<sum;
  return 0;
} 

Measured memory_bytes: 3636