akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

const int maxn = 25;
int a[maxn], b[maxn], c[maxn];

int main() {
    int n, points = 0, x;
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    
    for(int i = 0; i < n-1; i++){
        cin >> c[i];
    }
    
    for(int i = 0; i < n; i++){
    	if(i > 0 && a[i]==a[i-1]+1){
    		points = points + b[a[i]-1] + c[a[i]-2];
    	}
    	else{
    		points = points + b[a[i]-1];
    	}
    }
    
    cout << points << endl;
    
    
}

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


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

  vector<int> v(N);
  for( int i=0; i<N; ++i) {
    cin >> v[i];
  }

  sort( v.begin(), v.end() );

  double ans = (double)v[0];
  for (int i=0; i<N-1; ++i ) {
    ans = (ans + (double)v[i+1]) / 2;
  }

  cout << ans<< endl;

}


Measured memory_bytes: 256
N = int(input())

a_num = 97

def dfs(s, n, cnt): #s: 現在の文字列, n: 残りの文字数, cnt: 現在の文字列の最大の値
    if n == 0:
        print(s)
        return
    for i in range(cnt+2):
        if i == cnt+1:
            dfs(s+chr(a_num+i), n-1, cnt+1)
        else:
            dfs(s+chr(a_num+i), n-1, cnt)

dfs("a", N-1, 0)

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

int main(void){
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	const int dx=tx-sx,dy=ty-sy;

	// Path 1
	cout << string(dy,'U') << string(dx,'R');
	
	// Path 2
	cout << string(dy,'D') << string(dx,'L');
		
	// Path 3
	cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
	
	// Path 4
	cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
		
	// EndLine
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
cd = [list(map(int,input().split())) for _ in range(m)]
res = []
for a,b in ab:
    tmp = []
    for c,d in cd:
        tmp.append(abs(a-c)+abs(b-d))
    res.append(tmp.index(min(tmp))+1)
for r in res:
    print(r)

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



/*long long knapsack(long long w,long long* wt,long long* val,long long n)
{
	if(n==0||w==0)
	return 0;
	
	if(dp[n][w]!=-1)
	return dp[n][w];
	
	
	if(wt[n-1]<=w)
		return dp[n][w]= max(val[n-1]+knapsack(w-wt[n-1],wt,val,n-1),knapsack(w,wt,val,n-1));
	
	
	
	
	else if(wt[n-1]>w)
	return dp[n][w]= knapsack(w,wt,val,n-1);

}*/
int main() {
	// your code goes here
	
	
	long long n,W;
	
	cin>>n>>W;
	
	long long wt[n];
	
	long long val[n];
	
	for(long long i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
	
	long long dp[n+1][W+1];
	
	for(long long int i=0;i<=n;i++)
	{
		for(long long int j=0;j<=W;j++)
		{
			if(i==0||j==0)
			dp[i][j]=0;
			
			else if(wt[i-1]<=j)
			dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
			
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	
	cout<<dp[n][W]<<endl;

	
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int sum = 0, count = 0;
  if (a <= k) {
    count += a;
    sum = a;
  }
  else {
    count = k;
    sum = k;
  }
  
  if (b + count <= k) {
    count += b;
  }
  else {
    count = k;
  }
  
  if (count < k) {
    sum -= k - count;
  }
  
  cout << sum << '\n';
}

Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.ArrayList;


public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> array = new ArrayList<Integer>();

		int w = in.nextInt();
		int n = in.nextInt();

		for(int i = 1; i <= w; i++){
			array.add(i);
		}

		for(int j = 1; j <= n; j++){
			String[] values = in.next().split(",");
			int a = Integer.parseInt(values[0]);
			int b = Integer.parseInt(values[1]);
			int c = array.get(a-1);
			int d = array.get(b-1);

			array.set(a-1,d);
			array.set(b-1,c);

		}

		for(int k = 0;k < w; k++){
			int amida = array.get(k);
			System.out.println(amida);
		}
	}
}

Measured memory_bytes: 17204
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	c := x / 11 * 2
	if x%11 > 0 && x%11 <= 6 {
		c += 1
	}
	if x%11 > 6 {
		c += 2
	}
	fmt.Println(c)
}

Measured memory_bytes: 512
#include<iostream> 
    #include<cstring>
    #include<cstdlib>
    #include<cstdio>
    #include<cmath> 
    #include<algorithm>
    #define ll long long 
    using namespace std;
    const int maxn=500010, inf=1e9;
    const double eps=1e-7, pi=acos(-1);
    struct poi{ll x, y; double a;}q[maxn], sum[maxn];
    int n;
    ll ans;
    template<typename T>
    inline void read(T &k)
    {
    	int f=1; k=0; char c=getchar();
    	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
    	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
    	k*=f;
    }
    inline ll sqr(ll x){return 1ll*x*x;}
    bool operator < (poi a, poi b){return a.a+eps<b.a;} 
    inline void getans(int i, int j)
    {ans=max(ans, sqr(sum[j-1].x-sum[i-1].x)+sqr(sum[j-1].y-sum[i-1].y));}
    int main()
    {
    	read(n);
    	for(int i=1;i<=n;i++) 
    	read(q[i].x), read(q[i].y), q[i].a=atan2(q[i].y, q[i].x);
    	sort(q+1, q+n+1);
    	for(int i=1;i<n;i++) q[i+n]=q[i], q[i+n].a+=2*pi;
    	for(int i=1;i<2*n;i++) 
    	sum[i].x=sum[i-1].x+q[i].x, sum[i].y=sum[i-1].y+q[i].y;
    	for(int i=1, j=1;i<=n;i++)
    	{
    		while(j-i<n && q[j].a-eps<q[i].a+pi) j++, getans(i, j);
    		if(i!=j) getans(i+1, j);
    	}
    	printf("%.12lf\n", sqrt(ans));
    }

Measured memory_bytes: 2432
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def mod_combination(n, r, mod=10 ** 9 + 7):
    fact = 1
    for i in range(n - r + 1, n + 1):
        fact = fact * i % mod

    divisor = 1
    for j in range(1, r + 1):
        divisor = divisor * j % mod

    return fact * pow(divisor, mod - 2, mod) % mod


def main():
    mod = 10**9+7
    n, m, k = LI()
    # 　ある配置を固定した時、その2つの配置でmanhattan距離が計算される回数は、他の組み合わせ数。
    combination = mod_combination(n*m-2, k-2)
    x=y=0
    for i in range(1, n):
        x += i * (n-i)
    for j in range(1, m):
        y += j * (m-j)
    return (((m ** 2) % mod * x % mod) + ((n ** 2) % mod * y % mod)) * combination % mod


print(main())

Measured memory_bytes: 39280
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

struct Edge {
	int From;
	int To;
	int Cost;
};


int main() {
	ll X, Y, A, B, C, tmp, ans = 0;
	std::cin >> X >> Y >> A >> B >> C;

	priority_queue<pair<ll,ll>> p;
	rep(i, 0, A) {
		std::cin >> tmp;
		p.push(make_pair(tmp,1));
	}

	rep(i, 0, B) {
		std::cin >> tmp;
		p.push(make_pair(tmp, 2));
	}

	rep(i, 0, C) {
		std::cin >> tmp;
		p.push(make_pair(tmp, 0));
	}

	vll cnt(3, 0);
	while (cnt[0] + cnt[1] + cnt[2] < X + Y) {
		if (p.top().second == 1 && cnt[1] < X) {
			ans += p.top().first;
			cnt[1]++;
		}
		else if (p.top().second == 2 && cnt[2] < Y) {
			ans += p.top().first;
			cnt[2]++;
		}
		else if (p.top().second == 0) {
			ans += p.top().first;
			cnt[0]++;
		}
		p.pop();
	}
	

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


Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b;cin>>a>>b; b--;
  	string s; cin>>s;
  	cout << s.substr(0,b) << (char)(s[b] - 'A' + 'a') << s.substr(b+1,a-(b)) << ednl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int not_ok = true;
	for (int i = 10; i <= 10000; i++) {
		double X = (double)i * 0.08;
		double Y = (double)i * 0.1;
		if ((int)X == A && (int)Y == B) {
			cout << i << endl;
			not_ok = false;
			break;
		}
	}
	if (not_ok)cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  ll N; cin >> N;
  size_t res = INF;
  for (ll n = 1; n*n <= N; ++n) {
    if (N % n == 0) {
      ll k = N / n;
      auto sn = std::to_string(n).size();
      auto sk = std::to_string(k).size();
      chmin(res, std::max(sn, sk));
    }
  }
  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		// game set
		int gameset = sc.nextInt();

		int[][] cardset = new int[UTRummy.CARDPAGE][UTRummy.ONECARDSET];

		for (int i = 0; i < gameset; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 9; k++) {

					if (j == 0) {
						cardset[j][k] = sc.nextInt();
					} else {

						String tmpcolor = sc.next();
						int intColor = 0;
						if (tmpcolor.equals("R")) {
							intColor = UTRummy.RED;
						} else if (tmpcolor.equals("G")) {
							intColor = UTRummy.GREEN;
						} else {
							intColor = UTRummy.BLUE;
						}
						cardset[j][k] = intColor;
					}
				}
			}

			UTRummy utr = new UTRummy();
			utr.setCardset(cardset);
			cardset = utr.getCardset();

			int intCount = 0;
			intCount = utr.playtheGame(cardset); // ?????????

			if (3 <= intCount) {
				System.out.println(1);

			} else {
				System.out.println(0);
			}
		}
	}
}

class UTRummy {

	// declear
	static final int ONECARDSET = 9;
	static final int CARDPAGE = 2;

	// color
	static final int RED = 0;
	static final int GREEN = 1;
	static final int BLUE = 2;

	int[][] Cardset = new int[CARDPAGE][ONECARDSET];

	public UTRummy() {

	}

	public int[][] getCardset() {
		return Cardset;
	}

	public void setCardset(int[][] cardset) {
		this.Cardset = settingcardplay(cardset);
	}

	public int[][] settingcardplay(int[][] card) {

		for (int i = 0; i < 8; i++) {

			for (int j = 0; j < 8 - i; j++) {

				if (card[1][j] > card[1][j + 1]) {
					int temp = card[1][j];
					card[1][j] = card[1][j + 1];
					card[1][j + 1] = temp;

					int temp2 = card[0][j];
					card[0][j] = card[0][j + 1];
					card[0][j + 1] = temp2;
				}
			}
		}

		for (int i = 0; i < 8; i++) {

			for (int j = 0; j < 8 - i; j++) {
				if (card[1][j] == card[1][j + 1] && card[0][j] > card[0][j + 1]) {

					int temp = card[0][j];
					card[0][j] = card[0][j + 1];
					card[0][j + 1] = temp;

				}

			}
		}
		return card;
	}

	public int playtheGame(int[][] cardset) { // ?????????

		int intCount = 0;

		for (int k = 0; k < 7; k++) {

			for (int j = k + 1; j < 8; j++) {

				for (int i = j + 1; i < 9; i++) {
					if (cardset[1][k] == cardset[1][j] && cardset[1][j] == cardset[1][i]) {

						if (cardset[0][k] != 0 && cardset[0][k] == cardset[0][j] - 1
								&& cardset[0][k] == cardset[0][i] - 2) {

							intCount++;
							cardset[0][k] = 0;
							cardset[0][j] = 0;
							cardset[0][i] = 0;
						}
					}
				}
			}
		}

		for (int k = 0; k < 7; k++) {

			for (int j = k + 1; j < 8; j++) {

				for (int i = j + 1; i < 9; i++) {

					if (cardset[1][k] == cardset[1][j] && cardset[1][j] == cardset[1][i]) {
						if (cardset[0][k] != 0 && cardset[0][k] == cardset[0][j] && cardset[0][k] == cardset[0][i]) {

							intCount++;
							cardset[0][k] = 0;
							cardset[0][j] = 0;
							cardset[0][i] = 0;
						}
					}
				}
			}
		}
		return intCount;
	}

}

Measured memory_bytes: 28272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

ll dp[60][60][3000];
ll n,a;
ll x[60];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>a;
    REP(i,n) cin>>x[i];
    REP(i,60) REP(j,60) REP(k,3000) dp[i][j][k]=0;
    dp[0][0][0]=1;
    REP(i,n) REP(j,n) REP(k,3000){
        if(dp[i][j][k]==0)continue;
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=dp[n][i][i*a];
    cout<<ans<<endl;
}

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


int main () {
string S;
string T;
cin >> S >> T ;
if ( S == T.substr(0,S.size()) && S.size() + 1 == T.size()) {
cout << "Yes" << endl;}
else {cout << "No" << endl;}
 
return 0;
}

Measured memory_bytes: 3632
#include <iostream>

int main() {
  int N, A;
  std::cin >> N >> A;
  if (499 <= A) {
    std::cout << "Yes";
    return 0;
  }
  
  if (N%500 <= A) {
    std::cout << "Yes";
  } else {
    std::cout << "No";
  }  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a,b,c,d;
	cin >> a>>b>>c>>d;
	if (a <= b) cout << c * a << endl;
	else cout << c * b+ max(0,a-b) *d << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        string S; cin >> S;
            if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)){
                cout << "Bad" << endl;
            }else{
                cout << "Good" << endl;
            }
    return 0;}

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

int main(){
  int D[110] = {};
  int a, b;

  int len = 0;
  while(cin >> a >> b){
    D[a] += 1;
    D[b] += 1;
    if(a > len || b > len){
      len = max(a,b);
    }

    if(a == 0){
      string msg = "OK";
      // ??£?????§???????????¨???????¨?????????????????????§
      if((D[1] % 2) == 1 && (D[2] % 2) == 1){
        for(int i=3; i<=len; ++i){
          if((D[i] % 2) != 0){
            msg = "NG";
            break;
          }
        }
      } else {
        msg = "NG";
      }
      cout << msg << endl;

      // ?¬???????????????±???????????????????????????????????????????¬???°???0????????????
      for(int i=1; i<=len; ++i){
        D[i] = 0;
      }
      len = 0;
    }
  }
}

Measured memory_bytes: 3192
use proconio::{*, marker::Chars};

fn main() {
    input!{
        s: Chars,
        t: Chars,
    }

    let mut ans = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

long long power(int x,int y){
    int retn=1;
    for(int i=0;i<y;++i){
        retn*=x;
    }
    return retn;
}

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

    const long long mod=1000000007;
    long long rem=m;
    int cnt=0;
    for(int i=30;i>0;--i){
        
        if(n/power(2,i)==1){
            ++cnt;
            if(cnt==1){
                rem=(rem*rem)%mod;
            }
            else{
                rem=(m*rem)%mod;
                rem=(rem*rem)%mod;
            }
            n-=power(2,i);
        }

        else{
            if(cnt){
                rem=(rem*rem)%mod;
            }
        }
        //cout<<i<<" "<<n<<" "<<rem<<"\n";
    }

    if(n==1){
        rem=(m*rem)%mod;
        n--;
    }
    
    if(n==0){
        cout<<rem<<"\n";
    }
}

Measured memory_bytes: 3100
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

N = ni()
mx = 3501
for w in range(1,mx):
    for h in range(1,mx):
        t1=N*w*h
        t2=4*w*h-N*h-N*w
        if t2<=0:continue
        if t1%t2==0:
            print(h,w,t1//t2)
            exit()


Measured memory_bytes: 69856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    string s; cin >> s;
    bool isBad = false;
    for (int i = 0; i < 3; ++i)
    {
        if(s[i]==s[i+1]) isBad = true;
    }

    if(isBad) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int OFF = 101000;

vector<int> E[210000];
bool flag[210000] = {};

P func(int pos){
    if(flag[pos]){
        return P(0, 0);
    }
    flag[pos] = true;
    P ret;
    if(pos < OFF){
        ret = P(1, 0);
    }else{
        ret = P(0, 1);
    }
    for(int to : E[pos]){
        P cnt = func(to);
        ret.first += cnt.first;
        ret.second += cnt.second;
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        E[x].push_back(y + OFF);
        E[y + OFF].push_back(x);
    }
    long long int ans = 0;
    for(int i = 0; i < 210000; i++){
        P ret = func(i);
        ans += ret.first * ret.second;
    }
    cout << ans - N << endl;
    return 0;
}

Measured memory_bytes: 12416
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner scanner = new FastScanner();
        long n = scanner.nextLong();
        System.out.println(n * (n + 1) / 2 - n);
    }

    private static class FastScanner {
        private BufferedReader br;

        public FastScanner() { br = new BufferedReader(new InputStreamReader(System.in)); }
        public FastScanner(String input) throws Exception { br = new BufferedReader(new FileReader(input)); }
        public int[] nextIntArray() throws IOException {
            String line = br.readLine();
            String[] strings = line.trim().split("\\s+");
            int[] array = new int[strings.length];
            for (int i = 0; i < array.length; i++)
                array[i] = Integer.parseInt(strings[i]);
            return array;
        }
        public int nextInt() throws IOException { return Integer.parseInt(br.readLine()); }
        public long[] nextLongArray() throws IOException {
            String line = br.readLine();
            String[] strings = line.trim().split("\\s+");
            long[] array = new long[strings.length];
            for (int i = 0; i < array.length; i++)
                array[i] = Long.parseLong(strings[i]);
            return array;
        }
        public ArrayList<Integer> nextIntegerArrayList() throws IOException {
            String line = br.readLine();
            String[] strings = line.trim().split("\\s+");
            ArrayList<Integer> array = new ArrayList<Integer>();
            for (int i = 0; i < strings.length; i++)
                array.add(Integer.parseInt(strings[i]));
            return array;
        }
        public ArrayList<Long> nextLongArrayList() throws IOException {
            String line = br.readLine();
            String[] strings = line.trim().split("\\s+");
            ArrayList<Long> array = new ArrayList<Long>();
            for (int i = 0; i < strings.length; i++)
                array.add(Long.parseLong(strings[i]));
            return array;
        }
        public long nextLong() throws IOException { return Long.parseLong(br.readLine()); }
        public double nextDouble() throws IOException { return Double.parseDouble(br.readLine()); }
        public String nextLine() throws IOException { return br.readLine(); }


        public ArrayList<BigInteger> nextBigIntegers() throws IOException {
            String line = br.readLine();
            String[] strings = line.trim().split("\\s+");
            ArrayList<BigInteger> array = new ArrayList<BigInteger>();
            for (int i = 0; i < strings.length; i++)
                array.add(BigInteger.valueOf(Long.valueOf(strings[i])));
            return array;
        }
    }
}


Measured memory_bytes: 21204
a,b,c,d = map(int, input().split())
if a<0 and b<0:
    if c<0 and d<0:
        ans = a*c
    elif c<0 and d>=0:
        ans = a*c
    elif c>=0 and d>=0:
        ans = b*c
if a<0 and b>=0:
    if c<0 and d<0:
        ans = a*c
    elif c<0 and d>=0:
        ans = max((a*c),(b*d))
    elif c>=0 and d>=0:
        ans = b*d
if a>=0 and b>=0:
    if c<0 and d<0:
        ans = a*d
    elif c<0 and d>=0:
        ans = b*d
    elif c>=0 and d>=0:
        ans = b*d
print(ans)

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

const ll mod = 1000000007;

int main() {
    ll N; cin >> N;
    ll ans = 1;
    for (int i = 1; i <= N; i++)
    {
        ans = ans * i % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
type Point = (Double, Double)
type Direction = Int
type Distance = Int

main = do
    ((x,y),_) <- steps ((0.0, 0.0), 90)
    print (truncate x)
    print (truncate y)

steps :: (Point, Direction) -> IO (Point, Direction)
steps (p,ct) = do
    (d,t) <- input
    if d == 0 && t == 0
        then return (p,ct)
        else steps $ update (p,ct) (d,t)

input :: IO (Distance, Direction)
input = do
    line <- getLine
    return (split line)
    where
    split line = (read d, read t)
        where
        (d, _:t) = break (==',') line

update :: (Point, Direction) -> (Distance, Direction) -> (Point, Direction)
update ((x,y),ct) (d,t) = ((x',y'), ct')
    where
    x' = x + (fromIntegral d) * (cos ((fromIntegral ct) * pi / 180.0))
    y' = y + (fromIntegral d) * (sin ((fromIntegral ct) * pi / 180.0))
    ct' = ct - t

Measured memory_bytes: 4076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ull fun(ull n) {
	if (n < 2) {
		return 1;
	} else {
		return n * fun(n - 2);
	}
}

int main() {
	int d, n;
	cin >> d >> n;
	switch(d) {
		case 0:
			if (n == 100) {
				cout << "101" << endl;
			} else {
				cout << n << endl;
			}
			break;
		case 1:
			if (n == 100) {
				cout << "10100" << endl;
			} else {
				cout << (pow(100, d) * n) << endl;
			}
			break;
		case 2:
			if (n == 100) {
				cout << "1010000" << endl;
			} else {
				cout << (pow(100, d) * n) << endl;
			}
			break;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

   ll n;
   vector<ll> v;
   cin >> n;

   for(ll i = 1;i < 100000;i++){
      ll jo = i*i;
      if(jo <= n) v.pb(jo);
   }

   cout << v.back() << endl;
   
   rtn 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>

const int MAX = 100000 + 5;
using namespace std;

int main(){
    int n, m;
    int minv, maxv;
    minv = 0;
    maxv = MAX;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int l, r;
        cin >> l >> r;
        minv = max(minv, l);
        maxv = min(maxv, r);
    }
    if(maxv-minv<0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << maxv - minv + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  const a = s.split('\n')[1].split(' ').map(n => Number(n));

  let ans = 0;

  for (let n of a) {
    while (n % 2 === 0) {
      n = n / 2;
      ans += 1;
    }
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 12340
n = int(input())
p=list(map(int, input().split()))

cnt=0
for i in range(1,n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        cnt+=1
    elif p[i-1]>p[i] and p[i]>p[i+1]:
        cnt+=1

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[55];
int main()
{
    char t[8];
    scanf("%s",t+1);
    for(int i=1;i<=4;i++)
        a[t[i]-'A'+1]++;
    bool flag=1;
    for(int i=1;i<=26;i++)
        if(a[i]!=0&&a[i]!=2)
            flag=0;
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
a1, a2, a3 = map(int, input().split())
d1 = abs(a1 - a2)
d2 = abs(a1 - a3)
d3 = abs(a2 - a3)
ans = d1 + d2 + d3 - max(d1, d2, d3)
print(ans)

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

int main(){
    int N,X;
    cin >> N >> X; 
    int ans=1;
  	int l = 0;
    for(int i=0; i<N; i++){
        int y;
        cin>>y;
        l += y;
        if(l <= X) ans +=1;
    }
    cout <<ans << endl;
}   


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

using namespace std;


int main(){
    

    int N;
    cin >> N;
    
    long int A[N];
    
    long int x = 0;
    
    
    
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        
        if (i % 2 == 0) {
            x += A[i];
        }else{
            x -= A[i];
        }
        
        
    }
    
    cout << x;
    for (int i = 0; i < N-1; i++) {
        
        x = -x + 2 * A[i];
        
        cout << " " << x;
    
    }
    
    cout << endl;
    
    
    
}


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

#define si(v) v.size()
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (n); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

using ll = long long;
using ld = long double;
using namespace std;

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

  int a, b, c; cin >> a >> b >> c;
  if (b - a == c - b) cout << "YES\n";
  else cout << "NO\n";
  
  return (0);
}

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

int main() {
  long n;
  cin >> n;
  long num = n;
  
  long m = pow(n,0.5);
  //cout << m << endl;
  vector<int> vec(m+1);
  
  for(int i=2; i<=m; i++){
    while(num % i == 0){
      num /= i;
      vec[i]++;
    }
  }
  int ans = 0;
  if(n == num && n != 1) ans = 1;
  else{
    for(int i=2; i<=m; i++){
      int j = 1;
      while(vec[i] >= j){
        ans++;
        vec[i] -= j;
        j++;
      }
    }
    if(num > m) ans++;
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 7652
#include <stdio.h>
#define NIL -1
void echoPre(int );
void echoIn(int );
void echoPost(int );
typedef struct{
  int left,right,parent;
}Tree;
Tree Node[26];
int n;
int main(void){
  int i,j,migi,hidari,oya,node;
  scanf("%d",&n);
  i=0;
  while(i<n){
    Node[i].left=NIL;
    Node[i].right=NIL;
    Node[i].parent=NIL;
    i++;
  }

  i=0;
  while(i<n){
    // initial setting
    scanf("%d%d%d",&node,&hidari,&migi);
    if(hidari!=NIL)
      Node[hidari].parent=node;
    if(migi!=NIL)
      Node[migi].parent=node;
    Node[node].left=hidari;
    Node[node].right=migi;
    i++;
  }

  //search for node of root
  i=-1;
  while(++i<n)
    if(Node[i].parent==NIL)
      j=i;

  printf("Preorder\n");
  echoPre(j);
  printf("\nInorder\n");
  echoIn(j);
  printf("\nPostorder\n");
  echoPost(j);
  printf("\n");
  return 0;
}
void echoPre(int node){
  printf(" %d",node);
  if(Node[node].left!=NIL)
    echoPre(Node[node].left);
  if(Node[node].right!=NIL)
    echoPre(Node[node].right);
}
void echoIn(int node){
  if(Node[node].left!=NIL)
    echoIn(Node[node].left);
  printf(" %d",node);
  if(Node[node].right!=NIL)
    echoIn(Node[node].right);
}
void echoPost(int node){
  if(Node[node].left!=NIL)
    echoPost(Node[node].left);
  if(Node[node].right!=NIL)
    echoPost(Node[node].right);
  printf(" %d",node);
}


Measured memory_bytes: 2104
#include <cstdio>

const int MAXN = 305;

int cnt[3];
double f[MAXN][MAXN][MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1, a; i <= n; i++) {
        scanf("%d", &a);
        ++cnt[a - 1];
    }

    for (int k = 0; k <= n; k++) for (int j = 0; j <= n; j++) for (int i = 0; i <= n; i++) {
        if (i + k + j == 0) f[i][j][k] = 0;
        else {
            if (i) f[i][j][k] += 1.0 * i * f[i - 1][j][k] / (i + j + k);
            if (j) f[i][j][k] += 1.0 * j * f[i + 1][j - 1][k] / (i + j + k);
            if (k) f[i][j][k] += 1.0 * k * f[i][j + 1][k - 1] / (i + j + k);
            f[i][j][k] += 1.0 * n / (i + j + k);
        }
    }

    printf("%.9f\n", f[cnt[0]][cnt[1]][cnt[2]]);
    
    return 0;
}

Measured memory_bytes: 219392
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	string s,t;cin>>s>>t;
	cout<<t<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int s_len = s.size();
    rep(i, s_len){
        if(s[i]=='?') s[i] = 'D';
    }
    cout << s << endl;
    return 0;
}

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

int n;
int ans=0;
vector<int> p(21);

int main(){
	cin>>n;

	for(int i=0;i<n;i++)
		cin>>p.at(i);

	p.resize(n);

	for(int i=1;i<n-1;i++){
		if(p.at(i-1)<p.at(i) && p.at(i)<p.at(i+1))
			ans++;
		else if(p.at(i-1)>p.at(i) && p.at(i)>p.at(i+1))
			ans++;
	}

	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int S;
    scanf("%d",&S);
    
    int h = S/3600;
    int m = (S-h*3600)/60;
    int s = S-(h*3600+m*60);
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2760
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
using namespace std;
const int INF = 1e9 + 5;
int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if(a == b) {
    	if(a != c && b != c) {
    		cout << "Yes" << "\n";
    	}else {
    		cout << "No" << "\n";
    	}
    }
    else if(a == c) {
    	if(a != b && c != b) {
    		cout << "Yes" << "\n";
    	} else {
    		cout << "No" << "\n";
    	}
    }
    else if(b == c) {
    	if(b != a && c != a) {
    		cout << "Yes" << "\n";
    	}else {
    		cout << "No" << "\n";
    	}
    } else {
    	cout << "No" << "\n";
    }
	return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int ha, ma, hb, mb, k; cin >> ha >> ma >> hb >> mb >> k;

    int a = ha*60 + ma, b = hb*60 + mb;

    int ans = (b-a) - k;

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"x1,y1,x2,y2=map(int,input().split())\n"
"a=x2-x1\n"
"b=y2-y1\n"
"print(x2-b,y2+a,x1-b,y1+a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
#include <fstream>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)
#define get_bit(mask, x) (bool)(mask & (1LL << x))
#define set_bit(mask, x) (mask |= (1LL << x))
#define reset_bit(mask, x) (mask &= ~(1LL << x))
#define toggle_bit(mask, x) (mask ^= (1LL << x))

using namespace std;

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

    ll n;

    cin >> n;

    vector < ll > v(n);

    forn(i, n)
        cin >> v[i];

    ford(i, (n - 1))
        if(v[i] > v[i + 1])
            v[i]--;

    for1(i, (n - 1))
    {
        if(v[i] < v[i - 1])
        {
            cout << "No\n";

            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(x, f, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }
inline int lg(int x) { return 63 - __builtin_clzll(static_cast<unsigned int>(x)); }

signed main() {
  const int N = rint();
  vector<int> xs;
  xs.reserve(N);
  dotimes(i, N)
    xs.emplace_back(rint());
  const int L = rint();
  const int M = lg(N-1) + 1;
  vector<vector<int>> D(N, vector<int>(M));
  dotimes(i, N-1)
    D[i][0] = N - (lower_bound(xs.rbegin(), xs.rend(), xs[i] + L, greater<int>()) - xs.rbegin()) - 1;
  dotimes(j, M)
    D[N-1][j] = N-1;
  dotimes(j, M-1)
    dotimes(i, N-1)
      D[i][j+1] = D[D[i][j]][j];
  const int Q = rint();
  dotimes(i, Q) {
    int a = rint() - 1;
    int b = rint() - 1;
    if (a > b)
      swap(a, b);
    int r = 0;
    for (int j = M - 1; j >= 0; j--)
      if (D[a][j] < b) {
        r += 1 << j;
        a = D[a][j];
      }
    wint(r + 1);
  }
  return 0;
}


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

# define pb push_back
# define sz(x) ((int)(x).size())
# define whole(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
const int INF = (int)1e9 + 7;
const int N = (int)2e5 + 7;

int h, w, k;
char a[8][8];
int main(){
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int r = 0; r < (1 << h); ++r) {
        for (int c = 0; c < (1 << w); ++c) {
            int cnt = 0;
            for (int i = 0; i < h; ++i) {
                if ((r >> i) & 1) {
                    for (int j = 0; j < w; ++j) {
                        if ((c >> j) & 1)
                            cnt += (a[i][j] == '#');
                    }
                }
            }
            if (cnt == k)
                ++ans;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

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

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

// prepare for main routine
bool dfs(const int current, const int target, const int preEdge, vector<int> &usedEdge, vector<bool> &visited, const vector<list<pair<int, int>>> edge){
    visited[current] = true;

    if(current == target){
        usedEdge.push_back(preEdge);
        return true;
    }

    for(const auto E : edge[current]){
        if(!visited[E.first]){
            if(dfs(E.first, target, E.second, usedEdge, visited, edge)){
                if(preEdge >= 0){
                    usedEdge.push_back(preEdge);
                }
                return true;
            }
        }
    }

    return false;
}

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

    vector<list<pair<int, int>>> edge(N+1);
    for(int i = 0; i < N - 1; i++){
        int a,b;
        cin >> a >> b;
        edge[a].push_back(make_pair(b, i));
        edge[b].push_back(make_pair(a, i));
    }

    int M;
    cin >> M;

    vector<int> u(M),v(M);
    for(int i = 0; i < M; i++){
        cin >> u[i] >> v[i];
    }

    // existing edge between vertex u_i and vertex v_i for all element of query
    vector<vector<bool>> coveredEdge(M, vector<bool>(N-1, false));

    for(int i = 0; i < M; i++){
        vector<int> usedEdge;
        vector<bool> visited(N+1, false);

        dfs(u[i], v[i], -1, usedEdge, visited, edge);

        for(const auto E : usedEdge){
            coveredEdge[i][E] = true;
        }
    }

    // subsets of satisfied query after painting a edge black
    vector<int> querySubsets(N-1);

    for(int i = 0; i < N - 1; i++){
        int bit = 0;
        for(int j = 0; j < M; j++){
            if(coveredEdge[j][i]){
                bit += (1 << j);
            }
        }
        querySubsets[i] = bit;
    }

    // dp table for bitDp
    vector<vector<ll>> dp(N, vector<ll>((1 << M),0));
    dp[0][0] = 1;

    for(int i = 0; i < N - 1; i++){
        for(int j = 0; j < (1 << M); j++){
            dp[i + 1][j | querySubsets[i]] += dp[i][j];
            dp[i + 1][j] += dp[i][j];
        }
    }

    cout << dp[N-1][(1 << M) - 1] << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<vector<ll>> G(n);
    for(i=0;i<m;i++){
        cin >> j >> k;
        j--,k--;
        G[j].push_back(k);
        G[k].push_back(j);
    }
    queue<pair<ll,ll>> que;
    que.push({0,-1});
    vector<ll> ret(n,-1);
    ret[0]=INF;
    while(!que.empty()){
        auto now = que.front();
        que.pop();
        for(auto &x:G[now.first]){
            if(ret[x]==-1){
                ret[x]=now.first;
                que.push({x,now.first});
            }
        }
    }
    for(i=0;i<n;i++){
        if(ret[i]==-1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(i=1;i<n;i++){
        cout << ret[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 13584
import java.util.*;
class Main {
public static void main(String[]args)throws Exception {
Scanner sc = new Scanner(System.in);
int [] as = new int[3];
for(int i = 0; i < 3; i++) as[i] = sc.nextInt();
Arrays.sort(as);
for(int i = 0; i < 3; i++) System.out.print((i>0 ? " ":"") + as[i]);
System.out.println();
}
}

Measured memory_bytes: 17168