akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int			long long
#define ld			long double
#define uint 		unsigned long long

const int mod = 1e9 + 7;

struct box
{
	int weight;
	int strength;
	int value;
};

bool cmp(box a, box b)
{
	return ((a.strength + a.weight) > (b.strength + b.weight));
}

void solve()
{
	int n; cin >> n;
	box a[n];
	for(int i=0; i<n; i++)
	{
		cin >> a[i].weight >> a[i].strength >> a[i].value;
	}	
	sort(a, a + n, cmp);
	// dp[i][j] -> Max value for first I boxes and J units more weight can be carried by it
	const int mx = 2e4+2;
	int dp[n+1][mx];
	for(int i=0; i<n+1; i++) for(int j=0; j<mx; j++) dp[i][j] = 0;
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<mx; j++)
		{
			 dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			 if(j >= a[i].weight)
			 {
				 dp[i+1][min(j - a[i].weight, a[i].strength)] = max(dp[i+1][min(j - a[i].weight, a[i].strength)], dp[i][j] + a[i].value);
			 }
		}
	}
	int ans = 0;
	for(int i=0; i<n+1; i++) for(int j=0; j<mx; j++) ans = max(ans, dp[i][j]);
	cout << ans << endl;
}

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





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

int main()
{
	int N, A[100];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	int count = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(A[i], A[minj]);
			count++;
		}
	}
	cout << A[0];
	for (int i = 1; i < N; i++) {
		cout << " " << A[i];
	}
	cout << endl << count << endl;
}

Measured memory_bytes: 3088
fs = [ ("A", [(0,0),(1,0),(0,1),(1,1)]),
       ("B", [(0,0),(0,1),(0,2),(0,3)]),
       ("C", [(0,0),(1,0),(2,0),(3,0)]),
       ("D", [(0,0),(-1,1),(0,1),(-1,2)]),
       ("E", [(0,0),(1,0),(1,1),(2,1)]),
       ("F", [(0,0),(0,1),(1,1),(1,2)]),
       ("G", [(0,0),(1,0),(-1,1),(0,1)]) ]

scn' (x,y) [] = []
scn' (x,y) (d:ds) =
  if d == '1'
  then (x,y):r
  else r
  where
    r = scn' (x+1,y) ds

scn :: (Int,Int) -> [String] -> [(Int,Int)]
scn (_,_) [] = []
scn (x,y) (d:ds) =
  let s' = scn' (x,y) d
  in
    s' ++ (scn (x,y+1) ds)

ofs d@((x0,y0):ds) = map (\(xi,yi) -> (xi-x0,yi-y0)) d
  
search s =
  fst $ head $ filter (\ (name, pat) -> s == pat) fs

ans' x = (search . ofs . scn (0,0)) x

ans [] = []
ans ("":xs) = ans xs
ans x =
  let d = take 8 x
      r = drop 8 x
  in
    (ans' d):(ans r)

main = do
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ putStrLn o
       

Measured memory_bytes: 3992
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N;
    cin >> N;
    vector<ll> creatures;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        creatures.push_back(a);
    }
    sort(creatures.begin(), creatures.end());
    function<bool(ll)> can_survive = [&creatures](ll size) -> bool {
        bool found_me = false;
        ll size_now = size;
        for (ll other_size : creatures) {
            if (!found_me && other_size == size) {
                found_me = true;
                continue;
            }
            if (other_size > size_now * 2) {
                return false;
            } else {
                size_now += other_size;
            }
        }
        return true;
    };
    auto part_pt = partition_point(creatures.rbegin(), creatures.rend(), can_survive);
    cout << distance(creatures.rbegin(), part_pt) << endl;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N;
  string S;
  cin >> N >> S;

  int ans[N+10][3];

  ans[0][0]=0;
  ans[0][1]=0;

  REP(i ,N){
    if(S.at(i)=='#'){
      ans[i+1][0]=ans[i][0]+1;
      ans[i+1][1]=min(ans[i][0], ans[i][1]);
    }else{
      ans[i+1][0]=ans[i][0] ;
      ans[i+1][1]=min(ans[i][0]+1, ans[i][1]+1);
    }
  }


  cout << min(ans[N][0], ans[N][1]) << endl;
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N, x;
	cin >> N >> x;

	vector<int> a( N );
	for( auto& v: a ) { cin >> v; }

	int64_t result = 0;

	if( a[0] > x ) {
		result += a[0] - x;
		a[0] = x;
	}

	for( int i = 1; i < N; ++i ) {
		int s = a[i-1] + a[i];

		if( s > x ) {
			int t = min( a[i], s-x );
			a[i] -= t;
			result += t;
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int n,q,k,S[10000],T[500],i,c=1,count=0;
  scanf("%d",&n);
  for(k=0;k<n;k++){
    scanf("%d",&S[k]);
  }
  scanf("%d",&q);
  for(k=0;k<q;k++){
    scanf("%d",&T[k]);
  }

  for(k=0;k<q;k++)
    {
      i=0;
      S[n]=T[k];
      while(S[i]!=T[k])
	{
	  i++;
	  if(i==n){c=0;break;}
	}
      if(c==1)count++;
      c=1;
    }

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



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

bool kaibun(string s){
	int n = s.length();
	int h = n/2;
	REP(i,h){
		if(s[i] != s[n-i-1]) return false;
	}
	return true;
}

int main(void){

	string S; cin >> S;
	int N = S.length();
	bool a = kaibun(S);
	bool b = kaibun(S.substr(0, (N-1)/2));
	bool c = kaibun(S.substr((N+3)/2-1));

	if(a and b and c) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  double v;
  priority_queue<double,vector<double>,greater<double>> que;
  rep(i,n) {cin>>v;que.push(v);}
  double x,y;
  while(que.size()>1) {
    x=que.top();que.pop();
    y=que.top();que.pop();
    que.push((x+y)/2);
  }
  printf("%.8f\n",que.top());
  return 0;
}

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

int main(){

	int n;
	std::cin >> n;
	std::vector<int>v(n);

	for (int i = 0; i < n; i++)std::cin >> v[i];

	for (int k = 0; k < n; k++){
		if (k == 0)std::cout << v[k];
		else std::cout << " " << v[k];
	}
	std::cout << std::endl;

	for (int i = 1; i < n; i++){
		int key = v[i];
		int j = i - 1;

		while (j >= 0 && v[j]>key){
			v[j + 1] = v[j];
			j--;
		}
		v[j + 1] = key;

		for (int k = 0; k < n; k++){
			if (k == 0)std::cout << v[k];
			else std::cout << " " << v[k];
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

vector<set<int>> G(10);
int ans=0;
void per(int s,set<int> S){
    if(S.empty())ans++;
    for(auto itr=S.begin();itr!=S.end();itr++){
        if(G[s].find(*itr)==G[s].end())continue;
        set<int> T=S;
        T.erase(*itr);
        per(*itr,T);
    }
}

int main(){
    int N,M;cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        G[a].insert(b);
        G[b].insert(a);
    }
    set<int> S;
    for(int i=2;i<=N;i++){
        S.insert(i);
    }
    per(1,S);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	vector<string> MM = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };

	string S = "";
	cin >> S;

	string S1 = S.substr(0, 2);
	string S2 = S.substr(2, 2);

	bool v1 = (MM.end() != find(MM.begin(), MM.end(), S1));
	bool v2 = (MM.end() != find(MM.begin(), MM.end(), S2));

	if (v1 == true && v2 == true) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (v1 == true && v2 == false) {
		cout << "MMYY" << endl;
	}
	else if (v1 == false && v2 == true) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N,K,Q,*A = map(int, open(0).read().split())
ans = 10**10
for i in range(N-K+1):
  c = min(A[i:i+K])
  ls = []
  x = []
  for d in A:
    if d>=c:
      x.append(d)
    else:
      ls.append(x)
      x = []
  ls.append(x)
  m = []
  for x in ls:
    x.sort()
    m += x[:max(len(x)-K+1,0)]
  if len(m)<Q:
    continue
  m.sort()
  y = m[Q-1]
  ans = min(ans,y-c)
print(ans)

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

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

    string s = to_string(n);
    int sum = 0;
    for (char x : s)
        sum += x - '0';
    if (n%sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t N, A, B;
    int64_t max, min;

    scanf("%"PRId64"%"PRId64"%"PRId64, &N, &A, &B);

    max = A < B ? A : B;

    if (A + B > N) min = A + B - N;
    else min = 0;

    printf("%"PRId64" %"PRId64"\n", max, min);
}


Measured memory_bytes: 128
# 2020/02/22
# AtCoder Beginner Contest 156 - C

# Input
n = int(input())
x = list(map(int,input().split()))
xl = [0] * 101

# Calc
for p in range(101):
    for j in range(n):
        xl[p] = xl[p] + (x[j] - p) ** 2

# Output
print(min(xl))


Measured memory_bytes: 2940
N = int(input())
h = list(map(int,input().split()))
H = [0]*N
for i in range(1,N):
    if i == 1:
        H[i] = abs(h[1]-h[0])
    else:
        H[i] = min(H[i-1]+abs(h[i]-h[i-1]),H[i-2]+abs(h[i]-h[i-2]))
print(H[N-1])

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

#define MAX 100001
#define INF 1e+9

int V,E,r;
vector<pair<int, int> > adj[MAX];
int color[MAX];
int d[MAX];

void dijkstra(){
	priority_queue<pair<int, int> > pq;
	for(int i = 0;i < MAX;i++){
		color[i] = 0;
		d[i] = INF;
	}

	d[r] = 0;
	pq.push(make_pair(0,r));
	color[r] = 1;

	while(!pq.empty()){
		pair<int, int> f = pq.top();
		pq.pop();
		int u = f.second;
		color[u] = 2;

		if(d[u] < f.first*(-1)) continue;

		for(int i = 0;i < adj[u].size();i++){
			int v = adj[u][i].first;
			if(color[v] == 2)continue;
			if(d[v] > d[u] + adj[u][i].second){
				d[v] = d[u] + adj[u][i].second;
				pq.push(make_pair(d[v]*(-1), v));
				color[v] = 1;
			}
		}
	}
}

int main(){
	int s,t,di;
	cin >> V >> E >> r;
	for(int i = 0;i < E;i++){
		cin >> s >> t >> di;
		adj[s].push_back(make_pair(t,di));
	}

	dijkstra();

	for(int i = 0;i < V;i++){
		if(d[i] == INF){
			cout << "INF" << endl;
		}
		else{
			cout << d[i] << endl;
		}
	}

	return 0;
}


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

int a,b,c;
int Calc;
int main(){
 cin >> a >> b >> c;
  if(a >= b){
      if(a >= c){
           if(b >= c) Calc =(10*a + b) + c;
           else  Calc =(10*a + c) + b;
        }
      if(a < c) Calc =(10*c + a) + b;
  }
    
  if(a < b){
      if(b >= c){
           if(c >= a) Calc =(10*b + c) + a;
           else  Calc =(10*b + a) + c;
        } 
      if(b < c)  Calc =(10*c + b) + a;
  }
    
    cout << Calc << endl;
}



Measured memory_bytes: 256
using System;

namespace abc138_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            string result = s;

            if (a < 3200)
            {
                result = "red";
            }

            Console.WriteLine(result);

        }
    }
}


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

using namespace std;

#define inputInt(a) scanf("%d", &a)
#define inputStr(a) getline(cin, a)
#define inputLong(a) scanf("%lld", &a)
#define clr(a) memset(a, 0, sizeof(a))
#define printn(a) cout<<a<<"\n"
#define print(a) cout<<a

int main()
{
    long long N;
    cin>>N;

    long long sqint = (long long) sqrt(N);
    double sqdoub = (double) sqrt(N);

    if(sqint == sqdoub)
        printn(N);
    else
        printn(sqint*sqint);

   return 0;
}


Measured memory_bytes: 256
import bisect
import sys
input = sys.stdin.readline

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    # Get div of aoki - takahashi
    x = int(input())
    big = bisect.bisect_left(a, x)
    small = big - 1
    if (x - a[small]) ** 2 <= (x - a[big]) ** 2:
        l = small
    else:
        l = big
    r = n - 1
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        taka = n - m
        aoki = n - taka - (bisect.bisect_left(a, x - rng))
        if taka <= aoki + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    taka = n - r
    aoki = n - taka - (bisect.bisect_left(a, x - rng))
    taka_sum = sum_all[n] - sum_all[n - taka]
    aoki_sum = sum_all[r] - sum_all[r - taka]
    rest = n - taka * 2
    if rest > 0:
        if rest % 2 == 0:
            taka_sum += sum_even[rest]
            aoki_sum += sum_odd[rest]
        else:
            taka_sum += sum_odd[rest]
            aoki_sum += sum_even[rest]

    ans.append(taka_sum)
print("\n".join([str(item) for item in ans]))

Measured memory_bytes: 103276
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
	Scanner as = new Scanner(System.in);
	/*	int n = Integer.parseInt(as.next());
	int x = Integer.parseInt(as.next());
	int a[] = new int[n];
	for(int i=0;i<n;i++){
	    a[i] = Integer.parseInt(as.next());
	}
	int l=0;
	int c;
	for(int i=0;i<n-1;i++){
	    c=a[i]+a[i+1];
	    if(c>x){
		a[i+1]-=c-x;
		l+=c-x;
		if(a[i+1]<0){
		    a[i]+=a[i+1];
		    a[i+1]=0;
		}
	    }
	    }*/
	String a,b,c,d;
	a = as.next();
	b = as.next();
	c = as.next();
	d = String.valueOf(a.charAt(0))+String.valueOf(b.charAt(0))+String.valueOf(c.charAt(0));
	System.out.println(d);
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int N,K;
int A[222222],F[222222];

signed main(){
	cin>>N>>K;
	rep(i,N)cin>>A[i];
	rep(i,N)cin>>F[i];
	sort(A,A+N);
	sort(F,F+N);reverse(F,F+N);
	
	int lb=-1,ub=1001001001001ll;
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		int req=0;
		rep(i,N){
			int tmp=mid/F[i];
			req+=max(0ll,A[i]-tmp);
		}
		if(req<=K)ub=mid;
		else lb=mid;
	}
	cout<<ub<<endl;
	return 0;
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <climits>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <functional>
#include <set>
using namespace std;




int n;
long long memo[2001][2001], A[2001];
long long dp(int left, int right)
{
	if (left < 0)left = n - 1;
	if (right >= n)right = 0;
	int next_left = left, next_right = right;
	long long ans = 0;

	if (memo[left][right] != -1)return memo[left][right];
	if (left == right)return memo[left][right] = ans;

	

	//IOI?????????
	if (A[left]>A[right])next_left--;
	else next_right++;

	//?????°??????
	if (next_left < 0)next_left = n - 1;
	if (next_right >= n)next_right = 0;
	if (next_left == next_right)return memo[next_left][next_right] = ans + A[next_left];

	//JOI??????
	ans = max(dp(next_left - 1, next_right) + A[next_left], dp(next_left, next_right + 1) + A[next_right]);

	return memo[left][right] = ans;

}
int main()
{
	long long ans = -1;
	memset(memo, -1, sizeof memo);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}

	for (int i = 0; i < n; i++)
	{
		ans = max(dp(i - 1, i + 1) + A[i], ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 32512
import Control.Monad
import Data.Functor
 
import qualified Data.Array as Array

threshold = 1000000
 
main :: IO ()
main = do
    n <- readLn :: IO Int
    if n == 0 then return ()
    else do
        salesData <- replicateM n $ do
            [i, p, q] <- map read <$> words <$> getLine :: IO [Int]
            return (i, p*q)
        let salesArray = Array.accumArray const 0 (1, 4000) []
            loop arr [] b = do
              when (not b) $ putStrLn "NA"
              return ()
            loop arr ((i,s):xs) b = do
              let v' = (arr Array.! i) + s
              if v' >= threshold then do
                print i 
                loop (arr Array.// [(i, minBound)]) xs True
              else 
                loop (arr Array.// [(i, v')]) xs b
        loop salesArray salesData False
        main

Measured memory_bytes: 5256
//Confuse them with your silence and shock them with your results;
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define booster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PB push_back
#define F first
#define S second
#define int long long 

const int mod=1e9+7;
int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }
clock_t time_p=clock();
void rtime(){ time_p=clock()-time_p; cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}


int rr[]={0,1,1,1,0,-1,-1,-1};
int cc[]={1,1,0,-1,-1,-1,0,1};


signed main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    booster;
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin >>n;
        cout << pow(n,3) ;   
    }
    rtime();
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        ArrayList<String> registerID = new ArrayList<String>();
        boolean isClose = true;
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String u = sc.next();
            registerID.add(u);
        }
        Collections.sort(registerID);
        
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String t = sc.next();
            if (Collections.binarySearch(registerID, t) >= 0) {
                if (isClose) {
                    System.out.println("Opened by " + t);
                    isClose = false;
                } else {
                    System.out.println("Closed by " + t);
                    isClose = true;
                }
            } else {
                System.out.println("Unknown " + t);
            }
        }
    }
}

Measured memory_bytes: 20592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}
void solve() {
    int n;
    cin >> n;
    vi a(n);
    fori(i,0,n) cin >> a[i];
    int x = a[0];
    fori(i,1,n) x = gcd(x, a[i]);
    if(x != 1) {
        cout << "not coprime\n";
        return;
    }
    sort(all(a));
    fori(i,1,n) if(a[i] > 1 && a[i] == a[i -1]) {
        cout << "setwise coprime\n";
        return;
    }
    vb vis(1000001,false);
    fori(i,0,n) vis[a[i]] = true;
    fori(i,2,1000001) {
        int r = 0;
        for(int j = 1; j * i < 1000001; j++) {
            if(vis[j * i]) r++;
        }
        if(r > 1) {
            cout << "setwise coprime\n";
            return;
        } 
    }
    cout << "pairwise coprime\n";

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	//freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int main() {
    string s;
    cin>>s;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]=='x')cnt++;
    }
    if(cnt>=8)puts("NO");
    else puts("YES");

    return 0;
}

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

int main()
{
    int n,i,a[100],ans=0;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
        ans+=((n-i)%2)?(a[i]):(-a[i]);
    cout <<ans<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=4e5+10;
const double inf=1e9;
typedef long long ll;
typedef pair<int,int>pr;
const ll mod=1e9+7;
ll _pow(ll  a,ll b) {
    ll ans=1;
    while(b) {
        if(b&1)
            ans=ans*a;
        a=a*a;
        b>>=1;
    }
    return ans;
}
int dp[maxn],vis[maxn];
vector<int>g[maxn];
void dfs(int s){
    vis[s]=1;
    for(int i=0;i<g[s].size();i++){
        int v=g[s][i];
        if(!vis[v]){
            dp[v]+=dp[s];
            dfs(v);
        }
    }
}
int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n-1;i++){
     int u,v;
     cin>>u>>v;
     g[u].push_back(v);
     g[v].push_back(u);
  }
  for(int i=1;i<=m;i++){
     int x,v;
     cin>>x>>v;
     dp[x]+=v;
  }
  dfs(1);
  for(int i=1;i<=n;i++){
     cout<<dp[i]<<" ";
  }
  return 0;
}
/*
9 111 92
150 254 268 417 798 704 701 927 128
*/


Measured memory_bytes: 30336
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K,N = inpl()
MAX = K+N+10
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

#K=k,N=n,0pair = 0
def calc(k,n,i):
	#i=2に帰着させる
	pairs = (i-2)//2
	k -= pairs
	n -= pairs

	#色々と例外処理
	if n < 0 or k <= 0:
		return 0
	elif k == 1 and n >= 2:
		return 0

	if n == 0: 	 #球が0個なら1通り
		ans = 1
	else:
		ans = 0
		#i=2の時の数え上げ
		for x in range(2):
			ball = n-x	#球
			box = k-1	#箱
			ans += Comb(box-1+ball,ball)%mod

	ans *= pow(2,pairs,mod)	#0pairの選び方
	return ans % mod

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		pairs = (i-2)//2
		tmp = 0
		for p0 in range(pairs+1): #p0 = 0pairの数
			tmp1 = calc(K-p0*2 , N , i-p0*2) %mod #k-p0*2,i-p0*2で0pairが0組
			tmp2 = Comb(pairs,p0) %mod #0pairの選び方
			tmp += tmp1 * tmp2
			tmp %= mod
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print(ans[i])


Measured memory_bytes: 62164
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int Ai;
    vector<int> B(N);
    for (int i = 0; i < N; i++) {
        cin >> Ai;
        B[i] = Ai - (i+1);
    }

    sort(B.begin(), B.end());
    int b = N/2;
    long long ans = 0;
    for (int x : B) {
        ans += abs(x - B[b]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>

using namespace std;

int main()
{
    char prev = 0, c;
    int ans = 0;

    while (cin && cin >> c) {
        if (c != prev) {
            ans++;
            prev = c;
        }
    }
    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long dp[] = new long[n + 1];
        if (n >= 2) {
            dp[0] = 2;
            dp[1] = 1;
            for (int i = 2; i <= n; i++) {
                dp[i] = dp[i - 1] + dp[i - 2];
            }
            System.out.println(dp[n]);
        }
        if (n == 1) System.out.println(1);
    }
}


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

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

    int ans = 0;
    rep(i,n) {
        long long x, y;
        cin >> x >> y;
        if (sqrt(x*x + y*y) <= d) ans++;
    }

    cout << ans << endl;
    
}

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

int main() {
  int D, N;
  cin >> D >> N;

  int ans;
  if (D == 0) {
    ans = N;
    if (N % 100 == 0) ans += 1;
  }
  if (D == 1) {
    ans = 100 * N;
    if (N % 100 == 0) ans += 100;
  }
  if (D == 2) {
    ans = 10000 * N;
    if (N % 100 == 0) ans += 10000;
  }

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


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

int main(){
  vector<char> v;
  string s;
  cin >> s;
  int n=(int)s.size(),i;
  for(i=0;i<n;i++){
    if(s[i]=='B'){
      if(!v.empty())v.pop_back();
    }else v.push_back(s[i]);
  }
  n=(int)v.size();
  for(i=0;i<n;i++)cout << v[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    int res1 = a+b, res2 = a-b, res3 = a*b;
    int temp = max(res1, res2);
    cout << max(temp, res3);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		for(int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		
		for(int i = 1; i <= n; i++) {
			StringBuilder sb = new StringBuilder();
			sb.append("node ");
			sb.append(i);
			sb.append(": key = ");
			sb.append(a[i]);
			if(i/2 > 0) {
				sb.append(", parent key = ");
				sb.append(a[i/2]);
			}
			if(i*2 <= n) {
				sb.append(", left key = ");
				sb.append(a[i*2]);
			}
			if(i*2+1 <= n) {
				sb.append(", right key = ");
				sb.append(a[i*2+1]);
			}
			sb.append(", ");
			String s = sb.toString();
			System.out.println(s);
		}
		
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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


Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int> L;

void chmin(int &x,int y){
    if(x > y){
        x = y;
    }
}

int DFS(int i,int a,int b,int c){

    if(i == N){ //終了条件
        if(!a || !b || !c){
            return 100000;
        }
        else {
            return abs(a - A) + abs(b - B) + abs(c - C);
        }
    }
    int res = DFS(i+1,a,b,c);
    chmin(res,DFS(i+1,a + L[i],b,c) + (a ? 10 : 0));
    chmin(res,DFS(i+1,a,b + L[i],c) + (b ? 10 : 0));
    chmin(res,DFS(i+1,a,b,c + L[i]) + (c ? 10 : 0));

    return res;

}


int main(){
    cin >> N >> A >> B >> C;
    L.resize(N);
    for(int j = 0; j < N ;j++){
        cin >> L[j];
    }

    cout << DFS(0,0,0,0) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
const int N = 2e5+5;
const int mod = 1e9+7;
int n,X,Y,inv[N],mn[N],mn1=mod,mn2=mod,ans=1,tot;
vector<int>v[N];
int main(){
	n=gi();X=gi();Y=gi();inv[1]=1;
	for (int i=2;i<=n;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for (int i=2;i<=n;++i) inv[i]=1ll*inv[i]*inv[i-1]%mod;
	for (int i=1,x;i<=n;++i) x=gi(),v[x].push_back(gi());
	for (int i=1;i<=n;++i)
		if (v[i].size()){
			sort(v[i].begin(),v[i].end());
			mn2=min(mn2,mn[i]=v[i][0]);
			if (mn2<mn1) swap(mn1,mn2);
		}else mn[i]=mod;
	for (int i=1;i<=n;++i){
		int mm=mn[i]==mn1?mn2:mn1,sz=v[i].size();
		while (sz>1&&v[i][sz-1]+mn[i]>X&&v[i][sz-1]+mm>Y) --sz,v[i].pop_back();
		if (mn[i]+mn1<=Y) ans=1ll*ans*inv[sz]%mod,tot+=sz;
	}
	for (int i=1;i<=tot;++i) ans=1ll*ans*i%mod;
	printf("%d\n",ans);return 0;
}


Measured memory_bytes: 10880
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    // #pragma GCC optimize("Ofast")
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double

    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int a[MAX],b[MAX];
    int pre[MAX];
    int sum,cnt,lft,maxi,m;

    void solve()
    {
        cin>>n>>m>>k;
        fo(i,1,n+1)cin>>a[i];
        fo(i,1,m+1)cin>>b[i];
        fo(i,1,m+1)pre[i]+=pre[i-1]+b[i];
        fo(i,0,n+1)
        {
            sum+=a[i];
            if(sum>k)break;
            lft=k-sum;
            auto pos=upper_bound(pre+1,pre+m+1,lft)-(pre+1);
            maxi=max(maxi,i+pos);
        }
        cout<<maxi<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 8352
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> points[n];
    REP(i, n) {
        ll x, y, h; cin >> x >> y >> h;
        points[i].push_back(x);
        points[i].push_back(y);
        points[i].push_back(h);
    }

    for (ll cx = 0; cx <= 100; cx++) {
        for (ll cy = 0; cy <= 100; cy++) {
            ll h;
            REP(i, n) {
                if (points[i][2] > 0) {
                    h = points[i][2] + abs(points[i][0] - cx) + abs(points[i][1] - cy);
                    break; 
                }
            }

            bool flg = true;
            REP(i, n) {
                if (max(h - abs(points[i][0]-cx) - abs(points[i][1] - cy), 0LL) != points[i][2]) flg = false;
            }

            if (flg) {
                cout << cx << " " << cy << " " << h << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
tmp=2020
if b-a>=2019:
  print(0)
else:
  for i in range(b-a+1):
    for j in range(b-a+1):
      if i==j:
        continue
      x=a+i
      y=a+j
      if tmp>x*y%2019:
        tmp=x*y%2019
  print(tmp)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x,i,n,m;
    while(~scanf("%d",&n))
    {
        if(n%2==0)
        {
            printf("%d\n",n);
        }
        else
        {
            printf("%d\n",2*n);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
typedef pair<int, int> P;

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

ll a[100010];


ll plus_sequence(int n) {
	ll ans = 0, sum = a[0];
	if (a[0] <= 0) {
		ans = -a[0] + 1;
		sum = 1;
	}
	for (int i = 1;i < n;i++) {
		sum += a[i];
		if (i%2==1) {
			if (sum > 0) {
				ans = ans + sum + 1;
				sum = -1;
			}
			else {
				if (sum == 0) {
					ans++;
					sum--;
				}
			}
		}
		else {
			if (sum < 0) {
				ans = ans - sum + 1;
				sum = 1;
			}
			else {
				if (sum == 0) {
					ans++;
					sum++;
				}
			}
		}
	}
	return ans;
}

ll minus_sequence(int n) {
	ll ans = 0, sum = a[0];
	if (a[0] >= 0) {
		ans = a[0] + 1;
		sum = -1;
	}
	for (int i = 1;i < n;i++) {
		sum += a[i];
		if (i%2==0) {
			if (sum > 0) {
				ans = ans + sum + 1;
				sum = - 1;
			}
			else {
				if (sum == 0) {
					ans++;
					sum--;
				}
			}
		}
		else {
			if (sum < 0) {
				ans = ans - sum + 1;
				sum = 1;
			}
			else {
				if (sum == 0) {
					ans++;
					sum++;
				}
			}
		}
	}
	return ans;
}

int main(void) {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	ll ans = 0;
	ans = plus_sequence(n);
	cout << min(ans, minus_sequence(n)) << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

 class Graphs {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graphs() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}//for
		}//for
		for(i = 0; i < totalVertex; i ++) {
			for(j = 0; j < totalVertex; j ++) {
				int u = in.nextInt();
				if(u==-1) {
				adjMatrix[i][j] = 0;
				}
				else {
					adjMatrix[i][j] = 1;
				adjWeight[i][j] = u;
				}
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int[] Dijkstra(int s) {
		int[] distance = new int[totalVertex];
		distance[0] = 0;
		
		for(int i = 1; i < totalVertex; i++) {
			distance[i] = Integer.MAX_VALUE;
		}//for
		int currentNode = getUnsettledNearest(distance);
		
		while(currentNode!= -1) {
			LinkedList<Integer> neighborsOfCurrentNode = getUnsettledNeighbors(currentNode);
			ifSettled[currentNode]= true;
			
			for(Integer neighbor : neighborsOfCurrentNode) {
				distance[neighbor] = Math.min(distance[neighbor],  + getWeight(currentNode, neighbor));
			} 
			
			
		
			currentNode = getUnsettledNearest(distance);
		}//while
	
		
		
		
			
			
	
		return distance;
	
	}//dijkstra
}

public class Main {
	public static void main(String[] argv) {
		Graphs g = new Graphs();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		int sum = 0;
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			sum += dist[i];
		}	
		
		System.out.println(sum);
		}
	}


 
	


Measured memory_bytes: 41724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    vector<ll> NAME(5);
    ll N;
    cin >> N;
    vector<string> S(N);
    REP(i,N)cin >> S[i];
    REP(i,N){
        if(S[i][0] == 'M'){
            NAME[0]++;
        }else if(S[i][0] == 'A'){
            NAME[1]++;
        }else if(S[i][0] == 'R'){
            NAME[2]++;
        }else if(S[i][0] == 'C'){
            NAME[3]++;
        }else if(S[i][0] == 'H'){
            NAME[4]++;
        }
    }
    ll ans = 0;
    for(ll i = 0;i < 5;i++){
        for(ll l = i+1;l < 5;l++){
            for(ll k = l+1;k < 5;k++){
                ans += NAME[i]*NAME[l]*NAME[k];
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6312
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
 
int main() {
  string S, T;
  cin >> S >> T;
  if (T.size() > 11 || S.size() + 1 != T.size()) {
    cout << "No" << endl;
    return 0;
  }
  for (auto i = 0; i < S.size(); ++i) {
    if (S[i] != T[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using ll=long long;

int main() {
  string S; cin >>S;
  cout <<(count(S.begin(),S.end(),'x')<8 ? "YES":"NO") <<endl;
  return 0;
}


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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    a--; b--;

    vector<vector<char> > c(100, vector<char>(100));

    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 50; j++) {
            c[i][j] = '#';
        }
    }
    for (int i = 0; i < 100; i++) {
        for (int j = 50; j < 100; j++) {
            c[i][j] = '.';
        }
    }

    int x = 1, y = 1;
    for (int i = 0; i < a; i++) {
        c[x][y] = '.';
        y += 2;
        if (y >= 49) {
            x += 2;
            y = 1;
        }
    }

    x = 1, y = 51;
    for (int i = 0; i < b; i++) {
        c[x][y] = '#';
        y += 2;
        if (y >= 99) {
            x += 2;
            y = 51;
        }
    }
    
    cout << "100 100" << endl;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            cout << c[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math

a,b,x = map(int,input().split())	

Z=a*a*b
if x>(Z/2):
    theta=math.atan(((2*Z)-(2*x))/(a*a*a))
    
else:
    theta=math.atan((2*x)/(a*b*b))
    theta=1/2*(math.pi)-theta


print(theta*180/math.pi)

Measured memory_bytes: 3060
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll d[110];
    ll a[110][110];
    ll cnt[110] = {};
    rep(i,0,K){
        cin >> d[i];
        rep(j,0,d[i]){
            cin >> a[i][j];
            a[i][j]--;
            cnt[a[i][j]]++;
        }
    }
    ll ans = 0;
    rep(i,0,N){
        if(cnt[i] == 0) ans++;
    }
    print(ans);

    

}

Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int INF = 1001001001;

int c[10][1005];

int main() {
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	int ans = INF;
	rep(div,1<<(h-1)){
		int g = 0;
		vector<int> id(h);
		rep(i,h){
			id[i] = g;
			if (div>>i&1) ++g;
		}
		++g;
		rep(i,g)rep(j,w) c[i][j] = 0;
		rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');
		int num = g-1;
		vector<int> now(g);
		auto add = [&](int j){
			rep(i,g) now[i] += c[i][j];
			rep(i,g) if(now[i] > k) return false;
			return true;
		};
		rep(j,w){
			if (!add(j)) {
				num++;
				now = vector<int>(g);
				if (!add(j)){
					num = INF;
					break;
				}
			}
		}
		ans = min(ans,num);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int persons = sc.nextInt();
        int train = sc.nextInt();
        int cab = sc.nextInt();
        
        if (persons * train > cab) {
            System.out.println(cab);
        } else {
            System.out.println(persons * train);
        }
    }
}

Measured memory_bytes: 21716