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

using namespace std;

int MOD = 1000000000 + 7;
int N;

char acgt[] = {'A', 'C', 'G', 'T'};

int memo[100][4][4][4] = {0};

bool check3(char c0, char c1, char c2) {
    if (c0 == 'A' && c1 == 'G' && c2 == 'C') return false;
    if (c0 == 'A' && c1 == 'C' && c2 == 'G') return false;
    if (c0 == 'G' && c1 == 'A' && c2 == 'C') return false;
    return true;
}

bool check4(char c0, char c1, char c2, char c3) {
    if (c0 == 'A' && c2 == 'G' && c3 == 'C') return false;
    if (c0 == 'A' && c1 == 'G' && c3 == 'C') return false;
    return true;
}

int convert(char c) {
    if (c == 'A') return 0;
    if (c == 'C') return 1;
    if (c == 'G') return 2;
    if (c == 'T') return 3;
    return -1;
}

int dfs(string s) {
    int n = s.length();
    if (n == N) return 1;
    if (n >= 3 && memo[n][convert(s[n-3])][convert(s[n-2])][convert(s[n-1])] > 0) {
        return memo[n][convert(s[n-3])][convert(s[n-2])][convert(s[n-1])];
    }
    int ret = 0;
    for (int i = 0; i < 4; i++) {
        if (n >= 2 && !check3(s[n-2], s[n-1], acgt[i])) continue;
        if (n >= 3 && !check4(s[n-3], s[n-2], s[n-1], acgt[i])) continue;
        ret = (ret + dfs(s + acgt[i])) % MOD;
    }
    if (n >= 3) memo[n][convert(s[n-3])][convert(s[n-2])][convert(s[n-1])] = ret;
    return ret;
}

int main() {
    cin >> N;

    int ans = dfs("");
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
typedef long long ll;
typedef unsigned long long ull;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = (a); i < (ll) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define MOD 1000000007
ll dp[100105], alturas[100105], k; // agrego cien casillas demás donde voy a poner cosas que rompan
void iniciar()
{
     forn(i,100105)
    {
        dp[i]=1000000005;
        alturas[i]=1000000005;
    }
}
void solve(int n, int k)
{


    dp[k]=0;
    forr(i,1,n)
    {
        forn(j,k)
        {
            dp[i+k]=min(dp[i+k],dp[i+k-j-1]+abs(alturas[i+k]-alturas[i+k-j-1]));
        }
    }
    cout << dp[n+k-1] << "\n";
}


int main() {
    FIN;
    int n;
    cin >> n >> k;
    iniciar();
    forn(i,n) cin >> alturas[i+k];
    solve(n, k);
    return 0;
}


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

int main() {
    const int MAX = 200000;
    int r[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> r[i];

    int maxv = -2 * pow(10, 9);
    int minv = r[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, r[i] - minv);
        minv = min(minv, r[i]);
    }

    cout << maxv << endl;
}



Measured memory_bytes: 3868
n, *r = map(int, open(0).read().split())
a = r[:n]
q = r[n]
bc = r[n+1:]

d = {}
for x in a:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1
ret = sum(a)
for i in range(0, min(q*2, len(bc)), 2):
    b = bc[i]
    c = bc[i+1]
    if b in d:
        v = d.pop(b)
        if c in d:
            d[c] += v
        else:
            d[c] = v
        ret += c * v - b * v
    #ret = sum([k * v for k, v in d.items()])
    print(ret)


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,d;
  cin >> n >> d;
  cout << (n+2*d)/(2*d+1) << endl;
  return 0;
}


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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  int c[n],s[n],f[n];
  rep(i,0,n-1){
    cin >> c[i] >> s[i] >> f[i];
  }
  rep(i,0,n){
    int t = 0;
    rep(j,i,n-1){
      if(t<s[j]) t=s[j];
      else if(t%f[j] == 0);
      else t=t+f[j]-t%f[j];
      t+=c[j];
    }
    pout(t);
  }
	return 0;
}

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

using namespace std;

int main(void) {

	int n, m, d = 0, size;
	string a;

	cin >> a;

	size = a.size();

	for (n = 0; n <= size; n++) {

		for (m = 0; m <= size; m++) {

			if (n != m) {

				if (a[n] == a[m])
					d++;

			}

		}

	}

	if (d == 0)
		cout << "yes" << endl;

	else
		cout << "no" << endl;

}

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

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
const i64 MOD = 1e9+7;
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a%MOD, n /= 2) { if(n%2) ret = ret*a%MOD; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

const long double rate = 380000;
int n;
string t;
long double x, ans;
void input() {
	cin >> n;
}

int solve() {
	while(n--) {
		cin >> x >> t;
		if(t == "JPY") {
			ans += x;
		} else {
			debug(x*rate);
			ans += x*rate;
		}
		debug(ans);
	}
	cout.precision(10);
	cout << ans << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

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

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] sArray = S.toCharArray();
		Arrays.sort(sArray);
		String ans = new String(sArray).equals("abc") ? "Yes" : "No";
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23764
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(input())
before = [0]*K

ans = {"r": 0, "s": 0, "p": 0}


def win(sr):
    if sr == "r":
        return "p"
    elif sr == "s":
        return "r"
    elif sr == "p":
        return "s"


for i in range(N):
    for j in range(K):
        if i * K + j >= N:
            break
        if T[i*K+j] != before[j]:
            ans[win(T[i*K+j])] += 1
            before[j] = T[i*K+j]
        else:
            before[j] = 0


print(ans["r"]*R + ans["s"]*S + ans["p"]*P)


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



int main()
{
  ll N, M, C;
  cin >> N >> M >> C;
  vector<ll> B(M);
  for (ll i = 0; i < M; ++i)
  {
    cin >> B.at(i);
  }
  vector<vector<ll>> A(N, vector<ll>(M));
  for (ll i = 0; i < N; ++i)
  {
    for (ll j = 0; j < M; ++j)
    {
      cin >> A.at(i).at(j);
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i)
  {
    ll temp = 0;
    for (ll j = 0; j < M; ++j)
    {
      temp += A.at(i).at(j) * B.at(j);
    }
    if (temp + C > 0)
    {
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = gets.chomp

# s を半分に分ける

s1 = s[0,s.size/2]
s2 = s[(s.size.to_f/2).ceil,s.size/2].split(//).reverse

count = 0
s1.split(//).each_with_index { |e,i|
  count += 1 if e != s2[i]
}

puts count



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int64_t N,K;
int64_t sum=0;
cin>>N>>K;
vector<int>vec(N);
for(int i=0;i<N;i++){
cin>>vec.at(i);
}
sort(vec.begin(), vec.end());
for(int i=0;i<(N-K);i++){
sum+=vec.at(i);
}
cout<<sum<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  string s;
  cin>>n;
  cin>>s;
  int dp[n][n];
  for(int i=n-1;i>=0;i--){
    for(int j=n-1;j>=0;j--){
      if(s[i]==s[j]){
        if(i+1<n && j+1<n){
          dp[i][j] = 1 + dp[i+1][j+1];
        }else{
          dp[i][j] = 1;
        }
      }else{
        dp[i][j] = 0;
      }
    }
  }
  
  int ans = 0;
  int temp;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      temp = min(dp[i][j], j-i);
      ans = max(ans, temp);
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> zahyo(N, vector<int>(2));
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 2; j++) {
      cin >> zahyo.at(i).at(j);
    }
  }
  int count = 0;
  
  for(int k = 0; k < N; k++) {
    double l;
    l = pow(zahyo.at(k).at(0),2)+pow(zahyo.at(k).at(1),2);
    double l_sq;
    l_sq = sqrt(l);
    if(l_sq <= D){
      count++;
    }
  }
    cout << count << endl;
}


Measured memory_bytes: 14344
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()

	min := n
	rootN := math.Sqrt(float64(n))
	for i := 1; i <= int(rootN); i++ {
		if n%i == 0 && n/i <= n {
			d := i - 1 + (n / i) - 1
			if d < min {
				min = d
			}
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 640
MOD = 1000000007

N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(1 << N)]
dp[0] = 1

for i in range(1, 1 << N):
    k = 0
    for j in range(N):
        if (i >> j) & 1:
            k += 1
    for j in range(N):
        if (i >> j) & 1 and A[k - 1][j]:
            dp[i] += dp[i - (1 << j)]
            dp[i] %= MOD

print(dp[-1])

Measured memory_bytes: 201932
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

void bfs();

vector< L_P > graph[SIZE];

bool color[SIZE];
bool visit[SIZE];

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

    LL n;
    cin >> n;

    for( int i = 0; i < n - 1; ++i ) {
        LL x, y, w;
        cin >> x >> y >> w;
        graph[x].pb( MP( y, w ) );
        graph[y].pb( MP( x, w ) );

    }

    bfs();

    for( int i = 1; i <= n; ++i ) {
        if( color[i] ) cout << 1;
        else cout << 0;
        cout << endl;

    }

    return 0;
}

void bfs() {
    queue< L_P > q;
    q.push( MP( 1, 0 ) );

    while( !q.empty() ) {
        L_P p = q.front();
        q.pop();
        visit[p.F] = true;

        for( int i = 0; i < graph[p.F].size(); ++i ) {
            L_P node = graph[p.F][i];
            if( !visit[node.F] ) {
                if( ( p.S + node.S ) % 2 ) {
                    color[node.F] = 1;

                }
                q.push( MP( node.F, p.S + node.S ) );
            }
        }
    }
}



Measured memory_bytes: 8064
N,M=map(int,input().split())
ac=0
wa=0
a=[0]*N
w=[0]*N
for i in range(M):
    P,S=input().split()
    if S=="WA":
        w[int(P)-1]+=1
    else:
        if a[int(P)-1]==0:
            a[int(P)-1]+=1
            ac=ac+1
            wa+=w[int(P)-1]
        else:
            pass
print(ac,wa)

        





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

const int mod = 1e9 + 7;

long long pow_mod(long long x, long long n)
{
    long long res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    int N, a[100000 + 10];
    map<int, int> m;
    cin>>N;
    for(int i = 0; i < N; i++){
        cin>>a[i];
        m[a[i]]++;
    }

    if(N % 2 == 0){
        for(int i = 0; i < N; i++){
            if(m[a[i]] != 2 || a[i] == 0 || a[i] >= N || a[i] % 2 != 1){
                cout<<"0"<<endl;
                return 0;
            }
        }
        cout<<pow_mod(2, N / 2)<<endl;
    }
    else{
        if(N == 1 && m[0] == 1){
            cout<<"1"<<endl;
            return 0;
        }
        if(m[0] != 1){
            cout<<"0"<<endl;
            return 0;
        }
        m[0]++;
        for(int i = 0; i < N; i++){
            if(m[a[i]] != 2 || a[i] >= N || a[i] % 2 != 0){
                cout<<"0"<<endl;
                return 0;
            }
        }
        cout<<pow_mod(2, N / 2)<<endl;
    }


    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int >

const int N = 2005, mod = 1e9 + 7;
int fact[N] = {1}, inv[N] = {1};
int pow_mod(int a, int b) {
    if (b == 0) {
        return 1;
    }
    int nesf = pow_mod(a, b / 2);
    if (b % 2 == 0) {
        return (nesf * nesf) % mod;
    } else {
        return a * nesf % mod * nesf % mod;
    }
}
int comb(int n,int k) {
    if (k > n) return 0ll;
    return fact[n] * inv[k] % mod * inv[n - k] % mod;
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); 
    for (int i = 1; i < N; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
        inv[i] = pow_mod(fact[i], mod - 2);
    }
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        cout << comb(n - k + 1, i) * comb(k - 1, i - 1) % mod << "\n";
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int a;
    cin >> a;
    string s;
    cin >> s;
    cout << (a >= 3200 ? s : "red") << endl;
}


Measured memory_bytes: 256
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let d = Array.make n 0 in
  for _ = 1 to m do
    Scanf.scanf " %d %d" @@ fun a b ->
      d.(a-1) <- 1 + d.(a-1);
      d.(b-1) <- 1 + d.(b-1);
  done;
  let m = Array.fold_left (fun s x -> s + x mod 2) 0 d in
  print_endline @@ if m = 0 then "YES" else "NO"

Measured memory_bytes: 5248
H, W, K = map(int, input().split())
lis = []
ans = 0
for i in range(H):
  lis.append(list(input()))
for i in range(1<<H):
  for j in range(1<<W):
    cnt = 0
    for p in range(H):
      for q in range(W):
        if (i>>p) & 1:
          continue
        if (j>>q) & 1:
          continue
        if lis[p][q] == "#":
          cnt += 1
    if cnt == K:
      ans += 1
print(ans)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	double r,g;
	cin>>r>>g;
	cout<<g*2-r;
	re 0;
}

Measured memory_bytes: 3808
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N;

vector<int> div(int n) {
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    cin >> N;
    vector<int> d = div(N);
    int ansa = 0;
    int ansb = 0;
    for(auto di : d){
        for (int i = 0; i < min(N, 10000); i++)
        {
            int a = i;
            int b = a-di;
            if(pow(a, 5)-pow(b, 5)==N){
                ansa=a;
                ansb=b;
                break;
            }
        }
        if(ansa||ansb)break;
    }
    cout << ansa <<" "<< ansb << endl;
}

Measured memory_bytes: 4280
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    N = int(inp.readline().strip())

    r = (N * (N - 1)) // 2
    return int(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
fun main(args:Array<String>) {
     readLine()!!.toInt()
    val list = readLine()!!.split(" ").map(String::toInt)
    val list1 = list.filter { it % 2 == 0 }
    val new  =  list.filter { it % 6 == 0 || it % 10 == 0 }
    
    if (list1.size != new.size) {
        println("DENIED")
    } else {
        println("APPROVED")
    }

    
}


Measured memory_bytes: 37864
n = int(input())
a = list(map(int, input().split()))
q = int(input())
x = [0] * 100001
ans = sum(a)

for ai in a:
    x[ai] += 1  # xのなかでaiが登場する個数のカウント

for _ in range(q):
    b, c = map(int, input().split())
    ans += (c-b) * x[b]
    x[c] += x[b]  # bをcに入れ替えた個数だけcが増加する
    x[b] = 0
    print(ans)

# for i in range(q):
#     count = 0
#     b, c = map(int, input().split())
#
#     for j in a:
#         if j == b:
#             a[count] = c
#         count += 1
#     a_list = [_ for _ in a]
#     ans.append(a_list)
#
# for answer in ans:
#     print(sum(answer))


Measured memory_bytes: 20960
n = gets.to_i

array = Array.new(n).map{Array.new(n, 0)}

n.times do
  input = gets.split(" ").map{|x| x.to_i}
  u = input.shift
  k = input.shift
  input.each do |i|
    array[u-1][i-1] = 1
  end
end

array.each do |i|
  i.each_with_index do |j, t|
    print j
    print (" ") if t != n-1
  end
  puts
end



Measured memory_bytes: 6976
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (100010)

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);

	map<int, priority_queue<int, vector<int>>> sushi;
	for (int i = 0; i < N; i++) {
		int t, d;
		scanf("%d%d", &t, &d);
		sushi[t].push(d);
	}

	vector<int> top, other;
	for (auto iter = sushi.begin(); iter != sushi.end(); iter++) {
		priority_queue<int, vector<int>> q = iter->second;
		top.push_back(q.top()); q.pop();
		while (!q.empty()) {
			other.push_back(q.top()); q.pop();
		}
	}
	sort(top.begin(), top.end(), greater<int>());
	sort(other.begin(), other.end(), greater<int>());

	ll res = 0;
	for (int k = 1; k <= K; k++) {
		if (k > (int)top.size() || K - k > (int)other.size())
			continue;

		ll local = 0;
		for (int i = 0; i < k; i++)
			local += (ll)top[i];
		for (int i = k; i < K; i++)
			local += (ll)other[i - k];
		local += (ll)k * (ll)k;

		res = max(res, local);
	}

	printf("%lld\n", res);

	return 0;
}


Measured memory_bytes: 11772
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}
const int NMAX = 100010;
ll nor[NMAX], rev[NMAX], nor2[NMAX], rev2[NMAX], norMax[NMAX], revMax[NMAX];
ll x[NMAX], v[NMAX];

int main() {
   int N;
   ll C;
   cin >> N >> C;
   for (int i = 0; i < N; i++) {
      cin >> x[i] >> v[i];
      if (i == 0) {
         nor[i] = v[i] - x[i];
         norMax[i] = nor[i];
      } else {
         nor[i] = nor[i - 1] - (x[i] - x[i - 1]) + v[i];
         norMax[i] = llmax(norMax[i - 1], nor[i]);
      }
      nor2[i] = nor[i] - x[i];
   }
   for (int i = N - 1; i >= 0; i--) {
      if (i == N - 1) {
         rev[i] = v[i] - (C - x[i]);
         revMax[i] = rev[i];
      } else {
         rev[i] = rev[i + 1] + (x[i] - x[i + 1]) + v[i];
         revMax[i] = llmax(revMax[i + 1], rev[i]);
      }
      rev2[i] = rev[i] - (C - x[i]);
   }

   ll ans = 0;

   // 1
   for (int i = 0; i < N - 1; i++) {
      ll tmp = nor2[i];
      tmp += revMax[i + 1];
      chmax(ans, tmp);
   }
   // 2
   for (int i = N - 1; i > 0; i--) {
      ll tmp = rev2[i];
      tmp += norMax[i - 1];
      chmax(ans, tmp);
   }
   // 3
   chmax(ans, norMax[N - 1]);
   // 4
   chmax(ans, revMax[0]);
   
   cout << ans << endl;

   return 0;
}


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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
int n,k,p,h,c,d;
int main()
{
	n=read(); k=read();
	for(int i=1; i<=n; ++i)if(read()==1)p=i;
	h=(p-1+k-2)/(k-1);
	d=(k-1)*h;
	c=(n-d-1+k-2)/(k-1);
	printf("%d\n",h+c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define all(c) c.begin(),c.end()
#define sz(c) ((int)c.size())
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;

string jfen(vector<string> board) {
    int n = sz(board);
    string ret;
    rep(i, 0,n) {
        int cnt = 0;
        string line;
        rep(j, 0, sz(board[i])) {
            if (board[i][j] == '.') {
                cnt++;
            } else {
                if (cnt) line += cnt + '0';
                cnt = 0;
                line += 'b';
            }
        }
        if (cnt) line += cnt + '0';
        ret += line;
        if (i != n - 1) ret += '/';
    }
    return ret;
}
vector<string> unjfen(string s) {
    vector<string> ret;
    auto to_line = [](string line) {
        string r;
        rep(i, 0, sz(line)) {
            if (line[i] == 'b') {
                r += "#";
            } else {
                r += string(line[i] - '0', '.');
            }
        }
        return r;
    };
    s += "/";
    string tmp;
    rep(i, 0, sz(s)) {
        if (s[i] == '/') {
            ret.push_back(to_line(tmp));
            tmp = "";
        } else {
            tmp += s[i];
        }
    }
    return ret;
}

signed main() {
    while (1) {
        string s;
        cin >> s;
        if (s == "#") break;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        auto board = unjfen(s);
        swap(board[a][b], board[c][d]);
        auto ans = jfen(board);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3168
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<VMAX;i++) C[i] = 0;

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

  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d", B[i]);
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 9568
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final int[] balls = new int[n + 1];
        Arrays.fill(balls, 1, n + 1, 1);
        final boolean[] isContainingRedBall = new boolean[n + 1];
        isContainingRedBall[1] = true;

        for (int i = 0; i < m; i++) {
            final int x = scanner.nextInt();
            final int y = scanner.nextInt();

            isContainingRedBall[y] |= isContainingRedBall[x];
            balls[x]--;
            balls[y]++;
            if (balls[x] == 0) {
                isContainingRedBall[x] = false;
            }
        }

        final long answer = IntStream.rangeClosed(1, n)
                .mapToObj(i -> isContainingRedBall[i])
                .filter(Boolean::booleanValue)
                .count();
        System.out.println(answer);
    }
}


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

int main(){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  
  if (A1 + A2 + A3 >= 22) {
    cout << "bust" << endl;;
  } else {
    cout << "win" << endl;
  }
  return 0;
    
    
  
  
  
}
  

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
    }
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  int s = 0;
  for (int i = 0; i < n; i ++) {
    int x;
    scanf("%d", &x);
    s ^= x;
  }
  puts(s == 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int N;
	vector<long long> A, B, C;
	cin >> N;
	REP(i, 0, N) {
		long long a;
		cin >> a;
		A.push_back(a);
	}
	REP(i, 0, N) {
		long long b;
		cin >> b;
		B.push_back(b);
	}
	REP(i, 0, N) {
		long long c;
		cin >> c;
		C.push_back(c);
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	
	long long ans = 0;
	REP(i, 0, N) {
		long long lba = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
		long long ubc = C.end() - upper_bound(C.begin(), C.end(), B[i]);
		ans += (lba*ubc);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char s[200010];
int a[200010][30];
queue< pair< int, vector<int> > > q;
int main(){
  int n;
  scanf("%s",s);
  n=strlen(s);
  reverse(s, s+n);
  for(int i=0; i<26; ++i)
    a[0][i]=-1;
  for(int i=1; i<=n; ++i){
    for(int j=0; j<26; ++j){
      if(s[i-1]-'a'==j){
        a[i][j]=i-1;
      }
      else{
        if(i==0)
          a[i][j]=-1;
        else
          a[i][j]=a[i-1][j];
      }
//      cout<<i<<","<<j<<"="<<a[i][j]<<endl;
    }
  }
  vector <int> v;
  v.push_back(1);
  int mn=n;
  for(int i=0; i<26; ++i){
    v[0]=i;
    if(a[n][i]==-1){
      cout<<(char(i+'a'))<<endl;
      return 0;
    }
    if(a[n][i]>=mn)
      continue;
    mn=a[n][i];
//    cout<<mn<<",,,"<<i<<endl;
    q.push(mk(a[n][i], v));
  }
  int tmp;
  pair< int, vector <int> > tp;
  while(!q.empty()){
//    cout<<tp.fs<<"***"<<endl;
    tp=q.front();
    q.pop();
    tmp=tp.fs;
    for(int i=0; i<26; ++i){
      if(a[tmp][i]==-1){
        for(int j=0; j<tp.sc.size(); ++j){
          cout<<(char(tp.sc[j]+'a'));
        }
        cout<<(char(i+'a'));
        cout<<endl;
        return 0;
      }
//      cout<<"&&&"<<a[tmp][i]<<endl;
//
//        for(int j=0; j<tp.sc.size(); ++j){
//          cout<<(char(tp.sc[j]+'a'));
//        }
//        cout<<(char(i+'a'));
//        cout<<endl;
      if(a[tmp][i]>=mn)
        continue;
      mn=a[tmp][i];
      tp.sc.push_back(i);
      q.push(mk(a[tmp][i], tp.sc));
      tp.sc.pop_back();
    }
  }
  return 0;
}




Measured memory_bytes: 24344
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x,k,d = inpl()
x = abs(x)
if x - k*d >= 0:
    print(x - k*d)
    quit()
res1 = x - x//d*d
res2 = abs(x - (x//d+1) *d)
if (k-x//d)%2:
    print(res2)
else:
    print(res1)

Measured memory_bytes: 10492
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Data.Array.ST
import Control.Monad.ST
import Data.STRef

asSTUArray :: ST s (STUArray s i a) -> ST s (STUArray s i a)
asSTUArray = id

main = do
  [h,w] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 1 <= h <= 1000, 1 <= w <= 1000
  initialState <- V.replicateM h BS.getLine
  -- for all (i, j), ((a ! i) `BS.index` j) `elem` "#."
  let answer :: Int
      answer = runST $ do
        arr <- asSTUArray $ newArray ((0,0),(h-1,w-1)) False
        let initCells :: [(Int,Int)]
            initCells = [(i,j) | i <- [0..h-1], j <- [0..w-1], (initialState V.! i) `BS.index` j == '#']
        forM_ initCells $ \p ->
          writeArray arr p True
        let -- loop :: Int -> [(Int,Int)] -> m Int
            loop !k xs = do
              ref <- newSTRef []
              let doCell p@(!i,!j) | 0 <= i && i < h && 0 <= j && j < w = do
                                       b <- readArray arr p
                                       when (not b) $ do
                                         writeArray arr p True
                                         modifySTRef ref (p :)
                                   | otherwise = return ()
              forM_ xs $ \(i,j) -> do
                doCell (i-1,j)
                doCell (i+1,j)
                doCell (i,j-1)
                doCell (i,j+1)
              ys <- readSTRef ref
              case ys of
                [] -> return k
                _ -> loop (k+1) ys
        loop 0 initCells
  print answer


Measured memory_bytes: 86396
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

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

	if (a > b) {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
#define pb push_back
#define M 1000000007
typedef long long int ll;


void solve(){

	ll n, cnt = 0;
	string str;
	cin >> n >> str;
	ll l = 0, r = n-1;
	while(1){
		while(l < r && str[l] == 'R')
			l++;
		if(l >= r)
			break;
		while(r > l && str[r] == 'W')
			r--;
		if(l >= r)
			break;
		cnt++;
		l++; r--;
	}
	cout << cnt << endl;
}	

int main(){

	int t;
	// cin >> t;
	t = 1;
	for(int q = 0; q < t; q++){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3756
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  int n;
  cin >> n;
  int ans = 0;
  while(n>0){
    if(n%10==2) ans++;
    n/=10;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
struct a
{
	int num;
	int sum;
	bool operator < (const a &s)const
	{
		return sum<s.sum;
	}
	a(){num=0;sum=0;
	}
};
a s[100050];
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>s[i].sum;
		s[i].num=i+1;
	}
	sort(s,s+N);
	for(int i=0;i<N;i++)
	{
		cout<<s[i].num<<" ";
	}
} 

Measured memory_bytes: 1536
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        a: i64,
        p: i64,
    }
    println!("{}",(a * 3 + p) / 2 );
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int a[N];
  for (int i=0;i<N;i++){
    cin >> a[i];
  }

  sort(a, a+N);
  int sum1 = 0;
  for (int i=0;i<N;i+=2){
    sum1 += a[i];
  }
  int sum2 = 0;
  for (int i=1;i<N;i+=2){
    sum2 += a[i];
  }

  int ans = max(sum1, sum2) - min(sum1, sum2);
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int N, A[100];
    int diffmax;
    scanf("%d", &N);

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

   diffmax = 0;
    for(int i=1; i<N;i++){
        for(int j=0;j<i;j++){
             int diff = abs(A[i] - A[j]);
             if( diff > diffmax ) diffmax = diff;
        }
    }

    printf("%d\n", diffmax);
}

Measured memory_bytes: 128
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

double hoge1(double a, double b, double x) {
  double t1 = 0;
  double t2 = atan(static_cast<double>(b) / a);

  while (t1 + 1e-15 < t2) {
    double tm = (t1 + t2) / 2;
    double s = (b * cos(tm) - a * sin(tm)) / cos(tm);
    double g = (b + s) * a / 2 * a - x;
    if (g < 0)
      t2 = tm;
    else
      t1 = tm;
  }
  return t1;
}

double hoge2(double a, double b, double x) {
  return atan(a * b * b / 2. / x);
}

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  double ans = (b * a * a / 2 < x) ? hoge1(a, b, x) : hoge2(a, b, x);
  cout << fixed << setprecision(10) << ans / M_PI * 180 << endl;
}

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

    using namespace std;
    using namespace std::chrono; 

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin>>t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()

    void __print(int x) {cerr << x;}
    void __print(long x) {cerr << x;}
    void __print(long long x) {cerr << x;}
    void __print(unsigned x) {cerr << x;}
    void __print(unsigned long x) {cerr << x;}
    void __print(unsigned long long x) {cerr << x;}
    void __print(float x) {cerr << x;}
    void __print(double x) {cerr << x;}
    void __print(long double x) {cerr << x;}
    void __print(char x) {cerr << '\'' << x << '\'';}
    void __print(const char *x) {cerr << '\"' << x << '\"';}
    void __print(const string &x) {cerr << '\"' << x << '\"';}
    void __print(bool x) {cerr << (x ? "true" : "false");}

    template<typename T, typename V>
    void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
    template<typename T>
    void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
    void _print() {cerr << "]\n";}
    template <typename T, typename... V>
    void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
    #ifndef ONLINE_JUDGE
    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    #else
    #define debug(x...)
    #endif

    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }

    /*CHECK FOR CORNER CASES FOR GOD'S SAKE*/
    int main()
    {
      //freopen("dislodging_logs_validation_input.txt", "r", stdin);
      //freopen("output.txt", "w", stdout);
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      vector<ll> a(n);
      forn(i,0,n){
        cin>>a[i];
      }
      ll maxm = -1;
      ll sum = 0;
      forn(i,0,n){
          maxm = max(maxm,a[i]);
          sum += maxm-a[i];
      }
      cout<<sum<<endl;
  } 



     
    


Measured memory_bytes: 4760
import math

def bs(lis,target): 

    result = -1
    left = 0
    right = len(lis) - 1

    while left <= right:
        center = (left + right)//2
        if lis[center] == target:
            result = center
            break
        elif lis[center] < target:
            left = center + 1
        elif lis[center] > target:
            right = center - 1

    return result

n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))

ans = 0
for i in t:
    if bs(s,i) != -1:
        ans += 1
        
print(ans)


Measured memory_bytes: 16772
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=1000,n=0,m=0;
string s;
std::cin >> s;
rep(i,s.size()-2){
  y=((int)s[i]-48)*100+((int)s[i+1]-48)*10+((int)s[i+2]-48);
  if(w>abs(y-753))w=abs(y-753);
}
std::cout << w << '\n';
}


Measured memory_bytes: 256
from itertools import product

h, w, k = list(map(int, input().split()))
s = [list(map(int, list(input()))) for i in range(h)]
INF = float("inf")
ans = INF
for bits in product([0, 1], repeat=h-1):
    cnt = sum(bits)
    cuts = [0]+[i + 1 for i, x in enumerate(bits) if x == 1]+[h]
    data = [[0]*w for _ in range(len(cuts)-1)]
    for i in range(len(cuts)-1):
        target = s[cuts[i]:cuts[i+1]]
        for tt in target:
            for j, t in enumerate(tt):
                data[i][j] += t
    check = [[0]*(w+1) for _ in range(len(data))]
    flag = False
    for j in range(w):
        if flag:
            continue
        change = False
        for i in range(len(data)):
            if check[i][j] + data[i][j] > k:
                change = True
                break
        if change:
            for i in range(len(data)):
                if data[i][j] <= k:
                    check[i][j+1] = data[i][j]
                else:
                    flag = True
                    break
            cnt += 1
        else:
            for i in range(len(data)):
                check[i][j+1] = check[i][j] + data[i][j]
    if flag:
        continue
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 50780
#coding:utf-8
import numpy as np
h,w = map(int,input().split())
mat = []
for i in range(h):
    mat.append(list(input()))
mat = np.array(mat)
#mat=np.array([['.','#'],['#','#']])#test
isDot = mat == '.'
y = list(np.where(np.mean(isDot,axis=0)!=1)[0])
x = list(np.where(np.mean(isDot,axis=1)!=1)[0])
output = mat[np.ix_(x,y)]
for line in output:
    print("".join(line))


Measured memory_bytes: 12760
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

typedef pair<int, int> P;

int main(){
  int n;
  cin >> n;
  priority_queue<int> q;
  vector<P> vec;
  for(int i = 0; i < n; ++i){
    int a, b;
    cin >> a >> b;
    vec.push_back(make_pair(a, b));
  }
  sort(vec.begin(), vec.end());
  vec.push_back(make_pair(100, 100));
  int i = 0;
  int ans = 0;
  for(int d = 1; d <= 31; ++d){
    while(d == vec[i].first){
      q.push(-vec[i].second);
      ++i;
    }
    bool f = false;
    while(!q.empty()){
      int p = -q.top();
      q.pop();
      if(d <= p){
	f = true;
	break;
      }
    }
    if(f){
      ans += 100;
    }else{
      ans += 50;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    printf("%d",15-a-b-c-e-d);
    return 0;
}

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


ll calc(ll x){
  ll res=0;
  while(x){
    res+=x%10;
    x/=10;
  }
  return res;
}

int main(){
  ll N;  
  ll ans=(1LL<<60);
  
  cin>>N;
  priority_queue< P, vector<P> , greater<P> > Q;
  Q.push( P( 0, 0 ) );
  map<ll,ll> d;
  d[0]=0;
  
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    ll cost = p.first;
    ll pos=p.second;

    
    if(d[pos]<cost)continue;
    for(ll i=0;i<10;i++){
      ll ncost=cost+(pos+N*i)%10;
      ll to=(pos+N*i)/10;

      if(i){
        ans=min(ans,ncost+calc(to));
      }
      if(d.count(to)==0 || d[to]>ncost){
        d[to]=ncost;
        Q.push( P(d[to],to));
      }
    }
  }

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


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

int main(){
  string S,T="CODEFESTIVAL2016";
  cin >> S;
  int count=0;
  for(int i=0;i<16;i++){
    if(S.at(i)!=T.at(i)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3568
N = int(input())
A = list(map(int, input().split()))
num_2 = 0
num_4 = 0
odd = 0

for i in range(N):
    if A[i] % 2 != 0:
        odd += 1
    elif A[i] % 4 == 0:
        num_4 += 1
    else:
        num_2 += 1

if num_2 == 0:
    if odd - 1 <= num_4:
        print('Yes')
    else:
        print('No')
else:
    if odd <= num_4:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <cmath>
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int main()
{
    int i;
    int K;
    cin >> K;

    int tmp = 7 % K;

    rep0(i, K + 1)
    {
        if (tmp == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
        tmp = (tmp * 10 + 7) % K;
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3636
from heapq import heappop,heappush
N,M = map(int,input().split())
T = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    T[a].append(b)
    T[b].append(a)
D = [5]*(N+1)
Q = [(0,1)]
while Q:
    cost,v = heappop(Q)
    if cost>2 or cost>=D[v]:continue
    D[v] = cost
    for c in T[v]:
        heappush(Q, (cost+1, c))
print("POSSIBLE" if D[N]<=2 else "IMPOSSIBLE")

Measured memory_bytes: 46604
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
     sc.Scan()
     i, e := strconv.Atoi(sc.Text())
     if e != nil {
     	panic(e)
     }
     return i
}

func main() {
     sc.Split(bufio.ScanWords)

     x := nextInt()

     a := x / 500
     b := (x % 500) / 5

     fmt.Println(a * 1000 + b * 5)
}

Measured memory_bytes: 640