akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let K: usize = read();
    let mut ranges = vec![];
    for _ in 0..K {
        let l: usize = read();
        let r: usize = read();
        ranges.push((l, r));
    }
    println!("{}", solve1(N, ranges));
}

fn solve1(N: usize, ranges: Vec<(usize, usize)>) -> i64 {
    let MOD = 998244353;
    let mut dp = vec![0; N * 2 + 100];
    let mut pluses: Vec<i64> = vec![0; N * 2 + 100];
    dp[0] = 1;
    let mut plus = 0;
    for i in 0..N {
        plus += pluses[i];
        plus %= MOD;
        dp[i] += plus;
        for &(l, r) in &ranges {
            pluses[i + l] += dp[i];
            pluses[i + l] %= MOD;
            pluses[i + r + 1] -= dp[i];
            pluses[i + r + 1] %= MOD;
        }
    }
    if dp[N - 1] < 0 {
        dp[N - 1] + MOD
    } else {
        dp[N - 1]
    }
}

fn solve2(N: usize, ranges: Vec<(usize, usize)>) -> i64 {
    use std::collections::HashSet;
    let mut S: HashSet<usize> = HashSet::new();
    let MOD = 998244353;
    for (l, r) in ranges {
        for i in l..=r {
            S.insert(i);
        }
    }
    let mut dp = vec![0; N * 2 + 100];
    dp[0] = 1;
    for i in 0..N {
        for &plus in &S {
            dp[i + plus] += dp[i];
            dp[i + plus] %= MOD;
        }
    }
    dp[N - 1]
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn all() {
        for i in 2..10000 {
            assert_eq!(solve1(i, vec![(1, i)]), solve1(i, vec![(1, i)]));
        }
    }
}


Measured memory_bytes: 6844
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int f(int a) {
  if (a % 10 == 0)
    return 100;
  else
    return a % 10;
}

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

  vector<int> v(5), d(5);
  rep(i, 0, 5) cin >> v[i];
  rep(i, 0, 5) d[i] = f(v[i]);
  int min_ind = min_element(d.begin(), d.end()) - d.begin();
  int ans = 0;
  rep(i, 0, 5) {
    if (i == min_ind)
      ans += v[i];
    else
      ans += (v[i] + 10 - 1) / 10 * 10;
  }
  cout << ans << endl;
}


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

long long n, k, a[100005], b, ans;
int main() {
	int i;
	cin>>n;
	for(i=0; i<=n; i++) scanf("%d", &a[i]);
	for(i=0; i<n; i++) {
		scanf("%d", &b);
		k = min(a[i], b);
		ans += k;
		b -= k;
		k = min(a[i+1], b);
		ans += k;
		a[i+1] -= k;
	}
	cout<<ans;
	return 0;
}


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

int dfs(int k, const int n, int l, const int m, int A[], const int q, const int a[], const int b[], const int c[], const int d[]) {
  if (k < n) {
    int ans = 0;
    for (int i = l; i <= m; i++) {
      A[k] = i;
      ans = max(ans, dfs(k+1, n, i, m, A, q, a, b, c, d));
    }
    return ans;
  }

  int ans = 0;
  for (int i = 0; i < q; i++) {
    if (A[b[i]-1] - A[a[i]-1] == c[i]) ans += d[i];
  }
  return ans;
}

int main() {
  int n, m, q;
  cin >> n >> m >> q;

  int a[q], b[q], c[q], d[q];
  for (int i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];

  int A[n];

  cout << dfs(0, n, 1, m, A, q, a, b, c, d) << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

bool canPut(vector<bool> map, int x, int y){
	for(int vx = -1; vx <= 1; vx++){
		for(int vy = -1; vy <= 1; vy++){
			for(int ax = x, ay = y; (vx || vy) && ax >= 0 && ax < 8 && ay >= 0 && ay < 8; ax += vx, ay += vy){
				if(map[ax + 8 * ay]) return false;
			}
		}
	}
	return true;
}

vector<bool> eightQueen(vector<bool> map, int num){
	if(num==8) return map;
	
	for(int x = 0; x < 8; x++){
		for(int y = 0; y < 8; y++){
			if(canPut(map, x, y)){
				vector<bool> mapPut = map;
				mapPut[x + 8 * y] = true;
				mapPut = eightQueen(mapPut, num+1);
				if(mapPut.size()) return mapPut;
			}
		}
	}
	
	map.clear();
	return map;
}

int main() {
	int n;
	cin >> n;
	vector<bool> map;
	for(int i = 64; i--;){
		map.push_back(false);
	}
	for(int i = n; i--;){
		int x, y;
		cin >> x >> y;
		map[x + 8 * y] = true;
	}
	
	map = eightQueen(map, n);
	
	for(int i = 0; i < 8; i++){
		for(int j = 0; j < 8; j++){
			cout << (map[i + 8 * j] ? 'Q' : '.');
		}
		cout << endl;
	}
	
}

Measured memory_bytes: 1216
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		long W = Long.parseLong(tokens[0]);
		long H = Long.parseLong(tokens[1]);
		long x = Long.parseLong(tokens[2]);
		long y = Long.parseLong(tokens[3]);
		int status = 0;
		if (x * 2 == W && y * 2 == H) {
			status = 1;
		}
		double result = (double) W * (double) H / 2.0;
		System.out.println(result + " " + status);

		in.close();
	}

}


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

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

    map<string, ll> ma;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        if (ma.count(s) == 0) {
            ma[s] = 1;
        } else {
            ma[s] += 1;
        }
    }

    ll res = 0;
    for(auto it : ma) res += it.second * (it.second - 1) / 2;
    cout << res << endl;
}

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

int main() {
  int x, a;
  cin >> x >> a;
  if(x<a) cout << "0" << endl;
  else cout << "10" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from itertools import product
m = int(input())

for i in range(m):
    train = list(input())
    train_set = set()
    for j in range(0,len(train)):
        A = ''.join(train[:j+1])
        B = ''.join(train[j+1:])
        invA = ''.join(reversed(train[:j+1]))
        invB = ''.join(reversed(train[j+1:]))
        for t in product((A,invA),(B,invB)):
            train_set.add(''.join(t))
        for t in product((B,invB),(A,invA)):
            train_set.add(''.join(t))
    print(len(train_set))

Measured memory_bytes: 6800
N,M = map(int,input().split())
inf = float('inf')
D = [[inf]*N for _ in range(N)]
for i in range(N):
    D[i][i] = 0

edges = []
for _ in range(M):
    a,b,c = list(map(int,input().split()))
    a -= 1
    b -= 1
    D[a][b] = c
    D[b][a] = c
    edges.append([a,b,c])

for k in range(N):
    for i in range(N):
        for j in range(N):
            D[i][j] = min(D[i][j],D[i][k] + D[k][j])
# for i in range(N):
#     print(D[i])
ans = 0
for e in edges:
    used = False
    for s in range(N):
        for t in range(N):
            if D[s][e[0]] + e[2] + D[e[1]][t] == D[s][t]:
                used = True
    if not used:
        ans += 1
print(ans)

Measured memory_bytes: 48604
#include <iostream>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n;
  cin>>s;
  int x;
  char c[s.length()];
  for(int i=0;i<s.length();i++){
    x='Z'-s.at(i);
    if(x>=n){
      s.at(i)+=n;
    }
    else{
      s.at(i)='A'+(n-x-1);
    }
    cout<<s.at(i);
  }
  cout<<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int calc(vector<int> &P){
    int N = P.size();
    vector<int> x(N);
    REP(i, N) x[i] = i+1;
    int cnt = 0;
    do{
        cnt++;
        if(P == x) break;
    } while(next_permutation(x.begin(), x.end()));
    return cnt;
}

int main(){
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    REP(i, N) cin >> P[i];
    REP(i, N) cin >> Q[i];
    int a = calc(P);
    int b = calc(Q);
    cout << abs(a-b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mass(char ch)
{
    if(ch=='A')return 10;
    if(ch=='B')return 11;
    if(ch=='C')return 12;
    if(ch=='D')return 13;
    if(ch=='E')return 14;
    if(ch=='F')return 15;
}
int main()
{
    char a,b;
    cin>>a>>b;
    if(mass(a)>mass(b))puts(">");
    else if(mass(a)==mass(b))puts("=");
    else if(mass(a)<mass(b))puts("<");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=998244353;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int A,B,n;

int main(){
	cin>>A>>B>>n;
	for(int i=0;i<n;i++){
		if(i%2==0){
			B+=A/2;
			A=A/2;
		}
		else{
			A+=B/2;
			B=B/2;
		}
	}
	cout<<A<<' '<<B<<endl;
}

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

using namespace std;

int n,m,k,a,b,c;
vector<int> G[100010];
vector<pair<int,int> > e;
int comp[100010];
int cnt[100010];
int bel[100010];
long long ans[100010];

void dfs(int u) {
    if(comp[u] != -1) return;
    comp[u] = c;
    cnt[c]++;
    for (int v: G[u])
        dfs(v);
}

int main() {
    memset(comp, -1, sizeof comp);

    scanf("%d %d %d", &n, &m, &k);

    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &a, &b);
        G[a].push_back(b);
        G[b].push_back(a);
        e.emplace_back(a,b);
    }

    for (int i = 0; i < k ; ++i) {
        scanf("%d %d", &a, &b);
        e.emplace_back(a,b);
    }
    c = 0;

    for (int i = 1; i <= n; ++i) {
        if(comp[i] == -1) {
            c++;
            dfs(i);
        }
    }
    
    for (auto p: e) {
        if(comp[p.first] == comp[p.second]) 
            bel[p.first]++, bel[p.second]++;
    }

    for (int i = 1; i <= n; ++i) {
        int cur = cnt[comp[i]] - 1 - bel[i];
        //cout << i << ": " << cnt[comp[i]] - 1 << " " << bel[i] << " test\n";
        printf("%d ", cur);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 9072
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pii pair<int,int>
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n,m; cin>>n>>m;
  if(n==m) co("a == b");
  else if(n<m) co("a < b");
  else co("a > b");
  return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define int long long
using namespace std;
long long dp[61][125010];
int num[61][125010];
struct Val{
	int val;
	long long c;
	int lim,tlim;
}v[61];
bool cmp(Val a,Val b)
{
	return a.val*b.c>b.val*a.c;
}
int p[61];
int n,X,D;
void work()
{
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	num[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n*n*n;j++)
			dp[i][j]=dp[i-1][j],num[i][j]=0;
		int t=v[i].lim;
		while(t)
		{
			int k=t/2+(t&1);
			for(int j=n*n*n;j>=k*v[i].val;j--)
				if(dp[i][j-k*v[i].val]+(long long)k*v[i].c<dp[i][j])
				{
					num[i][j]=num[i][j-k*v[i].val]+k;
					dp[i][j]=dp[i][j-k*v[i].val]+(long long)k*v[i].c;
				}
			t-=k;
		}
	}
	return ;
}
int rest[61];
long long solve(int S)
{
	long long ans=S;
	S=X-dp[n][S];
	if(S<0)return 0;
	for(int i=n;i>=1;i--)
		rest[i]=v[i].tlim-v[i].lim;
	for(int i=1;i<=n;i++)
	{
		int num=min(S/v[i].c,(long long)rest[i]);
		ans+=(long long)num*v[i].val;
		S-=num*v[i].c;
	}
	return ans;
}
signed main()
{
	scanf("%lld",&n);
	scanf("%lld",&X);
	scanf("%lld",&D);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&v[i].c);
		v[i].val=1;
		if(i==1){
			v[i].lim=min(X,n);
			v[i].tlim=X;
		}
		else{
			scanf("%lld",&p[i]);
			v[i].lim=min(D,n);
			v[i].tlim=D;
		}
	}
	for(int i=n;i>=2;i--)
	{
		v[p[i]].c+=v[i].c;
		v[p[i]].val+=v[i].val;
	}
	sort(v+1,v+n+1,cmp);
	work();
	long long ans=0;
	for(int i=0;i<=n*n*n;i++)
		ans=max(ans,solve(i));
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;

const int N = 1e5 + 5;
const int black = 0, white = 1;
const int mod = 1e9 + 7;

int n;
vector<int> tree[N];
ll dp[N][2];

ll dfs(int parent, int v, int color) {
	ll &ret = dp[v][color];
	if (ret != -1) {
		return ret;
	}
	ret = 1;
	for (int i = 0; i < (int)tree[v].size(); i++) {
		int child = tree[v][i];
		if (child == parent) {
			continue;
		}
		ll cnt = 1;
		if (color == black) {
			cnt = dfs(v, child, white);
		} else {
			cnt = (dfs(v, child, white) + dfs(v, child, black)) % mod;
		}
		ret = (ret * cnt) % mod;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for (int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		tree[u].push_back(v);
		tree[v].push_back(u);
	}
	memset(dp, -1, sizeof(dp));
	cout << (dfs(0, 1, black) + dfs(0, 1, white)) % mod << '\n';
}

Measured memory_bytes: 17024
import Control.Monad
import Control.Applicative

check :: Int -> [Int] -> Bool
check x ys = x >= sum ys


cook :: [Int] -> [[Int]] -> Bool
cook [] _ = True
cook _ [] = True
cook xs ys = check (head xs) (map head ys) && cook (tail xs) (map tail ys)

main :: IO()
main = do
  (n:k:_) <- map (read :: String -> Int) . words <$> getLine
  unless (n == 0 && k == 0) $ do
    ref <- map (read :: String -> Int) . words <$> getLine
    fam <- map (map (read :: String -> Int) . words) <$> replicateM n getLine
    if cook ref fam
      then putStrLn "Yes"
      else putStrLn "No"
    main

Measured memory_bytes: 7716
import os
import heapq
import sys,threading
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

sys.setrecursionlimit(10 ** 5)
threading.stack_size(2**27)


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""


def inpt():
    return [int(k) for k in input().split()]


def main():
    s=input()
    t=input()
    ans=100000000000000
    for i in range(len(s)-len(t)+1):
        ct=0
        for j in range(len(t)):
            if(s[i+j]!=t[j]):
                ct+=1
        ans=min(ans,ct)
    if(ans==100000000000000):
        ans=0
    print(ans)






BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threading.Thread(target=main).start()


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

int main(){
  int A, B;
  cin >> A >> B;
  int K;
  if((max(A,B) - min(A,B)) % 2 == 0){
    K = (A + B) / 2;
    cout << K << endl;
  }else{
    cout << "IMPOSSIBLE";
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	ll N;
	cin >> N;
	vector<ll>V;
	for (ll i = 0; i < N; ++i) {
		ll a;
		cin >> a;
		V.push_back(a);
	}
	ll one = 0;
	ll second = 0;
	int k = 0;
	sort(V.begin(), V.end(), greater<ll>());
	for (ll i = 0; i < N - 1; ++i) {
		if (V[i] == V[i + 1]) {
			one = V[i];
			k = i + 2;
			break;
		}
	}
	if (one != 0) {
		for (ll i = k; i < N - 1; ++i) {
			if (V[i] == V[i + 1]) {
				second = V[i];
				break;
			}
		}
	}
	cout << one * second << endl;
	return 0;
}


Measured memory_bytes: 1400
n,m = map(int,input().split())
l = list(map(int,input().split()))

for i in range(n,100000):
    k = i
    c=0
    while k>0:
        if k%10 not in l:
            c+=1
        else:
            break
        k = k//10
    if len(str(i))==c:
        print(i)
        break

Measured memory_bytes: 40176
N = int(input())
a = list(map(int,input().split()))
count = 0
while True:
    flag = 0
    for i in range(N):
        if a[i] % 2 is 0:
            a[i] = a[i] // 2
        else:
            flag = 1
    if flag:
        break;
    else:
        count += 1
print(count)


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    
    int h,w,m;
    cin>>h>>w>>m;
    pvec memo(m);
    pvec u(h);
    pvec v(w);
    map<P,int> mp;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        u[a].first++;
        v[b].first++;
        memo[i]=P(a,b);
        mp[P(a,b)]++;
    }
    rep(i,h) u[i].sc=i;
    rep(j,w) v[j].sc=j;

    int ans=0;


    sort(rall(u));
    sort(rall(v));

    rep(i,h){
        chmax(ans,u[i].fs+v[0].fs-mp[P(u[i].sc,v[0].sc)]);
    }
    rep(i,w){
        chmax(ans,u[0].fs+v[i].fs-mp[P(u[0].sc,v[i].sc)]);
    }

    cout<<ans<<endl;
    
    
}

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

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

/*

g++ -std=c++1z code.cpp
./a.out

*/

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


int main(){
    int tmp;

    rep(i, 5){
		cin >> tmp;
		if(tmp == 0){
			cout << (i+1);
		}
	}


	return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;
    cout << t + s << "\n";

    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>

int Check(int);

int main(){

  int i, j, count, num, data;

  count = 0;
 
  scanf("%d", &num);

  for(i = 0; i < num; i++){
    
    scanf("%d",&data);

    j = Check(data);

    if(j == 1) count++;

  }

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

}

int Check(int data){

  int i;

  if(data == 2){
    
    return 1;
    
  }

  else if(data % 2 == 0) return 0;

  for(i = 3; i < sqrt(data) + 1; i += 2){

    if(data % i == 0) return 0;

  }
    
  return 1;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define NREP(i, n) for(int i = 1; i <= (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int nums(int n){
	return to_string(n).length();
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cout << fixed << setprecision(7);
////////////////////////////////////////////
	int n;
	cin >> n;
	int a[n];
	bool bb=true;
	REP(i,n){
		cin >> a[i];
	}
	SORT(a,n);
	REP(i,n-1){
		if(a[i]==a[i+1]) bb=false;
	}

	cout << (bb ? "YES" : "NO") << endl;
///////////////////////////////////////////
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int A,B,C;
  
  scanf("%d %d",&A,&B);
  
  if(A<=9 && B<=9){
    C=A*B;
    printf("%d",C);
  }else{
    printf("-1");
  }
  
  return 0;
  
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);

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

  for (int g = 1; g <= n; g++) {
    if (n <= k + (k-1) * (g-1)) {
      cout << g << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3148
labels = input().split()
copy = [0, 0, 0, 0, 0, 0]
order = input()
rolls = {'W':[2, 1, 5, 0, 4, 3], 
         'N':[1, 5, 2, 3, 0, 4], 
         'E':[3, 1, 0, 5, 4, 2], 
         'S':[4, 0, 2, 3, 5, 1]
        }
for d in order:
    roll = rolls[d]
    labels = [labels[i] for i in roll]
print(labels[0])


Measured memory_bytes: 5568
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1000000000000 ;
const ll mod=1000003 ;
 
int main(){
  int n;
  cin >> n;
  ll a[n],b[n],c[n];
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  rep(i,n)cin >> c[i];
  ll ans=0;
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  rep(i,n){
    ll x=lower_bound(a,a+n,b[i])-a;
    ll y=upper_bound(c,c+n,b[i])-c;
    ans+=x*(n-y);
  }
  cout << ans << endl;
return 0;}

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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    int n,w;
    cin >> n >> w;
    vi weight(n);
    vi value(n);

    repz(i,n)
        cin >> weight[i] >> value[i];

    vll dp(w+1);

    for (int i = 1; i <= n; i++)
    {
        for (int j=w; j>=0;j--)
        {
            if (j-weight[i-1]>=0)
                dp[j] = max(dp[j], dp[j-weight[i-1]] + value[i-1]);
        }
    }

    cout << dp[w] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


Measured memory_bytes: 1024
use io::*;

fn main()
{
    let con =read_string();
    let mut sc =Scanner::new(&con);

    let N:i32 = sc.next();
    let K:i32 =sc.next();

    let n:i32 = N%K;
    if n==0
    {
        println!("0");
    }
    else
    {
        println!("1");
    }
}

pub mod io {
    use std;
    use std::str::FromStr;
 
    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }
 
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
 
        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }
 
        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }
 
        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }
 
    pub fn read_string() -> String {
        use std::io::Read;
 
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
 
    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    int a , b, c;
    double s, l, h, d;
    cin >> a >> b >> c;
    d = (acos(-1.0) * c) / 180.0;
    s = a * b * sin(d) / 2;
    l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(d));
    h = b * sin(d);
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);
    return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;

#define NIL -1

typedef struct {
  int parent, left, right;
} Node;


Node T[100];
int D[100];


void depth(int key, int d) {
  if (key == NIL) return;
  D[key] = d;
  depth(T[key].left, d + 1);
  depth(T[key].right, d + 1);
}

int getHeight(int key) {
  if (key == NIL) return -1;
  return max(getHeight(T[key].left), getHeight(T[key].right)) + 1;
}

int main() {
  int n;
  cin >> n;
  // Node T[n + 10];

  REP(i, n + 10) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  REP(i, n) {
    int key, left, right;
    cin >> key >> left >> right;

    T[key].left = left;
    T[key].right= right;
    if (left != NIL) T[left].parent = key;
    if (right != NIL) T[right].parent = key;
  }

  // calc depth
  REP(i, n) {
    if (T[i].parent == NIL) {
      depth(i, 0);
      break;
    }
  }


  REP(i, n) {
    string role;
    if (T[i].parent == NIL) {
      role = "root";
    } else if (T[i].left == NIL && T[i].right == NIL) {
      role = "leaf";
    } else {
      role = "internal node";
    }

    cout << "node " << i << ": parent = " << T[i].parent << ", sibling = ";

    int sibling = -1;
    if (T[i].parent != NIL) {
      if (T[T[i].parent].left != i) {
        sibling = T[T[i].parent].left;
      } else {
        sibling = T[T[i].parent].right;
      }
    }
    cout << sibling << ", degree = ";

    int degree = 0;
    if (T[i].left != NIL) degree++;
    if (T[i].right != NIL) degree++;
    cout << degree << ", depth = " << D[i] << ", height = " << getHeight(i);

    cout << ", " << role << endl;
  }

  return 0;
}

Measured memory_bytes: 3204
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    mut a: [i64; n]
    }
    let p = 1_000_000_007;
    // let n = 200000;
    // let k = 200000;
    // let mut a = (0..n).map(|_| (rand::random::<i64>() % p)).collect::<Vec<_>>();
    a.sort();
    let n_a = a.iter().filter(|&&x| x < 0).copied().collect::<Vec<_>>();
    let p_a = a.iter().filter(|&&x| x >= 0).rev().copied().collect::<Vec<_>>();
    if k % 2 == 1 && p_a.is_empty() {
        let ans = (p + n_a[n_a.len() - k..].iter().fold(1, |acc, x| acc * x % p)) % p;
        println!("{}", ans);
        return;
    }
    let mut s = vec![];
    let (mut ni, mut pi) = (0, 0);
    while s.len() < k {
        let nv = if ni < n_a.len() {
            n_a[ni] * n_a.get(ni + 1).unwrap_or( &1)
        } else {
            std::i64::MIN
        };
        let pv = if pi < p_a.len() {
            if s.len() < k - 1 {
                p_a[pi] * p_a.get(pi + 1).unwrap_or(&1)
            } else {
                std::i64::MAX
            }
        } else {
            std::i64::MIN
        };
        if nv <= pv {
            s.push(p_a[pi]);
            pi += 1;
        } else {
            s.push(n_a[ni]);
            if ni + 1 < n_a.len() {
                s.push(n_a[ni + 1]);
            }
            ni += 2;
        }
    }
    let ans = (p + s.iter().fold(1, |acc, x| acc * x % p)) % p;
    println!("{}", ans);
}



Measured memory_bytes: 9744
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ans := 1
	for i := 0; i < n; i++ {
		if ans <= k {
			ans *= 2
		} else {
			ans += k
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())

counts = defaultdict(int)

for i in range(1, N + 1):
    p = int(str(i)[0])
    s = int(str(i)[-1])
    counts[p, s] += 1
ans = 0
for (p, s), cnt in list(counts.items()):
    ans += counts[s, p] * cnt


print(ans)


Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	Count := ReadLineInt()[0]
	Inputs := map[string]int{}
	Result := 0

	for i := 0; i < Count; i++ {
		Input := ReadLine()
		if _, exists := Inputs[Input]; !exists {
			Inputs[Input] = 1
			Result++
		}
	}

	fmt.Println(Result)
}

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

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}

Measured memory_bytes: 19392
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10

# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

mod = 998244353

N, K = inpl()
left, right = [0] * K, [0] * K
for i in range(K):
    left[i], right[i] = inpl();

dp = [0] * (N + 1) 
dp[1] = 1
wa = [0] * (N + 1)
wa[1] = 1

for i in range(2, N + 1):
    for k in range(K):
        dp[i] += wa[max(0, i - left[k])] - wa[max(0, i - right[k] - 1)]
        dp[i] %= mod
    wa[i] = (wa[i-1] +  dp[i]) % mod
print(dp[N])



Measured memory_bytes: 77040
import numpy as np
from sys import stdin
ans=0
c=0
N = int(input().rstrip())
for i in range(N):
  c=0
  i+=1
  if i%2==1:
    for j in range(i):
      j+=1
      if i%j==0:
        c+=1
  if c==8:
    ans+=1

print(ans)

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

using namespace std;

signed main() {
	int n, k; cin >> n >> k;
	if (n < 2 * k - 1) { // 構築不可
		cout << -1 << endl;
	}
	else { // 構築可能
		vector<int> a(n), b(n), c(n);
		for (int i = 0; i < n; ++i)
			c[i] = k + 2 * n + i;
		for (int i = 0; i < (n + 1) / 2; ++i)
			b[i] = k + 2 * i;
		for (int i = (n + 1) / 2; i < n; ++i)
			b[i] = k + 2 * (i - (n + 1) / 2) + 1;
		for (int i = 0; i < (n + 1) / 2; ++i)
			a[i] = k + n + (n - 1) / 2 - i;
		for (int i = (n + 1) / 2; i < n; ++i)
			a[i] = k + 2 * n - 1 - (i - (n + 1) / 2);
		for (int i = 0; i < n; ++i)
			cout << a[i] << " " << b[i] << " " << c[i] << endl;
	}
	return 0;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    int rmin = 1e9,rmax = 0,bmin = 1e9,bmax = 0,cnt = 1;
    priority_queue<P,vector<P>,greater<P>> que;
    for (int i = 0;i < n;++i) {
        int x,y;
        cin >> x >> y;
        if (x > y) swap(x,y);
        rmin = min(rmin,y);
        bmin = min(bmin,x);
        bmax = max(bmax,x);
        if (rmax == y) cnt++;
        else if (rmax < y) cnt = 1;
        rmax = max(rmax,y);
        que.push(P(x,y));
    }
    ll ans = (ll)(rmax-rmin)*(bmax-bmin);
    while (1) {
        P t = que.top();
        que.pop();
        if (t.first >= t.second) break;
        if (t.second == rmax) cnt--;
        if (cnt == 0) break;
        swap(t.first,t.second);
        que.push(t);
        bmax = max(bmax,t.first);
        rmin = min(rmin,t.second);
        bmin = que.top().first;
        ans = min(ans,(ll)(rmax-rmin)*(bmax-bmin));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
while line = gets
  count = 0;
  n, x = line.split.map(&:to_i)
  if n == 0 then break end
  for i in 1..n do
    for j in (i + 1)..n do
      for k in (j + 1)..n do
        if (i + j + k) == x then count += 1 end
      end
    end
  end
  puts count
end

Measured memory_bytes: 8816
n = int(input())
x = list(map(int,input().split()))

minDis = 0
flag = True

for p in range(1,101):

    dis = 0
    for i in range(n):
        dis += (x[i]-p)**2

    if flag:
        minDis = dis
        flag = False
        continue

    if dis < minDis:
        minDis = dis

print(minDis)

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

int main() {
  int N, M;
  cin >> N >> M;
  int total = 0;
  vector<int> A(N);
  for (int i= 0; i< N; i++){
    cin >> A.at(i);
    total += A.at(i);
  }
  
  double ts = double(total) / (4 * double(M));
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if(A.at(M - 1) >= ts){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl; 
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W, N;
	cin >> H >> W >> N;

	int ans = 0;
	while (N > 0) {
		N -= max(H, W);
		ans++;
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

int n;
int S[1<<18];
int Q[19];


int main(){
  scanf("%d",&n);
  for(int i=0;i<(1<<n);i++) scanf("%d",S+i);
  std::sort(S, S+(1<<n), std::greater<int>());
  int k = 0;
  for(int i=0;i<(1<<n);){
    int j = i;
    for(i++; S[i] == S[j]; i++) ;
    S[k++] = i-j;
  }
  Q[n] = 1;
  for(int i=0;i<k;i++){
//for(int t=0;t<=n;t++) printf("%d ", Q[t]);
//puts("");
    int l;
    int a=0;
    for(l=n;l>=0 && a < S[i];l--) a += Q[l];
    if(a<S[i]){
      puts("No");
      return 0;
    }
    l++;
    for(int t=0;t<l;t++) Q[t] += S[i];
    int b = a-Q[l];
    Q[l] = a-S[i]+b;
    for(int t=l+1;t<=n;t++){
      b -= Q[t];
      Q[t] = b;
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1152
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] == L[j] or L[j] == L[k]:
                continue
            if L[i] + L[j] > L[k]:
                ans += 1

print(ans)



Measured memory_bytes: 73192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static void Yes() { print("YES"); }
        private static void No() { print("NO"); }
        private static void print(object obj) { Console.WriteLine(obj); }

        static void Main(string[] args)
        {
            var a = Read();
            if (a == "A")
            {
                print("T");
            }
            if (a == "T")
            {
                print("A");
            }
            if (a == "C")
            {
                print("G");
            }
            if (a == "G")
            {
                print("C");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main()
{
	long N,K;

	cin >> N >> K;

	vector<long> longlist(N);
	long num = 0;

	for (long i = 0; i < N; i++)
	{
		cin >> num;
		
		longlist[i] = abs(num-K);
	}

	long n, a, b;
	n = longlist.size();
	a = longlist[0];

	for (long i = 1; i < n; i++) {
		b= longlist[i];
		a = gcd(a, b);
	}

	cout << a << endl;

	return 0;


}



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

string a, b = "CF";
int al, bl;

int main() {
    getline(cin, a);
    al = a.length();
    for (int i = 0; i < al; i++) {
        if (a[i] == b[bl]) { 
            bl++;
            if (bl == 2) {
                break;
            }
        }
    }
    if (bl == 2) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
#   ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???????????¨??????????¨?????????\????????°????????¨???????????????????????°??????
r, c = map(int, input().split())
spreadSheet = [[0 for i in range(c + 1)] for j in range(r + 1)]
#   ??¨??\????????????
for i in range(0, r):
    spreadSheet[i][:c] = map(int, input().split())
    #   print(spreadSheet)
#   ?????????????¨??????????
for i in range(0, r):
    for j in range(0, c):
        spreadSheet[i][c] += spreadSheet[i][j]
#   ?????????????¨??????????
for i in range(0, c + 1):
    for j in range(0, r):
        spreadSheet[r][i] += spreadSheet[j][i]
#   print(spreadSheet)
for i in range(0, r + 1):
    for j in range(0, c + 1):
        print("{0}".format(spreadSheet[i][j]), end="")
        if j != c:
            print(" ",end="")
        else:
            print("")

Measured memory_bytes: 8788
fun main(args:Array<String>) {
    val (N,M) = readLine()!!.split(" ").map(String::toInt)
    val a_integers = readLine()!!.split(" ").map(String::toLong)
 
    val b_c = (1..M).map {
        val (b,c) = readLine()!!.split(" ").map(String::toLong)
        Pair(b.toInt(),c)
    }.sortedByDescending {it.second} 

    val result_list = mutableListOf<Long>()

    outer@ for ((b,c) in b_c) {
        for (i in (1..b)) {
            result_list.add(c)
            if(result_list.size >= N) {
                break@outer
            }
        }
    }
    result_list.addAll(a_integers)
    result_list.sortedDescending().take(N).fold(0L) {sum,ele-> sum+ele}.run(::println)
}

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

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

  vector<vector<int>> dp(n,vector<int>(3));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  for (int i = 1; i < n; i++)
  {
    dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
  }
  cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
}

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

const int MX = 100005;
int n, m;
vector<vector<int> > adj(MX);
vector<int> dp(MX, 0);
int seen[MX];

void dfs(int v) {
    seen[v] = 1;
    for (auto p : adj[v]) {
        if (!seen[p]) dfs(p);
        dp[v] = max(dp[v], dp[p] + 1);
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
    }
    for (int i = 0; i < n; i++) {
        if (!seen[i]) dfs(i);
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (dp[i] > res) res = dp[i];
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(void){
    int i,n;
    double ans;
    cin >> n;
    ans=100.000;
    for(i=0;i<n;i++){
        ans*=1.05;
        ans=(int)(ans+0.999);
        ans=(double)ans;
    }
    ans*=1000;
    printf("%d\n",(int)ans);
    return 0;
}

Measured memory_bytes: 3040