akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if(a < b && b < c)
    {
      printf("Yes\n");
    }
  else
    {
      printf("No\n");
    }
  return 0;
}


Measured memory_bytes: 2116
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    char c;
    cin >> c;

    if ('A' <= c && c <= 'Z') {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

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

	    String c= gs();

	    if(c.equals("a") || c.equals("i")||c.equals("u")||c.equals("e")||c.equals("o")) {
        System.out.print("vowel");
	    }else {
	    	System.out.print("consonant");
	    }
        
	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35340
x, k, d = map(int,input().split())
x = abs(x)
if (x >= k*d):
  print(x - k*d)
else:
  nokori = k - x//d
  if (nokori%2 == 0):
    print(abs(x%d))
  else:
    print(abs(x%d - d))


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin >> s;
	vector<int> dp(s.size() + 1);
	int g = 0, p = 0;
	for(int i = 1; i <= s.size(); i++) {
		if(g == p) {
			if(s[i - 1] == 'g') {
				dp[i] = dp[i - 1];
				g++;
			}
			else {
				dp[i] = dp[i - 1] - 1;
				g++;
			}
		}
		else {
			if(s[i - 1] == 'g') {
				dp[i] = dp[i - 1] + 1;
				p++;
			}
			else{
				dp[i] = dp[i - 1];
				p++;
			}
		}
	}
	cout << dp.back() << endl;
	return 0;                                              
}
	


Measured memory_bytes: 848
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<int> A;

int N, K;

void input()
{
    cin >> N >> K;
    A.reserve(N);
    for (int i = 0; i < N; ++i)
    {
        int v;
        cin >> v;
        A.push_back(v);
    }
}

int solve()
{
    int ans = 0;
    for (int total = 1; total <= K && total <= A.size(); ++total)
    {
        for (int left = 0; left <= total; ++left)
        {
            priority_queue<int, vector<int>, std::greater<int>> Q;
            int right = total - left;
            int sum = 0;
            for (int i = 0; i < left; ++i)
            {
                int x = A[i];
                sum += x;
                Q.push(x);
            }
            for (int i = 0; i < right; ++i)
            {
                int x = A[A.size() - 1 - i];
                sum += x;
                Q.push(x);
            }
            int z = total;
            while (!Q.empty() && Q.top() < 0 && z < K)
            {
                int x = Q.top();
                Q.pop();
                sum -= x;
                ++z;
            }
            if (sum > ans)
                ans = sum;
        }
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    input();
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>

using namespace std;

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

  vector<int> a,b,c;
  vector<int> an,bn,cn;

  for(int i=0;i<n;++i){
    int tempa,tempb,tempc;
    cin >> tempa >> tempb >> tempc;
    a.push_back(tempa);
    b.push_back(tempb);
    c.push_back(tempc);
  }

  an.push_back(a[0]);
  bn.push_back(b[0]);
  cn.push_back(c[0]);

  for(int i=1; i<n; i++){
    if(bn[i-1] < cn[i-1]){
      an.push_back(cn[i-1]+a[i]);
    }else{
      an.push_back(bn[i-1]+a[i]);
    }
    if(an[i-1] < cn[i-1]){
      bn.push_back(cn[i-1]+b[i]);
    }else{
      bn.push_back(an[i-1]+b[i]);
    }
    if(bn[i-1] < an[i-1]){
      cn.push_back(an[i-1]+c[i]);
    }else{
      cn.push_back(bn[i-1]+c[i]);
    }
  }

  int max = std::max({an[n-1],bn[n-1],cn[n-1]});
  cout << max << endl;
        return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  string str;
  int f, l;
  cin >> str;
  f = stoi(str.substr(0,2));
  l = stoi(str.substr(2,2));
  if(f<=12 and f>=1) cout << ((l<=12 and l>=1) ? "AMBIGUOUS" : "MMYY");
  else cout << ((l<=12 and l>=1) ? "YYMM" : "NA");
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int N, M, xi, yi, zi;
vector<pair<int, int> > g[100099];
vector<int> visited_1(100099, -1);
vector<int> visited_2(100099, -1);

bool issue = false;

void dfs(int s, vector<int> &visited, int label) {
  visited[s] = label;

  for(auto &pi : g[s]) {
    if(visited[pi.first] != -1) {
      if((visited[s] + pi.second + visited[pi.first]) % 2) {
        issue = true;
      }
    } else {
      dfs(pi.first, visited, (visited[s] + pi.second) % 2);
    }
  }
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> M;
  for(int i = 0;i < M;i++) {
    cin >> xi >> yi >> zi;
    g[xi].push_back({yi, zi % 2});
    g[yi].push_back({xi, zi % 2});
  }

  int ans = 0;
  for(int i = 1;i <= N;i++) {
    if(visited_1[i] == -1) {
      dfs(i, visited_1, 1);
      bool i1 = issue;
      issue = false;
      dfs(i, visited_2, 0);
      bool i2 = issue;
      issue = false;
      // if(i1 + i2 == 0) ans++;
      // cout << i1+i2 << endl;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
typedef unsigned long long ull;
using namespace std;

ull hanten(ull n, ull* A);
void merge_sort(ull* A, ull left, ull right);
void merge(ull* A, ull left, ull mid, ull right);

int main() {
  ull n; cin >> n;
  ull A[n]; for (ull i=0; i<n; i++) cin >> A[i];
  cout << hanten(n, A) << endl;
}

ull result = 0;// グローバル変数でカウントする
ull hanten(ull n, ull* A) {
  merge_sort(A, 0, n-1);
  return result;
}

void merge_sort(ull* A, ull left, ull right) {
  if (left == right) return;
  ull mid = (left + right) / 2;
  merge_sort(A, left, mid); merge_sort(A, mid + 1, right);
  merge(A, left, mid, right);
}

void merge(ull* A, ull left, ull mid, ull right) {
  ull i = left; ull j = mid + 1; ull k = 0;
  ull B[right - left + 1];
  ull invnum = 0;// 反転した回数（既に飛び越えた跡地の数）
  while (i <= mid && j <= right) {
    if (A[i] <= A[j]) {
      B[k] = A[i]; i++;
    } else {
      B[k] = A[j];
      result += j - i - invnum; invnum++;
      j++;//次のステップへ
    }
    k++;
  }
  if (i == mid + 1) {
    while (j <= right) {
      B[k] = A[j]; j++; k++;
    }
  } else {// 右配列が先に空になった時
    while (i <= mid) {
      B[k] = A[i]; i++; k++;
    }
  }
  for (ull i=0; i<k; i++) {
    A[left + i] = B[i];
  }
}


Measured memory_bytes: 6220
#include<stdio.h>

#define N 2000
#define Q 2000

int solve(int,int);

int n,A[N];

int main()
{

  int q,M[Q],i;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i = 0; i < q; i++){
    scanf("%d",&M[i]);
  }

  for(i = 0; i < q; i++){
    if(solve(0,M[i]) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(i,m){

  int res;

  if (m == 0) return 1;
  if (i >= n) return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);

  return res;
}

Measured memory_bytes: 588
#include<stdio.h>

int main(){
  int n;
  int i, j, k;
  int b, f, r, v;
  int arr[4][3][10];

  // array initialization
  for(i = 0; i < 4; i++){
    for(j = 0; j < 3; j++){
      for(k = 0; k < 10; k++){
	arr[i][j][k] = 0;
      }
    }
  }

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    arr[b - 1][f - 1][r - 1] += v;
  }

  for(i = 0; i < 4; i++){
    for(j = 0; j < 3; j++){
      for(k = 0; k < 10; k++){
	printf(" %d", arr[i][j][k]);
      }
      printf("\n");
    }
    if(i != 3){
      printf("####################\n");
    }
  }

  return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin>>s;
	if (s[2] == s[3] && s[4] == s[5]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

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

#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

signed main(){
 float n;
 cin>>n;
  float a;
 a = ceil(n/1.08);
 float b = floor(n/1.08);
  if(n==floor(a*1.08)){
	cout << a;
             }else if (n==floor(b*1.08)){
             cout << b;
             }else{
   cout << ":("; 
  }
			 
             }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int abc[3];
    rep(i,3) cin>>abc[i];
    sort(abc,abc+3);
    cout<<abc[0]+abc[1]+abc[2]*10<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
max = 0
c = 0
x = h[0]
for i in range(1, n):
    if x >= h[i]:
        x = h[i]
        c += 1
    else:
        x = h[i]
        c = 0
    if max < c:
        max = c
print(max)

Measured memory_bytes: 14224
from collections import deque

def solve():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    INF = 10 ** 9
    d = [[INF] * W for i in range(H)]
    d[0][0] = 1 if A[0][0] == '#' else 0

    prepare = 1 if A[0][0] == '#' else 0
    q = deque([(prepare, 0, 0)])
    while q:
        c, x, y = q.popleft()
        for a, b in [(1,0), (0,1)]:
            nx, ny = x+a, y+b
            if nx >= W or ny >= H: continue
            k = 1 if A[y][x] != A[ny][nx] else 0
            if c+k >= d[ny][nx]: continue
            d[ny][nx] = c+k
            q.append((c+k, nx, ny))

    return (d[H-1][W-1]+1)//2

print(solve())

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		long ans=0;
		int max=0;
		int n=sc.nextInt();
		while(n-->0)
		{
			int x=sc.nextInt();
			if(x>=max)
				max=x;
			else
				ans+=max-x;
		}
		System.out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 52548
n, m = [int(i) for i in input().split()]
A = [int(i) for i in input().split()] #A[0]-A[n-1]
S = sum(A)
threshold = S /(4 * m) 
ans = 0
no = 0
for i in range(n):
    if A[i] >= threshold:
        ans = ans +1
        if ans == m:
            print("Yes")
            break
        else:
            continue
    else:
        no = no +1
        if no == (n-m+1):
            print("No")
            break
        else:
            continue



Measured memory_bytes: 9108
package main

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

var (
	in = bufio.NewScanner(os.Stdin)
)

func init() {
	in.Buffer([]byte{}, math.MaxInt64)
	in.Split(bufio.ScanWords)
}
func main() {
 tmp := readFloat64Slice(2)
 n := tmp[0]
 m := tmp[1]
 a := readIntSlice(int(n))
 //sort.Ints(a)
 sum := 0.0
 for _,val := range a {
	sum += float64(val)
 }
 //if a[m-1] >= sum/(4*m) {
 //	fmt.Println("Yes")
 //	return
 //}
 //fmt.Println("No")
 count := 0
 ninki := sum  / float64(4 * m)
 for _, val := range a {
	if float64(val) >= ninki {
		count++
	}
 }
 if count >= int(m) {
 	fmt.Println("Yes")
 	return
 }
 fmt.Println("No")
}

func readIntSlice(n int) []int {
	line := readStringSlice(n)
	slice := make([]int, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseInt(tmp, 10, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, int(val))
	}
	return slice
}
func readFloat64Slice(n int) []float64 {
	line := readStringSlice(n)
	slice := make([]float64, 0, len(line))
	for _, tmp := range line {
		val, err := strconv.ParseFloat(tmp, 64)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		slice = append(slice, val)

	}
	return slice
}
func readString() string {
	in.Scan()
	return in.Text()

}
func readStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = readString()
	}
	return s
}
func dump(value ...interface{}) {
	for _, v := range value {
		fmt.Printf("%#v\n", v)
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

string N;

int g[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1};
int memo[1010101][2];
int f(int i, int j) {  // =[0,i]円+j円を支払う最小枚数
    if (i < 0) {
        if (j == 0)
            return 0;
        else
            return 1;
    }
    if (0 <= memo[i][j])
        return memo[i][j];

    int res = INF;
    FOR(d, 0, 10) {
        int n = N[i] - '0' + j;

        int sm = g[d];
        if (d < n)
            sm += f(i - 1, 1) + g[10 + d - n];
        else
            sm += f(i - 1, 0) + g[d - n];

        chmin(res, sm);
    }

    return memo[i][j] = res;
}
/*
void _main() {
    cin >> N;
    rep(i, 0, 10101) rep(j, 0, 2) memo[i][j] = -1;
    cout << f(N.length() - 1, 0) << endl;
}
*/

void solve() {
    FOR(i, 0, 1010001)
    FOR(j, 0, 2)
    memo[i][j] = -1;
    cout << f(N.length() - 1, 0) << endl;
}

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


Measured memory_bytes: 95260
#coding:utf-8
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
cnt = [0,0,0]
for p in P:
    if p <= A:
        cnt[0] +=1
    elif  p >= B+1:
        cnt[2] += 1
    else:
        cnt[1] += 1
print (min(cnt))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n,k;
int main(){
    cin >> n >> k;
    int cur = 1;
    for(int i=1;i<=n;i++){
        if((cur*2)>(cur+k)) cur += k;
        else cur *= 2;
    }
    cout << cur << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
constexpr ll MOD = 998244353LL;
ll power(const ll p, const ll n)
{
    if (n == 0) { return 1; }
    if (n % 2 == 1) {
        return power(p, n - 1) * p % MOD;
    } else {
        const ll pp = power(p, n / 2);
        return pp * pp % MOD;
    }
}
int main()
{
    string S;
    cin >> S;
    if (S == string(S.size(), 'a') or S == string(S.size(), 'b') or S == string(S.size(), 'c')) {
        cout << 1 << endl;
        return 0;
    }
    vector<int> s(S.size());
    for (int i = 0; i < S.size(); i++) { s[i] = S[i] - 'a'; }
    if (S.size() <= 3) {
        set<vector<int>> used;
        queue<vector<int>> q;
        q.push(s);
        used.insert(s);
        while (not q.empty()) {
            const auto v = q.front();
            q.pop();
            for (int i = 0; i < v.size() - 1; i++) {
                if (v[i] != v[i + 1]) {
                    auto tmp = v;
                    const int u = (3 - v[i] - v[i + 1]) % 3;
                    tmp[i] = u;
                    tmp[i + 1] = u;
                    if (used.find(tmp) == used.end()) {
                        used.insert(tmp);
                        q.push(tmp);
                    }
                }
            }
        }
        cout << used.size() << endl;
    } else {
        const int size = s.size();
        ll ans = 1;
        ll sum = accumulate(s.begin(), s.end(), 0LL) % 3;
        for (int i = 0; i < size - 1; i++) {
            if (s[i] == s[i + 1]) {
                ans--;
                break;
            }
        }
        ans += power(3, size - 1);
        vector<vector<vector<ll>>> dp(size, vector<vector<ll>>(3, vector<ll>(3, 0)));
        dp[0][0][0] = 1;
        dp[0][1][1] = 1;
        dp[0][2][2] = 1;
        for (int i = 1; i < size; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    for (int l = 0; l < 3; l++) {
                        if (l == j) { continue; }
                        (dp[i][l][(k + l) % 3] += dp[i - 1][j][k]) %= MOD;
                    }
                }
            }
        }
        ll minus = 0;
        for (int j = 0; j < 3; j++) {
            (minus += dp[size - 1][j][sum]) %= MOD;
        }
        cout << (ans + MOD - minus) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 40248
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
string S;
cin >> S;
int ans = 0;
for (int i = 0;i < S.size();i++) {
    if (S.at(i) == '+') ans++;
    else ans--;
}
cout << ans << endl;


return 0;
}


Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

a = int(ri())

print(a+a*a+a*a*a)

Measured memory_bytes: 62840
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	string S;
	cin >> S;
	
	rep(i, 4)cout << S[i];
	cout << " ";
	rep(i, 8)cout << S[i + 4];
	cout << endl;
}

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

int main()
{
  int n,m;cin>>n>>m;
  string s;cin>>s;
  int now=n;
  int i;
  bool ch=false;
  vector<int> ans(0);
  while(true)
  {
    if(now<=m)
    {
      ans.emplace_back(now);
      break;
    }
    for(i=m;i>=1;i--)
    {
      if(s.at(now-i)=='0')
      {
        now=now-i;
        ans.emplace_back(i);
        break;
      }
      if(i==1)ch=true;
    }
    if(ch)break;
  }
  if(ch)cout<<-1<<endl;
  else
  {
    for(i=ans.size()-1;i>=0;i--)
    {
      if(i==0)cout<<ans.at(i);
      else cout<<ans.at(i)<<' ';
    }
    cout<<endl;
  } 
}


Measured memory_bytes: 1144
#include <stdio.h>

int main (void)

{

char in[1001];

int out,i;

for(;;)

{

scanf("%s",in);

if(in[0]=='0')

{

return 0;

}

out=0;

for(i=0;in[i]!='\0';i++)

{

out+=in[i]-'0';

}

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

}

}

Measured memory_bytes: 536
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;

int main(){
    int a,b,k;
    double N;
    cin >> a >> b;
    if(b<10){
        N = a*10 + b;
    }else if(b>=10 && b<100){
        N = a*100 + b;
    }else{
        N = a*1000 + b;
    }
    k = sqrt(N);
    if (N == k * k){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;

}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, A, B;
int H[100010];

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

	cin >> N >> A >> B;
	rep(i, 0, N)cin >> H[i];

	int l = 0, r = (int)1e9;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		int cnt = 0;
		rep(i, 0, N)
		{
			cnt += (max(0LL, H[i] - mid * B) + (A-B) - 1) / (A-B);
		}
		if (cnt <= mid)
		{
			r = mid;
		}
		else
		{
			l = mid;
		}
	}

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 1024
a11,a12,a13 = map(int,input().split())
a21,a22,a23 = map(int,input().split())
a31,a32,a33 = map(int,input().split())
n = int(input())
b = [int(input()) for i in range(n)]

A = [a11,a12,a13,a21,a22,a23,a31,a32,a33]


for i in range(9):
  for j in range(n):
    if A[i] == b[j]:
      A[i] = 0

if \
(A[0]+A[1]+A[2]) *\
(A[3]+A[4]+A[5]) *\
(A[6]+A[7]+A[8]) *\
(A[0]+A[3]+A[6]) *\
(A[1]+A[4]+A[7]) *\
(A[2]+A[5]+A[8]) *\
(A[0]+A[4]+A[8]) *\
(A[2]+A[4]+A[6])  == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque()
for i in range(n):
    if ((i+1) % 2) == (n % 2):
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = ' '.join([str(i) for i in b])
print(ans)

Measured memory_bytes: 29124
class Edge
  def initialize arr
    @x, @y, @cost = arr
  end
  attr_reader :x, :y, :cost
end

class Graph
  def initialize v, es
    @v, @es = v, es
    @inf = 1.0 / 0
  end

  def toAdjacencyMatrix
    return if @m
    @m = Array.new(@v).map{Array.new(@v, @inf)}
    @es.each{|e|
      if @m[e.y][e.x] > e.cost
        @m[e.x][e.y] = @m[e.y][e.x] = e.cost
      end
    }
  end

  def floydWarshall
    @dist = @m
    @v.times{ |i| @v.times{ |j| @v.times{ |k|
      # @dist[j][k] = [@dist[j][k], @dist[j][i] + @dist[i][k]].min
      if @dist[j][k] > x = @dist[j][i] + @dist[i][k]
        @dist[j][k] = [@dist[j][k], @dist[j][i] + @dist[i][k]].min
      end
    }}}
    return @dist
  end
end
# require 'benchmark'
# result = Benchmark.realtime {

  n, m, r_ = gets.split.map(&:to_i)
  r = gets.split.map{|i| i.to_i.pred}
  e = m.times.map {
    a, b, c = gets.split.map(&:to_i)
    Edge.new([a.pred, b.pred, c])
  }

  g = Graph.new n, e
  g.toAdjacencyMatrix()
  d = g.floydWarshall
  p r.permutation.map{|perm|
    perm.each_cons(2).map{|a,b|d[a][b]}.inject:+
  }.min

# }
# p result



Measured memory_bytes: 5116
#include <stdio.h>

int main(void){
	int c['z' - 'a' + 1];
	char str[105];
	scanf("%s", str);
	for(int i = 0; i < 'z' - 'a' + 1; i++)
		c[i] = 0;
	for(int i = 0; str[i] != '\0'; i++)
		c[str[i] - 'a']++;
	for(int i = 0; i < 'z' - 'a' + 1; i++){
		if(c[i] % 2){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    k: usize,
    aa: [usize; n]
  }
  let modulo = 1_000_000_007;
  let mut dp = vec![vec![0i64; k+1]; n+1];
  dp[0][0] = 1;
  for (i, &a) in aa.iter().enumerate() {
    dp[i+1][0] = 1;
    for c in 0 .. k {
      dp[i+1][c+1] = (dp[i+1][c] + dp[i][c+1]) % modulo;
      if let Some(d) = c.checked_sub(a) {
        dp[i+1][c+1] = (dp[i+1][c+1] - dp[i][d] + modulo) % modulo;
      }
    }
  }
  println!("{}", dp[n][k]);
}


Measured memory_bytes: 106748
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn=400;
const int mod=998244353;
int n;
struct que
{
	int A,B;
}a[405];
int dp[405][405][405],sumA,sumB;
long long fir[405],inv[405],A[405][405];
int dev(int v)
{
	return v<0?v+mod:v;
}
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
int main()
{
	fir[0]=fir[1]=1;
	for(int i=2;i<=maxn;i++)fir[i]=fir[i-1]*i%mod;
	inv[maxn]=ksm(fir[maxn],mod-2);
	for(int i=maxn-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].A,&a[i].B);
	for(int i=1;i<=n;i++)
	{
		A[i][0]=1;
		for(int j=1;j<=maxn;j++) A[i][j]=A[i][j-1]*a[i].A%mod;
	}
	dp[0][0][0]=mod-1;
	for(int i=1;i<=n;i++)
	{
		sumA+=a[i].A;sumB+=a[i].B;
		for(int j=0;j<=sumA;j++)
		for(int k=0;k<=sumB;k++)
		{
			dp[i][j][k]=dp[i-1][j][k];
			if(j>=a[i].A) for(int l=0;l<=min(a[i].B-1,k);l++) dp[i][j][k]=dev(dp[i][j][k]-1ll*dp[i-1][j-a[i].A][k-l]*inv[l]%mod*A[i][l]%mod);
		}
	}
	long long ans=0;
	for(int i=1;i<=sumA;i++)
	for(int j=0;j<=sumB;j++)
	{
		long long w=ksm(ksm(i,mod-2),j);
		long long p=sumA*ksm(i,mod-2)%mod;
		ans=(ans+p*fir[j]%mod*w%mod*dp[n][i][j]%mod)%mod;
	}
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
}

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 510000;
int a[MAXN];
int p[MAXN];
set<int> ss;
int cc[MAXN];
vector<int> go[MAXN];
int rmq[MAXN * 4];
int n, k;
int lg[MAXN];
int rg[MAXN];
int ans[MAXN];

void build(int v, int tl, int tr) {
	rmq[v] = n;
	if (tl + 1 == tr)
		return;
	int m = (tl + tr) >> 1;
	build(v * 2 + 1, tl, m);
	build(v * 2 + 2, m, tr);
}

void upd(int v, int tl, int tr, int x, int y) {
	if (tl + 1 == tr) {
		rmq[v] = y;
		return;
	}
	int m = (tl + tr) >> 1;
	if (x < m)
		upd(v * 2 + 1, tl, m, x, y);
	else
		upd(v * 2 + 2, m, tr, x, y);
	rmq[v] = min(rmq[v * 2 + 1], rmq[v * 2 + 2]);
}

int get(int v, int tl, int tr, int l, int r) {
	if (r <= tl || tr <= l)
		return n;
	if (l <= tl && tr <= r)
		return rmq[v];
	int m = (tl + tr) >> 1;
	return min(get(v * 2 + 1, tl, m, l, r), get(v * 2 + 2, m, tr, l, r));
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i)
		scanf("%d", p + i), --p[i], a[p[i]] = i;
	build(0, 0, n);
	for (int i = n - 1; i >= 0; --i) {
		lg[i] = get(0, 0, n, max(0, a[i] - k + 1), a[i]);
		rg[i] = get(0, 0, n, a[i], min(n, a[i] + k));
		if (lg[i] != n)
			go[lg[i]].push_back(i), ++cc[i];
		if (rg[i] != n)
			go[rg[i]].push_back(i), ++cc[i];
		upd(0, 0, n, a[i], i);
		if (lg[i] == n && rg[i] == n)
			ss.insert(a[i]);
	}
	int cur = n - 1;
	while (!ss.empty()) {
		int x = *ss.rbegin();
		ss.erase(x);
		int y = p[x];
		ans[x] = cur;
		--cur;
		for (int j: go[y]) {
			--cc[j];
			if (cc[j] == 0)
				ss.insert(a[j]);
		}
	}
	for (int i = 0; i < n; ++i)
		printf("%d ",  ans[i] + 1);
	printf("\n");
	return 0;
}



Measured memory_bytes: 56704
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n; 

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  ll ans=0;

    rep(i,n-1){
      if(p[i]==i+1) {
        swap(p[i],p[i+1]);
        ans++;
      }
    }

    if(p[n-1]==n) ans++;

  cout << ans << endl;

}

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

int main() {
	int N, K, a, b;
	cin >> N >> K;
	for (int i = 0; i < K; ++i) {
		cin >> a >> b;
		cout << 1 + min({ N - a, N - b, a - 1, b - 1 }) % 3 << endl;
	}
}


Measured memory_bytes: 3044
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author NMouad21
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    LDeque solver = new LDeque();
    solver.solve(1, in, out);
    out.close();
  }

  static class LDeque {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] a = in.nextIntArrayOneBased(n);
      if (n == 1) {
        out.println(a[1]);
        return;
      }

      long[] pre = new long[n + 1];
      for (int i = 1; i <= n; i++) {
        pre[i] = pre[i - 1] + a[i];
      }

      long[][] dp = new long[n + 1][n + 1];
      for (int i = n; i >= 1; i--) {
        for (int j = i; j <= n; j++) {
          if (j == i) {
            dp[i][j] = a[i];
          } else {
            dp[i][j] = pre[j] - pre[i - 1] - Math.min(dp[i + 1][j], dp[i][j - 1]);
          }
        }
      }
      out.println(dp[1][n] - Math.min(dp[1][n - 1], dp[2][n]));
    }
  }

  static final class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private final int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {}

      byte sgn = 1;
      if (c == 45) { // 45 == '-'
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) { // 48 == '0', 57 == '9'
        res *= 10;
        res += c - 48; // 48 == '0'
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    private static final boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }

    public final int[] nextIntArrayOneBased(final int n) {
      int[] ret = new int[n + 1];
      for (int i = 1; i <= n; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


Measured memory_bytes: 129744
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const long long INF = 1LL<<60;

#define Pdi pair<double, int>
#define Pid pair<int, double>
#define mkp(a, b) make_pair(a, b)
#define ll long long
#define rep(i, a, n) for(int i = a; i < (n); ++i)

struct Graph {
  Graph(int size) {
    this-> n = size;
    adj = vector<vector<Pid>>(size, vector<Pid>());
  }

  void addEdge(int a, int b, double w) {
    adj[a].push_back(mkp(b, w));
    adj[b].push_back(mkp(a, w));
  }

  void dijkstra(int a) {
    d = vector<double>(n, INF);
    d[a] = 0;
    priority_queue<Pdi, vector<Pdi>, greater<Pdi>> que;
    que.push(mkp(0, a));

    while (!que.empty()) {
      int u = que.top().second;
      que.pop();

      for (auto i: adj[u]) {
        if (d[i.first] > d[u] + i.second) {
          d[i.first] = d[u] + i.second;
          que.push(mkp(d[i.first], i.first));
        }
      }
    }
  }

  double dist(int a) {
    return d[a];
  }

private:
  int n;
  vector<vector<Pid>> adj;
  vector<double> d;
};

int main(){
  ll n, m, s, t;
  scanf("%lld%lld%lld%lld", &n, &m, &s, &t);
  --s; --t;
  Graph yen(n), snuke(n);
  rep(i, 0, m) {
    ll u, v, a, b;
    scanf("%lld%lld%lld%lld", &u, &v, &a, &b);
    --u; --v;
    yen.addEdge(u, v, a);
    snuke.addEdge(u, v, b);
  }
  yen.dijkstra(s);
  snuke.dijkstra(t);

  vector<ll> ans;
  rep(i, 0, n) {
    ll a = 1e15 - yen.dist(n - 1 - i) - snuke.dist(n - 1 - i);
    if (ans.empty() || a > ans.back()) {
      ans.push_back(a);
    } else {
      ans.push_back(ans.back());
    }
  }

  reverse(ans.begin(), ans.end());
  for (auto e : ans) {
    cout << e << endl;
  }
}

Measured memory_bytes: 19964
#include <stdio.h>
  
int n,A[2000];
  
int solve(int i, int m) {
    if (m == 0) return 1;
    if (i >= n) return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}
  
int main() {
    int q, x, i;
  
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &x);
        if (solve(0, x)) printf("yes\n");
        else printf("no\n");
    }
  
    return 0;
}


Measured memory_bytes: 2136
import numpy as np
N, M = map(int, input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])
# print('AB', A, B)
for i in range(N - M + 1):
    for j in range(N - M + 1):
        # print('i j', i, j)
        A_subset = A[i:i + M, j:j + M]
        # print('A_subset', A_subset)
        if np.all(A_subset == B):
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 12448
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int a, b, c;
	int ans = 999;
	cin >> a >> b >> c;
	ans = (b + c) - a;
	if (ans < 0) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

l = 0
r = 0
m = []


def fin():
    print("No")
    exit()


for word in s:
    stack = []
    for e in word:
        if stack and stack[-1] == "(" and e == ")":
            stack.pop()
        else:
            stack.append(e)

    if stack:
        if stack[0] == ")" and stack[-1] == "(":
            m.append(stack)
        elif stack[0] == ")":
            r += len(stack)
        else:
            l += len(stack)

ml = []
mm = 0
mr = []

for word in m:
    ll = word.index("(")
    rr = len(word) - ll
    if ll > rr:
        mr.append([ll, rr])
    elif ll < rr:
        ml.append([ll, rr])
    else:
        mm = max(mm, ll)

ml.sort()
for ll, rr in ml:
    l -= ll

    if l < 0:
        fin()

    l += rr

mr.sort(key=lambda x: x[1])
for ll, rr in mr:
    r -= rr

    if r < 0:
        fin()

    r += ll

if mm <= l or mm <= r:
    if l == r:
        print("Yes")
        exit()

fin()


Measured memory_bytes: 57024
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int n,x,y;
    cin>>n>>x>>y;
    --x;--y;
    vector<vector<int>> dist(n,vector<int>(n,-1));
    rep(i,n){
        queue<int> q;
        q.push(i);
        dist[i][i]=0;

        while(!q.empty()){
            int v=q.front();
            q.pop();
            vector<int> nvi;            
            if(v>0) nvi.push_back(v-1);
            if(v<n-1) nvi.push_back(v+1);
            if(v==x) nvi.push_back(y);
            if(v==y) nvi.push_back(x);
            for(auto nv: nvi){
                if(dist[i][nv]!=-1) continue;
                dist[i][nv] = dist[i][v] + 1;
                q.push(nv); 
            }
        }
    }

    vec cnt(n,0);
    rep(i,n)for(int j=i+1;j<n;j++){
        cnt[dist[i][j]]++;
    }

    rep1(i,n-1){
        cout<<cnt[i]<<endl;
    }


}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);
Node treeserch(Node,int);
Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSuccessor(Node);

void treeDelete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if(z->right == NIL || z->left == NIL)
    y = z;
  else
    y = treeSuccessor(z);
  if(y->left != NIL)
    {
      x = y->left;
    }
  else
    {
      x = y->right;
    }

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;

  else
    {
      if(y==y->parent->left)
	y->parent->left = x;
      else
	y->parent->right = x;
    }
  if(y!=z)
    z->key = y->key;
  free(y);
}

Node treeMinimum(Node x)
{
  while(x->left != NIL )
    x = x->left;
  return x;
}

Node treeSearch(Node u, int k)
{
  while(u != NIL && k != u->key)
    {
      if(k < u->key)
	u = u->left;
      else
	u = u->right;
    }
  return u;
}

Node treeSuccessor(Node x)
{
  if(x->right != NIL)
    return treeMinimum(x->right);
  Node y = x->parent;
  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}


void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL)
    {
      y = x;
      if(z->key < x->key)
	{
	  x = x->left;
	}
      else
	{
	  x = x->right;
	}
    }
  z->parent = y;
  if(y==NIL)
    {
      root=z;
    }
  else
    {
      if(z->key < y->key)
	{
	  y->left = z;
	}
      else
	{
	  y->right = z;
	}
    }

}

void inorder(Node u)
{
  if(u == NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u)
{
  if(u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20552
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    if(a + b == c + d){
      System.out.println("Balanced");
    }else{
      System.out.println((a+b) > (c+d) ? "Left" : "Right");
    }
  }
}

Measured memory_bytes: 22868