akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	if (num[1] == 1) {
		cout << "1\n";
		return 0;
	} 
	else if (num[1] > 1) {
		cout << "0\n";
		return 0;
	}

	int ans = 0;
	for (int i = 1; i <= 1e6; ++i) {
		if (num[i] && num[i] == 1) {
			bool div = false;
			for (int j = 2; j * j <= i; ++j) {
				if (i % j == 0) {
					if (num[j]) {
						div = true;
						break;
					}

					int k = i / j;
					if (k != j && num[k]) {
						div = true;
						break;
					}
				}
			}

			if (!div) {
				++ans;
			}
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 7140
#include<bits/stdc++.h>
using namespace std;
/*
    By: Umang Srivastava
*/
#define lli long long int
#define ld long double
#define mod 1e9+7
#define lp(var,start,end,inc) for (var = start; var <end ; var=var+inc)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<lli>
#define pll pair<lli,lli> 
#define vpll vector<plli>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s;
    cin>>t;

    int l1=s.length(), l2=t.length(),i,j;
    int c=0,ans=l1;
    for(i=0;i<=l1-l2;i++)
    {
    	c=0;
    	for(j=0;j<l2;j++)
    	{
    		if(s[i+j]!=t[j])
    			c++;
    	}
    	ans=min(ans,c);
    }
    cout<<ans<<"\n";


}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;

using mint = modint998244353;

//S is the data type that is stored in the segment tree nodes
struct S {
	modint value; //Stores the value represented by all the digits in the segment
	int digits; //Stores how many digits are in this node
};
//For example, a node for "3572" will have value = 3572 and digits = 4

//Op is the operation that merges two segments into one
S op(S l, S r) {
	//The new value will be the left value multiplied by 10^(number of digits of the right value) + the right value
	//The new number of digits is the sum of the number of digits from both segments
	return S { l.value * modint(10).pow(r.digits) + r.value, l.digits + r.digits };
}

//e is created such that op(l,e) == l and op(e,r) == e. It should not modify the other value that is not e.
//The value 0 works since it will add nothing, and digits = 0 doesn't add more digits.
S e() {
	return S { 0, 0 };
}


//F contains the attributes of the function that is applied to a segment
//The actual function is implemented in "mapping"
struct F {
	modint digit; //Stores the digit to assign to the segment
	int t; //Stores the "time" of the operation, later assignments have priority over early ones
		   //Special case when t == -1, in this case the function will act as the identity function (it will not modify the node)
};


//mapping is the function that is applied to a segment with "apply"
//This function replaces every digit in the segment
S mapping(F l, S r) {
	if (l.t == -1) {
		//Special case, do not modify the node.
		return r;
	}
	//The value has to be replaced with 'l.digit' repeated 'r.digit' times.
	//We can do that with the formula 111...1 (n times) = ((10^n)-1)/9 and multiply that by 'l.digit'
	return S { (modint(10).pow(r.digits) - 1) * modint(9).inv() * l.digit,	r.digits };
}

//composition is the way to combine two functions that were applied to the same segment.
//If we have two updates, the one with the latest time will be kept
F composition(F l, F r) {
	return F { l.t > r.t ? l : r };
}

//id should represent a function that does not modify the node.
//In this case, set t=-1 since it is the special case
F id() {
	return F { 0, -1 };
}

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

	int n;
	cin >> n;
	vector<S> arr(n, S { 1, 1 }); //Fill with '1' (also, they have 1 digit)

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

	int t = 0;

	int q;
	cin >> q;
	while (q--) {
		int x, y;
		cin >> x >> y;
		
		x--;
		y--;
		
		y++; //The right has to be excluded
		
		int d;
		cin >> d;
		
		//'apply' applies 'composition' to the segment [x,y) with attributes digit=d and the time is always increased by 1
		seg.apply(x, y, F { modint(d), t++ });
		
		//
		cout << seg.all_prod().value.val() << "\n";
	}

}


Measured memory_bytes: 10840
fun main(args: Array<String>) {
    val (x, y) = readListInt()
    var flag = false
    for (i in 0..x) {
        if ( y == (2 * i + 4 * (x - i))){
            flag = true
            break
        }
    }
    if (flag) println("Yes") else println("No")


}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 36388
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll

int main() {
  ll n,q;
  cin>>n;
  vec s(n);
  loop(i,n){
    cin>>s[i];
  }
  cin>>q;
  vec t(q);
  loop(i,q){
    cin>>t[i];
  }
  ll count=0;
  map<ll,ll> check;
  loop(i,q){
    loop(j,n){
      if(t[i]==s[j]&&check[t[i]]!=1){
        count++;
        check[t[i]]++;
      }
    }
  }
  
  cout<<count<<endl;


}


Measured memory_bytes: 3160
#include <stdio.h>
int linerSearch (int, int, int *, int *);
#define N 10000
  
int main (){
  int n,m,a[N],k,l,b[N],i,ans;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&m);
    a[i]=m;
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&l);
    b[i]=l;
  }
  /*for(i=0;i<n;i++){
    printf("%d",a[i]);
  }
  printf("\n");
    for(i=0;i<n;i++){
    printf("%d",b[i]);
    }*/
  
    ans=linerSearch(k,n,a,b);
    printf("%d\n",ans);
  return 0;
}

int linerSearch(int k, int n, int a[],int b[]){
  int i,j;
  int count = 0;
  for(i=0;i<k;i++){
    for(j=0;j<n;j++){
      if(b[i]==a[j]){
	count++;
	break;
      }
    }
  }
  return count;
}



Measured memory_bytes: 2052
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	n := x%100/5
	if x%100%5 > 0 {
		n++
	}
	if n <= x/100 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	// if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
void solve()
{
	ll n, d, a;
	cin >> n >> d >> a;
	vector<pll> x(n);
	ll sum = 0;
	set<pll> st;
	for(int i = 0; i < n; ++i){
		cin >> x[i].F >> x[i].S;
	}
	sort(all(x));
	ll ans = 0;
	cout << endl;
	for(int i = 0; i < n; ++i){
		while(!st.empty() && x[i].F - (*st.begin()).F  > 2 * d) sum -= (*st.begin()).S, st.erase(st.begin());
		x[i].S -= sum;
		if(x[i].S < 0) continue;
		ll cur = (x[i].S + a - 1) / a;
		// cout << cur << " " << i  << " " << sum << endl;
		ans += cur;
		cur *= a;
		st.insert({x[i].F, cur});
		sum += cur;
	}
	cout << ans;


}

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

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int fact(int n) {
	if (n > 1)
		return n * fact(n - 1);
	else
		return 1;
}

int rec(int length, int* a) {
	if (length == 1)
		return 0;

	int x = fact(length - 1);

	for (int i = 1; i < length; i++)
		if (a[i] > a[0])
			a[i] -= 1;

	return a[0] * x + rec(length - 1, a + 1);
}

int main(int argc, char const* argv[]) {
	int p[8];
	int q[8];

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> p[i];

	for (int i = 0; i < n; i++)
		cin >> q[i];

	int a = rec(n, p);
	int b = rec(n, q);

	int ans = a - b;
	if (ans < 0)
		ans *= -1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);

            int n = Integer.parseInt(sc.next());
            int m = Integer.parseInt(sc.next());
            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
            int[] par = new int[n+1], rank = new int[n+1];
            int a, b, count = 0;
            
            for(int i=0; i<n; i++){
            	map.put(Integer.parseInt(sc.next()), i+1);
            }
            
            for(int i=0; i<n+1; i++){
            	par[i] = i;
            	rank[i] = 0;
            }
            
            for(int i=0; i<m; i++){
            	a = Integer.parseInt(sc.next());
            	b = Integer.parseInt(sc.next());
            	
            	unite(a, b, par, rank);
            }
            
            for (Integer key : map.keySet()) {
            	if(same(key, map.get(key), par)){
        			count++;
        		}
    		}

            System.out.println(count);
            sc.close();
        }
        
        // 各unionのリーダーを返す関数
        public static int getLeader(int a, int[] par){            
        	return par[a] == a ? a : (par[a] = getLeader(par[a], par));
        }
      
        public static boolean same(int a, int b, int[] par){
        	return getLeader(a, par) == getLeader(b, par);
        }
        
        public static void unite(int a, int b, int[] par, int[] rank){
        	a = getLeader(a, par);
        	b = getLeader(b, par);
        	
        	if(a == b){
        		return;
        	}
        	
        	if(rank[a] < rank[b]){
        		par[a] = b;
        	}else{
        		par[b] = a;
        		if(rank[a] == rank[b]){
        			rank[a]++;
        		}
        	}
        }
    }
	

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

using namespace std;

using Int = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
    int N;
    cin >> N;
    vector<int> B(N - 1);
    int ans = 0;
    for (int i = 0; i < N - 1; ++i) cin >> B[i];
    for (int i = 0; i < N - 2; ++i) ans += min(B[i], B[i + 1]);
    ans += B[0] + B[N - 2];
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String[] args) {
		//宣言
		int n[]= new int[101];
		int x[]= new int[300];
		sc = new Scanner(System.in);
		int i=1;
		int s[]= new int[101];
		int sum=0;
		int count=0;
		//入力
		//System.out.println("Please input n and x below:");
		for(;;) {
			n[i]=sc.nextInt();
			x[i]=sc.nextInt();
			if(n[i]==0 && x[i]==0) {
				break;
			}
			i++;
		}
		i=1;
		for(;;) {
			if(n[i]==0 && x[i]==0) {
				break;
			}
			for(int j=1;j<=n[i];j++) {//s[j]=jとしてループで利用
				s[j]=j;
			}
			i++;
		}
		//出力
		i=1;
		for(;;) {
			if(n[i]==0 && x[i]==0) {
				break;
				}
			for(int l=1;l<=n[i];l++) {
				for(int m=l+1;m<=n[i];m++) {
					for(int p=m+1;p<=n[i];p++) {							
						sum=s[l]+s[m]+s[p];
						if(x[i]==sum) {
							count+=1;
							//System.out.println(s[l]+" "+s[m]+" "+s[p]);	
						}
					}
				}
			}
			i++;
			System.out.println(count);
			count=0;
		}
	}
}


Measured memory_bytes: 26496
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a >= k) {cout << k; return 0;}
    else k -= a;
    if(b >= k) {cout << a; return 0;}
    else {
    k -= b;
    cout << a - k;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e9+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
void solve()
{
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=0;i<n;i++)
    cout<<s[i]<<t[i];
    cout<<endl;
}
int main()
{
   solve();
   return 0;
}

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

typedef long long ll;

void solve() {
    ll N, a, ans = 0, m, x, y;
    cin >> N;
    vector<int> b(N + 1), l(N + 2), r(N + 2);
    rep(i, N) {
        cin >> a;
        b[a] = i + 1;
    }
    rep(i, N + 2) {
        l[i] = i;
        r[i] = i;
    }
    for (int i = N; i > 0; i--) {
        m = b[i];
        x = l[m];
        y = r[m];
        ans += (m - x + 1) * (y - m + 1) * i;
        r[x - 1] = y;
        l[y + 1] = x;
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val (N, A, B) = readLine()!!.split(" ").map { it.toInt() }
    val h = LongArray(N)
    for (i in 0 until N) {
        h[i] = readLine()!!.toLong()
    }

    var ok = 1000000000L
    var ng = -1L
    fun isOk(num: Long) : Boolean {
        var count = 0L
        for (i in 0 until N) {
            val remains = h[i] - B * num
            if (remains > 0) {
                count += remains / (A-B) + if (remains %(A-B) > 0) 1 else 0
            }
        }
        return count <= num
    }

    while (Math.abs(ok - ng) > 1L) {
        val mid = (ok + ng) / 2L

        if (isOk(mid)) {
            ok = mid
        } else {
            ng = mid
        }
    }

    println(ok)
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
  }

  sort(ALL(a));
  vector<ll> su(n);
  ll sum = 0;
  REP(i, n) {
    sum += a[i];
    su[i] = sum;
  }

  vector<ll> diff(n-1);
  REP(i, n-1) {
    diff[i] = a[i+1] - su[i];
  }

  int now = -1;
  REP(i, n-1) {
    if(su[i] < diff[i]) now = i;
  }

  cout << n-now-1 << endl;
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
# #import sys
# input = sys.stdin.readline

n,m = list(map(int,input().split()))
x = list(map(int,input().split()))
x.sort()
#各座標の、右隣の座標までの距離を求める
right_distance = [j-i for i,j in zip(x,x[1::])]
right_distance.sort()
ret = 0
while n < m:
    ret += right_distance.pop(0)
    m -= 1
print(ret)

Measured memory_bytes: 13968
#include<stdio.h>

int main(void){
    int i;
    int N;
    scanf("%d",&N);

    int A[N+2];
    long B[N+2];
    int K[N+2];

    long sum_K=0;
    
    for(i=1;i<N+2;i++){
        scanf("%d",&A[i]);
    }
    for(i=1;i<N+1;i++){
        scanf("%ld",&B[i]);
    }
    B[N+1]=0;

    for(i=1;i<N+2;i++){
        if(A[i]>=B[i]){
            K[i]=B[i];
        }else if(A[i+1]>(B[i]-A[i])){
            K[i]=A[i];
            B[i+1]+=(B[i]-A[i]);
        }else{
            K[i]=A[i];
            B[i+1]+=A[i+1];
        }
    }

    for(i=1;i<N+2;i++){
        sum_K+=K[i];
    }

    printf("%ld",sum_K);

    return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <bitset>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <cfloat>
#include <initializer_list>
#include <iomanip>
#include <functional>
#include <unordered_map>
#include <regex>

using namespace std;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N + 1);
  long long sum = 0;
  for (int i = 0; i < N; ++i)
    {
      cin >> A[i];
      sum += A[i];
    }
  long long s = N * (N + 1) / 2;
  if (sum % s) return cout << "NO" << endl, 0;
  A[N] = A[0];
  long long k = sum / s;
  for (int i = 0; i < N; ++i)
    {
      long long d = A[i + 1] - A[i];
      if (k - d < 0 || (k - d) % N) return cout << "NO" << endl, 0;
    }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
N = input()
N = int(N)
t_list = [0]
x_list = [0]
y_list = [0]
for i in range(N):
    txy = input()
    t, x, y = txy.split()
    t = int(t)
    x = int(x)
    y = int(y)
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)



for i in range(1, N+1):
    t = t_list[i] - t_list[i-1]
    x = abs(x_list[i] - x_list[i-1])
    y = abs(y_list[i] - y_list[i-1])
    xy = x+y
    if t%2 == xy%2:
        res = 'Yes'
    elif not t%2 == xy%2:
        res = 'No'
    if t < xy:
        res = 'No'

print(res)


Measured memory_bytes: 11768
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
typedef long long lint;
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(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

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

    int N;
    cin >> N;
    vector<int> h(N + 1, 0);
    rep(i, 1, N + 1) { cin >> h[i]; }
    vector<int> dp(N + 10, 0);
    dp[2] = dp[1] + abs(h[2] - h[1]);
    // cout << dp[1] << " " << dp[2] << endl;
    rep(i, 3, N + 1) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]),
                    dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[N] << endl;
}

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

vector<ll> fact, fact_inv;
// 繰り返し二乗法
ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%NUM;
		a=a*a%NUM;
		b>>=1;
	}
	return res;
}
void make_fact(int n){
	fact.resize(n+1);
	fact_inv.resize(n+1);
	fact[0] = fact[1] = 1;
	for(int i(2);i<=n;++i){
		fact[i] = (fact[i-1] * i)%NUM;
	}
	fact_inv[n]=power(fact[n], NUM-2);
    for(int i(n-1);i>0;--i){
		fact_inv[i]=fact_inv[i+1]*(i+1)%NUM;
	}
}

ll nCr(ll n, ll r){
	if(n == r || r == 0){
		return 1;
	}else{
		return (fact[n]*fact_inv[r])%NUM*fact_inv[n-r]%NUM;
	}
}

map<ll,ll> get_div2(ll n){
	map<ll,ll> div{};
	ll t(2);
	while(n >= t * t){
		if(n % t == 0){
			n /= t;
			if(div.count(t) == 0) div[t] = 1;
			else div[t]++;
		}else{
			t++;
		}
	}
	if(n != 1){
		if(div.count(n) == 0) div[n] = 1;
		else div[n]++;
	}
	return div;
}

int main(){
	int n;
	ll m;
	cin >> n >> m;
	if(m == 1){
		cout << 1 << endl;
		return 0;
	}
	map<ll,ll> mp = get_div2(m);
	make_fact(10 * n);
	ll ans(1);
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        int p = itr->second;
		ans *= (nCr(p+n-1,p))%NUM;
		ans %= NUM;
    }
	cout << ans << endl;
	return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    int num = 0;
    REP(i,n){
        num+= (s[i]=='I'?1:-1);
        ans = max(ans,num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
inputlist = list(map(int, input().split()))
snum = inputlist[0]
kindofsweets = inputlist[1]
setofkind = []
for i in range(kindofsweets):
    input()
    setofkind += (list(map(int, input().split())))
counter = 0
for i in range(snum):
    if i + 1 not in setofkind:
        counter += 1
print(counter)

Measured memory_bytes: 9296
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }



//---------- 1000000007 ----------
const int MOD = 1000000007;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_div(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}
int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_div(p, i);
	}
	return p;
}
int m_comb_with_rep(int n, int r)
{
	return m_comb(n + r - 1, r);
}
int m_perm(int n, int r)
{
	int a = 1;
	for (int i = n; i > n - r; i--)
	{
		a = m_mul(a, i);
	}
	return a;
}

int N, K;
vector<int> _link[100001];
int _ans = 1;


void func(int depth, int parent, int n)
{
	int a = K - min(2LL, depth);
	int r = 0;
	for (int l : _link[n])
	{
		if (l != parent)
		{
			r++;
			func(depth + 1, n, l);
		}
	}

	if (r == 0)
	{
		return;
	}

	int p = m_perm(a, r);
	_ans = m_mul(_ans, p);
}

signed main()
{
	cin >> N >> K;
	REP(i, N - 1)
	{
		int a, b;
		cin >> a >> b;
		_link[a].push_back(b);
		_link[b].push_back(a);
	}

	func(1, -1, 1);
	cout << m_mul(_ans, K) << endl;
}



Measured memory_bytes: 13316
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
struct dsu
{
	vector<int> par, sz;
	int comp;
	dsu(int n)
	{
		comp = n;
		par.assign(n + 1, -1);
		iota(par.begin(), par.end(), 0);
		sz.assign(n + 1, 1);
	}
	int find(int x)
	{
		if (x != par[x])
			return (par[x] = find(par[x]));
		return par[x];
	}
	bool unite(int x, int y)
	{
		int a = find(x);
		int b = find(y);
		if (a != b)
		{
			if (sz[a] < sz[b])
			{
				par[a] = b;
				sz[b] += sz[a];
			}
			else
			{
				par[b] = a;
				sz[a] += sz[b];
			}
			comp--;
			return true;
		}
		else
			return false;
	}
	int countSet()
	{
		return comp;
	}
	int sizeOfSet(int i)
	{
		return sz[find(i)];
	}
};
void solve(int tc)
{
	int n, m;
	cin >> n >> m;
	dsu D(n);
	while (m--)
	{
		int u, v;
		cin >> u >> v;
		D.unite(u, v);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, D.sizeOfSet(D.find(i)));
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define fl long double
#define pb push_back
#define mk make_pair
#define endl "\n"
#define ff first
#define ss second
#define mt make_tuple
#define np next_permutation
#define mod 998244353
#define pi 3.141592653589793238
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}

int main()
{
    fastio;
    ll i,j,k,n,m,t;
    cin>>n;
    ll ans=0;
    ll fin=0;
    while (n % 2 == 0)
    {
        ans++;
        n = n/2;
    }
    if(ans>0)
    {
        ll tp=1;
        while(tp*(tp+1)/2<ans)
        {
            tp++;
        }
        if(tp*(tp+1)/2!=ans)
        {
            tp--;
        }
        fin=fin+tp;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        ans=0;
        while (n % i == 0)
        {
            ans++;
            n = n/i;
        }

        if(ans>0)
        {
           ll tp=1;
           while(tp*(tp+1)/2<ans)
           {
                tp++;
           }
           if(tp*(tp+1)/2!=ans)
           {
               tp--;
           }
           fin=fin+tp;
        }
    }

    if(n>2)
    {
        fin++;
    }
    cout<<fin<<endl;
    return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define I inline
//#define R register int
namespace io{
    const int l=1<<19;
    char buf[l],*s,*t,c;
    char gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            return s==t?EOF:*s++;
        }
        return *s++;
    }
    template<class IT>void gi(IT &x){
        x=0;c=gc();while(c<'0'||c>'9')c=gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gc();}
    }
};
using io::gi;
template<class IT>void chkmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>void chkmax(IT &a,IT b){if(a<b)a=b;}
const int N=200005,K=2000,M=K<<1|1,L=M<<1|1,p=1000000007,p2=500000004;
int n,dp[M][M],c[L][M],a,b,x[N],y[N],s;
void upd(int &a,int b){a=a+b<p?a+b:a+b-p;}
void sub(int &a,int b){a=a-b<0?a-b+p:a-b;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		++dp[K-a][K-b];
		x[i]=a;y[i]=b;
	}
	for(int i=1;i<M;i++)upd(dp[i][0],dp[i-1][0]);
	for(int i=1;i<M;i++)upd(dp[0][i],dp[0][i-1]);
	for(int i=1;i<M;i++)for(int j=1;j<M;j++){
		upd(dp[i][j],dp[i-1][j  ]);
		upd(dp[i][j],dp[i  ][j-1]);
	}
	for(int i=0;i<L;i++)c[i][0]=1;
	for(int i=1;i<L;i++)for(int j=1;j<=i&&j<M;j++){
		upd(c[i][j],c[i-1][j  ]);
		upd(c[i][j],c[i-1][j-1]);
	}
//	for(int i=1;i<=n;i++)printf("dp[%d][%d]=%d\n",x[i],y[i],dp[K+x[i]][K+y[i]]);
	for(int i=1;i<=n;i++)upd(s,dp[K+x[i]][K+y[i]]);
	for(int i=1;i<=n;i++)sub(s,c[(x[i]+y[i])<<1][x[i]<<1]);
//	for(int i=1;i<=n;i++)printf("c [%d][%d]=%d\n",x[i],y[i],c[(x[i]+y[i])<<1][x[i]<<1]);
	s=(ll)s*p2%p;
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 189184
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define pu(n) cout << n; 
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
int i,j,a[100000];
long long dp[100001];
long long  f=1000000007;
int main(void){
		int n;//max10e5
		cin >> n;
		int m;//max10e5
		cin >> m;
		rep(i,0,m){
			cin >> a[i];
		}
		dp[0]=1;
		if(a[0]==1){
			dp[1]=0;
			j++;
		}else{
			dp[1]=1;
		}
		rep_(i,2,n){
			if(j<m && a[j]==i){
				dp[i]=0;
				j++;
			}
			else{
				dp[i]=(dp[i-1]+dp[i-2])%f;
			}
		}
		
		puts(dp[n]);
		return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
    int a = 0, b = 0, c = 0;
    cin >> a;
    cin >> b;
    cin >> c;
    if (b * c >= a) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=5050;
//templete
int main() {
	int N;
	cin>>N;
	vint v;
	for(int i=0;i<26;i++)
		v.pb(0);
	map<vint,ll> pam;
	for(int i=0;i<N;i++){
		vint w=v;
		string S;
		cin>>S;
		for(int i=0;i<S.length();i++){
			w[S[i]-'a']++;
		}
		pam[w]++;
	}
	ll ans=0;
	for(auto p:pam){
		ll x=p.second;
		ans+=x*(x-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <vector>

using namespace std;

//貪欲法で解く。
// 貪欲法についてわかりやすい理解の説明がコメントに流れてきたので載せておく。
// nueko TATAKIさん
//貪欲法: ある局面で最善の行動を選択する。それが全体にとっても最適な行動になる場合はそのまま解法として使える (私の理解では)


int main(){
  int n;
  cin >> n;
  vector<long long> hi(n);
  for(int i=0; i<n; i++) cin >> hi[i];

  bool outFlag = false;
  int prevalue = -999;
  for(int i=0; i<n; i++){
    if( prevalue <=  hi[i] - 1 ){
      prevalue = hi[i] - 1;
    }else if( prevalue <= hi[i] ){
      prevalue = hi[i];
    }else{
      outFlag = true;
    }
  }

  if(outFlag) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1024
x, a = map(int, input().split())
print('0') if x < a else print('10')
cons = 10 ** 7
def primes(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 [i for i in range(n + 1) if is_prime[i]]
primes(cons)

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

int main(void) {
  long N, M; cin >> N >> M;
  vector<long> boxes(N, 1);
  vector<long> red(N, 0); red.at(0) = 1;
  for (long i = 0; i < M; i++) {
    long a, b; cin >> a >> b;
    if (red.at(a-1) && !red.at(b-1)) red.at(b-1) = 1;
    if (red.at(a-1) && boxes.at(a-1) == 1) {
      red.at(a-1) = 0;
    }

    boxes.at(a-1)--;
    boxes.at(b-1)++;
  }

  long ans = 0;
  for (long a : red) if (a) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const long long int INF=1001001001001001001;
int N,K;
vector<int> D;

int main(){
	scanf("%d",&N);
	int ans=0;
	rep(i,N+1){ans+=i;}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 636
n=int(input())
a = list(map(int,input().split()))
def p(val):
    print(val)
 
sho = 10**9 +7
a1 = sum(a)**2
b1 = list(map(lambda y:y**2,a))
b2=sum(b1)
result = ((a1-b2)//2)% sho
p(result)

Measured memory_bytes: 31616
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
const int Maxn=100005;
int p[Maxn];
pair<int,int> e[Maxn];
vector<int> G[Maxn];
int findset(int x){
	return p[x]=(p[x]==x)?x:findset(p[x]);
}
void Union(int x,int y){
	x=findset(x);
	y=findset(y);
	if (x==y) return;
	p[y]=x;
} 
void _init(){
	for (int i=0;i<Maxn;i++) p[i]=i;
}
int cnt[Maxn];
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for (int i=0;i<m;i++){
		scanf("%d %d",&e[i].first,&e[i].second);
		cnt[e[i].first]++;
		cnt[e[i].second]++;
		if (findset(e[i].first)!=findset(e[i].second)){
			G[e[i].first].push_back(e[i].second);
			G[e[i].second].push_back(e[i].first);
			Union(e[i].first,e[i].second);
		}
	}
	for (int i=2;i<=n;i++){
		if (findset(i)!=findset(1)){
			Union(i,1);
			G[1].push_back(i);
			G[i].push_back(1);
		}
	}
	bool flag=false;
	for (int i=1;i<=n;i++) if (cnt[i]&1) flag=true;
	if (!flag){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;

	int ans = n*n*n;

	cout<<ans;


}


Measured memory_bytes: 256
import numpy as np


def imos2d(x1, y1, x2, y2, board):
    board[y1][x1] += 1
    board[y2][x2] += 1
    board[y2][x1] -= 1
    board[y1][x2] -= 1


if __name__ == '__main__':
    N, K = map(int, input().split())
    lines = [input() for _ in range(N)]

    # N, K = 4, 3
    # lines = ["0 1 W", "1 2 W", "5 3 B", "5 4 B"]

    K2 = 2 * K
    add_dict = {"W": 0, "B": K}
    board = [[0 for _ in range(K2 + 1)] for _ in range(K2 + 1)]
    for line in lines:
        ls = line.split()
        x = int(ls[0]) % K2
        y = (int(ls[1]) + add_dict[ls[2]]) % K2
        x_ = x % K
        y_ = y % K

        # 左上・右上・中央・左下・右下
        if (x < K and y < K) or (K <= x and K <= y):
            # 左上
            imos2d(0, 0, x_ + 1, y_ + 1, board)
            # 右上
            imos2d(x_ + K + 1, 0, K2, y_ + 1, board)
            # 左下
            imos2d(0, y_ + K + 1, x_ + 1, K2, board)
            # 右下
            imos2d(x_ + K + 1, y_ + K + 1, K2, K2, board)
            # 中央
            imos2d(x_ + 1, y_ + 1, x_ + K + 1, y_ + K + 1, board)
        # 上・下・左・右
        else:
            # 上
            imos2d(x_ + 1, 0, x_ + K + 1, y_ + 1, board)
            # 下
            imos2d(x_ + 1, y_ + K + 1, x_ + K + 1, K2, board)

            # 左
            imos2d(0, y_ + 1, x_ + 1, y_ + K + 1, board)
            imos2d(x_ + K + 1, y_ + 1, K2, y_ + K + 1, board)

    board = np.array(board)
    for x in range(K2):
        board[:, x + 1] += board[:, x]
    for y in range(K2):
        board[y + 1, :] += board[y, :]

    print(board.max())


Measured memory_bytes: 83720
n = int(input())
strings = [input() for _ in range(n)]

candidate_char = [100] * 26 # alphabet

for string in strings:
  string_char = [0] * 26
  for char in string:
    string_char[ord(char) - ord('a')] += 1
  
  for i in range(26):
    candidate_char[i] = min(candidate_char[i], string_char[i])

# print(candidate_char)
for i, char_num in enumerate(candidate_char):
  for j in range(char_num):
    print(chr(ord('a') + i), end="")

Measured memory_bytes: 3064
require 'prime'
n = gets.strip.to_i

ans = [1,1]
divs=Prime.prime_division(n)
nums = divs.map{|pr,c| [pr]*c } .flatten

if nums.length==1
  p n-1
  exit
end

result = n
Math.sqrt(n).to_i.times do |i|
  next unless (n%(i+1)).zero?
  tmp = (i+1 + n/(i+1))-2
  #p [n, n/(i+1)*n==n, tmp]
  result = [result, tmp].min
end

p result


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long K, long long S)
{
    ll ans = 0;
    for (int x = 0; x <= K; x++)
    {
        for (int y = 0; y <= K; y++)
        {
            if (0 <= S - x - y && S - x - y <= K)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

int main()
{
    long long K;
    scanf("%lld", &K);
    long long S;
    scanf("%lld", &S);
    solve(K, S);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
As = list(map(int, input().split()))
counter = Counter(As)
ans = 0
for k,v in counter.items():
  ans += k*v

Q = int(input())
for _ in range(Q):
  B, C = map(int, input().split())
  if B in counter:
    if C not in counter:
      counter[C] = 0
    counter[C] += counter[B]
    ans += C * counter[B]
    ans -= B * counter[B]
    counter[B] = 0
  print(ans)

Measured memory_bytes: 21464
def check(s1, s2):
    ss1 = set(s1)
    ss2 = set(s2)
    count = 0
    for si in ss1:
        if si in ss2:
            count += 1;
    return count


def main():
    n = int(input())
    s = input()

    mx = 0
    for i in range(1, len(s)):
        s1 = s[:i]
        s2 = s[i:]
        mx = max(check(s1, s2), mx)

    print(mx)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
ll gcd(ll a, ll b){
    if(b > a){
        ll x = a;
        a = b;
        b = x;
    }
    ll q, r;
    q = a / b;
    r = a % b;
    if(r == 0) return b;
    return gcd(b, r);
}
int main() {
    ll a, b; cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3636
N = int(input())
A = [None] + list(map(int, input().split()))

B = [None] * (N+1)

C = []

for i in range(N+1 -1, 1 -1, -1):
  ans = A[i]
  j = i*2
  while j <= N:
    if B[j]:
      ans ^= 1
    j += i
  B[i] = ans
  if ans:
    C.append(i)

print(sum(B[1:]))
print(*C)


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

struct Card
{
    char suit;
    int value, index;
};

void bubble(struct Card A[], int N)
{
    bool flag = 1;
    int i = 0;
    while(flag){
        flag = 0;
        for(int j = N-1; j >= i+1; j--)
        {
            if (A[j].value < A[j-1].value)
            {
                Card tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
            }
        }
        
    }
}

void slection(struct Card A[], int N)
{
    for(int i = 0; i < N; i++)
    {
        int minj = i;
        for(int j = i; j < N; j++)
        {
            if (A[j].value < A[minj].value) minj = j;
        }
        Card tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
    }
}

void print(struct Card A[], int N)
{
    for(int i = 0; i < N; i++)
    {
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

void isStable(struct Card A[], int N)
{
    bool is_stable = true;
    for(int i = 0; i < N-1; i++)
    {
        if (A[i].value == A[i+1].value & A[i].index > A[i+1].index)
        {
            is_stable = false;
            break;
        }
    }
    
    if (is_stable)
    {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    } 
}

int main()
{
    int n;
    cin >> n;
    
    Card C1[n], C2[n];
    for(int i = 0; i < n; i++)
    {
        cin >> C1[i].suit >> C1[i].value;
        C1[i].index = i;
    }

    for (int i=0; i<n; i++) C2[i] = C1[i];

    bubble(C1, n);
    print(C1, n);
    isStable(C1, n);

    slection(C2, n);
    print(C2, n);
    isStable(C2, n);
    return 0;
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	long long A, X[100000] = {}, count = 0, Minus = 0, Zero = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		X[i] = abs(A);
		if (A < 0) Minus++;
		else if (A == 0) Zero = 1;
		count += X[i];
	}
	if (Minus % 2 == 0 || Zero == 1) {
		cout << count;
	}
	else {
		sort(X, X + N);
		cout << count - X[0] * 2;
	}
}

Measured memory_bytes: 1024