akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if ( 0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H ){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
}

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

int main(){
  int N, W;
  cin >> N >> W;
  
  long long w[N], v[N];
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  
  
  long long dp[N+1][W+1];
  for (int i = 0; i <= N; i++) {
    for (int sumW = 0; sumW <= W; sumW++) {
      dp[i][sumW] = 0;
    }
  }
  
  for (int i = 0; i < N; i++) {
    for (int sumW = 0; sumW <= W; sumW++) {
      if (sumW-w[i] >= 0) {
        dp[i+1][sumW] = max(dp[i+1][sumW],dp[i][sumW-w[i]] + v[i]);
      }
      dp[i+1][sumW] = max(dp[i+1][sumW],dp[i][sumW]);
    }
  }
  
  cout << dp[N][W] << endl;
  
  return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int charge, basic, limit, add, use;
    cin >> charge >> basic >> limit >> add >> use;
    charge*=use;
    if(limit < use) basic+=((use - limit) * add);
    cout << (charge < basic ? charge : basic)  << endl;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//const int cm = 1 << 17;
//char cn[cm], * ci = cn + cm, ct;
//inline char getcha() {
//	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
//	return *ci++;
//}
//inline int getint() {
//	int A = 0;
//	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
//	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
//	return A;
//}
const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}


const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10], *K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = C;
		K[1] = di;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = di;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.K[X]; *i != '\n'; i++)* di++ = *i;
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    if(n%x==0) cout << n/x * t << endl;
    else cout << (n/x + 1) * t << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  int l[n];
  rep(i, 0, n){
    cin >> l[i];
  }
  sort(l, l + n);
  int sm = 0;
  rep(i, 0, n - 1){
    sm += l[i];
  }
  if(sm > l[n - 1]){
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
}

Measured memory_bytes: 3640
#include<stdio.h>

int main()
{
	int i,j;
	char r[100];
	scanf("%s", r);
	for(i=0; r[i]!='\0'; ++i);
	if(i==2)for(i=0;i<2;i++)printf("%c",r[i]);
	else for(i=2;i>-1;i--)printf("%c",r[i]);
	
	return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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 ll INF = 1LL << 60;
//cout << fixed << setprecision(10);
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
    ll a, b, c;
    cin>>a>>b>>c;
    if((b-a)==(c-b)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        while (true) {
            int a = scanner.nextInt();
            char op = scanner.next().charAt(0);
            int b = scanner.nextInt();
        if(op == '+'){
            System.out.println(a + b);
        }else if(op == '-'){
            System.out.println(a - b);
        }else if(op == '*'){
            System.out.println(a * b);
        }else if(op == '/'){
            System.out.println(a / b);
        }else{
        break;
        }
        }
        scanner.close();
    }
}


Measured memory_bytes: 26240
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;


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

		//??\??????????????????0 0?????§??°?????????
		while (sc.hasNext()) {
			x=sc.nextInt();
			y=sc.nextInt();
			Integer[] sort = new Integer[2];
			sort[0]=x;
			sort[1]=y;

			//0??\??????????????????
			if(x==0 && y==0){
				break;
			}
			//??\???????????´??°??????????????????
			Arrays.sort(sort);
			num.add(sort);
		}
		//??\???????????´??°?????¨???
		for (int i = 0; i < num.size(); i++) {
			System.out.println(num.get(i)[0]+" "+num.get(i)[1]);
		}
	}
}

Measured memory_bytes: 26788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>

struct A {
  bool operator<(const A &a) const {
    return p != a.p ? p < a.p : y < a.y;
  }
  int p, y, i;
};

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

  std::vector<A> a(m);
  std::vector<A> r(m);
  for (int i = 0; i < m; ++i) {
    int p, y;
    std::cin >> p >> y;
    a[i] = { p, y, i};
  }
  std::sort(a.begin(), a.end());

  int k;
  int p = -1;
  for (int i = 0; i < m; ++i) {
    if ( a[i].p != p ) {
      p = a[i].p;
      k = 0;
    }
    a[i].y = k++;
    r[a[i].i] = a[i];
  }

  for (int i = 0; i < m; ++i) {
    std::cout << std::setw(6) << std::setfill('0') << r[i].p;
    std::cout << std::setw(6) << std::setfill('0') << r[i].y + 1 << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3840
#include<iostream>

using namespace std;

int N, M;

int ans = 0;
int pow2[6] = {1,2,4,8,16,32 };

int main() {
	cin >> N >> M;
	ans = (N - M) * 100 + M * 1900;
	ans *= pow2[M];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n, m, L = 0, R = INF;
	cin >> n >> m;
	vector<int> l(m), r(m);
	rep(i, 0, m) {
		cin >> l[i] >> r[i];
	}
	rep(i, 0, m) {
		L = max(L, l[i]);
		R = min(R, r[i]);
	}
	if(L<=R) cout << R - L + 1 << endl;
	else cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main (void){

    int a,b,d,r;

    double f;

    scanf("%d",&a);

    scanf("%d",&b);

    d=a/b;

    r=a%b;

    f=(double)a/(double)b;

    printf("%d %d %lf",d,r,f);

    return 0;

}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

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(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
vector<string> split(const string&s,char d){vector<string>r;stringstream ss(s);string k;while(getline(ss,k,d))if(!k.empty())r.pb(k);return r;}

// Template ends here

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

    rep(i, 5e4) {
        if (floor(i * 1.08) == n) {
            cout << i << "\n";
            return 0;
        }
    }

    cout << ":(\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var x = cin.ReadInt();
            var a = cin.ReadInt();
            var b = cin.ReadInt();

            WriteLine(Abs(a - x) < Abs(b - x) ? "A" : "B");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}


Measured memory_bytes: 11220
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

n, m = map(int,input().split())
#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for _ in range(m):
  a, b = map(int,input().split())
  a -= 1
  b -= 1
  unite(a,b)
  
print(-min(par))
  

  
              

Measured memory_bytes: 14720
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

const int MAX_N = 100010;
const int INF_COST = 2000000000;
int N, K;
int h[MAX_N];
int memo[MAX_N];

int Solve(int pos)
{
    if (memo[pos] >= 0) return memo[pos];
    if (pos >= N) return memo[pos] = INF_COST;
    if (pos == N - 1) return memo[pos] = 0;

    int res = INF_COST;
    REP(i, K)
    {
        int nextPos = pos + (i + 1);
        res = min(res, Solve(nextPos) + abs(h[pos] - h[nextPos]));
    }
    return memo[pos] = res;
}

int main()
{
    cin >> N >> K;
    REP(i, N) cin >> h[i];
    REP(i, MAX_N) memo[i] = -1;
    cout << Solve(0) << endl;
    return 0;
}

Measured memory_bytes: 5760
N, K = list(map(int, input().split()))
S = str(input())

for i in range(N):
  if(i == K - 1):
    if(S[i] == 'A'):
      print('a',end='')
    elif(S[i] == 'B'):
      print('b',end='')
    else:
      print('c',end='')
  else:
    print(S[i],end='')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, l, sum = 0;
    cin >> n >> l;
    vi ls(n);
    rep(i, n){
        ls[i] = l + (i+1) -1;
        sum += ls[i];
        if(ls[i]<0) ls[i] *= -1;
    }
    sort(all(ls));
    if(sum >= 0) cout << sum - ls[0] << endl;
    else cout << sum + ls[0] << endl;
}

Measured memory_bytes: 256
n = int(input())
A = input()
B = input()
C = input()
cnt = 0
for i in range(n):
    a = A[i]
    b = B[i]
    c = C[i]
    if a == b == c:
        continue
    elif a == b or b == c or c == a:
        cnt += 1
    else:
        cnt += 2
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 180*n-360 << "\n";
    return 0;
}

Measured memory_bytes: 256
//どうかACをお恵みくださいお願いしますお願いしますお願います何もしませんから
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());//500円
            string[] n = Console.ReadLine().Split();
            int[] a = new int[N * 3];
            for(int x = 0;x < N * 3;x++)
            {
                a[x] = int.Parse(n[x]);
            }
            Array.Sort(a);
            Array.Reverse(a);
            long kotae = 0;
            for(int x = 1;x < N*2;x = x + 2)
            {
                kotae = kotae + a[x];
            }
            Console.WriteLine(kotae);
        }
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  if(S == "AAA" || S == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; ++i) cin >> S[i];
    
    sort(S.begin(), S.end());
    for (int i = 0; i < N; ++i) cout << S[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/*
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

ll factor(ll x) {
	ll ret = 1;
	ll tmp = 0;
	for (ll p = 2;;p++) {
		if (x == 1) {
			ret *= tmp + 1;
			break;
		}
		if (x % p == 0) {
			tmp += 1;
			x /= p;
			p--;
			continue;
		}
		ret *= tmp + 1;
		tmp = 0;
	}
	return ret;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	ll N;
	cin >> N;
	ll ans = 0;

	for (ll i = 1; i <= N; i++) {
		ll ret = factor(i);
		ll tmp = ret;
		ans += i * tmp;
	}

	cout << ans << endl;



EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}


*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	ll a;
	cin >> a;

	cout << a + a * a + a * a * a << endl;



EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
vector<int> G[1001];
bool used[1001];
int cnt=0;
int ans=0;

void dfs(int v){
	cnt++;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		if(!used[i]){
			cnt=0;
			dfs(i);
			if(cnt==1)ans++;
			else ans--;
		}
	}
	printf("%d\n",abs(ans));
	return 0;
}


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

void solve(){
    // int n;
    // cin>>n;
    // int a[n];
    // for(int i=0;i<n;i++){
    //     cin>>a[i];
    // }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--){
    //     solve();
    // }
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int k=t.length();
    int ans=k;
    for(int i=0;i<n-k+1;i++){
        int temp=k;
        for(int j=i;j<i+k;j++){
            if(s[j]==t[j-i]){
                temp--;
            }
        }
        ans=min(ans,temp);
    }
    cout<<ans;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    int left = 0, right = (int)s.size()-1;
    int ans = 0;
    while (left < right) {
        if (s[left] == s[right]) {
            left++;
            right--;
        } else if (s[left] == 'x') {
            left++;
            ans++;
        } else if (s[right] == 'x') {
            right--;
            ans++;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import string

n = int(input())
ls = [input().rstrip() for _ in range(n)]
cs = {c: [] for c in string.ascii_lowercase}
for i in range(n):
    for c in string.ascii_lowercase:
        k = ls[i].count(c)
        cs[c].append(k)
res = ''
for c in string.ascii_lowercase:
    res += c * min(cs[c])
print(res)

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;

const int N = 2e5 + 47;

int n, d, a, x[N], h[N];
map<int, int> mapa;
map<int, int> open, close;

void PUNKS_NOT_DEAD() {
    cin >> n >> d >> a;
    set<int> kek;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> h[i];
        mapa[x[i]] = h[i];
        kek.insert(x[i]);
        kek.insert(x[i] + 2 * d);
    }
    int cur = 0, ans = 0;
    for (auto tt : kek) {
        int who = (mapa.count(tt) ? mapa[tt] : -1);
        who += cur;
        if (who > 0) {
            int dd = (who - 1) / a + 1;
            ans += dd;
            dd *= a;
            cur -= dd;
            close[tt + 2 * d] += dd;
        }
        cur += close[tt];
    }
    cout << ans;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    PUNKS_NOT_DEAD();
}

Measured memory_bytes: 59648
#include<bits/stdc++.h>
using namespace std;
const int N=1010,M=5050;
int i,j,k,n,m,En;
int h[N],fa[N],f[N],X[N];
bitset<M>g;
struct edge
{
    int s,n;
} E[N];
void E_add(int x,int y)
{
    E[++En].s=y;
    E[En].n=h[x];
    h[x]=En;
}
bool dfs(int x)
{
    for(int k=h[x]; k; k=E[k].n)
        if(!dfs(E[k].s))
            return 0;
    g.reset();
    g[0]=1;
    int sum=0;
    for(int k=h[x]; k; k=E[k].n)
    {
        g=g<<X[E[k].s]|g<<f[E[k].s];
        sum+=X[E[k].s]+f[E[k].s];
    }
    for(int i=X[x]; i>=0; i--)
        if(g[i])
        {
            f[x]=sum-i;
            return 1;
        }
    return 0;
}
int main()
{
    scanf("%d",&n);
    for(i=2; i<=n; i++)
        scanf("%d",&fa[i]),E_add(fa[i],i);
    for(i=1; i<=n; i++)
        scanf("%d",&X[i]);
    puts(dfs(1)?"POSSIBLE":"IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

typedef long long llong;
int n, k;
llong T[MAX];


int check(llong P){
  int i = 0,j;
  for(j = 0 ; j < k ; j++){
    llong s = 0;
    while(s + T[i] <= P){
      s += T[i];
      i++;
      if(i == n) return n;
    }
  }
  return i;
}


int solve(){
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while(right - left > 1){
    mid = (left + right) / 2;
    int v = check(mid);
    if(v >= n) right = mid;
    else left = mid;
  }

  return right;
}


int main(){
  int i;
  
  scanf("%d %d", &n, &k);
  for(i = 0 ; i < n ; i++) scanf("%d", &T[i]);
  llong ans = solve();
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 2528
#include <bits/stdc++.h>
using namespace std;
typedef double ld;
int main() {
	int n;
	ld sum;
	cin >> n;
	for(int i = 0; i < n; i++){
		ld a; string b;
		cin >> a >> b;
		if(b == "JPY") sum += a;
		else{
			sum += a * 380000.0;
		}
	}
	printf("%9.6f\n", sum);
	return 0;
}


Measured memory_bytes: 764
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

int main()
{
	speed;
	
	ll n,k;
	cin>>n>>k;
	ll arr[n+1];
	ll mmin=INT_MAX;
	for(ll i=1;i<=n;i++)
	{
		cin>>arr[i];
		mmin=min(mmin,arr[i]);
	}

	ll ind;
	for(ll i=1;i<=n;i++)
	{
		if(arr[i]==mmin)
		{
			ind=i;
			break;
		}
	}

	ll last=-1;
	ll ans=0;
	float fm=ceil((float)(ind-1)/(k-1));
	ll m=(ll)fm;
	ans+=m;
	last=(k-1)*m+1;
	for(ll i=last+1;i<=n;i++)
	{
		if(arr[i]==mmin )
		{
			last=max(i,last);

		}
		else if(i>last)
		{
			ans++;
			last+=(k-1);
		}
		
	}

	cout<<ans;






	
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  unordered_map<string,int> mp;
  for(int i=0;i<n;i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto& p : mp) {
    int s = p.second;
    ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10660
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);
int h, w, n;
vector<int> c;


int main(void) {
	cin >> h >> w;
	c = vector<int>(h * w);
	cin >> n;
	int pos = 0;
	for (int i = 0; i < n; i++) {
		int ai, j;
		cin >> ai;
		for (j = pos; j < pos + ai; j++) {
			c[j] = i + 1;
		}
		pos = j;
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i % 2 == 0)
				cout << c[i * w + j];
			else
				cout << c[(i + 1) * w - j - 1];
			cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
typedef long long int ll;

int main(void){
	char s[100001];
	ll k;
	cin>>s;
	int size=strlen(s);
	cin>>k;
//	vector<char> s(h.size());
//	for(int i=0;i<h.size();i++){
//s[i]=h[i];
//	}
for(int i=0;i<size-1;i++){
	if(s[i]=='a')continue;
	int t='z'-s[i]+1;
	if(t<=k){
	k-=t;
	s[i]='a';
	}
}
if(k>0){
	k%=26;
	//s[size-1]+=k;
	//if(s[size-1]>'z'){
	//	s[size-1]-=26;
	//}
	s[size-1]='a'+(s[size-1]-'a'+k)%26;
}

cout<<s<<endl;
return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define reg register
#define ll long long
#define int long long
#define ull unsigned long long
#define db double
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vpi vector<pi>
#define vpl vector<pl>
#define pb push_back
#define er erase
#define SZ(x) (int) x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mkp make_pair
#define dmin(x, y) ((x) < (y) ? (x) : (y))
#define dmax(x, y) ((x) > (y) ? (x) : (y))
#define checkmax(x, y) ((x) < (y) ? ((x) = (y)) : (x))
#define checkmin(x, y) ((x) > (y) ? ((x) = (y)) : (x))
#define ms(data_name) memset(data_name, 0, sizeof(data_name))
#define msn(data_name, num) memset(data_name, num, sizeof(data_name))
#define For(i, j) for(reg int (i) = 1; (i) <= (j); ++(i))
#define For0(i, j) for(reg int (i) = 0; (i) < (j); ++(i))
#define Forx(i, j, k) for(reg int (i) = (j); (i) <= (k); ++(i))
#define Forstep(i , j, k, st) for(reg int (i) = (j); (i) <= (k); (i) += (st))
#define fOR(i, j) for(reg int (i) = (j); (i) >= 1; (i)--)
#define fOR0(i, j) for(reg int (i) = (j) - 1; (i) >= 0; (i)--)
#define fORx(i, j, k) for(reg int (i) = (k); (i) >= (j); (i)--)
#define tour(i, u) for(reg int (i) = head[(u)]; (i) != -1; (i) = nxt[(i)])
using namespace std;
char ch, B[1 << 20], *S = B, *T = B;
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 20, stdin), S == T) ? 0 : *S++)
#define isd(c) (c >= '0' && c <= '9')
int rdint() {
  int aa, bb;
  while(ch = getc(), !isd(ch) && ch != '-');
  ch == '-' ? aa = bb = 0 : (aa = ch - '0', bb = 1);
  while(ch = getc(), isd(ch))
    aa = aa * 10 + ch - '0';
  return bb ? aa : -aa;
}
ll rdll() {
  ll aa, bb;
  while(ch = getc(), !isd(ch) && ch != '-');
  ch == '-' ? aa = bb = 0 : (aa = ch - '0', bb = 1);
  while(ch = getc(), isd(ch))
    aa = aa * 10 + ch - '0';
  return bb ? aa : -aa;
}
const int MAXN = 1e5 + 10;
int n, f[(MAXN << 1) + 10], cnt1[(MAXN << 1) + 10], cnt2[(MAXN << 1) + 10];
int find(int x) {
  return f[x] == x ? x : f[x] = find(f[x]);
}
inline void work() {
  n = rdint();
  Forx(i, 0, MAXN << 1) {
    f[i] = i;
  }
  For(i, n) {
    int x = rdint(), y = rdint();
    f[find(x)] = f[find(y + MAXN)];
  }
  For(i, MAXN) {
    ++cnt1[find(i)];
  }
  Forx(i, MAXN + 1, MAXN << 1) {
    ++cnt2[find(i)];
  }
  ll ans = 0;
  For(i, MAXN << 1) {
    ans += cnt1[i] * cnt2[i];
  }
  printf("%lld\n", ans - n);
}
signed main() {
  // freopen("input.txt", "r", stdin);
  work();
  return 0;
}


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

ll gcd(ll a, ll b) { if (!b)return a; return gcd(b, a%b); }
ll lcm(ll a, ll b) {
	ll g = gcd(max(a, b), min(a, b));
	return a / g*b / g*g;
}
ll d[20], v[20];
int main() {
	ll n;
	while (scanf("%lld", &n), n) {
		ll ans = 1;
		rep(i, n) {
			scanf("%lld%lld", &d[i], &v[i]);
			ans = lcm(ans, lcm(d[i], v[i]) / v[i]);
		}
		ll g = ans*v[0] / d[0];
		rep(i, n)g = gcd(g, ans*v[i] / d[i]);
		rep(i, n)printf("%lld\n", ans*v[i] / d[i] / g);
	}
}

Measured memory_bytes: 3180
// ABC 173 C Tsundoku
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int solve(int N, int M, int K, int A[], int B[]) {
  ll total_cost = 0;
  for (int i = 0; i < M; i++) {
    total_cost += B[i];
  }
  int ans = 0;
  int j = M;
  for (int i = 0; i < N+1; i++) {
    while (j > 0 && total_cost > K) {
      j--;
      total_cost -= B[j];
    }
    if (total_cost > K) break;
    ans = max(ans, i + j);
    if (i == N) break;
    total_cost += A[i];
  }
  return ans;
}

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  int A[N];
  int B[M];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  cout << solve(N, M, K, A, B) << endl;
  return 0;
}

Measured memory_bytes: 5116
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=(1LL<<31)-1;
const double pi=acos(-1);
const double eps=1e-10;

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

class SquareDivision{
    private:
        const int bucketSize = 256;
        ll N, B;
        vector<ll> data;
        vector<bool> lazyFlag;
        vector<int> lazyUpdate;

    public:
        void prepare(int n){
            B = (n + bucketSize - 1)/ bucketSize;
            N = B * bucketSize;
            data.assign(N, INF);
            lazyFlag.assign(B, false);
            lazyUpdate.assign(B, 0);
        }

        void eval(int k){
            if(lazyFlag[k]){
                lazyFlag[k] = false;
                for(int i=k*bucketSize; i<(k+1)*bucketSize; i++){
                    data[i] = lazyUpdate[k];
                }
            }
        }

        void update(int s, int t, int x){
            for(int k=0; k<B; k++){
                int l = k * bucketSize;
                int r = (k + 1) * bucketSize;

                if(r <= s || t <= l) continue;

                if(s <= l && r <= t){
                    lazyFlag[k] = true;
                    lazyUpdate[k] = x;
                }
                else{
                    eval(k);
                    for(int i=max(s, l); i<min(t, r); i++){
                        data[i] = x;
                    }
                }
            }
        }

        int find(int i){
            int k = i / bucketSize;
            eval(k);
            return data[i];
        }
};

int main(){
    int n, q; cin>>n>>q;
    SquareDivision ans;
    ans.prepare(n);

    while(q--){
        int c; cin>>c;
        if(c == 0){
            int s, t, x; cin>>s>>t>>x;
            ans.update(s, t+1, x);
        }
        else{
            int i; cin>>i;
            cout << ans.find(i) << endl;
        }
    }
}


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

int main(){
  int n,m;
  cin>>n;
  vector<string> s(n);
  for (int i=0;i<n;i++){
    cin>>s.at(i);
  }
  cin>>m;
  vector<string> t(m);
  for (int i=0;i<m;i++){
    cin>>t.at(i);
  }
  int ans=0,d;
  string a;
  for (int i=0;i<n;i++){
    a=s.at(i);
    d=1;
    for (int j=0;j<n;j++){
      if (i!=j && a==s.at(j)){
        d++;
      }
    }
    for (int j=0;j<m;j++){
      if (a==t.at(j)){
        d--;
      }
    }
    if (ans<d){
      ans=d;
    }
  }
  cout<<ans<<endl;
}
        
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 200005
#define mo 994711
//#define ivorysi
using namespace std;
typedef unsigned long long int64;
typedef long double db;
typedef unsigned int u32;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 + c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N,a[105];
int64 x;
void Solve() {
    read(N);read(x);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    sort(a + 1,a + N + 1);
    int cnt = 0;
    for(int i = 1 ; i <= N ; ++i) {
	if(x >= a[i]) ++cnt,x -= a[i];
    }
    if(x && cnt == N) --cnt;
    out(cnt);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include"iostream"

using namespace std;
int main()
{
	int d;
	cin >> d;
	if (d == 25)cout << "Christmas" << endl;
	if (d == 24)cout << "Christmas Eve" << endl;
	if (d == 23)cout << "Christmas Eve Eve" << endl;
	if (d == 22)cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n,k;
  string s;
  cin >> n >> k >>s;
  s[k-1]=tolower(s[k-1]);
  cout<< s <<endl;

}


Measured memory_bytes: 256
from itertools import accumulate

num = int(input())
a, b = [int(x) for x in input().split()]
p = int(input())

T = []
C = []

for _ in range(num):
    T.append(int(input()))

C.append(int(p/a))
T.sort(reverse=True)

for i,c in enumerate(accumulate(T),start=1):
    C.append( int( (p+c) / (a+i*b)) )

print( sorted(C,reverse=True)[0] )


Measured memory_bytes: 5644
import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int n=sc.nextInt();
        BigInteger x=BigInteger.ONE;
        long a[]=new long[n];
        for (int i=0;i<n;i++){
            a[i]=sc.nextLong();
            if (a[i]==0){
                System.out.println(0);
                return;
            }
        }
        for (int i=0;i<n;i++){
            x=x.multiply(new BigInteger(a[i]+""));
            if (x.compareTo(new BigInteger("1000000000000000000"))>=1){
                System.out.println(-1);
                return;
            }
        }
        System.out.println(x);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 48844
fun main(args : Array<String>) {
    val (n, w) = readLine()!!.split(" ").map { it.toInt() }
    val ww = mutableListOf<Int>()
    val vv = mutableListOf<Int>()

    ww.add(0)
    vv.add(0)

    repeat(n) {
        val (w1, v1) = readLine()!!.split(" ").map { it.toInt() }
        ww.add(w1)
        vv.add(v1)
    }

    val vMax = 1000*n
    val dp = Array(n+1) { LongArray(vMax+1){ Int.MAX_VALUE * 100L } }

    dp[0][0] = 0

    for (idx in 0 until n) {
        for (vSum in 0..vMax) {
            if (vv[idx+1] <= vSum) {
                dp[idx+1][vSum] = Math.min(dp[idx][vSum], dp[idx][vSum-vv[idx+1]] + ww[idx+1])
            } else {
                dp[idx+1][vSum] = dp[idx][vSum]
            }
        }
    }

    /*
    dp.forEach {
        println(it.toList())
    }
     */

    var ans = 0
    for (i in 0..vMax) {
        if (dp[n][i] <= w) {
            ans = i
        }
    }

    println(ans)
}

Measured memory_bytes: 140636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

int n;
ll l[1005];
map< pair< pair<int,int>, int >, int >m;

int main() {

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> l[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k]) {
                    if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[i] + l[k] > l[j]) {
                        vector<int>vec;
                        vec.pb(i),vec.pb(j),vec.pb(k);
                        sort(vec.begin(), vec.end());
                        if (!m[mp(mp(vec[0],vec[1]),vec[2])]) ans++, m[mp(mp(vec[0],vec[1]),vec[2])]=1;

                    }
                }
            }
        }
    }

    cout << ans;

return 0;
}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<n; ++i)
#define FOR(i, a, b) for(int i=a; i<b; ++i)
#define FORR(i, a, b) for(int i=b-1; i>=a; --i)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int cnt=1;
	while(true){
		if(cnt*cnt>n){
			--cnt;
			break;
		}
		++cnt;
	}
	cout<<cnt*cnt<<'\n';
	return 0;
}


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

int main() {
  int cards;
  int deal = 3;
  int hand = 0;

  while (deal--) {
    cin >> cards;
    hand+=cards;
  }
  if (hand >= 22) {
    cout << "bust";
  }
  else {
    cout << "win";
  }
  return 0;
}

Measured memory_bytes: 256
io = STDIN
l,r=io.gets.split.map(&:to_i)
def calc(l,r)
  ans=2019
  l.upto(r-1) do |i|
    (i+1).upto(r) do |j|
      ans=[ans,(i*j)%2019].min
    end
  end
  p ans
end
if r-l <= 4038
  calc(l,r)
else
  p 0
end


Measured memory_bytes: 1788
N,K=map(int,input().split())
height = []
for i in range(N):
    height.append(int(input()))
height_s = sorted(height)
diff = []
i = 0
while True:
    if i + K == len(height_s) + 1:
        break
    diff.append(height_s[i + K -1]-height_s[i])
    i += 1
s = sorted(diff)

print(s[0])

Measured memory_bytes: 12848
import java.math.BigDecimal;
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		double num;
		Scanner sc = new Scanner(System.in);
		Doctor d;
		
		while(true){
			num = sc.nextDouble();
			if(num < 0){
				break;
			}
			d = new Doctor(num);
			if(d.judge()){
				System.out.println(d.getBD());
			}else{
				System.out.println("NA");
			}
		}
	}
}

class Doctor {
	double num;
	String bd;
	int integers;
	double decimals;
	
	Doctor(double num){
		this.num = num;
		bd = "";
		integers = (int)num;
		decimals = new BigDecimal(num - integers).setScale(4, BigDecimal.ROUND_UP).doubleValue();
	}
	
	public boolean judge(){
		if(integers>255 || decimals>0.9375){
			return false;
		}
		return true;
	}
	
	private boolean toBinaryDigits(){
		String tmp = "";
		int count = 1;
		
		for(int i=integers;i>0;i/=2){
			tmp += i%2;
		}
		StringBuffer sb = new StringBuffer(tmp);
		for(int i=0;i<8-tmp.length();i++){
			bd += "0";
		}
		bd += sb.reverse().toString()+".";
		while(true){
			if(decimals == 0){
				bd += "0000";
				break;
			}
			
			if(count > 4){
				return false;
			}
			decimals *= 2;
			if(decimals >= 1){
				decimals -=1;
				bd += "1";
				if(decimals == 0){
					for(int i=0;i<4-count;i++){
						bd += "0";
					}
					break;
				}
			}else{
				bd += "0";
			}
			count++;
		}
		
		return true;
	}
	
	public String getBD(){
		if(toBinaryDigits()){
			return bd;
		}
		return "NA";
	}
}

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

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

int N;
vector<pair<int,int>> E;
vector<int> EE[201010];
map<int,int> M;

void add(int x,int y) {
	E.push_back({x,y});
	EE[x].push_back(y);
	EE[y].push_back(x);
}

void dfs(int cur,int pre,int v) {
	if(cur>N) v^=(cur-N);
	else v^=cur;
	M[v]=cur;
	FORR(e,EE[cur]) if(e!=pre) dfs(e,cur,v);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	if((N&(N-1))==0) return _P("No\n");
	
	x=1;
	while(x*2<=N) x*=2;
	
	cout<<"Yes"<<endl;
	if(N+1==x*2) {
		for(i=1;i<x;i++) {
			add(i,i+x);
			add(i+x,x);
			add(x,i+N);
			add(i+N,i+x+N);
		}
		add(1,x+N);
	}
	else {
		y=x/2;
		for(i=1;i<y;i++) {
			add(i,i+y);
			add(i+y,y);
			add(y,i+N);
			add(i+N,i+y+N);
		}
		add(1,y+N);
		add(x,x+1);
		add(x+1,1);
		add(1,x+N);
		add(x+N,x+1+N);
		
		dfs(x+N,-1,0);
		
		for(i=x+2;i<=N;i++) {
			add(i,x+N);
			assert(M.count(i));
			add(i+N,M[i]);
		}
		
	}
	
	FORR(e,E) cout<<e.first<<" "<<e.second<<endl;
}


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


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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    map<string,int> mmp;
    map<string,int> amp;
    map<string,int> rmp;
    map<string,int> cmp;
    map<string,int> hmp;
    string tmp;
    for(int i = 0; i < n; i++) {
        tmp=s[i];
        if(tmp[0]=='M')      mmp[tmp]++;
        else if(tmp[0]=='A') amp[tmp]++;
        else if(tmp[0]=='R') rmp[tmp]++;
        else if(tmp[0]=='C') cmp[tmp]++;
        else if(tmp[0]=='H') hmp[tmp]++;
        else continue;
    }
    ll ms=mmp.size();
    ll as=amp.size();
    ll rs=rmp.size();
    ll cs=cmp.size();
    ll hs=hmp.size();

    ll ans = ms*as*rs + ms*as*cs + ms*as*hs + ms*rs*cs + ms*rs*hs + ms*cs*hs + as*rs*cs+ as*rs*hs + as*cs*hs +rs*cs*hs;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 16640