akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;

int main()
{
    //fast_io
    //file_io
	ll n, a, b; cin >> n >> a >> b;
	ll d = floor(ld(n) / ld(a + b));
	cout << a * d + min(a, n - (a + b) * d);
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let (n, k) = scan!(sc; i32, i32);
  let x = scan!(sc => n; i32);
  let mut d = 0;
  for &i in x.iter() {
    d += min(i, k - i);
  }
  println!("{}", d * 2);
}

fn min<T: Ord>(a: T, b: T) -> T {
  if a < b { a } else { b }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end();
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n; cin >> n;
	vector<int> vs(n);
	for(auto &x:vs) cin >> x;
	int ans =0 ;
	for(int i=1; i<n-1; ++i){
		int mn = min(vs[i-1], vs[i]);
		mn = min(mn, vs[i+1]);
		int mx = max(vs[i-1], vs[i]);
		mx = max(mx, vs[i+1]);
		if(vs[i]!=mn and vs[i]!=mx) ++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
mod=10**9+7
A.append(-1)
B.append(-1)
used_A,used_B=0,0
ans=1
S=0
for i in range(1,N*M+1)[::-1]:
  if A[used_A]==B[used_B]==i:
    used_A+=1
    used_B+=1
  elif A[used_A]==i:
    used_A+=1
    ans*=used_B
  elif B[used_B]==i:
    used_B+=1
    ans*=used_A
  else:
    ans*=max(used_A*used_B-(N*M-i),0)
  ans%=mod
print(ans)
 
    

Measured memory_bytes: 41708
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let l: f64 = parse!(it);
    println!("{}", (l * l * l) / 27.);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
N, M, C = map(int, input().split())
Blist = list(map(int, input().split()))
ans = 0
for i in range(N):
    score = C
    Alist = list(map(int, input().split()))
    for j in range(M):
        score += Alist[j]*Blist[j]
    if score > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;


template <typename T>
T digsum(T a) {
    T res = 0;
    while (a > 0) {
        res += (a-(a/10)*10);
        a /= 10;
    }
    return res;
}





int main()
{

    int N;
    cin >> N;
    int ans = 1000000000;
    reps(i,1,N){
        ans = min(ans,digsum(i)+digsum(N-i));
    }
    cout << ans << endl;
    
    
    
    

    return 0;
}


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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;
const int mxn = 2e5+7;

int sz[mxn], par[mxn];

int fp(int x){
	if (x == par[x]) return x;
	else return par[x] = fp(par[x]);
}

void join(int a, int b){
	a = fp(a), b = fp(b);
	if (a == b) return;
	sz[a] += sz[b];
	sz[b] = 0;
	par[b] = a;
}

int main(){
	setIO();
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) par[i] = i, sz[i] = 1;
	for (int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		join(a, b);
	}
	int mx = 0;
	for (int i = 0; i < n; i++){
		mx = max(mx, sz[i]);
	}
	cout << mx << endl;
}

Measured memory_bytes: 5172
import java.util.*
fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var max = 0;
    var ans = 0;
    for (i in 0 until n) {
        val h = sc.nextInt()
        if (max > h) continue;
        max = h
        ans++
    }

        println(ans)
}


Measured memory_bytes: 31268
use std::fmt::Debug;
use std::str::FromStr;

#[allow(dead_code)]
#[allow(deprecated)]
fn read_line_from_stdin() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer.trim_right().to_owned()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_single<T>() -> T
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    T::from_str(buffer.trim_right()).unwrap()
}

#[allow(dead_code)]
#[allow(deprecated)]
fn parse_line_to_multiple<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).unwrap();
    buffer
        .trim_right()
        .split_whitespace()
        .flat_map(|s| T::from_str(s))
        .collect()
}

#[allow(unused_macros)]
macro_rules! parse_line {
    [$( $x:tt : $t:ty ),+] => {
        //declare variables
        $( let $x: $t; )+
        {
            use std::str::FromStr;
            // read
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            #[allow(deprecated)]
            let mut splits = buf.trim_right().split_whitespace();
            // assign each variable
            $(
                $x = splits.next().and_then(|s| <$t>::from_str(s).ok()).unwrap();
            )+
            // all strs should be used for assignment
            assert!(splits.next().is_none());
        }
    };
}

use std::collections::HashMap;

#[derive(Debug, Clone, Copy, PartialEq)]
struct City {
    id: usize,
    born_year: usize,
}

fn main() {
    parse_line![prefecture_count: usize, city_count: usize];

    let mut cities_on_prefectures = HashMap::<usize, Vec<City>>::new();

    for i in 1..prefecture_count + 1 {
        cities_on_prefectures.insert(i, vec![]);
    }

    for i in 1..city_count + 1 {
        parse_line![belonging_prefecture: usize, born_year: usize];

        let city = City {
            id: i,
            born_year: born_year,
        };

        cities_on_prefectures
            .get_mut(&belonging_prefecture)
            .unwrap()
            .push(city);
    }

    let mut idstrings = HashMap::<usize, String>::new();

    for i in 1..prefecture_count + 1 {
        if let Some(cities) = cities_on_prefectures.get(&i) {
            let mut cities = cities.to_vec();
            cities.sort_by_key(|c| c.born_year);
            let id_left = to_id_string(i);
            for (index, city) in cities.into_iter().enumerate() {
                let id_right = to_id_string(index + 1);
                let idstring = format!("{}{}", id_left, id_right);
                idstrings.insert(city.id, idstring);
            }
        }
    }

    for i in 1..city_count + 1 {
        println!("{}", idstrings[&i]);
    }
}

fn to_id_string(x: usize) -> String {
    let right = x.to_string();
    let zero_count = 6 - right.len();

    let mut s = String::new();

    for _ in 0..zero_count {
        s.push('0');
    }
    s.push_str(&right);

    s
}


Measured memory_bytes: 27724
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
  string str;
  cin>>str;
  int a=0;
  int b=0;
  for(int i=0;i<str.length();i++)
  {
    if(str[i]=='A')
    {
        a=i;
        break;
    }
  }
  for(int i=str.length()-1;i>=0;i--)
  {
    if(str[i]=='Z')
    {
        b=i;
        break;
    }
  }
  cout<<b-a+1;


    return 0;
}








Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int ans = pow(10,9);

    vector<vector<int>>CAs(N, vector<int>(M+1));

    for (int i=0; i<N; i++){
        cin >> CAs[i][0];
        for (int j=1; j<M+1; j++){
            cin >> CAs[i][j];
        } 
    }


    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int>Xs(M);
        int cost = 0;
        //各参考書を買うかどうか見ていく
        for (int i=0; i<N; i++){
            //i番目の参考書を買う場合
            if (bit & (1 << i)){
                cost += CAs[i][0];
                for (int j=0; j<M; j++){
                    Xs[j] += CAs[i][j+1];
                }
            }
        }
        bool skill_up = true;
        for (int i=0; i<M; i++){
            if (Xs[i] < X)skill_up = false;
        }
        if (skill_up)chmin(ans, cost);
    }

    if (ans == pow(10,9))cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int A, B, C;

    cin >> A >> B >> C;

    int possible = A - B;
    int remain = C - possible;

    cout << std::max(0,remain) << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

ll mod = 1e9 + 7;

ll calc(ll b, ll exp){
    ll result = 1;
    while(exp > 0){
        if(exp % 2 == 1){
            result = (result * b) % mod;
        }
        exp >>= 1;
        b = (b * b) % mod;
    }
    return result;
}

ll diver(ll a, ll b) {
    return a*calc(b, mod-2)%mod;
}

ll choose(ll n, ll k) {
    ll res = 1;
    for (ll i = n-k+1; i <= n; ++i) {
        res = (res*i)%mod;
    }
    for (ll i = 2; i <= k; ++i) {
        res = diver(res, i);
    }
    return res%mod;
}

int main(){
    ll n, a, b, ans, apow, bpow;
    cin >> n >> a >> b;
    ans = calc(2, n) - 1;
    ans += mod - choose(n, a);
    ans %= mod;
    ans += mod - choose(n, b);
    ans %= mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long f(long long b,long long n)
{
	if (b==1)
	return -1;
	if (!n)
	return 0;
	return f(b,n/b)+n%b;
}
int main()
{
	long long n,s,mini=(1LL<<60);
	cin >> n >> s;
	for (long long i=2;i*i<=n;i++)
	{
		if (f(i,n)==s)
		mini=min(mini,i);
	}
	if (n==s)
	mini=min(mini,n+1);
	long long d=n-s;
	for (long long i=1;i*i<=d;i++)
	{
		if (d%i==0)
		{
			if (f(i+1,n)==s)
			mini=min(mini,i+1);
			if (f(d/i+1,n)==s)
			mini=min(mini,d/i+1);
		}
	}
	if (mini==(1LL<<60))
	mini=-1;
	cout << mini;
}

Measured memory_bytes: 384
import sys
from math import sin, cos, atan

pi = atan(1) * 4

A, B, H, M = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

yukati = H + M / 60.0

theta_zi = 2 * pi * yukati / 12
theta_fun = 2 * pi * yukati

zix = A * sin(theta_zi)
ziy = A * cos(theta_zi)
funx = B * sin(theta_fun)
funy = B * cos(theta_fun)

print("%.15f" % (((zix - funx) * (zix - funx) + (ziy - funy) * (ziy - funy)) ** 0.5))


Measured memory_bytes: 9648
import java.util.*;

public class Main{

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int a = sc.nextInt();
			if((n|m|a) == 0)break;
			ArrayList<ArrayList<int []>> amida = new ArrayList<ArrayList<int[]>>();
			for(int i = 0; i <= 1000; i++){
				amida.add(new ArrayList<int[]>());
			}
			
			for(int i= 0; i < m;i ++){
				int h = sc.nextInt();
				int p = sc.nextInt();
				int q = sc.nextInt();
				amida.get(h).add(new int[]{p,q});
				amida.get(h).add(new int[]{q,p});
			}
			int nowpos = a;
			for(int i = 1000; i >= 0; i--){
				for(int j = 0; j < amida.get(i).size();j++){
					if(nowpos == amida.get(i).get(j)[0]){
						nowpos = amida.get(i).get(j)[1];
						break;
					}
				}
			}
			System.out.println(nowpos);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 63028
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int r, c, k;
  cin >> r >> c >> k;
  vector<vector<int>> g(r, vector<int>(c));
  for (int i = 0; i < k; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[--a][--b] = c;
  }
  const int C = 4;
  vector<vector<vector<long long>>> dp(r, vector<vector<long long>>(c, vector<long long>(C, -(1LL << 60))));
  dp[0][0][0] = 0;
  if (g[0][0] > 0) {
    dp[0][0][1] = g[0][0];
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (j > 0) {
        for (int k = 0; k < C; k++) {
          if (k > 0) {
            dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + g[i][j]);
          }
          dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
        }
      }
      if (i > 0) {
        long long mx = -(1LL << 60);
        for (int k = 0; k < C; k++) {
          mx = max(dp[i - 1][j][k], mx);
        }
        dp[i][j][0] = max(dp[i][j][0], mx);
        dp[i][j][1] = max(dp[i][j][1], mx + g[i][j]);
      }
    }
  }
  long long ans = -(1LL << 60);
  for (int i = 0; i < C; i++) {
    ans = max(ans, dp[r - 1][c - 1][i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 670892
(defun b (n &optional (i 1) (stack nil))
  (if (= n 0)
      (sort stack 
            #'(lambda (a b) 
                (or (string< (car a) (car b))
                    (and (string= (car a) (car b))
                         (> (cadr a) (cadr b))))))
      (let* ((line (read-line))
             (px (multiple-value-list (read-from-string line)))
             (s (car px))
             (p (read-from-string line t nil :start (cadr px))))
        (b (1- n) (1+ i) (cons (list s p i) stack)))))
    
(format t "~{~A~%~}"  (mapcar #'caddr (b (parse-integer (read-line)))))

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int K, A, B;
  std::cin >> K >> A >> B;

  int d = K;
  while(d <= B) {
    if(d >= A) {
      std::cout << "OK" << '\n';
      return 0;
    }
    d += K;
  }

  std::cout << "NG" << '\n';
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p[n+1];
    vector<int>v;
    for(int i=0; i<n; i++)
    {
        cin>>p[i];
        v.push_back(p[i]);
    }
    int flag=0;
    for(int i=1; i<n; i++)
    {
        if(p[i]>p[i-1])
        {
            flag++;
        }
    }
    if(flag==n-1)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        int temp=0;
        sort(p, p+n);
        for(int i=0; i<n; i++)
        {
            if(p[i]!=v[i])
            {
                temp++;
            }
        }
        if(temp==2)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>


struct number{
	char before;
	char after;
};

int main(void)
{
	int i;
	int k;
	int n;
	int m;
	char str1[10 + 1];
	
	int s;
	
	struct number ctable[62 + 1];

	
	while(1){
		scanf("%d",&n);
		if(n == 0) break;
		
		fgets(str1, (sizeof(str1)), stdin);
		
		for(i = 0; i < n; i++){
			fgets(str1,sizeof(str1), stdin);
			ctable[i].before = str1[0];
			ctable[i].after = str1[2];
		}
		
		
		scanf("%d",&m);
		fgets(str1, sizeof(str1), stdin);
		
		
		for(k = 0; k < m; k ++){
			fgets(str1, sizeof(str1), stdin);				
			for(i = 0; i < n; i++){							
				if(ctable[i].before == str1[0]){			
					printf("%c",ctable[i].after);		
					break;
				}
			}
			if(i == n){
				printf("%c",str1[0]);
			}			
		}
		
		
		printf("\n");
	
	}
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)


int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\stdout", "w", stdout);
    }

    int p, q, r;
    cin >> p >> q >> r;
    cout << min(p+q, min(p+r, q+r)) << endl;

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _##i = (b); i <= _##i; ++i)
#define FORD(i, a, b) for (int i = (a), _##i = (b); i >= _##i; --i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

#define TWO(X) (1LL<<(X))
#define CONTAIN(S,X) ((S) & TWO(X))

double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }
int GI(int& x) { return scanf("%lld", &x); }

int n, W;
vector< pair<int,int> > ls[4];
int w[111], v[111];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << (fixed) << setprecision(9) << boolalpha;
    while (cin >> n >> W) {
        REP(i,4) {
            ls[i].clear();
        }

        FOR(i,1,n) {
            cin >> w[i] >> v[i];
            ls[w[i] - w[1]].emplace_back(-v[i], 0);
        }

        REP(i,4) {
            sort(ALL(ls[i]));
            REP(j,SZ(ls[i])) {
                ls[i][j].second = -ls[i][j].first;
                if (j) ls[i][j].second += ls[i][j-1].second;
            }
        }

        int res = 0;
        FOR(a,0,SZ(ls[0])) FOR(b,0,SZ(ls[1])) FOR(c,0,SZ(ls[2])) {
            int has = W - a * w[1] - b * (w[1] + 1) - c * (w[1] + 2);
            if (has < 0) continue;

            int d = has / (w[1] + 3);
            if (d > SZ(ls[3])) d = SZ(ls[3]);

            int cur = 0;
            if (a) cur += ls[0][a-1].second;
            if (b) cur += ls[1][b-1].second;
            if (c) cur += ls[2][c-1].second;
            if (d) cur += ls[3][d-1].second;

            res = max(res, cur);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  //一番素直に考えると、2^2Nを全部ためすやり方が考えられるが、2^(2*18)=6*1e10のため余裕でオーバー
  //右n文字と左ｎ文字に分割して右側を反転して逆の色で塗り分けることでこの作業自体は2^18=262144ぐらいのオーダー
  //input
  int n;
  string s;
  cin>>n>>s;
  map<pair<string,string>,ll>mp;
  ll ans=0;
  
  rep(i,1<<n){
    string red="",blue="";
    rep(j,n){
      if((i>>j)&1)red+=s[j];
      else blue+=s[j];
    }
    mp[{red,blue}]++;
  }

  rep(i,1<<n){
    string red="",blue="";
    rep(j,n){
      if((i>>j)&1)red+=s[n+j];
      else blue+=s[n+j];
    }
    reverse(all(red));
    reverse(all(blue));
    ans+=mp[{blue,red}];
  }
  cout<<ans<<endl;
  
    
  return 0;
}


Measured memory_bytes: 60848
A, B, C ,Req_A ,Req_B = map(int,input().split())
min = 10000000000000
end = True
result = 0

while (Req_A + Req_B) > 0:
    if 2*C < A+B and 0 < Req_A and 0 < Req_B:
        Req_B -= 1
        Req_A -= 1
        result += 2*C
    elif 2*C < A and 0 < Req_A:
        Req_A -= 1
        result += 2*C
    elif 2*C < B and 0 < Req_B:
        Req_B -= 1
        result += 2*C
    elif 0 < Req_A :
        Req_A -= 1
        result += A
    elif 0 < Req_B:
        Req_B -= 1
        result += B
print(result)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    mut n: i64,
  }
  use std::collections::BTreeMap;
  let mut factor = BTreeMap::new();
  for i in 2.. {
    if i * i > n {
      break;
    }
    while n % i == 0 {
      n /= i;
      *factor.entry(i).or_insert(0i64) += 1;
    }
  }
  if n != 1 {
    *factor.entry(n).or_insert(0) += 1;
  }
  let mut ans = 0;
  for &e in factor.values() {
    let mut e = e;
    for i in 1.. {
      if i > e {
        break;
      }
      e -= i;
      ans += 1;
    }
  }

  println!("{}", ans);
}


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

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

    vector<vector<int>> dp1(n + 1, vector<int>(s + 1)), dp2(n + 1, vector<int>(t - s + 1));
    for(int i = 0; i < n; ++i) {
        dp1[i + 1] = dp1[i];
        for(int j = s - b[i]; j >= 0; --j) {
            dp1[i + 1][j + b[i]] = max(dp1[i + 1][j + b[i]], dp1[i][j] + a[i]);
        }
    }
    for(int i = n; i >= 1; --i) {
        dp2[i - 1] = dp2[i];
        for(int j = t - s - b[i]; j >= 0; --j) {
            dp2[i - 1][j + b[i]] = max(dp2[i - 1][j + b[i]], dp2[i][j] + a[i]);
        }
    }

    int ans = 0;
    for(int i = 0; i <= n; ++i) {
        ans = max(ans, dp1[i][s] + dp2[i][t - s]);
    }

    cout << ans << endl;
}



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

int main() {
    int M, D;
    cin >> M >> D;
    int ans = 0;
    for (int i = 1; i <= M; ++i) {
        for (int j = 11; j <= D; ++j) {
            if((j/10) >= 2 && (j%10) >= 2){
                if((j/10) * (j%10) == i) ans++;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
extern crate proconio;
use proconio::{input};

#[allow(unused_imports)]
use std::cmp::Reverse;

fn main() {
    input! {
        n: usize,
        h: [i64; n],
    }
    let mut dp = vec![0; n];
    dp[1] = (h[1] - h[0]).abs();

    for i in 2..n{
        dp[i] = (dp[i - 1] + (h[i] - h[i - 1]).abs()).min(dp[i - 2] + (h[i] - h[i - 2]).abs());
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 3980
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
#define ll long long int


int main()
{
	ll p = 100, i=0, x;
	cin>>x;
	while(p<x)
	{
		p += p/100;
		i++;
	}
    cout << i <<endl;
	return 0;
}

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

int main(int argc, char const *argv[])
{
    long n, m, x;
    cin >> n >> m >> x;
    vector<pair<long, vector<long>>> vec(n, make_pair(0, vector<long>(m)));
    for (int i = 0; i < n; i++)
    {
        cin >> vec.at(i).first;
        for (int j = 0; j < m; j++)
        {
            cin >> vec.at(i).second.at(j);
        }
    }

    long min = LONG_MAX;
    for (int b = 1; b < (1 << n); b++)
    {
        long t = 0;
        vector<long> t_vec(m, 0);
        for (int i = 0; i < n; i++)
        {
            // cout << min << endl;
            if (b & (1 << i))
            {
                t += vec.at(i).first;
                for (int j = 0; j < m; j++)
                {
                    t_vec.at(j) += vec.at(i).second.at(j);
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < m; j++)
        {
            if (t_vec.at(j) < x)
            {
                flag = false;
                break;
            }
        }
        if (flag && min > t)
        {
            min = t;
        }
    }
    if (min == LONG_MAX)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << min << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        string s;
        cin>>s;
        int n=s.length();
        for(int i=0;i<n;i++)
        {
            cout<<"x";
        }
        
        // your code goes here
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	int a,b,c,n;
	
	
	scanf("%d",&n);
	for(;n>0;n--)
	{
		scanf("%d %d %d",&a,&b,&c);
		if((a*a==b*b+c*c)||(b*b==a*a+c*c)||(c*c==a*a+b*b))
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 580
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B,C,D = imn()
S = list(input())

def can_reach(a, b):
    reachable = True
    for i in range(a-1, b-1):
        if S[i] != '#' or S[i+1] != '#': continue
        reachable = False
    return reachable

def takeoverable(a, b):
    cantakeover = False
    for i in range(a-2, b-1):
        if S[i] == '#' or S[i+1] == '#' or S[i+2] == '#': continue
        cantakeover = True
    return cantakeover

ans = True
if C == D:
    ans = False
if not can_reach(A, C) or not can_reach(B, D):
    ans = False
if C > D:
   if not takeoverable(B,D):
       ans = False
print('Yes' if ans else 'No')

Measured memory_bytes: 7208
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[81*81*27 + 1];
int n,m;

int chenge(vector<int> v)
{
	int ret = 0;
	REP(i,v.size())
	{
		ret = ret * 3 + v[i];
	}
	return ret;
}

int dfs(vector<string> sv,vector<int> lv)
{
	int now = chenge(lv);
	if(mp[now] != -1)
	{
		return mp[now];
	}
	if(sv.size() <= 1)
	{
		return 0;
	}
	
	int ret = 100000;
	
	REP(i,m)
	{
		bool flag = false;
		REP(j,sv.size())
		{
			if(sv[0][i] != sv[j][i])flag = true;
		}
		if(!flag)continue;
		vector<string> A,B;
		
		REP(j,sv.size())
		{
			if(sv[j][i] == '1')
			{
				A.PB(sv[j]);
			}
			else
			{
				B.PB(sv[j]);
			}
		}
		vector<int> X,Y;
		X = lv;Y = lv;
		X[i] = 1;Y[i] = 2;
		ret = min(ret,max(dfs(A,X),dfs(B,Y))+1);
	}
	
	return mp[now] = ret;

}
	

int main()
{
	while(cin >> m >> n,m|n)
	{
		memset(mp,-1,sizeof(mp));
		
		vector<string> v;
		
		REP(i,n)
		{
			string tmp;
			cin >> tmp;
			v.PB(tmp);
		}
		
		cout << dfs(v,vector<int>(m)) << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, m, x, y;
    int *A, *B;
    cin >> n;
    cin >> m;
    cin >> x;
    cin >> y;
    A = new int[n];
    B = new int[m];
    for(int i=0; i<n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >>B[i];
    }
    int xmax = -1000, ymin = 1000;
    for (int i = 0; i < n; i++)
    {
        xmax = max(xmax, A[i]);
    }
    for (int i = 0; i < m; i++)
    {
        ymin = min(ymin, B[i]);
    }
    if(xmax < ymin && x < ymin && xmax < y) cout << "No War" << endl;
    else cout << "War" << endl;
    delete[] A;
    delete[] B;
 }

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

#define SE second
#define FI first
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int) (x).size())

#define _ << " " <<
#define TR(x) cout << #x _ x << endl

using namespace std;
const int INF = (int) 1e9 + 5;

int main() {
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    bool haveOdd = false;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        haveOdd |= (a[i] % 2 == 1);
    }

    if (haveOdd) {
        cout << (1LL << (n - 1)) << endl;
    } else if (p == 0) {
        cout << (1LL << n) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N,T;
signed main() {
    cin >> N>>T;
    int ans=114514;
    for(int i=0;i<N;i++){
        int c,t;
        cin>>c>>t;
        if(t<=T)ans=min(ans,c);
    }
    if(ans==114514)cout<<"TLE"<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline

P = 10 ** 9 + 7
Q = 13


@nb.njit("i8(i8[:])", cache=True)
def solve(S):
    N = len(S)
    dp = [[0] * Q for _ in range(N + 1)]
    dp[0][0] = 1
    for i in range(N):
        D = S[i]
        if D == -1:
            for d in range(10):
                for j in range(Q):
                    dp[i + 1][(10 * j + d) % Q] += dp[i][j]
        else:
            d = int(D)
            for j in range(Q):
                dp[i + 1][(10 * j + d) % Q] += dp[i][j]

        for j in range(Q):
            dp[i + 1][j] %= P

    return dp[N][5]


def main():
    S = input().rstrip()

    S = np.array([int(s) if s != "?" else -1 for s in S], dtype=np.int64)
    ans = solve(S)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

using int64 = long long;

int main()
{
  int N;

  cin >> N;
  map< int, int > mp;
  for(int i = 0; i < N; i++) {
    int k;
    cin >> k;
    mp[k]++;
  }
  int ret = 0;
  for(auto &p : mp) {
    if(p.first <= p.second) ret += p.second - p.first;
    else ret += p.second;
  }
  cout << ret << endl;
}


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

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = (n / (a+b) * a) + min(a, n % (a+b));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;
int main(){
    int n,m;cin >> n >> m;
    vector<vector<pair<int,ll>>> g(n);
    for(int i=0;i<m;i++){
        int a,b;ll c;
        cin >> a >> b >> c;
        a--,b--;
        g[a].push_back({b,-c});
    }
    vector<ll> d(n,INF);
    bool f=false;
    d[0]=0;
    for(int i=0;i<=2*n;i++){
        for(int j=0;j<n;j++){
            if(d[j]>=INF/2){
                continue;
            }
            for(auto x:g[j]){
                if(d[x.first]>d[j]+x.second){
                    d[x.first]=d[j]+x.second;
                    if(x.first==n-1&&i==2*n){
                        f=true;
                    }
                }
            }
        }
    }
    if(!f){
        cout << -d[n-1] << endl;
    }
    else{
        cout << "inf" << endl;
    }
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <math.h>
#include <set>
  
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
  
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<" "<<2*(a+b)<<endl;
}


Measured memory_bytes: 3076
#include <cstdio>
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
    // int n;
    // while (cin >> n) {
    //     cout << n*n*n << endl;
    // }
    int n;
    while (scanf("%d", &n) == 1) {
        printf("%d\n", n * n * n);
    }

    return 0;
}



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

int N, C, X;
int D[30][30], t[3][30];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> C;
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            cin >> D[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> X;
            t[(i+j)%3][X-1]++;
        }
    }
    int ans = 1 << 30;
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            if(i == j) continue;
            for(int k = 0; k < C; k++){
                if(k == i || k == j) continue;
                int tt = 0;
                for(int l = 0; l < C; l++) tt += D[l][i]*t[0][l];
                for(int l = 0; l < C; l++) tt += D[l][j]*t[1][l];
                for(int l = 0; l < C; l++) tt += D[l][k]*t[2][l];
                ans = min(ans, tt);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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


int n;

int a[100005],dp[100005];


int func(int i)
{
    if(i+1==n)return 0;

    int p=1e9,q=1e9;

    if(dp[i]!=-1)return dp[i];

    if(i+1<n)p=abs(a[i]-a[i+1])+func(i+1);
    if(i+2<n)q=abs(a[i]-a[i+2])+func(i+2);

    return dp[i]=min(p,q);

}


int main()
{
    scanf("%d",&n);
    memset(dp,-1,sizeof dp);

    for(int i=0;i<n;i++)scanf("%d",a+i);

    printf("%d\n",func(0));

    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e9;
ll MOD = 1e9;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()
#define count(V,x) ub(ALL(V),x,cmp) - lb(ALL(V),x,cmp)

struct cube{
  ll a, b, c, d, orien;
  cube(ll _a, ll _b, ll _c, ll _d): a(_a), b(_b), c(_c), d(_d), orien(1){
    ll m = min({a,b,c,d});
    if (a == b && a == c && a == d)orien = 4;
    else if (a == c && b == d)orien = 2;
  }

  bool fit(cube cmp){
    return a == cmp.a && b == cmp.b && c == cmp.c && d == cmp.d;
  }

  cube rotate(){
    return cube({b,c,d,a});
  }

  void pp(){
    cout<<a<<' '<<b<<' '<<c<<' '<<d<<'\n';
  }
};

bool cmp(cube a, cube b){
  if (a.a != b.a)return a.a < b.a;
  if (a.b != b.b)return a.b < b.b;
  if (a.c != b.c)return a.c < b.c;
  return a.d < b.d;
}

bool biggay = 0;

cube bal(cube t){
  cube q = t.rotate();
  cube r = q.rotate();
  cube u = r.rotate();
  if (cmp(q, t))t = q;
  if (cmp(r, t))t = r;
  if (cmp(u, t))t = u;
  return t;
}

ll N;
ll a,b,c,d;
vector<cube> V,faces,comp;
vi rep;

int main(){
  // freopen("in.txt","r",stdin);
  cin >> N;
  for (int i=0;i<N;++i){
    cin >>a >> b >> c >> d;
    V.pb({a,b,c,d});
    V[i] = bal(V[i]);
  }
  sort(ALL(V), cmp);

  ll ans=0;
  for (int i=0;i<N-1;++i){
    // Base
    // if (i != 0)continue;
    for (int j=i+1;j<N;++j){
      // if (j != 5)continue;
      cube top = V[i];
      cube btm = V[j];
      for (int k=0;k<4;++k){
        ll r = 1;

        faces.pb(bal(cube(top.d,top.c,btm.c,btm.b)));
        faces.pb(bal(cube(top.c,top.b,btm.d,btm.c)));
        faces.pb(bal(cube(top.b,top.a,btm.a,btm.d)));
        faces.pb(bal(cube(top.a,top.d,btm.b,btm.a)));

        sort(ALL(faces), cmp);

        r *= faces[0].orien;
        r *= faces[1].orien;
        r *= faces[2].orien;
        r *= faces[3].orien;
        
        comp.pb(faces[0]);
        rep.pb(1);

        if (comp.back().fit(faces[1])){
          ++rep.back();
        }else{
          comp.pb(faces[1]);
          rep.pb(1);
        }
        if (comp.back().fit(faces[2])){
          ++rep.back();
        }else{
          comp.pb(faces[2]);
          rep.pb(1);
        }
        if (comp.back().fit(faces[3])){
          ++rep.back();
        }else{
          comp.pb(faces[3]);
          rep.pb(1);
        }

        for (int k=0;k<SZ(comp); ++k){
          cube it = comp[k];
          int cnt = count(V, it);
          if (V[i].fit(it))--cnt;
          if (V[j].fit(it))--cnt;
          while(rep[k]){
            --rep[k];
            r *= cnt;
            cnt--;
          }
        }
        ans += r;
        top = top.rotate();
        rep.clear();
        faces.clear();
        comp.clear();
      }
    }
  }
  cout<<ans/3;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n, i, a, min = 1000000, max = -1000000;
	long long sum = 0;
	scanf("%d", &n);

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

		if(min > a) min = a;
		if(max < a) max = a;
		sum += a;
	}

	printf("%d %d %ld\n", min, max, sum);

	return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <fstream>
#include <cstring>

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	string s;
	int res1 = 0, res2 = 0;

	cin >> s;
	n = s.length();

	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] != '0')
			{
				res1++;
			}
			if (s[i] != '1')
			{
				res2++;
			}
		}
		else
		{
			if (s[i] != '1')
			{
				res1++;
			}
			if (s[i] != '0')
			{
				res2++;
			}
		}
	}

	cout << min(res1, res2) << '\n';
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,ans=1;
string s;

signed main() {
    cin >> n >> s;
    rep11(i,n) {
        if (s[i-1] != s[i]) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>vec;
  int n,m,a[222222],x[222222]={0};
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a[i];
    x[a[i]]++;
  }
  for(int i=1;i<=n;i++){
    if(x[i]!=0) vec.push_back(x[i]);
  }
  int ans=0,z=vec.size();
  if(z-m<0) ans=0;
  else{
    sort(vec.begin(),vec.end());
    for(int i=0;i<z-m;i++) ans+=vec[i];
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  for (int i = 0; i < N; i++){
    cin >> s[i];
  }
  vector<int> dp(10, -INF);
  dp[0] = 0;
  for (int i = 0; i < N; i++){
    vector<int> dp2 = dp;
    for (int j = 0; j < 10; j++){
      dp2[(j + s[i]) % 10] = max(dp2[(j + s[i]) % 10], dp[j] + s[i]);
    }
    dp = dp2;
  }
  int M = 0;
  for (int i = 1; i < 10; i++){
    M = max(M, dp[i]);
  }
  cout << M << endl;
}

Measured memory_bytes: 256