akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 105, MAX = 1e5 + 5;
int n, W, w[N], v[N], dp[N][MAX];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> W;
	fw (i, 0, n) cin >> w[i] >> v[i];
	memset(dp, 63, sizeof dp);
	dp[0][0] = 0;
	fw (i, 0, n) fw (j, 0, MAX) {
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
	}
	int ans = 0;
	fw (j, 0, MAX) if (dp[n][j] <= W) ans = j;
	cout << ans;
	return 0;
}

Measured memory_bytes: 41344
#include <string>
#include <cstdio>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <deque>
#include <stack>
#include <queue>
using namespace std;
const int N = 1e7;
const int mod = 998244353;
int n, m;
long long a[N +1], ni[N + 1];
long long calc(long long x, long long y) {
    long long z = 1;
    while (y) {
        if (y & 1) (z *= x )%= mod;
        (x *= x) %= mod, y /= 2;
    }
    return z;
}
long long C(int x, int y) {
    if (x < y || x < 0) return 0;
    return a[x] * ni[y] % mod * ni[x - y] % mod;
}
long long get(int n, int m) {
    return C(n + m  - 1, n - 1);
}
int main()
{
    scanf("%d %d", &n ,&m);
    a[0] = 1;
    for (int i = 1; i <= N ; i ++)
        a[i] = a[i - 1] * i % mod;
    ni[N] = calc(a[N] , mod -  2);
    for (int i = N - 1; i >= 0 ; i --)
         ni[i] = ni[i + 1] * (i + 1) % mod;
    long long ans = get(n, m * 3);
    for (int i = m + 1; i <= n ; i ++) {
        if ((3 * m - i) % 2 == 0 && m * 3 - i >= 0)
            (ans += mod - C(n, i) * get(n, (m * 3 - i) / 2) % mod) %= mod;
    }
    (ans += mod - C(n , 1) * get(n, m * 3 - m - m - 1)% mod) %= mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 156544
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, A: "List[List[int]]"):
    mx = 0
    for i in range(N):
        d = sum(A[0][:i+1]) + sum(A[1][i:])
        mx = max(d, mx)
    print(mx)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ [ int(next(tokens)) for _ in range(N) ] for _ in range(2) ]  # type: "List[List[int]]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end());
    bool flag = true;
    rep(i,n - 1){
        if (a[i] == a[i+1]) flag = false;
    }
    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1792
n = int(input())
while(n):
    bottom_record = [0]*(n+1)

    for i in range(0, n):
        l = list(map(int, input().split()))
        l.append(sum(l))
        bottom_record = [x + y for(x,y) in zip(bottom_record, l)]
        print(''.join(map('{0:5d}'.format, l))) 
    print(''.join(map('{0:5d}'.format, bottom_record)))
    n = int(input())

Measured memory_bytes: 7628
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  vi v(5);
  char gomi;
  while (cin >> v[0] >> gomi >> v[1] >> gomi >> v[2] >> gomi >> v[3] >> gomi >> v[4]) {
    sort(all(v));
    if (v[0] == v[3] || v[1] == v[4]) {
      cout << "four card" << endl;
      continue;
    }
    if ((v[0] == v[1] && v[2] == v[4]) || (v[0] == v[2] && v[3] == v[4])) {
      cout << "full house" << endl;
      continue;
    }
    if (v[4] - v[0] == 4 || (v[0] == 1 && v[1] == 10 && v[4] - v[1] == 3)) {
      cout << "straight" << endl;
      continue;
    }
    if (v[0] == v[2] || v[1] == v[3] || v[2] == v[4]) {
      cout << "three card" << endl;
      continue;
    }
    if ((v[0] == v[1] && (v[2] == v[3] || v[3] == v[4])) || (v[1] == v[2] && v[3] == v[4])) {
      cout << "two pair" << endl;
      continue;
    }
    if (v[0] == v[1] || v[1] == v[2] || v[2] == v[3] || v[3] == v[4]) {
      cout << "one pair" << endl;
      continue;
    }
    cout << "null" << endl;
  }
}

Measured memory_bytes: 3012
/* CODED WITH ❤️ by Sidharth Anand aka sidanand6 */

#include "bits/stdc++.h"
#define mod 1000000007
typedef long long ll;
typedef std::vector<int> vi;
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif	

    //start coding from here
    int n;
    cin >> n;
    vector<vector<int> > matrix(n, vector<int>(2));
    for (int i = 0; i < n; i++) {
    	cin>> matrix[i][0] >> matrix[i][1];
    }

    int count = 0, best = 0;
    for (int i = 0; i< n; i++) {
    	if (matrix[i][0] == matrix[i][1]) {
    		count++;
    	}
    	else {
    		count = 0;
    	}
    	best = max(count, best);
    }

    if (best >= 3) {
    	cout<<"Yes";
    }
    else {
    	cout<<"No";
    }

	return 0;
}


Measured memory_bytes: 3652
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <istream>
#include <algorithm>

int main()
{
    int x, a, b,c;

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> x;

    int count = 0;
    for (int i = 0; i <= a; i++)
        for (int j = 0; j <= b; j++)
            for (int k = 0; k <= c; k++)
                if (500 * i + 100 * j + 50 * k == x)
                    count++;
    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if((a<=9&&a>=1)&&(b<=9&&b>=1))
    {
        printf("%d\n",a*b);
    }
    else
    {
        printf("-1\n");
    }
}


Measured memory_bytes: 1724
/*        ~ABC 171~
 *    code by kazalika   */
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  ll vars = 26, sm = 0, cn = 0;
  while (sm < n) {
    sm += vars;
    cn++;
    vars *= 26;
  }
  sm -= vars / 26;
  n -= sm + 1;
  vector<int> ans(cn);
  for (int i = 0; i < cn; ++i) {
    ans[i] = n % 26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  for (int i : ans)
    cout << char('a' + i);
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
int n,i,a,b,c,d,count;
for(i=0;i<50;i++){
count=0;
scanf("%d",&n);
for(a=0;a<10;a++){
for(b=0;b<10;b++){
for(c=0;c<10;c++){
for(d=0;d<10;d++){
if((a+b+c+d)==n)count++;
}
}
}
}
printf("%d\n",count);
}
return 0;
}

Measured memory_bytes: 596
const main = (input: void) => {
  const n: number = input.split('\n')[0];
  const a: number = input.split('\n')[1].split(' ');
  let flg: boolean = true;
  let cnt: number = 0;

  while (flg) {
    for (let i = 0; i < n; i++) {
      if (a[i] % 2 != 0) {
        flg = false;
      }
      a[i] = a[i]/2;
    }
    cnt++;
  }
  console.log(cnt -1);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N, M;
  cin >> N >> M;
  vector<ll> ans(N, -1);
  rep (i, M) {
    ll s, c;
    cin >> s >> c;
    s--;
    if (ans[s] == -1 or ans[s] == c) ans[s] = c;
    else {
      cout << -1 << endl;
      return;
    }
  }
  if (N >= 2 and ans[0] == 0) {
    cout << -1 << endl;
    return;
  }
  rep (i, N) {
    if (ans[i] == -1) {
      if (i == 0) {
        if (N == 1) ans[i] = 0;
        else ans[i] = 1;
      } else {
        ans[i] = 0;
      }
    }
  }
  rep (i, N) cout << ans[i];
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	long[] a = new long[n];
	long[] asum = new long[n];
	long[] bsum = new long[n+1];

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

	for(int i = 0; i<n; i++) {
	    if(i == 0) {
		asum[i] = a[i];
		continue;
	    }
	    asum[i] = a[i] + asum[i-1];
	}

	for(int i = n; i>=0; i--) {
            if(i == n) {
		bsum[i] = 0;
		continue;
            }
            bsum[i] = a[i] + bsum[i+1];
        }

	long min = Long.MAX_VALUE;
	for(int i = 0; i<n-1; i++) {
	    min = Math.min(min, Math.abs(asum[i]-bsum[i+1]));
	}
	System.out.println(min);
    }
}

Measured memory_bytes: 91736
//ProblemE

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemE

class Solve {
private:
	int n, a, b;

	void solve() {
		cin >> n >> a >> b;

		int mina = n / b;
		if (n % b != 0) mina++;
		int maxa = n - b + 1;

		if (a < mina || a > maxa) {
			cout << "-1" << endl;
			return;
		}

		int remain = a - mina;
		int cur = n % b;
		if (cur == 0) cur = b;

		int l = 1, r = cur;
		vector<int> rst;
		rst.reserve(n);

		while (l <= n) {
			int t = r - l;
			if (t > remain) t = remain;

			for (int i = r - t; i >= l; i--) {
				rst.push_back(i);
			}
			for (int i = r - t + 1; i <= r; i++) {
				rst.push_back(i);
			}

			remain -= t;
			l = r + 1;
			r = l + b - 1;
		}

		cout << rst[0];
		for (int i = 1; i < n; i++) {
			cout << ' ' << rst[i];
		}
		cout << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
    int M = sc.nextInt();
    Integer[] ai = new Integer[N];
    Integer sum = 0;
    for(int i=0; i < N; i++){
      ai[i] = sc.nextInt();
      sum += ai[i];
    }
    Integer limit = (int) Math.floor(sum/(4*M));
    if((sum%(4*M))==0){
      limit--;
    }
    Arrays.sort(ai, Collections.reverseOrder());
    
    if(ai[M-1] > limit){
      System.out.println("Yes");
      return;
    }
    
    System.out.println("No");
    return;
  }
}

Measured memory_bytes: 21844
characteristic=10**9+7
def plus(input1,input2):
    return (input1+input1)%characteristic
def minus(input1,input2):
    return (input1-input2)%characteristic
def times(input1,input2):
    return (input1*input2)%characteristic
def exponen(input1,input2):
    binaryl=list(str(bin(input2))[2:])
    binarysize=len(binaryl)
    binarylist=[int(binaryl[binarysize-1-i]) for i in range(binarysize)]
    modlist=[0 for i in range(binarysize)]
    modlist[0]=input1
    for i in range(1,binarysize):
        modlist[i]=times(modlist[i-1],modlist[i-1])
    answer=1
    for i in range(binarysize):
        if binarylist[i]==1:
            answer=times(answer,modlist[i])
    return answer
def divide(input1,input2):
    return times(input1,exponen(input2,characteristic-2))
N=int(input())
A=sorted([int(i) for i in input().split()],reverse=True)
#6,6,4,4,2,2,0
#7,7,5,5,3,3,1,1
B=[]
for i in range(N//2):
    for p in [0,1]:
        B.append(N-1-2*i)
if N%2==1:
    B.append(0)
for i in range(N):
    if A[i]!=B[i]:
        print(0)
        exit()
print(exponen(2,N//2))


Measured memory_bytes: 13812
--選択ソート

import Data.Array
import Data.Array.ST
import Data.STRef
import Control.Monad.ST
import Control.Monad

import Data.List
--bounds,array,未ソート開始インデックス、Actionと交換の有無
select_ins::(Int,Int) -> STArray s Int Int -> Int -> ST s Bool
select_ins (s,e) ar idx = if idx == e then return False else do
  (min_id,min_v)<-find_min ar (idx,e)
  h<-readArray ar idx
  writeArray ar idx min_v
  writeArray ar min_id h
  return (min_id/=idx)

--アレイ、探索範囲、インデックスリターン
find_min::STArray s Int Int -> (Int,Int) -> ST s (Int,Int)
find_min ar (s,e) = do
  iar<-freeze ar
  return (minimumBy (\ (i_x,x) -> \ (i_y,y) -> compare x y ) (filter (\(i,v)-> i<=e&&i>=s) (assocs iar)))

sel_sort::Array Int Int ->(Int,Array Int Int)
sel_sort ar = runST $ do
  let (s,e) =  bounds ar
  mar<-thaw ar
  bs<-forM [s..e-1] (select_ins (s,e) mar)
  iar<-freeze mar
  return (length (filter id bs),iar)

main::IO()
main=do
  nc<-getLine
  let n = read nc
  d<-getLine
  let ar = listArray (1,n) (map read (words d))
  let (c,out) = sel_sort ar
  putStr ((ls_show (elems out))++"\n")
  print c

ls_show::[Int]->String
ls_show [] = []
ls_show (x:xs) = (show x)++(if xs == [] then (ls_show xs) else ' ':(ls_show xs))


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  vector<P> a; 
  REP(i,n){
    int x,l;
    cin >> x >> l;
    a.emplace_back(make_pair(x+l,x-l));
  }
  sort(ALL(a));

  // REP(i,a.size()){
  //   printf("%d %d\n",a[i].first, a[i].second);
  // }


  int m = a[0].first;
  int ans=n;
  FOR(i,1,a.size()){
    if(a[i].second < m){
      ans--;
    }else{
      m = a[i].first;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 4272
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	a := []int{}
	for i := 0; i < n; i++ {
		a = append(a, stdin.ReadInt())
	}

	c := map[int]int{}
	for i := 0; i < n; i++ {
		d := f(a[i])
		for k := range d {
			if _, ok := c[k]; ok {
				c[k] = Max(c[k], d[k])
			} else {
				c[k] = d[k]
			}
		}
	}

	lcm := 1
	for k := range c {
		lcm = (lcm * ModPow(k, c[k])) % MOD
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans = (ans + lcm*ModInv(a[i])) % 1000000007
	}

	stdout.Println(ans)
}

func f(x int) map[int]int {
	primes := map[int]int{}
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			if _, ok := primes[i]; ok {
				primes[i]++
			} else {
				primes[i] = 1
			}
			x /= i
		}
	}

	if x > 1 {
		if _, ok := primes[x]; ok {
			primes[x]++
		} else {
			primes[x] = 1
		}
	}

	return primes
}

func Gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm(x, y int) int {
	return x * y / Gcd(x, y) % MOD
}

func Max(a ...int) int {
	v := a[0]
	for i := 1; i < len(a); i++ {
		if v < a[i] {
			v = a[i]
		}
	}
	return v
}

const MOD = 1000000007

func ModPow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x = (x * x) % MOD
			y /= 2
		} else {
			z = (z * x) % MOD
			y--
		}
	}
	return z
}

func ModInv(x int) int {
	return ModPow(x, MOD-2)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 4352
date=[]
while True:
    x, y= [int(i) for i in input().split()]
    count=0
    if x == 0 and y ==0:
        break
    else:
        for k in range(1,x-1):
            for h in range(k+1,x):
                for g in range(h+1,x+1):
                    if k + h + g == y:
                        count = count + 1
    date.append(count)

for u in range(0,len(date)):
    print(date[u])

Measured memory_bytes: 7656
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX 200001
#define MOD 998244353
ll fac[MAX],finv[MAX],inv[MAX];
typedef vector<vector<int> > Graph;
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll RepeatSquare(ll a,ll b,ll mod){
    if(b==0) return 1;
    if(b%2==0){
        ll t=RepeatSquare(a,b/2,mod);
        t%=mod;
        return t*t%mod;
    }
    return a*RepeatSquare(a,b-1,mod);
}
int main(){
    COMinit();
    ll ans=0;
    ll n,m,k;cin>>n>>m>>k;
    for(int i=0;i<k+1;i++){
        ll cnt=(m*COM(n-1,i))%MOD*(RepeatSquare(m-1,n-1-i,MOD)%MOD)%MOD;
        ans+=cnt;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int L[100];
int main(){
    int N;
    cin >> N;
    REP(i,N){
        int l;
        cin >> l;
        L[i] = l;
    }
    sort(L, L+N, greater<int>());

    int sum = 0;
    for(int i = 1; i < N; i++) sum += L[i];

    if(sum > L[0])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N,M,K = map(int, input().split())
mod = 10**9+7
nm = N*M
n2 = (N**2)%mod
m2 = (M**2)%mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, 10**6 +1):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for x in range(1,M):
    ans += x*(M-x)*n2*cmb(nm-2,K-2,mod)
    ans %= mod

for y in range(1,N):
    ans += y*(N-y)*m2*cmb(nm-2,K-2,mod)
    ans %= mod

print(int(ans))

Measured memory_bytes: 128012
/*************************************************************************
	> File Name: D.cpp
	> Author: tyxxzjpdez
	> Mail: tyxxzjpdez@163.com
	> Created Time: 2017年02月17日 星期五 17时37分51秒
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100000+10;
const int INF=1<<30;
int N,T,arr[maxn];
vector<pii> v1,v2;
map<int,int> Map;

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    scanf("%d%d",&N,&T);
    for(int i=0;i<N;i++)
        scanf("%d",arr+i);
    int t=INF;
    for(int i=0;i<N;i++){
        if(arr[i]<=t)v1.push_back(make_pair(i,arr[i])),
        t=arr[i];
    }
    t=-1;
    for(int i=N-1;i>=0;i--){
        if(arr[i]>=t)v2.push_back(make_pair(i,arr[i])),
        t=arr[i];
    }
    reverse(v2.begin(),v2.end());
    /*
    for(int i=0;i<v1.size();i++)
        cout<<v1[i].second<<" ";cout<<endl;
    for(int i=0;i<v2.size();i++)
        cout<<v2[i].second<<" ";cout<<endl;
    */
    int res=0,times=0;
    for(int i=0;i<v1.size();i++){
        vector<pii>::iterator it=upper_bound(v2.begin(),v2.end(),v1[i]);
        if(it==v2.end())break;
        if((*it).second-v1[i].second>res)
            res=(*it).second-v1[i].second,times=1,Map.clear(),Map[(*it).second]=1;
        else if((*it).second-v1[i].second==res && !Map[(*it).second])times++,Map[(*it).second]=1;
    }
    printf("%d\n",times);
    return 0;
}


Measured memory_bytes: 3704
n,s,*w=open(0)
r=[-1]
n=int(n)
a=i=0
while i<n:
  if'W'>s[i]:r+=i,
  else:w+=i,
  i+=1
for w in w:
  if r.pop()>w:a+=1
  else:break
print(a)

Measured memory_bytes: 17052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int D;
    cin >> D;
    if(D == 25)
    cout << "Christmas" << endl;
    else if(D == 24)
    cout << "Christmas Eve" << endl;
    else if(D == 23)
    cout << "Christmas Eve Eve" << endl;
    else if(D == 22)
    cout << "Christmas Eve Eve Eve" << endl;
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

	string a,b;
	cin >> a >> b;
	ll na = a.length();
	ll nb = b.length();
	ll cnt = 0;
	ll ans = 0;
	for(int i = 0;i <= na-nb;i++){
		cnt = 0;
		for(int j = 0;j < nb;j++){
			if(a[i+j] == b[j])cnt++;
		}
		ans = max(ans,cnt);
	}
	cout << nb - ans << endl;

}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 3636
N, Y = map(int, input().split())

a = -1
b = -1
c = -1
judge = False

for x in range(N, -1, -1):
    money_max = x * 10000 + (N-x) * 5000
    money_min = x * 10000 + (N-x) * 1000
    if money_min <= Y and Y <= money_max:
        for y in range(N-x, -1, -1):
            money = x * 10000 + y * 5000 + (N - x - y)* 1000
            if money == Y:
                a = x
                b = y
                c = N - (x + y)
                judge = True
                break
    if judge:
        break
print(a, b, c)

Measured memory_bytes: 9228
while True:
    n,r = map(int ,input().split())
    if n==0: break
    deck = [n-i for i in range(n)]
    for i in range(r):
        p,c = map(int, input().split())
        p -= 1
        deck = deck[p:p+c]+deck[:p]+deck[p+c:]
    print(deck[0])

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

int N, K;
string S;

int main() {
	cin >> N >> K;
	cin >> S;
	int ss;
	
	int r = 0, cur = 0, cnt = 0;
	
	while (r < N && S[r] == '1') { cur++; r++; }
	int i = 0;
	int ans = cur;
	while (i < N) {
		
		while (r < N && cnt < K) {
			if (S[r] == '0') {
				cnt++;
				while (r < N && S[r] == '0') { cur++; r++; }
			}
			
			while (r < N && S[r] == '1') { cur++; r++; }
		}
		chmax(ans, cur);
		
		while (i < N && S[i] == '1') { cur--; i++; }
		cnt--;
		while (i < N && S[i] == '0') { cur--; i++; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int N, Y;
  cin >> N >> Y;

  int flag = 0;
  REP(i,N+1){
    REP(j,N-i+1){
      if((Y-10000*i-5000*j)/1000==N-i-j){
        flag = 1;
        cout << i << " " << j << " " << N-i-j << endl;
        break;
      }
    }
    if(flag == 1){
      break;
    }
  }

  if(flag == 0){
    cout << "-1 -1 -1" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
const LL mod=1000000007;

int main(){
  LL N, K;
  cin >> N >> K;
  LL ans=0;
  for(LL i=K; i<=N+1; i++){
    LL MinSum=i*(i-1)/2;
    LL MaxSum=i*(N*2-i+1)/2;
    ans+=MaxSum-MinSum+1;
    ans%=mod;
  }
  cout << ans << endl;

  return 0;
}


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



namespace Test1 {

    class ClassMain {

        public static int ryoukin(int taiseki, int weight) {
            if (taiseki <= 60 && weight <= 2) { return 600; }
            if (taiseki <= 80 && weight <= 5) { return 800; }
            if (taiseki <= 100 && weight <= 10) { return 1000; }
            if (taiseki <= 120 && weight <= 15) { return 1200; }
            if (taiseki <= 140 && weight <= 20) { return 1400; }
            if (taiseki <= 160 && weight <= 25) { return 1600; }
            return 0;
        }
       
        public static void Main(String[] args) {
            string line;

            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                int bestNum=-1;
                double bestGosa = double.MaxValue;

                for (int i = 0; i < n; i++) {
                    string[] strs = Console.ReadLine().Split(' ');
                    int n1 = int.Parse(strs[0]);
                    int h = int.Parse(strs[1]);
                    int w = int.Parse(strs[2]);
                    double hd = ((double)h)/100;
                    double bmi = w / (hd * hd);
                    //Console.WriteLine("bmi" + bmi);
                    double dif_bmi = bmi - 22.0;
                    if (dif_bmi < 0) { dif_bmi *= -1; }
                    //Console.WriteLine(n1+" bmiD "+dif_bmi);
                    if (dif_bmi < bestGosa) { bestNum = n1; bestGosa = dif_bmi; }

                }
                Console.WriteLine(bestNum);

            }
        }


    }

}

Measured memory_bytes: 5796
# 貰うDP
n, w = map(int, input().split())
WV = [list(map(int, input().split())) for i in range(n)]
# dp[i][w] 重さwでの最高価値
dp = [[-1] * (w + 1) for i in range(n + 1)]
for j in range(w + 1):
    dp[0][j] = 0
for i in range(n):
    for j in range(w + 1):
        if j - WV[i][0] >= 0 and j - WV[i][0] <= w:
            dp[i + 1][j] = max(dp[i][j - WV[i][0]] + WV[i][1], dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]
print(dp[n][w])


Measured memory_bytes: 120428
#include <iostream>

using namespace std;

template <typename It>
bool IsPalindrome(It begin, It end) {
  const auto d = distance(begin, end);
  for (int i = 0; i < d / 2; ++i) {
    if (*(begin + i) != *(end - i - 1)) {
      return false;
    }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  const int N = s.size();
  const bool ok = IsPalindrome(s.begin(), s.end()) &&
                  IsPalindrome(s.begin(), s.begin() + N / 2) &&
                  IsPalindrome(s.begin() + N / 2 + 1, s.end());
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

int main(){
  int N,K,Q;
  int pplus;
  cin >> N >> K >> Q;
  vector<int> point(N,K-Q);
  
  for(int i = 0; i < Q ; i++ ){
    cin >> pplus;
    ++point.at(pplus-1);
  }

  for(int i = 0; i < N; i++){
    if( point.at(i) > 0 ){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1024
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    T =iRaw()
    for t in range(T):
        N,A,B,C,D = isRaw()
        hq = []
        limitAns = min([
            int(math.log(N,2)+1)*A,
            int(math.log(N,3)+1)*B,
            int(math.log(N,5)+1)*C
        ])
        heappush(hq,(0,N))

        memo = {}
        memo[N]=0

        ans = N*D
        divcs = [[2,A],[3,B],[5,C]]
        while True:
            cC,cN = heappop(hq)
            memo[cN] = cC
            ans = min(ans,cC+D*cN)
            if cN  == 0:
                ans = min(cC,ans)
                break
            if cN == 1:
                ans = min(cC+D, ans)
                break
            for divc in divcs:
                div,dc = divc
                nM = cN % div
                nN = cN // div
                #if nM <= div//2:
                if True:
                    nC = cC+dc+(D*(cN % div))
                    if nN not in memo or memo[nN] > nC:
                        memo[nN] = nC
                        heappush(hq, (nC, nN))
                if nM!=0:
                    nN = nN+1
                    nC = cC+dc+(D*(div-nM))
                    if nN not in memo or memo[nN] > nC:
                        memo[nN] = nC
                        heappush(hq, (nC, nN))

        print(ans)

main()


Measured memory_bytes: 78432
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)],dtype=int)
cd = np.array([LI() for _ in range(M)],dtype=int)
for x in ab:
    vector = np.sum(np.abs(cd-x),axis=1).tolist()
    print(vector.index(min(vector))+1)


Measured memory_bytes: 21592
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;


int main() {

    int ti[50];
    int ta[50];
    int wa[50][10];
    while(true){
        int m,t,p,r;
        cin>>m>>t>>p>>r;
        if(m==0&&t==0&&p==0&&r==0)break;
        rep(i,50){ti[i]=0;ta[i]=0;}
        rep(i,50){rep(j,10){wa[i][j]=0;}}
        rep(rr,r){
            int time,team,pron,han;
            cin>>time>>team>>pron>>han;
            if(han!=0){
                wa[team-1][pron-1]++;
            }else{
                int k=wa[team-1][pron-1];
                wa[team-1][pron-1]=0;
                ti[team-1]++;
                ta[team-1]+=k*20+time;
            }
        }

        vector<tuple<int,int,int>> zyun;
        //vector<pair<int,int>> zyuni;
        rep(i,t){
            zyun.emplace_back(ti[i],-ta[i],i+1);
           // zyuni.push_back({ti[i],-ta[i]});
        }

        sort(zyun.rbegin(),zyun.rend());
        for(int i=0;i<zyun.size()-1;i++){


            if(get<0>(zyun[i+1]) < get<0>(zyun[i])){
                cout<<get<2>(zyun[i])<<",";
            }else if( get<0>(zyun[i+1])==get<0>(zyun[i])&&get<1>(zyun[i])>get<1>(zyun[i+1])){
                    cout<<get<2>(zyun[i])<<",";
            }else{
                cout<<get<2>(zyun[i])<<"=";
            }
        }
        cout<<get<2>(zyun[zyun.size()-1])<<endl;
    }






    return 0;
}



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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n; cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int res=INF;
    auto itr=max_element(all(x));
    rep(i,*itr+1){
        int temp=0;
        rep(j,n){
            temp+=pow(i-x[j],2);
        }
        chmin(res,temp);
    }
    cout<<res<<endl;
}

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

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n, m, a, b;
  cin >> n >> m >> a >> b;

  int const M = 1000'000'007;
  vector<int> f((n + m) + 1, 1);
  for (int i = 2; i < f.size(); ++i) f[i] = 1ll * i * f[i - 1] % M;
  auto bp = [M](ll x, ll e) {
    ll y = 1;
    for (; e; e >>= 1) {
      if (e & 1) y = x * y % M;
      x = x * x % M;
    }
    return y;
  };
  auto ncr = [&](int n, int r) {
    return 1ll * f[n] * bp(1ll * f[n - r] * f[r] % M, M - 2) % M;
  };
  int ans = 0;
  int i = n - a;
  for (int j = b + 1; j <= m; ++j) {
    ans += 1ll * ncr((i - 1) + (j - 1), (i - 1)) *
           ncr((n - i - 1) + (m - j), (m - j)) % M;
    ans %= M;
  }

  cout << ans;
}

Measured memory_bytes: 1024
n=int(input())
if n<=599:
  print(8)
elif n<=799:
  print(7)
elif n<=999:
  print(6)
elif n<=1199:
  print(5)
elif n<=1399:
  print(4)
elif n<=1599:
  print(3)
elif n<=1799:
  print(2)
elif n<=1999:
  print(1)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#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 pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	// D , D , 앳코더 1회 ㄱ? 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll a, b;
	cin >> a >> b;
	if (a == 0) {
		a = 1;
	}
	else if (a == 1) {
		a = 100;
	
	}
	else {
		a = 10000;
	}

	if (b == 100) {
		cout << a * b + a << '\n';

	}else
	cout << a * b << '\n';


}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; i++) {
    reverse(divide[i].begin(), divide[i].end());
  }

  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int INT_MAX_SQRT = sqrt(INT_MAX);
int powi(int x, int p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    int tmp = powi(x, p / 2);
    if (tmp > INT_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

long LONG_MAX_SQRT = sqrt(LONG_MAX);
long powl(long x, long p) {
    if (p == 0) return 1;
    if (p == 1) return x;
    long tmp = powl(x, p / 2);
    if (tmp > LONG_MAX_SQRT) return 0;  // overflow
    if (p % 2 == 0)
        return tmp * tmp;
    else
        return tmp * tmp * x;
}

using P = pair<long, int>;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;

    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int num=0;
    for(int i=0; i<4; i++){
        if(s[i] == '+') num++;
        else num--;
    }
    cout << num << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pint;
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());
signed main(void){
  int n;cin >> n;
  cout << (int)pow(n,3) << endl;

}


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

vector<vector<int>> dp(10001, vector<int>(10001, 999999999));
vector<int> A(10001), B(10001);
int H, N; 

void input(){
    cin >> H >> N;
    for (int i=0; i<N; i++){
        cin >> A.at(i) >> B.at(i);
    }
    return;
}

void DP(){
    dp.at(0).at(0)=0;
    for(int i=0; i<N; i++){
        for (int j=0; j<=H; j++){
            if(A.at(i)>=j){//今考える魔法が与えるダメージが体力j以上のとき（＝一撃で倒せるとき）
                dp.at(i+1).at(j)=min(dp.at(i).at(j), B.at(i));
            } else{
                dp.at(i+1).at(j)=min(dp.at(i).at(j), dp.at(i+1).at(j-A.at(i))+B.at(i));
            }
        }
    }
    return;
}

void output(){
    cout << dp.at(N).at(H) << endl;
    return;
}

int main(){
    input();
    DP();
    output();
    return 0;
}

Measured memory_bytes: 391424
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	string x;
	cin>>x;
	ll q;
	cin>>q;
	ll cflag=0;
	deque<char> res;
	for(auto i:x)
		res.push_back(i);
	while(q--)
	{
		ll t1;
		cin>>t1;
		if(t1==1)
		{
			cflag++;
			cflag%=2;
		}
		else
		{
			ll t2;
			cin>>t2;
			char xx;
			cin>>xx;
			if(cflag)
			{
				if(t2==1)
					res.push_back(xx);
				else
					res.push_front(xx);
			}
			else
			{
				if(t2==2)
					res.push_back(xx);
				else
					res.push_front(xx);
			}
		}
	}
	std::vector<char> res1;
	for(auto i:res)
		res1.pb(i);
	if(cflag)
		reverse(all(res1));
	for(auto i:res1)
		cout<<i;

}

Measured memory_bytes: 1364
#include <bits/stdc++.h>
#include<algorithm>
#include<deque>
#include<string>
using namespace std;

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)
#define N 110

int main(void){
  int k;
  cin>>k;
  if(k%2==0){
    cout<<k/2*k/2<<endl;
  }else{
    cout<<k/2*(k/2+1)<<endl;
  }

return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

int main() {
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n; cin >> n;

    if(2*q < h) h = 2*q;
    if(2*h < s) s = 2*h;
    if(2*s < d) d = 2*s;

    ll a = n/2;
    ll b = n%2;

    cout << s*b + d*a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int ctoi(char);

int main(void){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    vector<int> v;
    for(int i=0;i<n;i++){
        v.push_back(ctoi(s[i]));
    }
    
    vector<int> v0,v1;
    if(v[0] == 0){
        v1.push_back(0);
    }
    int a=0;
    while(a<n){
        int n0=0,n1=0;
        while(v[a] == 0){
            n0++;
            if(a==n-1){
                v0.push_back(n0);
                break;
            }
            else if(v[a+1] != 0){
                v0.push_back(n0);
                break;
            }
            a++;
        }
        while(v[a] == 1){
            n1++;
            if(a==n-1){
                v1.push_back(n1);
                break;
            }
            else if(v[a+1] != 1){
                v1.push_back(n1);
                break;
            }
            a++;
        }
        a++;
    }
    if(v[n-1] == 0){
        v1.push_back(0);
    }
    
    int result=0;
    int loop = v0.size() - k + 1;
    if(loop<1){
        result = std::accumulate(v1.begin(), v1.end(), 0) + std::accumulate(v0.begin(), v0.end(), 0);
    }else{
        for(int i=0;i<loop;i++){
            int res=0;
            for(int j=i;j<i+k;j++){
                res += v0[j] + v1[j];
                if(j==i+k-1){
                    res += v1[j+1];
                }
            }
            if(result<res){
                result=res;
            }
            
        }
    }
    
    cout << result << endl;
    
}

int ctoi(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


Measured memory_bytes: 1528
#include <iostream>

using namespace std;

int main(){

  char a, b;

  while(cin >> a >> b){

    if((int)a<(int)b) cout << "<" <<endl;
    else if((int)a>(int)b) cout << ">" <<endl;
    else cout << "=" <<endl;
  }

  return 0;
}



Measured memory_bytes: 256
x = int(input())
lank8 = list(range(400, 600))
lank7 = list(range(400, 800))
lank6 = list(range(400, 1000))
lank5 = list(range(400, 1200))
lank4 = list(range(400, 1400))
lank3 = list(range(400, 1600))
lank2 = list(range(400, 1800))
lank1 = list(range(400, 2000))
if x in lank8:
    print(8)
elif x in lank7:
    print(7)
elif x in lank6:
    print(6)
elif x in lank5:
    print(5)
elif x in lank4:
    print(4)
elif x in lank3:
    print(3)
elif x in lank2:
    print(2)
elif x in lank1:
    print(1)


Measured memory_bytes: 9356
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <map>

#define INF (1 << 8)

using namespace std;

map<string, int> table;
map<string, vector<string> > recipe;

int rec(string item)
{
    if(recipe[item].size() == 0) {
        return table[item];
    } else {
        int ret = 0;
        for(int i = 0; i < recipe[item].size(); i++) ret += rec(recipe[item][i]);
        return min(ret, table[item]);
    }
}

int main()
{
    int N, R; 
    while(cin >> N && N) {
        table.clear();
        for(int i = 0; i < N; i++) {
            int v; string name;
            cin >> name >> v;
            table[name] = v;
        }
        
        cin >> R;
        recipe.clear();
        for(int i = 0; i < R; i++) {
            int n; string name, tmp; vector<string> child;
            cin >> name >> n;
            for(int j = 0; j < n; j++) {
                cin >> tmp;
                child.push_back(tmp);
            }
            recipe[name] = child;
        }

        string query;
        cin >> query;
        cout << rec(query) << endl;
    }
}

Measured memory_bytes: 0