akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    string s; cin >> s;
    int n = s.size();
    int s1 = 0;
    rep(i,n) { s1 += (s[i] - '0'); };
    int s0 = n - s1;
    int s01 = abs(s0 - s1);
    cout << n - s01 << "\n";
    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}


void solve() {
  int a[3][3];
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  int c[3][3];
  fill_n(*c, 3 * 3, 0);

  int n;
  cin >> n;
  rep(i, n) {
    int b;
    cin >> b;
    rep(j, 3) rep(k, 3) {
      if (a[j][k] == b) c[j][k] = 1;
    }
  }
  // rep(i, 3) { rep(j, 3) cout << a[i][j] << " "; cout << endl; }

  rep(i, 3) {
    rep(j, 3) {
      if (c[i][j] == 0) break;
      if (j == 2) {
        cout << "Yes" << endl;
        return;
      }
    }
  }

  rep(j, 3) {
    rep(i, 3) {
      if (c[i][j] == 0) break;
      if (i == 2) {
        cout << "Yes" << endl;
        return;
      }
    }
  }

  rep(i, 3) {
    if (c[i][i] == 0) break;
    if (i == 2) {
      cout << "Yes" << endl;
      return;
    }
  }

  rep(i, 3) {
    if (c[i][2 - i] == 0) break;
    if (i == 2) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}
int solve(int n){
    int cnt = 0;
    while(n%2==0){
        n /= 2;
        cnt++;
    }
    return cnt;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1;i<=N;i++){
        ans = max(ans,solve(i));
    }
    cout << pow(2,ans) << endl;
}

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

int N;

int main() {
    cin >> N;

    int ans = 0;
    for (int i = N; i > 0; i--) {
        int num = i;
        int cnt = 0;
        while (num > 0) {
            num /= 10;
            cnt++;
        }
        if (cnt % 2 == 1) ans++; 
    }  

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i,n) cin >> h[i];
    ll dp[n+10];
    REP(i,n+10) dp[i] = LINF;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for (int i = 2; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i-j < 0) break;
            dp[i] = min(dp[i-j] + abs(h[i]-h[i-j]), dp[i]);
        }
    }
    cout << dp[n-1] << std::endl;
    //REP(i,n) cout << i << " = " << dp[i] << std::endl;
    return 0;
}

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

int main(void) {
    int n;

    cin >> n;

    vector<int> v(n), dp(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    dp[0] = 0;
    dp[1] = abs(v[0] - v[1]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val a, b = Scanner.nextInt

	pw.println(a * b)
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54560
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        if (x % y == 0) {
            System.out.println(-1);
            return;
        }
        System.out.println(x);
    }
}


Measured memory_bytes: 23636
#include<stdio.h>
#define N 1000
int main(){
 
  int Adj[N][N],n,i,j,s,u,k;
 
 
 
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      Adj[i][j] = 0;
 
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);

    if(k!=0)for(j=0;j<k;j++){
    scanf("%d",&s);
    Adj[u-1][s-1] = 1;
      }
  }
 
  for(i=0;i<n;i++)
    for(j=0;j<n;j++){
      if(j!=n-1)printf("%d ",Adj[i][j]);
      else printf("%d\n",Adj[i][j]);
    }

  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string S[101];
int R[101],C[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) {
		cin>>S[y];
		FOR(x,W) if(S[y][x]=='#') R[y]++,C[x]++;
	}
	
	FOR(y,H) if(R[y]) {
		FOR(x,W) if(C[x]) cout<<S[y][x];
		cout<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
module Main where

import Data.Foldable
import Data.List

main :: IO ()
main = do
    s <- getLine
    forM_ (elemIndex s wds) $ \s -> print $ 7 - s

wds :: [String]
wds = [ "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" ]


Measured memory_bytes: 380
#include <iostream>

using namespace std;

int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if(A>=1&&B<=500&& C>=1&&C<=1000)
    if(A+B>=C)
    cout<<"Yes"<<endl;
    else if(A+B<C)
    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n, a[101010], r[101010];

i64 gcd(i64 x, i64 y){
	if(y == 0) return x;
	return gcd(y, x%y);
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	if(n == 2){
		cout << max(a[0], a[1]) << endl;
		return 0;
	}
	r[n-2] = a[n-1];
	for(int i = n-3; i >= 0; i--){
		r[i] = gcd(r[i+1],a[i+1]);
	}
	i64 ans = r[0];
	i64 cnt = a[0];
	for(int i = 1; i < n-1; i++){
		ans = max(ans, gcd(r[i], cnt));
		cnt = gcd(cnt,a[i]);
	}
	ans = max(ans, cnt);
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve()
{
	COMinit();
	int n,k;
	cin>>n>>k;
	if(n<k){
		k=n-1;
	}
	ll ans=0;
	rep(i,k+1){
		ll t=COM(n,i)*COM(n-1,i);
		ans+=t%M;
		//cout<<t<<endl;
		ans%=M;
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 12288
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] vect1 = new int[n];
		int[] vect2 = new int[n];
		double temp = 0.0;
		for(int i=0;i<n; i++){
			vect1[i] = scan.nextInt();
		}
		for(int i=0;i<n; i++){
			vect2[i] = scan.nextInt();
		}

		for(int i=0;i<n; i++){		//?????????
			double abs = 0;
			abs = vect1[i] - vect2[i];
			abs = Math.abs(abs);
			abs = Math.pow(abs,1);
			temp += abs;
		}
		temp = Math.pow(temp, (1.0/1.0));
		System.out.println(temp);
		temp = 0.0;

		for(int i=0;i<n; i++){		//?????????
			double abs = 0;
			abs = vect1[i] - vect2[i];
			abs = Math.abs(abs);
			abs = Math.pow(abs,2);
			temp += abs;
		}
		temp = Math.pow(temp, (1.0/2.0));
		System.out.println(temp);
		temp = 0.0;

		for(int i=0;i<n; i++){		//?????????
			double abs = 0;
			abs = vect1[i] - vect2[i];
			abs = Math.abs(abs);
			abs = Math.pow(abs,3);
			temp += abs;
		}
		temp = Math.pow(temp, (1.0/3.0));
		System.out.println(temp);
		temp = 0.0;

		for(int i=0;i<n; i++){		//?????????
			double abs = 0;
			abs = vect1[i] - vect2[i];
			abs = Math.abs(abs);
			if(abs>temp){
				temp = abs;
			}
		}
		
		System.out.println(temp);
		temp = 0.0;
	}
}

Measured memory_bytes: 26492
a, b, c = list(map(int, input().split()))

if (a == b == c):
    print(str(a) + ' ' + str(b) + ' ' + str(c))
else:
    a, b = b, a
    a, c = c, a
    print(str(a) + ' ' + str(b) + ' ' + str(c))


Measured memory_bytes: 3060
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    	int a,b,c;
    	cin>>a>>b>>c;
      	a = a+b;
      	b = a-b;
      	a = a-b;
      	a = a+c;
      	c = a-c;
      	a = a-c;
      	cout<<a<<" "<<b<<" "<<c<<"\n";
     
    return 0;
}



Measured memory_bytes: 3652
def main():
    N,K = map(int,input().split())
    ans = 0
    souwa = N*(N+1)//2
    mod = 10 ** 9 + 7

    for i in range(K,N+2):
        mi = (i-1)*i//2
        ma = souwa - (N-i)*(N-i+1)//2
        ans += ma-mi+1

    print(ans%mod)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(b,a*n);



	return 0;
}


Measured memory_bytes: 256
#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)--)

const int N = 1e5 + 10;
const int L = 17;
int n, q;
int parent[N][L];
int depth[N];
int dists[N];
int cnt_color[N];
int sum_color[N];
vector<unordered_map<int, pii>> edges;
vector<set<int>> need;
map<pii, int> sums;
map<pii, int> cnts;

void dfs(int u, int p){
   depth[u] = 1 + depth[p];
   parent[u][0] = p;
   for(int i=1; i<L; i++)
       parent[u][i] = parent[parent[u][i-1]][i-1];
   for(auto it : edges[u]) if (it.first != p){
        dfs(it.first, u);
   }
}

void dfs2(int u, int p){
    if (need[u].size()){
        for(auto color : need[u]) {
            auto key = make_pair(u, color);
            cnts[key] = cnt_color[color];
            sums[key] = sum_color[color];
        }
    }
    for(auto it : edges[u]) if (it.first != p){
        cnt_color[it.second.first]++;
        sum_color[it.second.first] += it.second.second;
        dists[it.first] = dists[u] + it.second.second;
        dfs2(it.first, u);
        cnt_color[it.second.first]--;
        sum_color[it.second.first] -= it.second.second;
    }
}

int lca(int u, int v){
    if (depth[u] < depth[v])
        swap(u, v);
    if (depth[u] > depth[v]){
        FORI(i, L){
            int pu = parent[u][i];
            if (depth[pu] >= depth[v])
                u = pu;
        }
    }
    if (u==v)
        return u;
    if (depth[u]==depth[v]){
        FORI(i, L){
            int pu = parent[u][i];
            int pv = parent[v][i];
            if (pu != pv) {
                u = pu;
                v = pv;
            }
        }
    }
    return parent[u][0];
}


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

    cin >> n >> q;
    edges.resize(n+1);
    need.resize(n+1);
    FOR(i, n-1){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        edges[a][b] = {c, d};
        edges[b][a] = {c, d};
    }
    dfs(1, 1);

    struct xyuv{
        int x,y,u,v,t;
    };
    vector<xyuv> queries;
    FOR(i, q) {
        int x, y, u, v;
        cin >> x >> y >> u >> v;
        int t = lca(u, v);
        queries.push_back({x,y,u,v,t});
        need[u].insert(x);
        need[v].insert(x);
        need[t].insert(x);
    }

    dfs2(1, 1);

    FOR(i, q){
        auto& it = queries[i];
        ll dist = dists[it.u] + dists[it.v] - 2*dists[it.t];
        ll cnt = cnts[{it.u, it.x}] + cnts[{it.v, it.x}] - 2*cnts[{it.t, it.x}];
        ll sum = sums[{it.u, it.x}] + sums[{it.v, it.x}] - 2*sums[{it.t, it.x}];
        cout << dist - sum + cnt * it.y << '\n';
    }

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

Measured memory_bytes: 76864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int ans=0;
  rep(i,1,N-1){
    if(A[i-1]<A[i]&&A[i]<A[i+1])
      ans++;
    else if(A[i-1]>A[i]&&A[i]>A[i+1])
      ans++;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	_, a, b := nextInt(), nextInt(), nextInt()
	if (b-a)%2 == 0 {
		fmt.Println("Alice")
	} else {
		fmt.Println("Borys")
	}
}


Measured memory_bytes: 640
inp = input()
res = 0
for i in range(len(inp)+1):
  for j in range(i+1, len(inp)+1):
    if len([w for w in inp[i:j] if w in ["A", "C", "G", "T"]]) == (j-i):
      res = max(res, j-i)
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using lld=long double;
#define all(c) (c).begin(), (c).end()
#define rep( i, a, n ) for( int i=a; i<n; i++ )
#define repp( i, a, n, p ) for( int i=a; i<n; i+=p )
#define per( i, a, n ) for( int i=n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define acc accumulate

bool comp ( pair < int, pair <int, float > > a, pair <int, pair <int, float >> b ) { 
    return a.second.second > b.second.second;
}

int main () { 
    int n;
    cin >> n;
    
    vector < pair <int, pair < int, float > > > v  ;
    vector <int> v1(n);
    vector <int> v2(n);
    rep (i, 0, n) cin >> v1[i];
    rep (i, 0, n) cin >> v2[i];

    rep ( i, 0, n ) {
        v.pb ( { v1[i], {v2[i], (float) v1[i]/v2[i] } } );
    }

    sort ( all (v), comp);
    int countA=0, countB=0;


    rep ( i, 0, v.size() ){ 
        if ( v[i].second.second > 1 ) {
            //cout << v[i].first << " " << v[i].second.first << endl;
            countA += v[i].first;
            countB += v[i].second.first;
        }
    }
    cout << countA-countB << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a[101]={0};
	int i;
	int max=0;
	while((scanf("%d",&i))!=EOF){
		a[i]++;
	}
	for(i=1;i<101;i++){
		if(a[i]>max){
			max=a[i];
		}
	}
	for(i=1;i<101;i++){
		if(a[i]==max){
			printf("%d\n",i);
		}
	}
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a > b && a > c){
    cout << "A" << endl;
  }
  else if(b > a && b > c){
    cout << "B" << endl;
  }
  else{
    cout << "C" << endl;
  }
  return 0;
}



Measured memory_bytes: 3104
p = 10**9+7
S = input().strip()
n = len(S)
dp = [[0 for _ in range(13)] for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(13):
        if S[i]!="?":
            dp[i+1][(10*j+int(S[i]))%13] = dp[i][j]
        else:
            for k in range(10):
                dp[i+1][(10*j+k)%13] = (dp[i+1][(10*j+k)%13]+dp[i][j])%p
print(dp[n][5])

Measured memory_bytes: 66012
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

a,b,c = splitintinput()
if c - a - b < 0:
    print('No')
    exit()

if (c - a - b) ** 2 > 4 * a * b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 13564
# ABC069D - Grid Coloring (ARC080D)
from collections.abc import Iterable


def flatten(A: "Array") -> "Array":
    if isinstance(A, Iterable):
        return [i for a in A for i in flatten(a)]
    else:
        return [A]


def main():
    """
    move left to right in odd rows and vice versa in even rows
    1 s--->
    2 <----
    3 --->t
    """
    H, W, N, *A = map(int, open(0).read().split())
    grid = flatten([color] * cnt for color, cnt in enumerate(A, 1))
    for i, g in enumerate(zip(*[iter(grid)] * W)):
        if i & 1 == 0:
            print(*g)
        else:
            print(*g[::-1])


if __name__ == "__main__":
    main()

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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;

void sort_second(vector<pair<ll, ll>> &A, int N); //A:array of pair, N:size of array

int main() {
    int n, ans=0;
    cin >> n;
    vector<int> p(n);
    int min = INF;
    rep(i, n) cin >> p.at(i);
    rep(i, n) {
        if(p.at(i)<=min) {
            ans++;
            min = p.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}

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

#define int long long

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

signed main() {
    int A;
    cin >> A;
    cout << A / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100001],MOD=1e9+7,L,bi[100002];
map<ll,ll> mp;
ll f(ll n,ll k){
    if(k==0)return 1;
    if(k%2==1)return n*f(n,k-1)%MOD;
    else return f(n,k/2)*f(n,k/2)%MOD;
}
ll comb(ll n,ll k){
    return bi[n]*f(bi[n-k],1e9+5)%MOD*f(bi[k],1e9+5)%MOD;
}
int main(void){
    cin>>n;
    bi[0]=1;
    for(ll i=0;i<n+1;i++){
        bi[i+1]=(i+1)*bi[i];
        bi[i+1]%=MOD;
    }
    for(ll i=0;i<n+1;i++){
        cin>>a[i];
        if(mp[a[i]]==0)mp[a[i]]=i+1;
        else L=n-1-i+mp[a[i]];
    }
    //cout<<bi[5]<<endl;
    //cout<<comb(5,2)<<endl;
    for(ll i=1;i<=n+1;i++){
        //cout<<n<<L<<i<<endl;
        if(i==1)cout<<n<<endl;
        else if(L>=i-1)cout<<(MOD+comb(n+1,i)-comb(L,i-1))%MOD<<endl;
        else cout<<comb(n+1,i)<<endl;
    }
}


Measured memory_bytes: 11008
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    char s[100050],t[100050];
    scanf("%s",s);
    strcpy(t,s);
    int ans1=0,ans2=0;
    for (int i=0; i<strlen(s)-1; i++){
        if (s[i]==s[i+1]){
            ans1++;
            if (s[i]=='0'){
                s[i+1]='1';
            } else {
                s[i+1]='0';
            }
        }
    }
    printf("%d\n",ans1);
    return 0;
}

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

int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll solve()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    for (auto& in : X)
        cin >> in;
    ll res = 0;
    for (int i = 0; i < N - 1; i++) {
        res += min(A * (X[i + 1] - X[i]), B);
    }
    return res;
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
using namespace std;
long long gcd(long long a,long long b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
int main(){
    long long a,b;
    while(cin>>a>>b){
        long long x;
        if(a>b)x=gcd(a,b);
        else x=gcd(b,a);
        cout<<x<<" "<<a/x*b<<endl;

    }
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC154E();

#if 1
int main()
{
	ABC154E();
	fflush(stdout);
	return 0;
}
#endif

static void ABC154E()
{
	std::string orgs;
	std::cin >> orgs;

	int digitCount = orgs.size();
	int K;
	getint(K);
	
	std::vector<std::vector<std::vector<LLONG>>> dp(digitCount + 1, std::vector<std::vector<LLONG>>(2, std::vector<LLONG>(K + 2, 0)));
	dp[0][0][0] = 1;
	for (int digit = 1; digit <= digitCount; digit++) {
		int num = orgs[digit - 1] - '0';

		for (int smaller = 0; smaller < 2; smaller++) {
			int count = 9;
			if (!smaller) {
				count = num;
			}
			for (int n = 0; n <= count; n++) {
				for (int k = 0; k <= K; k++) {
					if (n == 0) {
						dp[digit][smaller || (n < num)][k] += dp[digit - 1][smaller][k];
					}
					else {
						dp[digit][smaller || (n < num)][k + 1] += dp[digit - 1][smaller][k];
					}
				}
			}
		}
	}
	printf("%lld\n", dp[digitCount][0][K] + dp[digitCount][1][K]);
}



Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,m=l()
if(n>m):
    n,m=m,n
if(n==1 and m==1):
    print(1)
    exit()
if(n==1 and m!=1):
    print(m-2)
    exit()
print((n-2)*(m-2))



Measured memory_bytes: 5124
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
using namespace std;

int main()
{
	int n, x;
	int min = 0;
	int ans = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x;
		if (i == 0 || min > x) {
			min = x;
			ans++;
		}
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int N = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    int[][] color = new int[H][W];
    int c = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int k = j;
        if (i % 2 != 0) k = W - j - 1;
        if (a[c] == 0) c++;
        color[i][k] = c + 1;
        a[c]--;
      }
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        System.out.print(color[i][j]);
        if (j < W - 1) System.out.print(' ');
      }
      System.out.println();
    }
  }
}


Measured memory_bytes: 31692
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<map>
#include<algorithm>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<string>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define For(i,N) for(ll i=0;i<N;i++)
int main()
{
	ll N;
	cin >> N;
	vector<ll>W(N);
	rep(N) {
		cin >> W[i];
	}
	ll ans = 10000000000;
	rep(N - 1) {
		ll a = 0;
		ll b = 0;
		for (ll k = 0; k < i + 1; k++) {
			a += W[k];
		}
		for (ll k = i + 1; k < N; k++) {
			b += W[k];
		}
		ans = min(ans, abs(a - b));
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1000

void trace(int A[], int n){
  int i;
  for(i = 0; i < n; i++){
    if(i >= 1) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

main(){
  int i, j, n;
  int arr[N+1];
  int key;

  scanf("%d",&n);

  for(i = 0; i <= n; i++) scanf("%d", &arr[i]);

  trace(arr, n);

  for(i = 1; i < n; i++){
    key = arr[i];
    j = i-1;
    while(j >= 0 && arr[j] > key){
      arr[j+1] = arr[j];
      j--;
    }
    arr[j+1] = key;
    trace(arr, n);
  }

  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[1005][10005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll h,n; cin>>h>>n;
  rep(i,n+1) rep(j,h+1) dp[i][j]=LINF;
  dp[0][0]=0;
  rep(i,n){
    ll a,b; cin>>a>>b;
    rep(j,h+1){
      ll nj=min(h, j+a);
      chmin(dp[i][nj], dp[i][j]+b);
      chmin(dp[i+1][j], dp[i][j]);
      chmin(dp[i+1][nj], dp[i][j]+b);
    }
  }
  
  // rep(i,n+1){
  //   rep(j, h+1){
  //     cout<<dp[i][j]<<' ';
  //   }
  //   cout<<endl;
  // }
  
  ll ans=dp[n][h];
  cout<<ans<<endl;
  
}

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

int main() {
  int n;
  cin >> n;
  if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) cout << "hon" << endl;
  else if (n % 10 == 3) cout << "bon" << endl;
  else cout << "pon" << endl;
  
}

Measured memory_bytes: 3588
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int min = 1000;
    int max = 0;
    for(int i = 0; i < n; i++){
      int tmp = sc.nextInt();
      min = tmp > min ? min : tmp;
      max = max > tmp ? max : tmp;
    }
    System.out.println(max - min);
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  long long ans=0;
  if(n%(a+b)>a)ans=n/(a+b)*a+a;
  else ans=n/(a+b)*a+n%(a+b);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n, i, j;
    cin >> n;
    for(i=1;i<=n;i++){
        j = i;
        if(i%3 == 0){
            cout << " " << i;
        }else{
            while(j){
                if(j%10==3){
                    cout << " " << i;
                    break;
                }else{
                    j /= 10;
                }
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include<string>
 using namespace std;
 
 int main(){
     int a, b, c;
     cin>>a>>b>>c;
 
 
    if(a==c && b!=c){cout<<"Yes";}
    else if(a==b && c!=b){cout<<"Yes";}
    else if(b==c && a!=c){cout<<"Yes";}
     else {cout<<"No";}
     }

Measured memory_bytes: 3604
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    string s;
    int q;
    cin >> s >> q;
    vector<char> l,r;

    bool rev = false;

    rep(i,q){
        int t;
        cin >> t;
        if(t == 1){
            if(rev) rev = false;
            else rev = true;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(rev){
                if(f == 1) f = 2;
                else f = 1;
            }
            if(f == 1){
                l.emplace_back(c);
            }else{
                r.emplace_back(c);
            }
        }
    }

    if(rev){
        reverse(all(s));
        reverse(all(r));
        for(auto e : r){
            cout << e;
        }
        cout << s;
        for(auto e : l){
            cout << e;
        }
        cout << '\n';
    }else{
        reverse(all(l));
        for(auto e : l){
            cout << e;
        }
        cout << s;
        for(auto e : r){
            cout << e;
        }
        cout << '\n';
    }




    return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,m; cin >> n >> m;
    vvl G(n);
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }
    vl ans(n+1);
    vl d(n,INF);
    vl pre(n,-1);
    rep(i,n){
        bool flag = false;
        rep(i,n) pre[i] = -1;
        rep(i,n) d[i] = INF;
        d[i] = 0;
        queue<ll> q;
        q.push(i);
        while(!q.empty()){
            ll u = q.front(); q.pop();
            for(auto v : G[u]){
                if(d[v] != INF && v != i) continue;
                d[v] = d[u] + 1;
                pre[v] = u;
                if(v == i){
                    flag = true;
                    break;
                }
                q.push(v);
            }
            if(flag) break;
        }
        if(d[i] > 0){
            if(ans.size() < d[i]) continue;
            ans.clear();
            ll u = i;
            ans.push_back(i+1);
            while(pre[u] != i){
                ans.push_back(pre[u]+1);
                u = pre[u];
            }
        }
    }
    if(ans.size()==n+1) puts("-1");
    else{
        cout << ans.size() << endl;
        for(auto i : ans){
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int s;
	cin >> s;
	if (s > 999) {
		cout << "ABD" << endl;
	}
	else {
		cout << "ABC"<< endl;
	}
		return 0;
}



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



int main(){
    
    long long int H,W,K;cin>>H>>W>>K;
    vector<vector<long long int>> dp(H+1,vector<long long int>(W));
    vector<int> S={1,1,1,2,3,5,8,13,21};
    dp[0][0]=1;
    for(int i=1;i<W;i++){
        dp[0][i]=0;
    }
    if(W==1) cout<<1<<endl;
    else{
    for(int i=1;i<=H;i++){
        for(int j=0;j<W;j++){
            if(j==0) dp[i][j]=(S[W]*dp[i-1][j]+S[W-1]*dp[i-1][j+1])%1000000007;
            else if(j==W-1) dp[i][j]=(S[W]*dp[i-1][j]+S[W-1]*dp[i-1][j-1])%1000000007;
            else if(j>0&&j<W-1) dp[i][j]=(S[j+1]*S[W-j]*dp[i-1][j]+S[j]*S[W-j]*dp[i-1][j-1]+S[j+1]*S[W-j-1]*dp[i-1][j+1])%1000000007;
        }
    }
    cout<<dp[H][K-1]<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

/*
二等辺三角形の頂角は 180/6°
扇型から三角形引けばいい
*/

void solve() {
  int n;
  cin >> n;
  cout << 3 * n * n << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
S = input()
L = list()
for s in S:
    if s == '.':
        L.append(0)
    else:
        L.append(1)

sharp_cumsum = [0] + list(accumulate(L))
period_cumsum = ([0] + list(accumulate([x^1 for x in L[::-1]])))[::-1]

ans = 10 ** 9

for i in range(N):
    left = i
    right = i+1
    tmp_ans = sharp_cumsum[left] + period_cumsum[right]
    ans = tmp_ans if tmp_ans < ans else ans
print(ans)


Measured memory_bytes: 23756