akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

//　セグメント木
const inf = 1100100100

type segtree struct {
	n int
	v []int
	a []int // 加算値
}

func (s *segtree) op(a, b int) int {
	if b != 0 {
		return b
	}
	return a
}

func (s *segtree) init(n int) {
	N := 1
	for n > N {
		N *= 2
	}
	s.v = make([]int, N*2)
	s.a = make([]int, N*2)
	s.n = N
}

func (s *segtree) update() {
	K := s.n
	for K > 0 {
		K /= 2
		for i := K; i < 2*K; i++ {
			s.v[i] = s.compare(s.v[i*2], s.v[i*2+1])
		}
	}
}

func (s *segtree) lazyCalc(k int) {
	s.v[k] = s.op(s.v[k], s.a[k])
	if k < s.n {
		s.a[2*k] = s.op(s.a[2*k], s.a[k])
		s.a[2*k+1] = s.op(s.a[2*k+1], s.a[k])
	}
	s.a[k] = 0
}

func (s *segtree) compare(p, q int) int {
	if p > q {
		return q
	}
	return p
}

func (s *segtree) setSub(a, b, k, l, r, x int) {
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		s.a[k] = s.op(s.a[k], x)
		s.lazyCalc(k)
	} else {
		s.lazyCalc(k)
		s.setSub(a, b, k*2, l, (l+r)/2, x)
		s.setSub(a, b, k*2+1, (l+r)/2, r, x)
		s.v[k] = s.compare(s.v[2*k], s.v[2*k+1])
	}
}

// set v[k] = val
func (s *segtree) set(a, b, x int) {
	s.setSub(a, b, 1, 0, s.n, x)
}

// querySub
func (s *segtree) querySub(a, b, k, l, r int) int {
	s.lazyCalc(k)
	if b <= l || r <= a {
		return inf
	}
	if a <= l && r <= b {
		return s.op(s.v[k], s.a[k])
	}
	return s.compare(
		s.querySub(a, b, k*2, l, (l+r)/2),
		s.querySub(a, b, k*2+1, (l+r)/2, r))
}

// query([a,b) )
func (s *segtree) query(a, b int) int {
	return s.querySub(a, b, 1, 0, s.n)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, Q := getInt(), getInt()
	var w, h segtree
	w.init(N + 1)
	h.init(N + 1)
	w.set(0, N+1, N-1)
	h.set(0, N+1, N-1)

	// h.set(0, 2, 3)
	// for j := 0; j <= N; j++ {
	// 	h.query(j, j+1)
	// }
	// out(h)
	// out("----")

	W := N
	H := N
	tot := (N - 2) * (N - 2)
	for i := 0; i < Q; i++ {
		op, x := getInt(), getInt()
		if op == 1 {
			tot -= w.query(x, x+1) - 1
			if x < W {
				W = x
				// v := h.query(0, 1)
				// h.set(0, H+1, -v+x-2)
				h.set(0, H+1, x-1)
			}
		} else {
			tot -= h.query(x, x+1) - 1
			if x < H {
				H = x
				// v := w.query(0, 1)
				// w.set(0, W+1, -v+x-2)
				w.set(0, W+1, x-1)
			}
		}
	}
	out(tot)
}


Measured memory_bytes: 16400
import math
a, b, x = [int(i) for i in input().split()]
m = a * a * b
if x >= m/2:
    c = (m - x) * 2 / (a ** 2)
    print(math.atan2(c, a)/math.pi*180)
else:
    c = x * 2 / (a * b)
    print(math.atan2(b, c)/math.pi*180)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}

//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}

int32_t main(void){
	IOS;
	
	inn(n, k);
	mi m;
	rep(i, 0, k)
	{
		in(d);
		rep(j, 0, d)
		{
			in(tmp);
			m[tmp] += 1;
		}
	}
	int ans = 0;
	rep(i, 1, n+1)
	{
		if(m[i] == 0) ans += 1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, a, b;
    cin >> n >> a >> b;
    if (a > b) {
        cout << 0 << "\n";
        return 0;
    }
    if (a == b) {
        cout << 1 << "\n";
        return 0;
    }
    if (n == 1 && a != b) {
        cout << 0 << "\n";
        return 0;
    }
    cout << (n - 2) * (b - a) + 1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
    int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int K;
    cin >> K;
    cout << a[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
from pprint import pprint
h, w , k = map(int, input().split())
maze = []
res = 0
for _ in range(h):
    l = list(input())
    maze.append(l)
for hpat in range(2**h):
    for wpat in range(2**w):
        dat = deepcopy(maze)
        for hh in range(h):
            if (hpat >> hh) & 1 == 1:
                dat[hh] = ["-"] * w
        for ww in range(w):
            if (wpat >> ww) & 1 == 1:
                for i in range(h):
                    dat[i][ww] = "-"
        #pprint(dat)
        cnt = 0
        for i in range(h):
            cnt += dat[i].count("#")
        if cnt == k:
            res += 1
print(res)




Measured memory_bytes: 73732
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST=1;cin>>TEST;while(TEST--)
#define all(x) x.begin(),x.end()
#define vsort(x) sort(all(x))
#define vrev(x) reverse(all(x));
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define opsp(x) cout<<x<<' '
#define opy cout<<"YES\n"
#define opn cout<<"NO\n"
#define flush fflush(stdout)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define reprev(i,a,b) for(int i=a;i>=b;i--)

int a;
void solve(){
	cin>>a;
	cout<<a+a*a+a*a*a;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    //test{solve();}
	solve();
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

template<typename T>
class tRMQ {
  vector<T> data;
  T unit;

public:
  static const long long INF = 100000000000;
  int n;
  function<T(const T &, const T &)> f;

  tRMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }

  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }

  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

tRMQ<ll> minrmq(int n) {
  return tRMQ<ll>(n, 10000000000000000LL, [](ll r, ll l) { return min(l, r); });
}

tRMQ<ll> maxrmq(int n) {
  return tRMQ<ll>(n, -10000000000000000LL,
                  [](ll r, ll l) { return max(l, r); });
}

tRMQ<ll> sumrmq(int n) {
  return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; });
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> v(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  tRMQ<ll> r = maxrmq(n + 1);
  r.update(0, 0);

  for (int i = 0; i < n; i++) {
    r.update(v[i], r.query(0, v[i]) + v[i]);
  }
  cout << sum - r.query(0, n + 1) << endl;
  return 0;
}



Measured memory_bytes: 7868
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, d[51] = {}, ans = 0;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> d[i];
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++)ans += d[i] * d[j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int pay,back,result,eat;
  	char str[16];
	
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d",&eat);
	
	pay = eat * 800;
	back = (eat / 15) * 200;
	result = pay - back;
	
	printf("%d",result);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>


struct Coordinate {
	int x, y;
	Coordinate operator+(const Coordinate& that) const {
		return Coordinate{ x + that.x, y + that.y };
	}
	bool operator==(const Coordinate& that) const {
		return x == that.x && y == that.y;
	}
};
constexpr std::array<Coordinate, 9> neighbors{ Coordinate{-1, -1}, Coordinate{-1, 0}, Coordinate{-1, 1},
Coordinate{0, -1}, Coordinate{0, 0}, Coordinate{0, 1},
Coordinate{1, -1}, Coordinate{1, 0}, Coordinate{1, 1}
};
template<typename T>
inline void hash_combine(unsigned int& seed, const T& value) {
	seed ^= std::hash<T>()(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
template<>
struct std::hash<Coordinate> {
	unsigned int operator()(const Coordinate& value) const {
		unsigned int seed = 0;
		hash_combine(seed, value.x);
		hash_combine(seed, value.y);
		return seed;
	}
};
int main() {
	int height, width, n; std::cin >> height >> width >> n;
	std::unordered_map<Coordinate, int> count;
	for (auto i = 0; i < n; ++i) {
		int a, b; std::cin >> a >> b;
		for (const auto& neighbor: neighbors) {
			const auto next = neighbor + Coordinate{ a, b };
			if (2 <= next.x && next.x <= height - 1 && 2 <= next.y && next.y <= width - 1)
				count[next]++;
		}
	}
	std::vector<long long int> result(10, 0);
	result[0] = (long long int)(height - 2) * (width - 2);
	for (const auto& p : count) {
		result[p.second]++;
		result[0]--;
	}
	for (const auto i : result) {
		std::cout << i << '\n';
	}
}

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

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		 int C[100][100];
		 int T[100][100];
	   for(int i=0; i<m; i++){
		   for(int j=0; j<m; j++){
			   if(i==j){
	         C[i][j] = T[i][j] = 0;
		     }else{
			     C[i][j] = T[i][j] = INF;
		     }
		   }
     }

	   for(int i=0; i<n; i++){
		   int a, b, c, t;
		   cin >> a >> b >> c >> t;

	     C[a-1][b-1] = C[b-1][a-1] = c;
		   T[a-1][b-1] = T[b-1][a-1] = t;
    }

    int k;
    int d[m][m];
    int e[m][m];
    cin>>k;
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
        e[i][j]=C[i][j];
        d[i][j]=T[i][j];
      }
    }
    for(int k=0;k<m;k++){
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(e[i][j]>e[i][k]+e[k][j]){
            e[i][j]=e[i][k]+e[k][j];
            e[j][i]=e[j][k]+e[k][i];
          }
          if(d[i][j]>d[i][k]+d[k][j]){
            d[i][j]=d[i][k]+d[k][j];
            d[j][i]=d[j][k]+d[k][i];
          }
        }
      }
    }
    for(int i=0;i<k;i++){
      int p, q, r;
      int a=0;
      cin>>p>>q>>r;
      if(r==0){
        a=e[p-1][q-1];
        cout<<a<<endl;
      }
      if(r==1){
        a=d[p-1][q-1];
        cout<<a<<endl;
      }
    }
	}

	return 0;
}




Measured memory_bytes: 3228
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define rep(a,b,c) for(ll a=b;a<=c;a++)
#define per(a,b,c) for(ll a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 1e3 + 5;
const int M = 2e5 + 5;
int n, m, c;

int main(){
    cin >> n >> m  >> c;
    int ans = c - (n-m);
    if(ans < 0) ans = 0;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(u==s){
    a--;
  }else if(u==t){
    b--;
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  S = S.substr(5, 2);
  int m = std::stoi(S);
  if (m <= 4)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;

  return 0;
}


Measured memory_bytes: 256
import Data.List
import Control.Monad

type Query = ((Int,Int,Int),Int)

toQuery :: [Int] -> Query
toQuery [b, f, r, v] = ((b,f,r),v)

getQuery :: IO Query
getQuery = fmap (toQuery . map read . words) getLine

sumPersons :: Int -> Int -> Int -> [Query] -> Int
sumPersons b f r list = sum [v | (k,v) <- list, k == (b,f,r)]

mkBuildings :: [Query] -> [String]
mkBuildings queries =
  intercalate [replicate 20 '#'] (buildings queries)
  where
    buildings  q = [building q b | b <- [1..4] ]
    building q b = [floor q b f | f <- [1..3] ]
    floor  q b f = concat [room q b f r | r <- [1..10] ]
    room q b f r = ' ':(show $ sumPersons b f r q)

main = do
  n <- readLn :: IO Int
  queries <- replicateM n getQuery
  let buildings = mkBuildings queries
  mapM_ putStrLn buildings

Measured memory_bytes: 4060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	cin >> N;
	vl A(N);
	vl num_1(62, 0);
	vl num_0(62, 0);
	rep(i, N) {
		cin >> A[i];
		rep(b, 62) {
			if ((A[i] >> b) % 2 == 1)
				num_1[b]++;
			else
				num_0[b]++;
		}
	}
	ll ans = 0;
	ll pow2 = 1;
	rep(i, 62) {
		ll anstmp = pow2;
		anstmp *= num_1[i];
		anstmp %= mod;
		anstmp *= num_0[i];
		pow2 *= 2;
		pow2 %= mod;
		ans += anstmp;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.io.*;

/**
 * Created by Ayushi on 03 May 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String a = br.readLine();
        br.close();
        System.out.println(a.equals("ABC")?"ARC":"ABC");
    }
}


Measured memory_bytes: 32420
#include<stdio.h>

int main(){
  int N,n,i;
  char S[100],T1[50],T2[50];
  scanf("%d\n",&N);
  scanf("%s\n",S);
  n=N/2;
  
  if (N==0||N%2==1)
    printf("No\n");
  else{
    for(i=0;i<n;i++){
      T1[i]=S[i];
      T2[i]=S[i+n];
      if(T1[i]!=T2[i]){
         printf("No\n");
         break;
      }
      else if(T1[i]==T2[i] && i == n-1){
        printf("Yes\n");
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define LEN 100005
typedef struct pp{
	char name[11];
	int t;
}P;
int head,tail,n;
P Q[LEN];
int min(int a,int b);
P dequeue(void);
void enqueue(P x);
int main(void)
{
	int elaps=0,c;
	int i,q;
	P u;
	scanf("%d %d",&n,&q);
	for (i=1;i<=n;i++){
		scanf("%s %d",Q[i].name,&Q[i].t);
	}
	head=1;tail=n+1;
	
	while (head!=tail){
		u=dequeue();
		c=min(q,u.t);
		u.t-=c;
		elaps +=c;
		if (u.t>0)enqueue(u);
		else {
			printf("%s %d\n",u.name,elaps);
		}
	} 
	
	return 0;
}
int min(int a,int b){return a<b?a:b;}
P dequeue(void)
{
	P x=Q[head];
	head=(head+1)%LEN;
	return x;
}
void enqueue(P x)
{
	Q[tail]=x;
	tail=(tail+1)%LEN;
}

Measured memory_bytes: 2160
class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        x = self.find(x)
        return -self.parent[x]

    def is_root(self, x):
        return self.parent[x] < 0


N,M = map(int,input().split())
p = list(map(int,input().split()))
uf = UnionFind(N)
for i in range(M):
    x,y = map(int,input().split())
    uf.unite(x-1,y-1)

ans = 0
for i in range(N):
    if p[i]-1 == i:
        ans += 1
    else:
        if uf.same(p[i]-1,i):
            ans += 1
print(ans)

Measured memory_bytes: 13812
import math
N, D = map(int, input().split())

point = []
for i in range(N):
    X = list(map(int, input().split()))
    point.append(X)

counter = 0
for i in range(N):
    for j in range(i+1, N):
        s = 0
        for d in range(D):
            s += (point[i][d] - point[j][d]) ** 2
        # print(s)
        dist = int(math.sqrt(s))
        # print(i, j, dist, s)
        if dist ** 2 == s:
            counter += 1
print(counter)

Measured memory_bytes: 3064
MOD = 10**9 + 7

N = int(input())

STT = [
    [1,0,2,0],[1,3,4,5],[6,0,2,0],[1,0,10,0],[6,10,7,8],
    [1,0,9,0],[1,10,4,5],[6,10,2,0],[1,10,2,0],[6,10,2,0]
]

dp = [[0]*(11) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for st in range(10):
        for ch in range(4):
            dp[i+1][STT[st][ch]] += dp[i][st]
            dp[i+1][STT[st][ch]] %= MOD

print(sum(dp[-1][:-1]) % MOD)


Measured memory_bytes: 3064
import java.util.Scanner


object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val r, g, b, n = sc.nextInt()
    var cnt = 0
    for (nr <- 0 to n) {
      for (ng <- 0 to n) {
        val x = r * nr + g * ng
        val nb = (n - x) / b
        val remain = (n - x) % b
        if(nb >= 0 && remain == 0){
          cnt +=1
        }
      }
    }
    println(cnt)
  }
}

Measured memory_bytes: 25536
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from fractions import gcd

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
gcd_a = a[0]
for i in range(1, n):
    gcd_a = gcd(a[i], gcd_a)
if k % gcd_a == 0 and k <= max(a):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


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

#define int long long
typedef long long ll;
typedef long long ll; 
typedef vector<ll> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef vector<vi> vvi;
#define sz(a) int((a).size())
#define F first
#define S second
#define pb emplace_back
#define M 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for(int i = a; i<= b; i++)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())

main() {
    IOS;

    int n;
    cin >> n;
    int a[n+1], b[n+1], c[n+1];

    fr (i, 1, n) {
        cin >> a[i] >> b[i] >> c[i];
    }

    int dpa[n+1] = {0}, dpb[n+1] = {0}, dpc[n+1] = {0};

    fr (i, 1, n) {
        if (i == 1) {
            dpa[1] = a[1];  dpb[1] = b[1]; dpc[1] = c[1];
        }
        else {
            dpa[i] = max(dpb[i-1], dpc[i-1]) + a[i];
            dpb[i] = max(dpa[i-1], dpc[i-1]) + b[i];
            dpc[i] = max(dpa[i-1], dpb[i-1]) + c[i];
        }
    }

    cout << max(max(dpa[n], dpb[n]),dpc[n]);
}

/*  Check for base cases such as n == 1
    and cases like it where code can fail */

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

template<long long mod>
class ModInt {
public:
	long long v;
	ModInt(long long v = 0) : v((v % mod + mod) % mod) {}
	ModInt operator+(ModInt t) {return ModInt((v + t.v) % mod);}
	ModInt operator-(ModInt t) {return ModInt((v - t.v + mod) % mod);}
	ModInt operator*(ModInt t) {return ModInt((v * t.v) % mod);}
	ModInt operator+=(ModInt t) {return *this = *this + t;} 
	ModInt operator-=(ModInt t) {return *this = *this - t;}
	ModInt operator*=(ModInt t) {return *this = *this * t;}
	ModInt operator-() {return ModInt(-v);}
	ModInt mpow(long long t) {
		if (t == 0) return ModInt(1);
		ModInt a = mpow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	ModInt inv() {mpow(mod - 2);}
	ModInt operator/(ModInt t) {return ModInt(v) * inv();}
	ModInt operator/=(ModInt t) {return *this = *this / t;}
	ModInt operator==(ModInt t) {return *this.v == t.v;}
	ModInt operator!=(ModInt t) {return *this.v != t.v;}
	friend ostream& operator<<(ostream& os, const ModInt& mi) {
		os << mi.v;
		return os;
	}
};

int main() {

	using mint = ModInt<1000000007>;

	string l;
	cin >> l;

	int n = l.size();

	mint dp[100005][2];
	// dp[i][j] := i桁目まで確定。j = 1ならa+bがそこまでlと等しい。j = 0なら異なる。

	memset(dp, 0, sizeof(dp));
	
	dp[0][1] = 1;
	for (int i = 0; i < n; i++) {
		dp[i + 1][0] += dp[i][0] * 3;
		if (l[i] == '1') {
			dp[i + 1][1] += dp[i][1] * 2;
			dp[i + 1][0] += dp[i][1];
		}
		else {
			dp[i + 1][1] += dp[i][1];
		}
	}

	cout << dp[n][0] + dp[n][1] << endl;
	return 0;
}

Measured memory_bytes: 5292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
ll mod = 1000000007;
int main(){
  ll n,m; cin >> n >> m;
  vector<vector<ll>> v(m);
  rep(i,n){
    ll a,b; cin >> a >> b;
    if(a>m) continue;
    v[a-1].push_back(b);
  }
  priority_queue<ll> pq;
  ll ans = 0;
  rep(i,m){
    for(auto e:v[i]){
      pq.push(e);
    }
    if(pq.empty()) continue;
    ans+=pq.top();
    pq.pop();
  }
  cout << ans << endl;
  return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int h, w; cin>>h>>w;
    string s[60];
    for(int i=0; i<h; i++){
        cin>>s[i];
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]=='.'){
                int cnt=0;
                for(int k=i-1; k<=i+1; k++){
                    for(int l=j-1; l<=j+1; l++){
                        if(0<=k && k<h && 0<=l && l<w){
                            if(s[k][l]=='#') cnt++;
                        }
                    }
                }
                s[i][j]='0'+cnt;
            }
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << s[i][j];
        }
        cout << endl;
    }
}

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

const int MAX = 2e5;
struct edge{int to, cost;};
struct Diameter{int from, to, d;};
vector<edge> g[MAX];

P farthest(int u,int p) {
  P r(0,u);
  for(auto e : g[u]) {
    if(e.to == p) continue;
    P c = farthest(e.to,u);
    c.first += e.cost;
    r = max(r,c);
  }
  return r;
}

Diameter tree_diameter() {
  P p = farthest(0,-1);
  P q = farthest(p.second,-1);
  return Diameter{p.second,q.second,q.first}; 
}

int main(){
  int n;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(edge{b,1});
    g[b].push_back(edge{a,1});
  }
  Diameter d = tree_diameter();
  cout << (d.d % 3 == 1 ? "Second" : "First") << endl;
  return 0;
}

Measured memory_bytes: 26752
N, K = map(int, input().split())
S = input()

lower_str = S[K-1].lower()

if K == 1:
    print(lower_str + S[K:])
elif 1 < K < N-1:
    print(S[:K-1] + lower_str + S[K:])
elif (K > 1) and (K == N-1):
    print(S[:K-1] + lower_str + S[K])
elif K == N:
    print(S[:K-1] + lower_str)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      
      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 2) {
        for(; arr[1]+2 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 2) {
        for(; arr[0]+2 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2], step);

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    int step=0;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      step = cur.step + 1;
      if(cur.e[0] < cur.e[1] && cur.e[0] < cur.e[2])
        que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2], step));
      else if(cur.e[1] < cur.e[2])
        que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2], step));
      else
        que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2, step));

      if(cur.e[0] < cur.e[2] && cur.e[1] < cur.e[2])
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2], step));
      else if(cur.e[1] < cur.e[0] && cur.e[2] < cur.e[0])
        que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1, step));
      else
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1, step));
      
    }
  }

  class Tuple3 {
    int[] e;
    int step;

    public Tuple3(int a, int b, int c, int step) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      this.step = step;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
int main()
{
	int n;
	int a;
	double sum=0.0;
	for(scanf("%d",&n);n>0;n--)
	{
		scanf("%d",&a);
		sum+=1/(double)a;
	}
	printf("%lf",1/sum);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)

#define all(v) (v).begin(), (v).end();
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

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

    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    vector<int> dp_a(n);
    vector<int> dp_b(n);
    vector<int> dp_c(n);

    dp_a[0] = a[0];
    dp_b[0] = b[0];
    dp_c[0] = c[0];

    repr(i, 1, n) {
        dp_a[i] = max(dp_b[i - 1] + a[i], dp_c[i - 1] + a[i]);
        dp_b[i] = max(dp_a[i - 1] + b[i], dp_c[i - 1] + b[i]);
        dp_c[i] = max(dp_a[i - 1] + c[i], dp_b[i - 1] + c[i]);
    }

    cout << max({dp_a[n - 1], dp_b[n - 1], dp_c[n - 1]}) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main()
{
    int x,y,z,nz,m;
    cin>>x>>y>>z;
    m=(x-1)/(y+z);
    nz=z*(m+1);
    if(((m*y)+nz)>x)
    {
        m--;
    }
    cout <<m;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  ll n,i=0;
  while(n){
    cin >> n;i++;
    if(n == 0)break;
    cout << "Case " << i << ": " << n << endl;
  }
}



Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int a[3];

int main()
{
	//ios::sync_with_stdio(false);
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	if(a[0]+a[1]==a[2])
	printf("Yes\n");
else printf("No\n");
	return 0;
}

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


int main(){
string s, pre, post;
cin>>s;pre = s.at(0), post ="";
int k = 1;
for(int i = 1; i<s.size(); i++){
post += s.at(i);
if(pre!=post){
k++;
pre = post;
post = "";
}


} 
cout<<k<<endl;
}

Measured memory_bytes: 640
N = int(input())
ABC = [list(map(int,input().split())) for _ in range(N)]

dp = [[0 for i in range(3)] for j in range(N)]
dp[0][0]= ABC[0][0]
dp[0][1]= ABC[0][1]
dp[0][2]= ABC[0][2]
for i in range(1,N):
    for toi in range(3):
        s = 0
        for fromi in range(3):
            if toi==fromi:
                continue
            s = max(s, dp[i-1][fromi] + ABC[i][toi])
        dp[i][toi] = s


print(max(dp[-1]))

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

int main(){
  int n;
  cin >> n;
  vector<int> T(n);
  vector<int> tmp(n);
  rep(i,n){cin >> T.at(i);tmp.at(i) = T.at(i);}
  int m;
  cin >> m;
  rep(i,m){
    tmp = T;
    int p,x;
    cin >> p >> x;
    tmp.at(p-1) = x;
    int ans = 0;
    rep(i,n)ans += tmp.at(i);
    cout << ans << endl;
  }


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define read FILE *fp;\
fp=freopen("testcase.txt","r",stdin);
#define ll long long
#define ull unsigned long long
#define sf(n) scanf("%I64d",&n)
#define pf(n) printf("%I64d\n",n)
#define loop for(long long i=0;i<n;i++)
#define lp(b,n) for(long long i=b;i<=n;i++)
#define pb(n) push_back(n)
#define srt(v) sort(v.begin(),v.end())
#define rvs(v) sort(v.begin(), v.end(), greater<long long>());
#define F first
#define S second
#define mp(a,b) make_pair(a,b);
#define fio ios::sync_with_stdio(false); cin.tie(),cout.tie();
ll llmax = numeric_limits<long long>::max();
ll llmin= numeric_limits<long long>::min();
ll mark[5010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    ll a[n+10],b=0,c=0,d=0;
    loop
    {
        cin>>a[i];
    }
    for(ll i=0;i<n;i++)
    {
        c=c+a[i];
        b=a[i];
        for(ll j=i+1;j<n;j++)
        {
            b=min(b,a[j]);
            if(a[j]==0)
            {
                break;
            }
            else if(a[j]>=b)
            {
                a[j]-=b;
            }
            else
            {
                a[j]=0;
            }
        }
        //cout<<c<<endl;
    }
    cout<<c<<endl;
}



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

using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){

        cout << "YES";
    } else{
        cout << "NO";
    }
    cout << endl;


}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long s1 = 1;
        long s2 = 1;
        for(int i = 0; i < n; i++){
            long t = sc.nextLong();
            long a = sc.nextLong();
            long n1 = s1/t;
            long n2 = s2/a;
            n1 += s1 % t !=  0 ? 1 : 0;
            n2 += s2 % a !=  0 ? 1 : 0;
            long max = Math.max(n1,n2);
            s1 = t * max;
            s2 = a * max;
        }
        System.out.println(s1+s2);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

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

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


Measured memory_bytes: 21460
N, M = map(int, input().split())
lmax = 0
rmin = 10**5
for i in range(M):
    L, R = map(int, input().split())
    lmax = max(lmax, L)
    rmin = min(rmin, R)
ans = rmin - lmax
if ans >= 0:
    print(ans + 1)
else:
    print(0)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll mod=1e9+7;
const ll inf=1e17+500;
const ll maxn=5e5+500;

ll ans[maxn];
bool vis[maxn];
int main(){
    ll n,x;
    cin>>n>>x;
    if(x==1 || x==2*n-1){
        cout<<"No";
        return 0;
    }
    cout<<"Yes\n";
    if(n==2){
        cout<<"1 2 3";
        return 0;
    }
    ans[n-1]=x-1;
    ans[n]=x;
    ans[n+1]=x+1;
    if(x==2){
        ans[n-2]=x+2;
    }
    else{
        ans[n+2]=x-2;
    }

    for(ll i=1;i<=2*n-1;i++){
        vis[ans[i]]=1;
    }
    stack<ll> stk;
    for(ll i=1;i<=2*n-1;i++){
        if(!vis[i])
            stk.push(i);
    }
    for(ll i=1;i<=2*n-1;i++){
        if(ans[i]==0){
            ans[i]=stk.top();
            stk.pop();
        }
        cout<<ans[i]<<endl;
    }
}




Measured memory_bytes: 6200
# 幅優先探索（行きがけ）
import collections
import sys


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    a = LI()
    ans = 0
    for i, v in enumerate(a):
        if v == 0:
            ans = i+1
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9328
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
	int n;
	while(1){
		cin >> n;
		if(n==0)
			break;
		long int c[4001]={};
		int id[100000];
		for (int i=0; i<n; i++){
			long int p , q;
			cin >> id[i] >> p >> q;
			c[id[i]] += p*q;
		}
		bool f=1;
		for (int i=0; i<n; i++){
			if (c[id[i]]>=1000000){
				cout << id[i] << endl;
				c[id[i]]=0;
				f=0;
			}
		}
		if (f)
			cout << "NA" << endl;

	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return a;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int h,w; cin >>h >>w;
  int n; cin >>n;
  int ans = 0;
  int cnt = 0;
  while (cnt < n){
    if (h >= w){
      cnt += h;
    }else{
      cnt += w;
    }
    ans++;
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

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

const int N = 3010;
int n, m, dp[N][N], decs[N][N];
string s, t;

int rec(int sid, int tid) {
	if(sid == 0 || tid == 0) return 0;
	int& memo = dp[sid][tid];
	if(memo != -1) return memo;
	int d1 = rec(sid-1, tid);
	int d2 = rec(sid, tid-1);
	int d3 = -2;
	if(s[sid] == t[tid]) d3 = 1+rec(sid-1, tid-1);
	int res = 0;
	if(d1 >= d2 && d1 >= d3) {
		res = d1;
		decs[sid][tid] = 1;
	} else if(d2 >= d1 && d2 >= d3) {
		res = d2;
		decs[sid][tid] = 2;
	} else {
		res = d3;
		decs[sid][tid] = 3;
	}
	return memo = res;
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    memset(dp, -1, sizeof(dp));
    cin >> s >> t;
    n = s.size(), m = t.size();
    s = " " + s, t = " " + t;
    rec(n, m);
    string ans;
    int sid = n, tid = m;
    while(sid && tid) {
    	int decision = decs[sid][tid]; // 1: sid-1, tid.  2: sid, tid-1. 3: sid-1, tid-1.
    	if(decision == 1) --sid;
    	else if(decision == 2) --tid;
    	else {
    		ans.push_back(s[sid]);
    		--sid;
    		--tid;
    	}
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


Measured memory_bytes: 71552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust" << "\n";
    else
        cout << "win" << "\n";
}

Measured memory_bytes: 256
def check(s, f, t):
    while (f < t):
        if s[f] != s[t]:
            return False
        f += 1
        t -= 1
    return True

s = input()
n = len(s)
if check(s, 0, n - 1) and check(s, 0, (n - 1) // 2 - 1) and check(s, (n + 3) // 2 - 1, n - 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int n;
	cin>>n;
	ll a[n];
	rep(i,n)cin>>a[i];
	ll total=0;
	rep(i,n)total+=a[i];
	ll b=total;
	rep(i,n/2){
		b-=a[i*2+1]*2;
	}
	cout<<b;
	rep(i,n-1){
		b=(a[i]-b/2)*2;
		cout<<" "<<b;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

//?????§??¬?´???°(????????????????????????????????????)
template<class T>T GCD(T a, T b);

//????°???¬?????°(ab == (GCD)(LCM) ??????)
template<class T>T LCM(T a, T b);


int main()
{
	long long a, b;
	cin >> a >> b;
	
	do{
		cout << GCD(a, b) << " " << LCM(a, b) << endl;
	}while( (cin >> a >> b) );
	
	return 0;
}


template<class T>T GCD(T a, T b)
{
	T ans;
	do
	{
		if( a == b )
		{
			ans = a;
			break;
		}
		
		if( a < b )swap(a, b);
		a -= b;
		
	}while( 1 );
	
	return ans;
}

template<class T>T LCM(T a, T b)
{
	return a * b / GCD(a, b);
}

Measured memory_bytes: 1160
n = gets.chomp.to_i

answer = 
  case n.to_s.size
  when 1
    n
  when 2
    9
  when 3
    9 + n - 99
  when 4
    900 + 9
  when 5
    900 + 9 + n - 9999
  when 6
    90000 + 900 + 9
  end

puts answer


Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000001
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 3001;
int dp[N][N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;
    s = '.' + s;
    t = '.' + t;

    int i = 1, j;

    for (; i < s.ln; i++) {
        for (j = 1; j < t.ln; j++) {
            if (s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    i = s.ln - 1, j = t.ln - 1;
    string res;

    while (dp[i][j]) {
        while (dp[i][j] == dp[i - 1][j] && i > 0)
            --i;
        while (dp[i][j] == dp[i][j - 1] && j > 0)
            --j;
        if (i)
            res += s[i];
        --i, --j;
    }

    reverse(res.B, res.E);
    cout << res;

    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))
const double pi=acos(-1);
const int maxn=2e5+5;

int main()
{
    int n;
    cin>>n;
    cout<<n*n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
	int x,y;
	cin>>x>>y;

	int ans=x+y/2;
	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,n[31]={0};
	int i;
	for(i=0;i<28;i++){
		scanf("%d",&a);
		n[a]=a;
	}
	
	for(i=1;i<31;i++){
		if(n[i]==0){
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	Long X = sc.nextLong();
	Long Y = sc.nextLong();
	if ( X % Y == 0 ) System.out.println(-1);
	else {
	    for ( int i = 2; X * i <= 1e18; i++ ) {
		if ( X * i % Y != 0 ) {
		    System.out.println(X * i);
		    return;
		}
	    }
	    System.out.println(-1);
	}
    }
}


Measured memory_bytes: 23124