akhauriyash/Code-Regression huggingface dataset:
object Main{
  def p(a : Array[Long]){
    for(i <- 0 until a.length){
      if(i != 0) print(" ")
      print(a(i))
    }
    println()
  }
  def main(args : Array[String]){
    val sc = new java.util.Scanner(System.in)
    val K = sc.nextLong
    val N = 50
    val a = new Array[Long](50)
    for(i <- 0 until 50) a(i) = if(i < K%N) 2*N + K / N - K % N else N - 1 + K / N - K % N
    println(N)
    p(a)
  }
}


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

using namespace std;
typedef long long ll;

/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
void solve(ll a[],ll b[],ll c[],ll n){
    ll dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(ll i=1;i<n;i++){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][2],dp[i-1][0]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


int main(){
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    solve(a,b,c,n);
}


Measured memory_bytes: 4992
MOD = 10 ** 9 + 7

# 繰り返し二乗法(x.pow(n, mod)でもOK)
def pow(x, n, mod = MOD)
  ans = 1
  # 下位ビットから繰り返し計算を行う
  while n > 0 do
    ans = ans * x % mod if n.odd? # 下位ビットが1かどうか
    x = x * x % mod
    n >>= 1 # 右ビットシフト
  end
  return ans
end

# (mod p)下での逆元
# フェルマーの小定理より a^(p-1) = 1 (mod p) (aは整数, pは素数, aとpは互いに素)
# a * a^(p-2) = 1 なので, aの逆元が a^(p-2) となる
def inv(a, mod = MOD)
  pow(a, mod - 2, mod)
end

# 階乗
# 再利用できるようグローバル変数化
$fact = [1] # 0! = 1
def fact(n, mod = MOD)
  # 計算済ならそれを返す
  return $fact[n] unless $fact[n].nil?

  # 階乗を求めながら$factへ格納
  f = $fact[-1]
  ($fact.size).upto(n) do |i|
    f = (f * i) % mod
    $fact << f
  end
  return $fact[n]
end

# 順列
def perm(n, r, mod = MOD)
  # n*(n-1)*(n-2)*...*(n-r+1)
  return n.downto(n - r + 1).reduce(1) {|ans, x| (ans * x) % mod }
end

# 組み合わせ
def comb(n, r, mod = MOD)
  return 0 unless 0 <= r && r <= n
  return 1 if r == 0 || r == n
  # nCk = n!/(n-k)! * 1/k!
  return perm(n, r, mod) * inv(fact(r, mod) % mod, mod) % mod
end

n, a, b = gets.chomp.split(" ").map(&:to_i)
puts ((pow(2, n) - 1) - comb(n, a) - comb(n, b)) % MOD


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if((A+B) == (C+D)) cout << "Balanced" << endl;
  else if((A+B) > (C+D)) cout << "Left" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    long long A[N];
    long long sum=0;
    for(long long i=0;i<N;i++){
        cin>>A[i];
    //    sum+=A[i]; // この段階では加算しない
    }
    long long ans=0;
    for(long long i=0;i<N-1;i++){
        sum=(sum+A[i])%1000000007; // この段階で加算し，modを取る
        ans+=sum*A[i+1]%1000000007; // sumに，いま加えた要素の次の要素を掛け，ansに加算する
    }
    cout<<ans%1000000007<<endl;
    return 0;
}


Measured memory_bytes: 5076
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
# 盤面の受け取り
H,W = map(int,input().split())
board = [[] for _ in range(H)]
for i in range(H):
    board[i] = list(input())
moves = [(-1, 0), (0, -1), (0, 1),(1, 0)]

def check(h,w):
    for mh,mw in moves:
        x,y = h+mh,w+mw
        # print(x,y)
        if 0<=x<H and 0<=y<W and board[x][y]=="#":
            # print(board[x][y])
            return True
    return False
        
ans = "Yes"
for h in range(H):
    for w in range(W):
        if board[h][w]=="#":
            flg = check(h,w)
            if not flg:
                print("No")
                exit()

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

int main(){
	string s,t;
	cin>>s>>t;

	bool frag = false;

	for (int i = 0; i < s.size(); i++){
		if(s == t){
			frag = true;
			break;
		}
		s = s.back() + s.substr(0,s.size()-1);
	}

	if(frag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

}




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

#define int long long

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

int N;
string s;

signed main() {
    cin >> N;
    int lb = 0, ub = N;
    cout << 0 << endl;
    cin >> s;
    if (s == "Vacant") {
        return 0;
    }
    bool lb_is_Male = s == "Male";
    while (true) {
        int med = (lb + ub) / 2;
        cout << med << endl;
        cin >> s;
        if (s == "Vacant") {
            return 0;
        }
        bool med_is_Male = s == "Male";
        if ((lb % 2 == med % 2) == (lb_is_Male == med_is_Male)) {
            lb = med;
            lb_is_Male = med_is_Male;
        } else {
            ub = med;
        }
    }
    return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  int L[N]; for (int i = 0; i < N; i++) cin >> L[i];
  sort(L, L + N, greater<int>());
  int sum = 0;
  for (int i = 0; i < K; i++) sum += L[i];
  cout << sum << endl;
}

Measured memory_bytes: 256
/* Coded by AlessandroChen */
#include <map>
#include <queue>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PI;

#define forn(i, n) for (int i = 1; i <= (int)(n); ++ i)
#define rep(i, s, t) for (int i = (int)(s); i <= (int)(t); ++ i)
#define Forn(i, n) for (int i = 0; i < (int)(n); ++ i)

#define seta(x, y) memset(x, y, sizeof(x))


char nc() {
	static char buf[1 << 30], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 30, stdin), p1 == p2) 
		? EOF : *p1 ++;
}

template <class T> inline void read(T &x) {
	x = 0; int ch, f = 0;
	for (ch = nc(); ch < '0' || ch > '9'; ch = nc()) if (ch == '-') f = 1;
	for (; ch >= '0' && ch <= '9'; ch = nc()) x = (x << 1) + (x << 3) + (ch ^ 48);
	if (f) x = ~x + 1;
}

template <class T> inline bool chkmax(T &x, const T &y) {
	return x < y ? x = y, 1 : 0;
}

template <class T> inline bool chkmin(T &x, const T &y) {
	return x > y ? x = y, 1 : 0;
}

const int maxn = 110;
int n, x, a[maxn], ans = 0;

int main() {
	read(n), read(x);
	for (int i = 1; i <= n; ++ i) read(a[i]);
	sort(a + 1, a + n + 1);
	bool flag = false;
	for (int i = 1; i <= n; ++ i) {
		if (x >= a[i]) {x -= a[i]; ans ++;}
		else {flag = true; break; }
	}
	if (!flag && x) ans --;
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var count = 0;
        var list = new List<long>();
        for (int i = 0; i < n; i++)
        {
            list.Add(CRL().ToInt());
        }
        list.Sort();
        var does = 1;
        var index = 0;
        while (index < n)
        {
            var target = list[index];
            var buf = 0;
            while (index < n && list[index] == target)
            {
                buf++;
                index++;
            }

            if (buf.IsEven() == false)
            {
                count++;
            }
        }
        CWL(count);
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    //テンプレここまで
}


Measured memory_bytes: 17116
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = 57;
struct Edge {
	int v, u;
	Edge(): v(NIL), u(NIL) {}
	int get(int w) {
		return v ^ u ^ w;
	}
};

vector<int> g[MAXN];
Edge E[MAXN];
int n, m;
pii r[MAXN];
ll msk[MAXN];

ll pw2(ll x) {
	return 1LL << x;
}

int dfs(int v, int p, int ii) {
	int fnd = (v == r[ii].second);
	for(auto& id: g[v]) {
		int u = E[id].get(v);
		if(u != p) {
			int rez = dfs(u, v, ii);
			if(rez) {
				msk[ii] |= pw2(id);
			}
			fnd += rez;
		}
	}

	return fnd;
}

void solve() {
	cin >> n;
	for(int i = 0; i < n - 1; ++i) {
		E[i].v = fetch<int>() - 1;
		E[i].u = fetch<int>() - 1;

		g[E[i].v].push_back(i);
		g[E[i].u].push_back(i);
	}
	cin >> m;
	for(int i = 0; i < m; ++i) {
		cin >> r[i].first >> r[i].second;
		--r[i].first, --r[i].second;
	}

	for(int i = 0; i < m; ++i) {
		dfs(r[i].first, NIL, i);
		DBG(msk[i]);
	}

	ll answ = 0;
	for(int who = 0; who < (1 << m); ++who) {
		ll curmsk = 0;
		ll p = 1;
		for(int i = 0; i < m; ++i) {
			if((who>>i)&1) {
				curmsk |= msk[i];
				p = -p;
			}
		}

		ll cnt = 0;
		for(ll i = 0; i < (ll)(n - 1); ++i) {
			if((curmsk>>i)&1LL) ++cnt;
		}

		answ += p * pw2(n - 1 - cnt);
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_arc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void add_edge(Graph &g, int a, int b, Weight w = 1) {
	add_arc(g, a, b, w);
	add_arc(g, b, a, w);
}

pair<vector<int>, bool> bellmanFord(const Graph &g, int s, Array &dist) {
	int n = g.size();
	vector<int> prev(n, -1);
	Edges es; for (int i = 0; i < n; i++) for (auto &e : g[i]) es.emplace_back(e);
	dist.assign(n, INF); dist[s] = 0;
	bool negative_cycle = false;
	for (int i = 0;; i++) {
		bool update = false;
		for (auto &e : es) {
			if (dist[e.s] != INF && dist[e.d] > dist[e.s] + e.w) {
				dist[e.d] = dist[e.s] + e.w;
				prev[e.d] = e.s;
				update = true;
			}
		}
		if (!update) break;
		if (i > n) { negative_cycle = true; break; }
	}
	return make_pair(prev, !negative_cycle);
}

//辺を逆に張ったグラフ
Graph reverse(const Graph &g) {
	Graph rg(g.size());
	for (auto &es : g)
		for (auto &e : es)
			rg[e.d].emplace_back(e.d, e.s, e.w);
	return rg;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	Graph g(N);
	rep(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		add_arc(g, a, b, -c);
	}
	Array dist1, dist2;
	auto res1 = bellmanFord(g, 0, dist1);
	Graph rg = reverse(g);
	auto res2 = bellmanFord(rg, N - 1, dist2);
	if (!res1.second && !res2.second) {
		cout << "inf" << endl;
	}
	else {
		cout << -dist1[N - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
using namespace std;

int H, W[100];
int M[100][100];
int dp[100][100]; // M[i][j]までの最大数

void input() {
  string str;
  
  while( getline( cin, str ) ) {
    replace( str.begin(), str.end(), ',', ' ' );
    stringstream ss(str);
    while( ss >> M[H][W[H]] ) W[H] ++;
    H ++;
    /*
    cout << H-1 << " " << W[H-1] << endl;
    for( int i=0; i<W[H-1]; i++ ) cout << M[H-1][i] << " ";
    cout << endl;
    */
  }
  
}

int solve() {

  for( int i=0; i<H; i++ ) {
    for( int j=0; j<W[i]; j++ ) {
      if( i-1 < 0 ) {
	dp[i][j] = M[i][j];
	continue;
      }
      if( i <= H/2 && j-1 < 0 ) {
	dp[i][j] = dp[i-1][j] + M[i][j];
	continue;
      }
      if( i <= H/2 && j+1 == W[i] ) {
	dp[i][j] = dp[i-1][j-1] + M[i][j];
	continue;
      }
      if( i<=H/2 ) {
	dp[i][j] = max( dp[i-1][j-1], dp[i-1][j] ) + M[i][j];
      } else {
	dp[i][j] = max( dp[i-1][j], dp[i-1][j+1] ) + M[i][j];
      }
    }
  }
  
  /*
  for( int i=0; i<H; i++ ) {
    for( int j=0; j<W[i]; j++ ) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */

  return dp[H-1][0];
}

int main() {
  input();
  cout << solve() << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(0<i){
      if(a[i-1]<a[i]) b[i]=1;
      else if(a[i-1]>a[i]) b[i]=-1;
    }
  }
  
  ll money=1000;
  ll kabu=0;
  
  for(int i=0;i<n-1;i++){
    if(b[i+1]==1){
      kabu+=money/a[i];
      money%=a[i];
    }
    else if(b[i+1]==-1){
      money+=kabu*a[i];
      kabu=0;
    }
  }
  
  money+=kabu*a[n-1];
  
  cout << money << endl;
}

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

int main(void) {
	long int N, M, ans = 0,in,ax;
	cin >> N >> M;
	in = min(N, M);
	ax = max(N, M);
	if (in == 1 && ax == 1)
		ans = 1;
	else if (in == 1 && ax>1)
		ans = ax - 2;
	else
		ans = (in - 2)*(ax - 2);
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int A, B, C;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B >> C;

    int ma = max(A, max(B, C));

    if (ma == A) printf("A\n");
    if (ma == B) printf("B\n");
    if (ma == C) printf("C\n");
}


Measured memory_bytes: 3112
//Moh_K_Imar .......
//24/08/2020  ... 5,45.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    if(a*500>=b)cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import log2

class Doubling:
    def __init__(self, lst, max_step):
        self.lst = lst
        self.max_step = max_step
        self.k = int(log2(max_step * 2 - 1)) + 1
        # print(self.k)
        self.D = self.create()

    def create(self):
        len_ = len(self.lst)
        D = [[-1] * len_ for _ in range(self.k)]
        D[0] = self.lst
        d = 2
        for i in range(1, self.k):
            for j in range(len_):
                D[i][j] = D[i - 1][D[i - 1][j]]
            d *= 2
        # print(D)
        return D

    def step(self, start, step):
        v = start
        for i in range(self.k, -1, -1):
            l = 1 << i
            if l <= step:
                v = self.D[i][v]
                # print(i, l)
                step -= l
        return v

def solve():
    n, k = MI()

    A = LI1()
    d = Doubling(A, k)

    v = d.step(0, k)
    print(v+1)







if __name__ == '__main__':

    solve()


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

using namespace std;
const int N = 600000;

int n;
string s;
map<string, int> mm;
vector<pair<int, string> > c;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a % 2 == 0)
        {
            if (a % 3 == 0 || a % 5 == 0) continue;
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i,n;
	scanf("%d",&n);
	int r[n],minv[n],maxv[n],Max=-1000000000;
	for(i=0;i<n;i++){
		scanf("%d",&r[i]);
    }

	minv[0]=r[0];
	maxv[0]=r[n-1];
	for(i=1;i<n-1;i++){
		minv[i] = r[i]<minv[i-1]?r[i]:minv[i-1];
		maxv[i] = r[n-1-i]>maxv[i-1]?r[n-1-i]:maxv[i-1];
	}
	for(i=0;i<n-1;i++){
		Max = maxv[n-2-i]-minv[i]>Max?maxv[n-2-i]-minv[i]:Max;
	}
	printf("%d\n", Max);

	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    rep(i, n) {
        cin >> b[i];
        ans += b[i];
    }
    rep(i, n - 1) {
        cin >> c[i];
    }
    rep(i, n - 1) {
        if (a[i] + 1 == a[i + 1]) ans += c[a[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll binarySearch(function<bool(ll)> check, ll ok, ll ng) {
  while ((ok - ng > 1) || (ng - ok > 1)) {
    ll mid = (ok + ng) / 2;
    if (check(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}
ll N,A,B;
ll h[100010];
bool Check(ll n){
    ll cnt=0;
    for(ll i=0;i<N;i++){
        if(h[i]>n*B)cnt+=(h[i]-n*B-1)/(A-B)+1;
    }
    return !(cnt<=n);
}
int main(){
    cin>>N>>A>>B;
    for(ll i=0;i<N;i++){
        cin>>h[i];
    }
    cout<<binarySearch(Check,0,1'000'000'000)+1<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
	char suit;
	int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right){
	int i, j, k;
	int n1 = mid - left;//要素の中央値-左端
	int n2 = right - mid;//右端-要素の中央値
	for(i = 0; i < n1; i++) L[i] = A[left + i];
	for(i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;//最大値の設定
	i = j = 0;
	for(k = left; k < right; k++){
		if(L[i].value <= R[j].value){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[], int n, int left, int right){
	int mid;
	if(left + 1 < right){
		mid = (left + right) / 2;//平均値を求める
		mergeSort(A, n, left, mid);//rightにmidを代入
		mergeSort(A, n, mid, right);//leftにmidを代入
		merge(A, n, left, mid, right);
	}
}

int partition(struct Card A[], int n, int p, int r){
	int i, j;
	struct Card t, x;
	x = A[r];
	i = p - 1;
	for(j = p; j < r; j++){
		if(A[j].value <= x.value){//A[j]がA[r]よりも小さかった時の処理
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;//値の入れ替え
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;//値の入れ替え
	return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r){
	int q;
	if(p < r){
		q = partition(A, n, p, r);
		quickSort(A, n, p, q - 1);//基準となる値より小さい値
		quickSort(A, n, q + 1, r);//基準となる値より大きい値
	}
}

int main(){
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d",&n);
	
	for( i = 0; i < n; i++){
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n - 1);
	
	for(i = 0; i < n; i++){
		if(A[i].suit != B[i].suit) stable = 0;//mergeSortとquickSortでの実行結果が異なる場合にstable = 0にする
	}
	
	if(stable == 1) printf("Stable\n");
	else printf("Not stable\n");//stableが0の時の値
	for(i = 0; i < n; i++){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int alph[]=new int[26];
		
		while(in.hasNext()) {
			String str=in.nextLine();char C[]=str.toCharArray();
			for(int i=0;i<C.length;i++) {
				if(C[i]>=65 && C[i]<=90)alph[C[i]-65]++;
				else if(C[i]>=97 && C[i]<=122)alph[C[i]-97]++;
			}
		}
		
		
		for(int i=0;i<26;i++) {
			char c=(char)(i+97);
			System.out.println(c+" : "+alph[i]);
		}
		out.flush();
	}

}



Measured memory_bytes: 26036
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std;
#define ing long long 

signed main(void){
  int N; scanf("%lld", &N);
  
  multiset<int> ms;
  for(int i = 0; i < N; i++){ 
    int a; cin >> a;
    //aより小さなものがなければ、そのまま入れる
    if( ms.empty() || *ms.begin() >= a ){ 
      ms.insert(a);
    }
    else{ // aより小さなものがある
      
      auto itr = ms.lower_bound(a);
      itr--;
      ms.erase(itr);
      ms.insert(a);
    }
  }
  
  printf("%lld\n", ms.size() );
  
  return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[100010];
long long b[100010];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();long long ans=0;
	for(int i=0;i<=n;i++)a[i]=read(),ans+=a[i];
	for(int i=n;i>=0;i--)b[i]=b[i+1]+a[i];
	long long now=1-a[0];bool pd=true;
	ans+=now;if(now<0)pd=false;
	for(int i=1;i<=n;i++)
	{
		now=min(2*now-a[i],b[i+1]);
		if(now<0){pd=false;break;}
		ans+=now;
	}
	if(pd==true)printf("%lld\n",ans);
	else puts("-1");
	return 0;
}

Measured memory_bytes: 2764
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

a = na()
s = set(a)
print(len(s))

Measured memory_bytes: 3064
n,m=map(int,input().split())
result=[]
a=list(map(int,input().split()))
for i in range(m-1):
    r1=a[i+1]-a[i]
    result.append(r1)
r2=n-a[-1]+a[0]
result.append(r2)
print(n-max(result))


Measured memory_bytes: 26004
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int x;
    vector<int> vec(4);
    for(int i=0;i<6;i++){
        cin>>x;vec[x-1]++;
    }
    int cnt=0;
    for(int i=0;i<4;i++){
        if(vec[i]%2==1)cnt++;
    }
    if(cnt==0||cnt==2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
  ll X, t; cin >> X >> t;
  cout << max(X - t, (ll)0) << endl;
  return 0;
}


Measured memory_bytes: 256
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;  

void test_case()
{  
    ll n,i,j;
    cin >> n;
    map<ll,ll> m;
    ll tot = 0;
    f(i,0,n)
    {
        ll x;
        cin >> x;
        tot += x;
        m[x]++;
    }
    ll q;
    cin >> q;
    while(q--)
    {
        ll x, y;
        cin >> x >> y;
        tot -= x*m[x];
        m[y] += m[x];
        tot += y*m[x];
        m[x] = 0;
        cout << tot << '\n';
    }

}
 
int32_t main()
{
    IOS(); 
  
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 9436
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
int mod = 998244353;
const int inf = 1e9 + 7;
const int N = 5e3 + 5;
const double eps = 1e-9;

int add(int x, int y) { return x+y < mod ? x+y : x+y-mod; }
int sub(int x, int y) { return x-y < 0 ? x-y+mod : x-y; }
int mul(int x, int y) { return x * 1ll * y % mod; }

int dp[5005][5005];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n >> mod;
  int ans = 0;
  dp[1][1] = 1;
  for (int i = 1; i < n; i++) {
    int s = i <= (n+1)/2 ? i : 2*(n+1)/2 - i;
    for (int j = 1; j <= n; j++) if (dp[i][j] != 0) {
      dp[i+1][j] = add(dp[i+1][j], dp[i][j]);
      for (int k = j + s; k <= n; k += s)
        dp[i+1][k] = add(dp[i+1][k], dp[i][j]);
    }
  }
  for (int i = 1; i <= n; i++)
    ans = add(ans, mul(dp[n][i], n-i+1));
  cout << ans << endl;
}

Measured memory_bytes: 101292
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

class Dice {
  private:
   int face[6];

  public:
    int getTop();
    int getFace(int);
    void setFace(int label,int value);
    void turnOver(char dir);
    void debugOut();
};

int Dice::getTop(){
  return face[0];
}

int Dice::getFace(int i){
  return face[i];
}

void Dice::setFace(int label,int value){
  if(label>5) return;
  face[label] = value;
}

void Dice::turnOver(char c){
  int tmp;
  if(c=='N'){
    tmp = face[0];
    face[0] = face[1]; face[1] = face[5];
    face[5] = face[4]; face[4] = tmp; // face[0]
  }

  if(c=='S'){
    tmp = face[0];
    face[0] = face[4]; face[4] = face[5];
    face[5] = face[1]; face[1] = tmp; //face[0]
  }

  if(c=='E'){
    tmp = face[0];
    face[0] = face[3]; face[3] = face[5];
    face[5] = face[2]; face[2] = tmp; //face[4]
  }

  if(c=='W'){
    tmp = face[0];
    face[0] = face[2]; face[2] = face[5];
    face[5] = face[3]; face[3] = tmp; //face[4]
  }
}

void Dice::debugOut(){
    for(int i=0;i<6;i++)
      printf("%d,",face[i]);
    putchar('\n');
}

int main(){
  Dice dice;
  Dice dice2;
  int l,count_n=0;

  for(int i=0;i<6;i++){
      scanf("%d ",&l);
      dice.setFace(i,l);
  }
  for(int i=0;i<6;i++){
      scanf("%d ",&l);
      dice2.setFace(i,l);
  }
  for(;;){
    if(dice.getFace(0) == dice2.getFace(0)) {
      if(dice.getFace(1) == dice2.getFace(1)) {
        if(dice.getFace(2) == dice2.getFace(2)){
          if(dice.getFace(3) == dice2.getFace(3)){
            if(dice.getFace(4) == dice2.getFace(4)){
              if(dice.getFace(5) == dice2.getFace(5)) {
                puts("Yes");
                return 0;
              } else{
                puts("No");
                return 0;
              }
            }
          } else {
            dice2.turnOver('E');
            dice2.turnOver('S');
            dice2.turnOver('S');
            }
        } else {
                puts("No");
                return 0;
        }
      }else{
        dice2.turnOver('W');
        dice2.turnOver('S');
        dice2.turnOver('E');
      }
    } else {
      if(count_n<3){
        dice2.turnOver('N');
        count_n++;
      } else {
        count_n=0;
        dice2.turnOver('E');
      }
    }
  }
}



Measured memory_bytes: 3148
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		string[] args = Console.ReadLine().Split(' ');
		int X = Int32.Parse(args[0]);
		int Y = Int32.Parse(args[1]);
		int Z = Int32.Parse(args[2]);
		Console.WriteLine((X - Z)/(Y + Z));
	}
}





Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
 
struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};
 
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};
 
ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}
 
//-----------------------------------------------------------------------------
 
string s,t;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	cin>>s>>t;
	reverse(ALL(t));
	if(s==t) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
 
	return 0;
}

Measured memory_bytes: 256
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys

def _i(): return int(sys.stdin.readline().strip())
def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

n = _i()
x = sorted(_ia())

ans = -1
for p in range(min(x), max(x)+1):
   tmp = 0
   for xx in x:
      tmp += (xx-p)**2
   if ans <0 or tmp<ans: ans= tmp
print(ans)

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

int main(){
    
   int N;
   cin >> N;
   
   int MAX=0;
   int MIN=pow(10,9.0);
   
   for(int i=0;i<N;i++){
       int a;
       cin >> a;
       if(a>MAX) MAX=a;
       if(a<MIN) MIN=a;
   }
   
   cout << MAX-MIN << endl;
   
}


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n+10);
  rep(i,n) cin >> h[i];
  int count = 1;
  for(int i = 1;i < n;++i){
    bool flag = true;
    for(int j = 0;j<i;++j){
      if(h[j] > h[i]){
        flag = false;
        break;
      }
    }
    if(flag) ++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
typedef long long int ll;

int N;
vector<int> A;
map<int, long> m;
map<int, ll> memo;

int main()
{
  int n;
  int ret=0;
  long aa, v;
  int i;
  ll asum, sum;

  cin >> N;

  for (i=0; i<N; i++) {
    cin >> aa;
    A.push_back(aa);
    decltype(m)::iterator it = m.find(aa);
    if (it != m.end()) {
      v = it->second+1;
      m.erase(aa);
    } else {
      v = 1;
    }
    m.emplace(aa, v);
  }
  asum = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    asum += it->second*(it->second-1);
  }
  asum/=2;
  for (i=0; i<N; i++) {
    sum=m.at(A[i]);
    printf("%lld\n", asum-sum+1);
  }

  return 0;
}



Measured memory_bytes: 10356
n = int(input())
a = list(map(int,input().split()))
total = 0
c = 0
small = 1000000000
for i in range(n):
    if a[i]<0:
        c+=1
        a[i] = abs(a[i])

    small= min(small,a[i])
if c&1:
    print(sum(a)-2*small)
else:
    print(sum(a))

Measured memory_bytes: 14412
//回答みてやり直し
#include <bits/stdc++.h>
using namespace std;

int N;

int main() {
    scanf("%d", &N);
    int ans = N;
    for (int i = 0; i <= N; i++) {
        int temp = 0;
        int t = i;
        while (t > 0) temp += t%6, t /= 6;
        t = N-i;
        while (t > 0) temp += t%9, t /= 9;
        ans = min(ans, temp);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N, T, A; cin>>N>>T>>A;
    int ans_=MOD; int ans=0;
    for(int i=0; i<N ;i++){
      int h; cin>>h;
      if( ans_ > abs(1000*T - 6*h - 1000*A)){
          ans_ = abs(1000*T - 6*h - 1000*A); ans = i+1;
      }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 31; i <= 55555; i += 30) {
		if (isprime(i) == true) {
			if (i != 31) cout << " ";
			cout << i; n--;
		}
		if (n == 0) break;
	}
	cout << endl;
	return 0;
}

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

using namespace std;

int n, k, q, a[mx], b[mx], ans = 1000000007;

int main(){
	scanf("%d%d%d", &n, &k, &q);
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
	copy(a, a+n, b);
	sort(b, b+n);
	for (int i = 0; i < n; i++) {
		int j = 0;
		vector<int> sm;
		while(j < n){
			vector<int> v;
			int l = 0;
			for(; j + l < n && a[j + l] >= b[i]; l++);
			if(l){
				v.insert(v.begin(), a+j, a+j+l);
				sort(v.begin(), v.end());
				if(v.size() >= k){
					sm.insert(sm.end(), v.begin(), v.end() - k + 1);
				}
			}else l = 1;
			j += l;
		}
		if(sm.size() < q) break;
		sort(sm.begin(), sm.end());
		ans = min(ans, sm[q-1] - sm[0]);
	}
	printf("%d\n", ans);
}

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

int main() {
    int n, d;
    cin >> n >> d;
    //配列を完成
    vector <vector<int>> data(n, vector<int>(d));
    for (int i = 0; i < n ; i++) {
        for (int j = 0; j < d; j++) {
            cin >> data.at(i).at(j);
        }
    }

    int count = 0;
    double a = 0;
    double b = 0;
    int c = 0;
    int x = 0;
    for (int k = 0; k < n ; k++) {
        for (int i = k + 1; i < n ; i++) {
            for (int j = 0; j < d ; j++) {
                a += (data.at(i).at(j) - data.at(k).at(j)) *  (data.at(i).at(j) - data.at(k).at(j));
            }
            b = sqrt(a);
            c = ceil(b);
            x = floor(b);
            if ( c == x)
                count ++;
            a = 0;
            b = 0;
            c = 0;
            x = 0;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <bitset>
using namespace std;

vector <string> form;
int p;
int Calculate(int nest){
	char op;
	int result;
	if (form[p][nest] == '+'){ result = 0; op = '+'; }
	else if (form[p][nest] == '*'){ result = 1; op = '*'; }
	else result = form[p][nest] - '0';
	p++;
	while (1){
		if (p >= form.size()) break;
		if (nest >= form[p].size()) break;
		if (form[p][nest] != '.') break;
		if ('0' <= form[p][nest + 1] && form[p][nest + 1] <= '9'){
			if (op == '+') result += form[p][nest + 1] - '0';
			if (op == '*') result *= form[p][nest + 1] - '0';
			p++;
		}
		else{
			if (op == '+') result += Calculate(nest + 1);
			if (op == '*') result *= Calculate(nest + 1);
		}
	}
	return result;
}
int main(){
	int i, n;
	while (1){
		cin >> n;
		if (n == 0) break;
		form.clear();
		for (i = 0; i < n; i++){
			string temp;
			cin >> temp;
			form.push_back(temp);
		}
		p = 0;
		cout << Calculate(0) << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	ll a[100];
	a[0] = 2;
	a[1] = 1;
	repr(i, 2, n+1) {
		a[i] = a[i - 1] + a[i - 2];
	}
	cout << a[n] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	double a,b,c,d,e,f,x,y;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&e,&c,&d,&f) != EOF){
		x = (e*d - b*f)/(a*d - b*c);
		y = (a*f - e*c)/(a*d - b*c);
		if(x == 0) x = 0;
		if(y == 0) y = 0;
		printf("%.03lf %.03lf\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define newline putchar('\n')
#define leave_space putchar(' ')
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	cout << (n - 2) * 180 << endl; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	int ans = 0;
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	vector<int> m(2019);
	int p = 1, n = 0;
	m[0]++;
	for(char c : s) {
		int x = c - '0';
		x = (x * p + n) % 2019;
		n = x;
		p = (p * 10) % 2019;
		ans += m[x];
		m[x]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
void solve() {
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int res = 0;
	for (int i = 0; i < n; i++) {
		res += (s[i] != t[i]);
	}
	cout << res;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
}



Measured memory_bytes: 3808
fn main() {
    let mut N = String::new();
    std::io::stdin().read_line(&mut N).expect("Fail get N");
    let N: u8 = N.trim().parse().expect("Fail N parse");
    
    let answer = match N % 2 {
        0 => 0.5,
        1 => (N + 1) as f64 / (2 * N) as f64,
        _ => -1.0,
    };
    println!("{}", answer);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

__int128_t UPPER=1e18;

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

int main(int argc, char **argv) {
    i64 a;
    string s;
    cin >> a >> s;

    i64 b2 = (s[0] - '0') * 100 + (s[2]-'0') * 10 + (s[3]-'0');


    cout << (a * b2)/100 << endl;

    return 0;
}

Measured memory_bytes: 3644