akhauriyash/Code-Regression huggingface dataset:
A=input().split()
a=int(A[0])
b=int(A[1])
c=int(A[2])
d=int(A[3])
e=a*c
f=a*d
g=b*c
h=b*d
if e>f:
    f=e
if g>h:
    h=g
if f>h:
    h=f
print(h)

Measured memory_bytes: 9080
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define LEN 1100

int **m;
int len1, len2;

void LCS(char *, char *);

int main(){
  int n;
  char str1[LEN], str2[LEN];
  char lgst[LEN];
  int i,j,k;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s%s",str1 ,str2);

    len1 = strlen(str1) + 1;
    len2 = strlen(str2) + 1;

    m = (int **)malloc(len1 * sizeof(int *));
    for(j=0; j<len1; j++)
       m[j] = (int *)malloc(len2 * sizeof(int));

    LCS(str1, str2);

    printf("%d\n",m[len1-1][len2-1]);
    
    for(j=0; j<len1; j++)
      free(m[j]);
    free(m);
  }
  
  return 0;
}

void LCS(char *X, char *Y){
  int i,j;
  
  for(i=1; i<len1; i++)
    m[i][0] = 0;

  for(j=0; j<len2; j++)
    m[0][j] = 0;

  for(i=1; i<len1; i++){
    for(j=1; j<len2; j++){
      if(X[i-1] == Y[j-1])
	m[i][j] = m[i-1][j-1] + 1;

      else if(m[i-1][j] >= m[i][j-1])
	m[i][j] = m[i-1][j];

      else
	m[i][j] = m[i][j-1];
    }
  }
}



Measured memory_bytes: 5444
import java.io.*;
import java.util.Scanner;

public class Main {
	
	public static int compute_maxprofit(int n, int[] R){
	    int max_profit = -100000000;
	    int min = 0;
	    if (n > 2){
    	    for (int i = 0; i < n-2; i++){
    	        if (i == 0){
    	            min = Math.min(R[i], R[i+1]);
    	        }
    	        else{
    	            min = Math.min(R[i+1], min);
    	        }
    	        max_profit = Math.max(max_profit, R[i+2] - min);
    	    }
    	}
	    else{
	        max_profit = R[1] - R[0];
	    }
	    return max_profit;
	}
	
	
    public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] numbs = new int[n];
		for (int i = 0; i < n; i++) {
			numbs[i] = in.nextInt();
		}
		System.out.println(compute_maxprofit(n,numbs));
	}
}


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

int main() {
  int H, W, A, B, C;
  cin >> H >> W;
  A = (H % 3 && W % 3) ? min(H, W) : 0;
  int w = W / 3, h = H / 3;
  B = min((H - H / 2) * (W - w) - w * H, (w + 1) * H - H / 2 * (W - w - 1));
  C = min((W - W / 2) * (H - h) - h * W, (h + 1) * W - W / 2 * (H - h - 1));
  cout << min({A, B, C}) << "\n";
}

Measured memory_bytes: 256
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]


class BinaryIndexedTree:
    """
        Parameters
        ----------
        array : list
            to construct BIT from
        f : func
            binary operation of the abelian group
        fi : func
            inverse mapping of f
            i.e. f(a, b) == c <-> fi(c, a) == b
        e : 
            identity element of the abelian group
        size : int
            limit for array size
    """

    def __init__(self, array, f, fi, e, size):
        self.f = f
        self.fi = fi
        self.e = e
        self.size = size
        self.n = len(array)
        self.dat = [e] * (size + 1)
        self.array = [e] * size
        self.build(array)

    def build(self, array_):
        for i, v in enumerate(array_):
            self.modify(i, v)

    def modify(self, p, v):
        """
        set value at position p (0-indexed)
        """
        self.add(p, self.fi(v, self.array[p]))

    def add(self, p, dv):
        """
        add value at position p (0-indexed)
        """
        fi, dat, f, size, array = self.fi, self.dat, self.f, self.size, self.array
        array[p] = f(array[p], dv)
        p += 1
        while p <= size:
            dat[p] = f(dat[p], dv)
            p += p & -p

    def query(self, l, r):
        """
        result on interval [l, r) (0-indexed)
        """
        return self.fi(self._query(r), self._query(l))

    def _query(self, p):
        dat, f, res = self.dat, self.f, self.e
        while p:
            res = f(res, dat[p])
            p -= p & -p
        return res


f = lambda x, y: x + y
fi = lambda z, x: z - x
e = 0
BIT = BinaryIndexedTree([0] * 2001, f=f, fi=fi, e=e, size=2001)
ans1 = N * (N + 1) // 2
for a in A:
    BIT.add(a, 1)
    ans1 -= BIT._query(a + 1)

BIT = BinaryIndexedTree([0] * 2001, f=f, fi=fi, e=e, size=2001)
ans2 = 2 * N * (2 * N + 1) // 2
for a in A:
    BIT.add(a, 1)
    ans2 -= BIT._query(a + 1)
for a in A:
    BIT.add(a, 1)
    ans2 -= BIT._query(a + 1)

BIT = BinaryIndexedTree([0] * 2001, f=f, fi=fi, e=e, size=2001)
ans3 = 3 * N * (3 * N + 1) // 2
for a in A:
    BIT.add(a, 1)
    ans3 -= BIT._query(a + 1)
for a in A:
    BIT.add(a, 1)
    ans3 -= BIT._query(a + 1)
for a in A:
    BIT.add(a, 1)
    ans3 -= BIT._query(a + 1)

x = ans1
y = ans2
z = ans3
mod = 10**9 + 7
K -= 1
print(((
    (K - 2) * (K - 1) * x - 2 * K * (K - 2) * y + (K - 1) * K * z) // 2) % mod)


Measured memory_bytes: 3280
w, h, n = map(int, input().split())

m = [[0]*(w) for i in range(h)]

for i in range(n):
  x, y, a = map(int, input().split())
  x -= 1
  y -= 1
  if a==1:
    for ii in range(h):
      for jj in range(w):
        if jj<=x:
          m[ii][jj] = 1
  if a==2:
    for ii in range(h):
      for jj in range(w):
        if jj>x:
          m[ii][jj] = 1
  if a==3:
    for ii in range(h):
      for jj in range(w):
        if ii<=y:
          m[ii][jj] = 1
  if a==4:
    for ii in range(h):
      for jj in range(w):
        if ii>y:
          m[ii][jj] = 1
          
cum = sum([sum(m[i]) for i in range(h)])
#[print(*m[i]) for i in range(h)]
print(h*w-cum)

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    ll a, b;
    cin >> a >> b;
    int xa, xb;
    for(int i = 10; i <= 1250; i ++) {
        xa = (double) i * 0.08;
        xb = (double) i * 0.1;
        if(xa == a && xb == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

int main(){
	int D;
	cin >> D;
	if(D==25)	cout << "Christmas" << endl;
	else if(D==24)	cout << "Christmas Eve" << endl;
	else if(D==23)	cout << "Christmas Eve Eve" << endl;
	else if(D==22)	cout << "Christmas Eve Eve Eve" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for(int i=A; i<=B; i++) {
        if(i%K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];


int main () {
    long long N,A,B;
    cin >> N >> A >> B;

    long long ans =0;
    ans += N/(A+B);
    ans *= A;

    N %= A+B;
    ans += min(N,A);

    cout << ans << endl;




}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	public void solve()
	{
		int w = nextInt();
		int h = nextInt();
		int N = nextInt();
		int in = 1;
		int ou = 1;
		int cnt = 0;
		for(int i = 0;i < N;i++)
		{
			int p = nextInt();
			if(p == 0)
			{
				ou++;
			}else
			{
				in++;
			}
			int s = 0;
			if(ou == w || ou == w + h - 1)continue;
			if(ou <= w - 1 && in <= w - 1)
			{
				s = 0;
			}else if(ou >= w + 1 && ou <= w + h - 2 && in >= w - 1 && in <= w - 2 + h - 2)
			{
				s = 2;
			}else if(ou <= 2 * w + (h - 2) && ou >= w + h && in >= w + h - 4 && in <= 2 * (w - 1) + (h - 4))
			{
				s = 4;
			}else continue;

			if(ou - s == in)
			{
				cnt++;
			}
		}
		out.println(cnt);
	}
	public static void main(String[] args)
	{
		out.flush();
		new Main().solve();
		out.close();
	}
	/*Input*/
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte()
	{
		if(p < buflen)return true;
		p = 0;
		try
		{
			buflen = in.read(buffer);
		}catch(IOException e)
		{
			e.printStackTrace();
		}
		if(buflen <= 0)return false;
		return true;
	}
	public boolean hasNext()
	{
		while(hasNextByte() && !isPrint(buffer[p]))
		{
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch)
	{
		if(ch >= '!' && ch <= '~')return true;
		return false;
	}
 
	private int nextByte()
	{
		if(!hasNextByte())return -1;
		return buffer[p++];
	}
 
	public String next()
	{
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while(isPrint((b = nextByte())))
		{
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt()
	{
		return Integer.parseInt(next());
	}
 
	public long nextLong()
	{
		return Long.parseLong(next());
	}
 
	public double nextDouble()
	{
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24492
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::Num num = data->getNum();
	
	const int BT = num[0] * 60 + num[1];
	const int ET = num[2] * 60 + num[3];
	const int K = num[4];

	const int QT = std::abs(ET - BT);

	const int ans = std::abs(QT - K);

	printf("%d\n", ans);

	delete(data);

	return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==1) {
		cout<<"Hello World"<<endl;
		return 0;
	}
	else if(n==2)
	{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
		return 0;
	}
 } 

Measured memory_bytes: 256
from collections import Counter
s = input()
S = set(s)
A = []

for i in S:
    a = 0
    p = s.split(i)
    #print(p)
    for j in range(len(p)):
        if len(p[j]) > a:
            a = len(p[j])
    A.append(a)
#print(A)
print(min(A))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    string s;cin >> s;
    ll ans = 0;
    rep(i,n-2){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;


const ll MX=1e18;
int main(){
    int n;
    cin >> n;
    ll ans =1;
    bool ok=false;

    rep(i,n){
        ll a;
        cin >> a;
        if(a==0){
            cout << 0 << endl;
            return 0;
        }
        //aをかけても10^18を超えないなら
        //そのままa*
        else if(a <= MX/ans){
           ans *= a;
        }
        else{
            ok = true;
        }
    }
    if(ok) cout << -1 << endl;
    else cout << ans << endl;
    return 0;

   

}

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define pll pair <ll, ll>
#define node second
#define dis first
#define setbiti(x) __builtin_popcount(x)
#define setbitll(x) __builtin_popcountll(x)
#define gcd(a, b) __gcd(a, b)

#define        MX        200005
vector < pii > adj[MX];
bool visited[MX];
int color[MX];

void dfs(int n)
{
    visited[n] = 1;
    for(int i = 0; i < adj[n].size(); i++){
        if(!visited[adj[n][i].node]){
            visited[adj[n][i].node] = 1;
            if(adj[n][i].dis == 1) color[adj[n][i].node] = 1-color[n];
            else color[adj[n][i].node] = color[n];
            dfs(adj[n][i].node);
        }
    }
}
int main()
{
    optimize
    int n;
    cin>>n;

    for(int i = 0; i < n-1; i++){
        int u, v, w;
        cin>>u>>v>>w;
        adj[u].push_back(pii(w&1, v));
        adj[v].push_back(pii(w&1, u));
    }

    dfs(1);

    for(int i = 1; i <= n; i++) cout<<color[i]<<endl;
}


Measured memory_bytes: 13952
#include<stdio.h>

int main(){
  double a, b, c, d, e, f;
  double x,y;
  double ABSx, ABSy, tmp;

  while(scanf("%lf %lf %lf %lf %lf %lf",&a, &b, &c, &d, &e, &f) != EOF){
    /*
    if(b != 0.0){
      if(b*d-a*e != 0.0){
	x = (b*f-c*e)/(b*d-a*e);
	y = (c-a*x)/b;
      }
      else{
	//xとyは一意に定まらない？
	return -1;
      }
    }
    //b == 0のとき
    else{
      if(a != 0.0){
	x = c/a;
	if(e != 0.0){
	  y = (f-d*x)/e;
	}
	else{
	  //yは一意に定まらない
	}
      }
      //a == 0のとき
      else{
	//xとyは一意に定まらない
	return -1;
      }
    }
    */
    y = (a*f-c*d)/(a*e-b*d);
    x = (c-b*y)/a;

    if(x > -0.0005 && x < 0) x = 0.0;
    if(y > -0.0005 && y < 0) y = 0.0;

    /*四捨五入
    ABSx = (x < 0)? -x : x;
    tmp = (ABSx - (double)(int)ABSx) * 1000;
    tmp = (double)(int)(tmp + 0.5); tmp = tmp/1000;
    x = (x < 0) ? -(double)(int)ABSx + tmp : (double)(int)ABSx + tmp;  
    ABSy = (y < 0)? -y : y;
    tmp = (ABSy - (double)(int)ABSy) * 1000;
    tmp = (double)(int)(tmp + 0.5); tmp = tmp/1000;
    y = (y < 0) ? -(double)(int)ABSy + tmp : (double)(int)ABSy + tmp;    
    */

    /*output*/
    printf("%.3lf %.3lf\n",x ,y);
  }

  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 
 
 
 
int main() {
	ll n;
	while(cin >> n){
		if(n == 0LL) break;
		else if (n == 1LL) {
			cout << "deficient number" << endl;
			continue;
		}
		ll a = 1LL;
		for (ll i = 2LL; i * i <= n; i += 1) {
			if (n % i == 0) {
				a += n / i;
				a += i;
			}
			if (n == (ll)i * i) {
				a -= i;
			}
		}
		//cout << a << endl;
		string ans;
		if (a < n) ans = "deficient number";
		else if (a == n) ans = "perfect number";
		else ans = "abundant number";
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    ll sum = 0;
    REP(i, n) sum += a[i];

    ll now = 0, ret = INF;
    REP(i, n) {
        now += a[i];
        // now と sum-now
        chmin(ret, abs(now-sum+now));
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1792
module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let remove a s =
  match IntMap.find a s with
  | exception Not_found -> s
  | 1 -> IntMap.remove a s
  | n -> IntMap.add a (n - 1) s

let add a s =
  IntMap.add a (1 + try IntMap.find a s with Not_found -> 0) s

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ =
    Array.fold_right add
      (Array.init n (fun _ ->
        Scanf.scanf "%d " (fun a -> a)))
      IntMap.empty in
  let rec solve s a1 a2 = function
    | 0 -> true
    | n -> IntMap.mem a2 s && solve (remove a2 s) a2 (a1 lxor a2) (n - 1) in
  print_endline @@
  if
    solve as_ (fst (IntMap.min_binding as_)) (fst (IntMap.max_binding as_)) n
  then "Yes"
  else "No"


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

    // 整数秒である必要はない
    double min, y, t;
    int ans;

    void run(){
	while(sc.hasNext()){
	    min = sc.nextDouble();
	    
	    t = min/9.8;

	    y = t*t*4.9;
	    ans = 0;
	    while(5*ans-5 < y)	ans++;
	    //System.out.println(v+" "+y+" "+t);
	    System.out.println(ans);
	}
    }
}
       

Measured memory_bytes: 18620
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll q;cin>>q;
    bitset<64>x;
    while(q--){
        ll a;cin>>a;
        if(a==0){   
            ll i;cin>>i;//i--;
            cout<<x[i]<<endl;
        }
        else if(a==1){
            ll i;cin>>i;//i--;
            x[i]=1;
        }
        else if(a==2){
            ll i;cin>>i;//i--;
            x[i]=0;
        }
        else if(a==3){
            ll i;cin>>i;//i--;
            x[i]=1-x[i];
        }
        else if(a==4){
            if(x.count()==64)cout<<1<<endl;
            else cout<<0<<endl;
        }
        else if(a==5){
            if(x.count()>0)cout<<1<<endl;
            else cout<<0<<endl;
        }
        else if(a==6){
            if(x.count()==0)cout<<1<<endl;
            else cout<<0<<endl;
        }
        else if(a==7){
            cout<<x.count()<<endl;
        }
        else if(a==8){
            cout<<x.to_ullong()<<endl;
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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

using i64 = long long;
using P = pair<i64, i64>;

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
    vector<i64> dp(N);
    dp[0] = 3;
    i64 ans = 1;
    for(int i = 0; i < N; ++i){
        ans = (ans * dp[A[i]]) % MOD;
        dp[A[i]]--;
        dp[A[i] + 1]++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'



int N;
string str;
int cnt;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");


	cin >> N >> str;
	F0R(i,N-2){
		if (str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C') cnt++;
		
	}
	cout << cnt << newl;

	










	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int que[200000];
int slide_min[200000];
int slide_max[200000];
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> P(n);
  for(int i=0;i<n;i++){
    cin>>P[i];
  }
  int s,t;
  s=0;
  que[0]=0;
  t=1;
  for(int i=1;i<k;i++){
    while(s<t && P[que[t-1]]>P[i]){
      t--;
    }
    que[t]=i;
    t++;
  }
  for(int i=0;i<n-k+1;i++){
    slide_min[i]=P[que[s]];
    if(i==que[s])s++;
    while(s<t && P[que[t-1]]>P[k+i]){
      t--;
    }
    que[t]=k+i;
    t++;
  }
  s=0;
  que[0]=0;
  t=1;
  for(int i=1;i<k;i++){
    while(s<t && P[que[t-1]]<P[i]){
      t--;
    }
    que[t]=i;
    t++;
  }
  for(int i=0;i<n-k+1;i++){
    slide_max[i]=P[que[s]];
    if(i==que[s])s++;
    while(s<t && P[que[t-1]]<P[k+i]){
      t--;
    }
    que[t]=k+i;
    t++;
  }
  int ans=n-k+1;
  
  /*  for(int i=0;i<n-k+1;i++){
    cout<<slide_max[i]<<endl;
  }*/
  int buf=1;
  vector<int> array(n);
  array[0]=1;
  int tmp=0;
  for(int i=1;i<n;i++){
    if(P[i-1]<P[i]){
      buf++;
      array[i]=buf;
    }
    else{
      buf=1;
      array[i]=buf;
    }
    if(array[i]==k)tmp++;
  }
  if(tmp>0) ans-=tmp-1;
  for(int i=0;i<n-k;i++){
    if(slide_min[i]==P[i] && slide_max[i+1]==P[i+k]) ans--;
  }
  cout<<ans<<endl;
  return 0;
}


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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}

int main()
{
    FASTIO;

    ll n;

    cin >> n;

    seive(1000000);


    if(mark[n]==0)
    {
        cout << n << endl;
    }
    else
    {
        for(int i=n+1; ; i++)
        {
            if(mark[i]==0)
            {
                cout << i << endl;
                return 0;
            }
        }
    }





    return 0;
}


Measured memory_bytes: 10496
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
  int a,b,i;
  cin>>a>>b;
  string c[1000];

  for(i=0;i<a;i++)
  {
    cin>>c[i];
  }

  for(i=0;i<a;i++)
  {
      cout<<c[i]<<endl;
      cout<<c[i]<<endl;
  }

    return 0;
}


Measured memory_bytes: 3652
var  n,i,k,l:longint;
     a:array[1..5]of  0..9;
begin
  readln(n);
  l:=0;
  repeat
    inc(l);
    a[l]:=n mod 10;
    n:=n div 10;
  until  n=0;
  k:=0;
  l:=0;
  for  i:=1  to  4  do
    if  a[i]=k  then
      begin
        inc(l);
        if  l>2  then
          begin
            writeln('Yes');
            exit;
          end;
      end
                else
      begin
        k:=a[i];
        l:=1;
      end;
  writeln('No');
end.


Measured memory_bytes: 128
import java.util.*;

public class Main {
    static char[] arr;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        arr = sc.next().toCharArray();
        System.out.println(getLength(0, arr.length - 1));
    }
    
    static int getLength(int left, int right) {
        if (arr[left] == 'i' || arr[right] == 'i') {
            return 3;
        }
        if (arr[left] == '(') {
            if (arr[right] == ')') {
                return getLength(left + 1, right - 1) + 2;
            }
        } else if (arr[left] == '{') {
            if (arr[right] == '}') {
                return getLength(left + 1, right - 1) + 2;
            }
        } else if (arr[left] == '[') {
            if (arr[right] == ']') {
                return getLength(left + 1, right - 1) + 2;
            }
        } else if (arr[left] == ')') {
            if (arr[right] == '(') {
                return getLength(left + 1, right - 1) + 2;
            }
        } else if (arr[left] == '}') {
            if (arr[right] == '{') {
                return getLength(left + 1, right - 1) + 2;
            }
        } else if (arr[left] == ']') {
            if (arr[right] == '[') {
                return getLength(left + 1, right - 1) + 2;
            }
        }
        return Math.max(getLength(left + 1, right), getLength(left, right - 1));
    }
    
}


Measured memory_bytes: 26320
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,a,ans=0;
    
    std::cin>>n;
    for(int i=0;i<n;i++){
        std::cin>>a;
        if(a%2==0 && a%3>0 && a%5>0){
            ans=1;
            break;
        }
    }
    
    if(ans==0){
        std::cout<<"APPROVED"<<"\n";
    }
    else{
        std::cout<<"DENIED"<<"\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int a[n];
  for(int i(0);i<n;i++){
    cin>>a[i];
  }
  int cnt[n]={0};
  for(int i(0);i<n;i++){
    while(a[i]%2==0){
      a[i]/=2;
      cnt[i]++;
    }
  }
  int min(cnt[0]);
  for(int i(1);i<n;i++){
    if(min>cnt[i])min=cnt[i];
  }
  cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c;
    vector<int>v;
    cin>>n>>m>>c;
    int t=n,g,r=m,x=c,p,i=0,j=0;
    while(r--)
    {
        cin>>g;
        v.push_back(g);
    }
    while(t--)
    {
        while(i<m)
        {
            cin>>p;
            x=x+(v[i]*p);
            i++;
        }
        //cout<<x<<endl;
        if(x>0)
        {
            //cout<<x<<endl;
            j++;
        }
        i=0;
        x=c;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cmath>
#include <cstdio>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N, A, B;
    gc(N);
    gc(A);
    gc(B);

    array<int, 100000> vm;
    for (int i = 0; i < N; i++) gc(vm[i]);

    // 二分探索
    int under = 0;
    int upper = 1000000000;

    while (under + 1 < upper)
    {
        int64_t mid = (under + upper) / 2;

        int64_t cnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (B * mid < vm[i])
            {
                cnt += ceil((double)(vm[i] - B * mid) / (A - B));
            }
        }

        if (cnt <= mid) upper = (int)mid;
        else (under = (int)mid);
    }

    printf("%d\n", upper);
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:
int n,t;
int a[100010],cmax[100010];

int profit=0,ans=0;

int main(void){
	cin >> n >> t;
	rep(i,n) cin >> a[i];
	rep(i,n) cmax[i]=a[i];
	rrep(i,n) if(i+1<n) chmax(cmax[i],cmax[i+1]);	

	rep(i,n){
		if(chmax(profit,cmax[i]-a[i])) ans=0;
		if(profit==cmax[i]-a[i]) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;

namespace DPL_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] coin = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(coin);
            int[] ret = new int[x[0] + 1]; ret[0] = 0;
            for (int i = 1; i <= x[0]; i++) ret[i] = int.MaxValue;
            for (int i = 1; i <= x[0]; i++)
            {
                for (int j = 0; j < x[1] && coin[j] <= i; j++)
                {
                    ret[i] = Math.Min(ret[i],ret[i - coin[j]] + 1);
                }
            }
            Console.WriteLine(ret[x[0]]);
        }
    }
}

Measured memory_bytes: 9888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
    int cnt,a,b;
    char num[5];
    while(1){
        cin >> num;
        cnt = 0;
        if(strcmp(num,"0000") == 0) break;
        if(num[0] == num[1] && num[1] == num[2] && num[2] == num[3]){
            cout << "NA" << endl;
            continue;
        }
        while(1){
            if(strcmp(num,"6174") == 0) break;
            cnt++;
            sort(num,num + 4);
            a = atoi(num);
            sort(num,num + 4,greater<char>());
            b = atoi(num);
            b -= a;
            sprintf(num,"%04d",b);
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end();
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int n;

void update(vv(int) &dist, vv(bool) &emp, int y, int x)
{
	int z = dist[y][x];
	if (!emp[y][x])
		++z;

	// 上下左右の席をzと比較
	// より短い距離に更新できる場合 => 更新してその席の上下左右も見る(再帰)
	if (y > 0 && dist[y-1][x] > z)
	{
		dist[y-1][x] = z;
		update(dist, emp, y-1, x);
	}
	if (y < n-1 && dist[y+1][x] > z)
	{
		dist[y+1][x] = z;
		update(dist, emp, y+1, x);
	}
	if (x > 0 && dist[y][x-1] > z)
	{
		dist[y][x-1] = z;
		update(dist, emp, y, x-1);
	}
	if (x < n-1 && dist[y][x+1] > z)
	{
		dist[y][x+1] = z;
		update(dist, emp, y, x+1);
	}
}

int		main(void)
{
	cin >> n;

	vector<int> P(n*n);
	for (int i = 0; i < n*n; ++i)
	{
		cin >> P[i];
	}
	
	vv(bool) emp(n, vector<bool>(n, false));
	vv(int) dist(n, vector<int>(n));
	// 00000
	// 01110
	// 01210
	// 01110
	// 00000
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			dist[i][j] = min(min(j, n-j-1), min(i, n-i-1));
		}
	}

	int ans = 0;
	for (int i = 0; i < n*n; ++i)
	{
		int x = P[i] % n - 1;
		int y = P[i] / n; 
		if (P[i] % n == 0)
		{
			x = n-1;
			y--;
		}

		ans += dist[y][x];
		emp[y][x] = true;

		update(dist, emp, y, x);
	}
	cout << ans << endl;
}




Measured memory_bytes: 31700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int count = 0;
	vector<int>have;
	vector<int>used;
	vector<int>v(n + 1);
	int four = 0, two = 0, odd = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 4 == 0)four++;
			if (x % 4 != 0 && x % 2 == 0)two++;
		}
		else
			odd++;
	}
	if (!two) {
		if (four >= n / 2)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
	{
		if ((four + two / 2) >= n / 2)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m){
        cin >> l[i] >> r[i];
    }
    sort(all(l));
    sort(all(r));

    int ans = r[0] - l[m-1] + 1;
    if(ans < 0){
        ans = 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(x, a, b) for(int x=a; x<=b; x++)
#define drp(x, a, b) for(int x=a; x>=b; x--)
typedef long long ll;
int u;
ll K, c[1000], v[1000];
ll gcd(ll a, ll b){
	return b?gcd(b, a%b):a;
}
ll C(int n, int m){
	ll res=1;
	int d=1;
	rep(i, 1, m) d*=i;
	rep(i, n-m+1, n) res*=i/gcd(i, d), d/=gcd(i, d);
	return res;
}
int D=7;
int main(){
	cin>>K;
	u=600;
	rep(i, D, 600)
	{
		c[i]=C(i, D);
		if(c[i]>K){ u=i-1; break; }
	}
	drp(i, u, D)
	{
		while(K>=c[i]) v[i]++, K-=c[i];
	}
	rep(i, D, u)
	{
		printf("FESTIVA");
		rep(j, 1, v[i]) putchar('L');
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>

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

  std::set<int> set;
  for (int i=0; i<N; ++i) {
    int A;
    scanf("%d", &A);

    if (set.count(A)) {
      set.erase(A);
    } else {
      set.insert(A);
    }
  }

  printf("%zu\n", set.size());
  return 0;
}



Measured memory_bytes: 4864
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        for(int i=0;i<s.length();i++){
            System.out.print("x");
        }
        System.out.println();
    }
}

Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
  int i,n,d,x,a;
  scanf("%d%d%d",&n,&d,&x);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    x+=d/a+1;
    if(d%a==0)x--;
  }
  printf("%d\n",x);
  return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int a[100003];

int mypartition(int p, int r) {
  int x = a[r];
  int i = p-1;
  for (int j=p; j<r; ++j) {
    if (a[j] <= x) {
      i++;
      int tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }
  int tmp = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp;
  return i+1;
}

int main() {
  int n, q;
  cin >> n;
  rep(i,n) cin >> a[i];

  q = mypartition(0, n-1);
  rep(i,n) {
    if (i == q) {
      cout << '[' << a[i] << ']';
    } else {
      cout << a[i];
    }
    cout << (i==n-1 ? '\n' : ' ');
  }
  return 0;
}



Measured memory_bytes: 3492
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int a;
	cin >> a;
	cout << 3 * pow(a, 2) << endl;
}


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

const int L = 16*9*5*7*11;

int main() {
  int N;
  while (cin >> N && N) {
    int Q[30][30] = {{0}};
    for (int i=0; i<N; i++) {
      int d, t;
      cin >> d >> t;
      for (int j=0; j<d; j++) {
	int q;
	cin >> q;
	Q[d][(j+d-t)%d] += q;
      }
    }
    int sum = 0;
    int T[L] = {0};
    for (int d=1; d<=24; d++) {
      if (d == 13 || d == 17 || d == 19 || d == 23 || d == 1) {
	int M = 0;
	for (int i=0; i<d; i++) {
	  if (M < Q[d][i]) M = Q[d][i];
	}
	sum += M;
      } else {
	for (int i=0; i<L; i++) {
	  T[i] += Q[d][i%d];
	}
      }
    }
    int MM = 0;
    for (int i=0; i<L; i++) {
      if (MM < T[i]) MM = T[i];
    }
    cout << sum + MM << endl;
  }
}

Measured memory_bytes: 1388
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int p,q,r;
  cin>>p>>q>>r;

  cout<<(p+q+r)-max(p,max(q,r))<<endl;
}

Measured memory_bytes: 256
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var n = toInt(input[0]);
	var i = toInt(input[1]);
	var ans = n+1-i;
	
	console.log(ans);
}

Measured memory_bytes: 22964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

signed main(){
	int n;
	scanf("%d", &n);
	vector<vector<int> > a(n,vector<int> (n));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++) scanf("%d", &a[i][j]);
	}
	vector<ll> dp(1 << n, 0);
	dp[0] = 1;
	for(int bit = 1; bit < (1 << n); bit++){
		int num = __builtin_popcount(bit);
		for(int j = 0; j < n; j++){
			if(bit & (1 << j) && a[num - 1][j]){
				(dp[bit] += dp[bit - (1 << j)]) %= MOD;
			}
		}
	}
	cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 19600
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll n,k;
    cin>>n>>k;
    vector <ll> h(n);
    rep(i,n)
    cin>>h[i];
    k=min(k,n);
    sort(all(h));
    ll ans=0;
    for (int i=0;i<n-k;i++)
        ans+=h[i];
    cout<<ans;



}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str[];
		int a, b, o, ab;

		a  = 0;
		b  = 0;
		o  = 0;
		ab = 0;
		while (sc.hasNext()) {
			str = sc.next().split(",");
			if (str[1].equals("A")) {
				a++;
			} else if (str[1].equals("B")) {
				b++;
			} else if (str[1].equals("O")) {
				o++;
			} else if (str[1].equals("AB")) {
				ab++;
			}
		}
		System.out.println(a);
		System.out.println(b);
		System.out.println(ab);
		System.out.println(o);
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	vector<string> a;
	int H, W; cin >> H >> W;
	bool mask[110] = { false };
	for (int i = 0; i < H; i++) {
		string ipts;
		string comp(W, '.');
		cin >> ipts;
		if (ipts == comp)continue;
		a.push_back(ipts);
		for (int j = 0; j < W; j++) {
			if (ipts[j] == '#')mask[j] = true;
		}
	}
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < W; j++) {
			if (mask[j] == true)cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	unsigned long long n, res = 1;

	cin >> n;

	for ( int i = 1; i <= n; i++ )
	{
		res *= i;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    
    while (op != '?') {
        if (op == '+')
            cout << a + b << endl;
        else if (op == '-')
            cout << a - b << endl;
        else if (op == '*')
            cout << a * b << endl;
        else if (op == '/')
            cout << a / b << endl;
        cin >> a >> op >> b;
    }
    
    return 0;
}


Measured memory_bytes: 3088