akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long penalty = in.nextInt();
            long[] x = new long[n];
            for (int i = 0; i < n; ++i) {
                x[i] = in.nextInt();
            }
            long[] psums = new long[n + 1];
            for (int i = 0; i < n; ++i) psums[i + 1] = psums[i] + x[i];
            long res = Long.MAX_VALUE;
            for (long trips = n; trips >= 1; --trips) {
                int val = 5;
                int iter = 0;
                long cur = 0;
                for (int i = n - 1; i >= 0; i -= trips) {
                    long s = psums[i + 1];
                    s -= psums[(int) Math.max(0, i + 1 - trips)];
                    cur += val * s;
                    ++iter;
                    if (iter > 1)
                        val += 2;
                }
                if (cur >= res) break;
                res = Math.min(res, cur + penalty * trips);
            }
            out.println(res + penalty * n);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
#define sqrt _sqrt
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;
using vll = vector<ll>;

const int S = 1e5 + 1; // S = sqrt(max)
bool is_prime[S];

bool check_prime(int n) {
    if (n < 2) return false;

    for (int d = 2; d * d <= n; d++)
        if (n % d == 0)
            return false;

    return true;
}

void calc_primes() {
    forsn(n, 2, S) 
        is_prime[n] = check_prime(n);
}

map<ll, int> sqrt;
void calc_squares() {
    forsn(n, 2, S) sqrt[(ll) n * n] = n;
}

ll cube(ll n) { return n * n * n; }

ll norm(ll n) {
    ll norm = 1;

    //cerr << "norm " << n << ' ';

    for (ll p = 0; cube(p) <= n; p++) if (is_prime[p]) {
        int e = 0;

        while (n % p == 0) n /= p, e++;
        e %= 3;

        while (e > 0) norm *= p, e--;
    }

    norm *= n;

    //cerr << norm << endl;

    return norm;
}

ll comp(ll n) {
    ll m = 1;
   
    for (ll p = 0; cube(p) <= n; p++) if (is_prime[p]) {
        int e = 0;

        while (n % p == 0) n /= p, e++;
        e %= 3;

        e = (3 - e) % 3;
        while (e > 0) m *= p, e--;
    }


    if (sqrt.count(n)){
        m *= (ll)sqrt[n];
    } 
    else {
        m *= n * n;
    }

    return m;
}

int main() {
	fastio;

    calc_primes();
    calc_squares();
	
    int n; cin >> n;
    vll v(n); for (ll &x : v) cin >> x;

    map<ll, int> norm_count;
    for (ll x : v) 
        norm_count[norm(x)]++;

    int set_size = 0;

    if (norm_count.count(1)) {
        norm_count.erase(1);
        set_size += 2;
    }

    for (auto ns1 : norm_count) {
        ll n; int s1; tie(n, s1) = ns1;
        ll m = comp(n);

        if (norm_count.count(m)) {
            int s2 = norm_count[m];
            set_size += max(s1, s2);
        }
        else {
            set_size += 2*s1;
        }
    }

    cout << set_size / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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 const INF = 1001001001;


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

int A,B;
cin >> A >> B;
int ans=1001;
rrep(n,1000) {
    if(floor(n*0.08) == A && floor(n*0.1) == B) {
        ans = n;
        break;
    }
}
if(ans == 1001) cout << -1 << endl;
else cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
H,N = list(map(int,input().split()))
A = list(map(int,input().split()))
para = H

list.sort(A, reverse=True)

for i in range(N):
    para = para - A[i]
    if para <= 0 :
        print('Yes')
        break
    elif i ==N - 1  and para > 0:
         print('No')


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


int main(void) {
  int  i, j, h, w, k;
  char hei[10];
  char wid[10];
  char input1[50];
  int  maze[20][20];
  int  l_path[400][400];
  int  height, width;
  int max_path;
  
  scanf("%s", hei);
  scanf("%s", wid);
  height = atoi(hei);
  width = atoi(wid);
  for (h=0; h<height; h++) {
    scanf("%s", input1);
    for(w=0; w<width; w++) {
      if('.' == input1[w]) {
        maze[h][w] = 1;
      } else {
        maze[h][w] = 0;
      }
    }
  }
  
  for(i=0; i<height*width; i++) {
    for(j=0; j<height*width; j++) {
      l_path[i][j] = height*width;
    }
  }
  
  for(h=0; h<height; h++) {
    for(w=0; w<width; w++) {
      if((w+1<width) && (maze[h][w] == 1) && (maze[h][w+1] == 1)) {
        l_path[width*h+w+1][width*h+w] = 1;
        l_path[width*h+w][width*h+w+1] = 1;
      }
      if((h+1<height) && (maze[h][w] == 1) && (maze[h+1][w] == 1)) {
        l_path[width*(h+1)+w][width*h+w] = 1;
        l_path[width*h+w][width*(h+1)+w] = 1;
      }
    }
  }
  
  for(k=0; k<width*height; k++) {
    for(i=0; i<width*height; i++) {
      for(j=0; j<width*height; j++) {
        if(l_path[i][j] > l_path[i][k]+l_path[k][j]) {
          l_path[i][j] = l_path[i][k] + l_path[k][j];
        }
      }
    }
  }
  
  max_path=0;
  for(i=0; i<width*height; i++) {
    for(j=0; j<i; j++) {
      if((l_path[i][j] < width*height) && (max_path < l_path[i][j])) {
        max_path = l_path[i][j];
      }
    }
  }
  
  printf("%d\n", max_path);
  
  return 0;
}

Measured memory_bytes: 768
# include <iostream>
# include <string>
# include <cstring>
using namespace std;
char ans[15] = {};
int main()
{
    string s;
    cin >> s;
    int cur = 0;
    for(int i = 0;i < s.length();i++)
    {
        if(s[i] != 'B')
        {
            ans[cur] = s[i];
            cur++;
        }
        else
        {
            if(cur > 0)
            {
                ans[cur-1] = '\0'; 
                cur--;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let q: usize = read();
    let q_taple: Vec<(i32, i32, i32, i32)> =
        (0..q).map(|_| (read(), read(), read(), read())).collect();
    //let mut a: Vec<Vec<i32>> = vec![Vec::new(); n];
    let mut ans = 0;

    /*
    for i in q_taple.iter() {
        for j in 1..=m {
            for k in 1..=m {
                if i.2 == (j as i32 - k as i32) {
                    a[i.0 as usize - 1].push(k as i32);
                    a[i.1 as usize - 1].push(j as i32);
                }
            }
        }
    }
    */

    for i1 in 1..m + 1 {
        for i2 in i1..m + 1 {
            for i3 in i2..m + 1 {
                for i4 in i3..m + 1 {
                    for i5 in i4..m + 1 {
                        for i6 in i5..m + 1 {
                            for i7 in i6..m + 1 {
                                for i_8 in i7..m + 1 {
                                    for i9 in i_8..m + 1 {
                                        for i10 in i9..m + 1 {
                                            let mut tmp = 0;
                                            let arrs =
                                                [0, i1, i2, i3, i4, i5, i6, i7, i_8, i9, i10];
                                            for j in q_taple.iter() {
                                                if j.2
                                                    == arrs[j.1 as usize] as i32
                                                        - arrs[j.0 as usize] as i32
                                                {
                                                    tmp += j.3;
                                                }
                                                ans = std::cmp::max(ans, tmp);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    //println!("{:?}", q_taple);
    //println!("{:?}", a);
    println!("{}", ans);
}


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

int main(){
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) cout << "Possible\n";
    else cout << "Impossible\n";
}

Measured memory_bytes: 256
'use strict'

function Main(input) {
  let nums = input.split('\n')[1].split(' ').map(n => parseInt(n, 10))
  
  let count = 0
  while(nums.every(num => num % 2 === 0)) {
    count ++ 
    nums = nums.map(n => n / 2)
  }
  
  console.log(count)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') {
		cout << a + b << endl;
	}
	else {
		cout << a - b << endl;
	}
}

Measured memory_bytes: 256
using System.Linq;
using System;
class Program
{
    static void Main(string[] args)
    {
        var numList = System.Console.ReadLine().Trim().Split(' ');
        var tosi = Int32.Parse(numList[0]);
        var way = Int32.Parse(numList[1]);
        var wayList = new int[way].SelectMany(w => System.Console.ReadLine().Split(' ').Select(i=>Int32.Parse(i))).ToList();

        for(var i = 0; i < tosi; i++)
        {
            System.Console.WriteLine(wayList.Count(w=> w == i+1));
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int h[22],w[22];
int cm[3];
int d[1<<16];
vector<int> mask;

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n)cin>>h[i]>>w[i];
  rep(i,4){
    string s;
    cin>>s;
    rep(j,4){
      if(s[j]=='R')cm[0]|=1<<(i*4+j);
      if(s[j]=='G')cm[1]|=1<<(i*4+j);
      if(s[j]=='B')cm[2]|=1<<(i*4+j);
    }
  }

  rep(k,n){
    repl(i,-h[k]+1,4)repl(j,-w[k]+1,4){
      int m=0;
      repl(ni,i,i+h[k])repl(nj,j,j+w[k]){
        if(ni>=0&&ni<4&&nj>=0&&nj<4)m|=1<<(ni*4+nj);
      }
      mask.pb(m);
    }
  }
  sort(all(mask)); uni(mask);

  rep(S,1<<16)d[S]=-1;
  
  d[0]=0;
  queue<int> que;
  que.push(0);
  while(que.size()){
    int S=que.front(); que.pop();
    if(S==(1<<16)-1){
      cout<<d[S]<<endl;
      break;
    }
    for(int msk : mask){
      rep(c,3){
        int cov=cm[c]&msk;
        int del=~(msk^cov);
        int nS=(S&del)|cov;
        if(d[nS]==-1){
          d[nS]=d[S]+1;
          que.push(nS);
        }
      }
    }
  }
  return 0; 
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
const int maxn = 2e5+10;

string s;
int main(){
    cin>>s;
    reverse(s.begin(),s.end());
    int cnt = 0,nx = 0;
    for(int i = 0;i<s.length();i++){
        int cur = s[i]-'0'+nx;nx = 0;
        if(cur>5){
            cnt += 10-cur;
            nx = 1;
        }else if(cur<5){
            cnt += cur;
        }else{
            if(i+1<s.length()&& s[i+1]-'0'>=5){
                cnt += 10-cur;
                nx = 1;
            }else{
                cnt += cur;
            }
        }
    }
    if(nx) cnt += nx;
    cout<<cnt<<endl;
    return 0;
}

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

typedef pair<int,int> PA;

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

vector<int> vx,vy;

void bfs(int sy,int sx,int w,int h){
  
  queue<PA> que;
  que.push(PA(sy,sx));
  
  while(!que.empty()){
    
    PA p = que.front();
    que.pop();
    
    for(int i=0;i<4;i++){
      int y = p.first + dy[i];
      int x = p.second + dx[i];
      if(y<0 || y>=w || x<0 || x>=h || masu[y][x]!=0) continue;
      masu[y][x] = -1;
      que.push(PA(y,x));
    }
  
  }
}

int main(){
  int w,h,n,x1[1010],y1[1010],x2[1010],y2[1010];
  while(scanf("%d %d",&w,&h),w!=0&&h!=0){
    
    scanf("%d",&n);
    
    vx.clear();
    vy.clear();
    fill_n(*masu,4010*4010,0);
    
    for(int i=0;i<n;i++){
      
      scanf("%d %d %d %d",&x1[i],&y1[i],&x2[i],&y2[i]);
      
      vx.push_back(x1[i]);
      vx.push_back(x2[i]-1);
      vy.push_back(y1[i]);
      vy.push_back(y2[i]-1);
      
      if(x1[i] > 0) vx.push_back(x1[i]-1);
      if(x2[i] < w) vx.push_back(x2[i]);
      if(y1[i] > 0) vy.push_back(y1[i]-1);
      if(y2[i] < h) vy.push_back(y2[i]);
    }
    
    sort(vx.begin(),vx.end());
    vx.erase(unique(vx.begin(),vx.end()),vx.end());
    sort(vy.begin(),vy.end());
    vy.erase(unique(vy.begin(),vy.end()),vy.end());
    
    for(int i=0;i<n;i++){
      
      int ax = lower_bound(vx.begin(),vx.end(),x1[i])-vx.begin();
      int bx = lower_bound(vx.begin(),vx.end(),x2[i])-vx.begin();
      int ay = lower_bound(vy.begin(),vy.end(),y1[i])-vy.begin();
      int by = lower_bound(vy.begin(),vy.end(),y2[i])-vy.begin();
      
      for(int i=ay;i<by;i++){
	for(int j=ax;j<bx;j++){
	  masu[i][j] = -1;
	}
      }
      
    }
    
    int cnt = 0;
    for(int i=0;i<vy.size();i++){
      for(int j=0;j<vx.size();j++){
	if(masu[i][j] == 0){
	  cnt++;
	  bfs(i,j,vy.size(),vx.size());
	}
      }
    }
    
    printf("%d\n",cnt);
  }  

  return(0);
}



Measured memory_bytes: 65988
#include <stdio.h>
#include<stdlib.h>
#include <math.h>
int main(void) {
	int N,K,tmp,i;
	double ans;
	scanf("%d %d",&N,&K);
	int count[100000]={};
	for(i=0;i<N;i++){
		tmp=i+1;
		while(1){
			if(tmp>=K){
				break;
			}else{
				tmp=tmp*2;
				count[i]++;
			}
		}
	}
	for(i=0;i<N;i++){
		ans=ans+(1/(double)N)*pow(0.5,count[i]);
	}
	printf("%.12f",ans);
	
	return 0;
}


Measured memory_bytes: 640
/*
 * atcoder/abc104_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll INF = 100000000000000000;
const int MAX = 14;
ll D, G;
ll S[MAX], P[MAX], C[MAX];

ll rec(int d = 0, int n = 0, ll acc = 0) {
  if (d == D) return acc >= G ? n : INF;
  ll min_ = INF;
  chmin(min_, rec(d+1, n, acc));
  chmin(min_, rec(d+1, n+P[d], acc + P[d]*S[d] + C[d]));
  if (acc + (P[d]-1)*S[d] >= G) {
    int count=0;
    while (acc < G) {
      acc += S[d];
      count++;
    }
    chmin(min_, rec(d+1, n+count, acc));
  }
  return min_;
}

void solve() {
  cin >> D >> G;
  loop(d,0,D) {
    cin >> P[d] >> C[d];
    S[d] = (d+1)*100;
  }
  reverse(S, S+D);
  reverse(P, P+D);
  reverse(C, C+D);
  cout << rec() << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int n,k,cnt=0,temp;
    int a[100][100] = {};
    int han[100] = {};
    int d;

    cin >> n >> k;
    
    for(int i=0; i < k; i=i+1){
        cin >> d;
        for(int j=0; j < d; j++){
            cin >> temp;
            a[temp-1][i] += 1;
        }
    }

    for(int i=0; i < n; i++){
        for(int j=0; j < 100; j++){
            han[i] += a[i][j];
        }
    }

    for(int i=0; i < n; i++){
        //cout << han[i] << endl;
        if(han[i]==0) cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int a = 0;
    int b = 0;
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '0') {
        a++;
      } else {
        b++;
      }
    }
    System.out.println(2 * Math.min(a, b));
  }
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    rep(i, h) cin >> c.at(i);

    rep(i, h) {
        cout << c.at(i) << endl;
        cout << c.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 3556
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m, a;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a;
		n -= a;
	}
	cout << max(-1, n) << endl;
	return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	ll m;
	cin >> m;

	vector<ll> b(m);
	for (ll i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	vector<ll> res;
	set_difference(all(a), all(b), inserter(res, end(res)));

	for (ll it : res)
	{
		println(it);
	}
}



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

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

using namespace std;

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

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

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

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

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

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

	string S;
	cin >> S;
	map<char, string> cmap;
	cmap['2'] = cmap['4'] = cmap['5'] = cmap['7'] = cmap['9'] = "hon";
	cmap['0'] = cmap['1'] = cmap['6'] = cmap['8'] = "pon";
	cmap['3'] = "bon";
	cout << cmap[S.back()] << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = long double;
constexpr R pi = acos((R)-1), eps = 1e-10;

int sgn(R a) { return (a > eps) - (a < -eps); }
int sgn(R a, R b) { return sgn(a - b); }
using P = complex<R>;
istream& operator>>(istream& i, P& p) { R x, y; i >> x >> y; p = P(x, y); return i; }
ostream& operator<<(ostream& o, P p) { return o << fixed << setprecision(15) << real(p) << ' ' << imag(p); }
bool cmp(P p, P q) { return 2 * sgn(real(p), real(q)) + sgn(imag(p), imag(q)) < 0; }
bool eql(P p, P q) { return !cmp(p, q) and !cmp(q, p); }
R dot(P p, P q) { return real(conj(p) * q); }
R crs(P p, P q) { return imag(conj(p) * q); }
int ccw(P p, P q) {
  int s = sgn(crs(p, q));
  if (s) return s;
  if (dot(p, q) < 0) return -2;
  if (dot(p, q - p) > 0) return 2;
  return 0;
}
int ccw(P o, P p, P q) { return ccw(p - o, q - o); }
struct L {
  P s, t;
  P vec() const { return t - s; }
  R abs() const { return std::abs(vec()); }
  R arg() const { return std::arg(vec()); }
};
int ccw(L s, P p) { return ccw(s.s, s.t, p); }

// BEGIN CUT HERE
P proj(P p, L l) {
  P e = l.vec() / l.abs();
  return l.s + dot(p - l.s, e) * e;
}
P refl(P p, L l) { return (R)2 * proj(p, l) - p; }
R distPP(P p, P q) { return abs(q - p); }
R distPL(P p, L l) { return distPP(p, proj(p, l)); }
R distPS(P p, L s) {
  P q = proj(p, s);
  if (!ccw(s, q)) return distPP(p, q);
  return min(distPP(p, s.s), distPP(p, s.t));
}
R distLL(L l, L m) {
  if (sgn(crs(l.vec(), m.vec()))) return 0;
  return distPL(l.s, m);
}
R distLS(L l, L s) {
  if (ccw(l, s.s) * ccw(l, s.t) != 1) return 0;
  return min(distPL(s.s, l), distPL(s.t, l));
}
R distSS(L s, L t) {
  if (ccw(s, t.s) * ccw(s, t.t) <= 0 and ccw(t, s.s) * ccw(t, s.t) <= 0) return 0;
  return min({distPS(s.s, t), distPS(s.t, t), distPS(t.s, s), distPS(t.t, s)});
}
P intxn(L l, L m) {
  assert(sgn(crs(l.vec(), m.vec())));
  return l.s + crs(m.s - l.s, m.vec()) / crs(l.vec(), m.vec()) * l.vec();
}
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int q; cin >> q;
  while (q--) {
    L l, m; cin >> l.s >> l.t >> m.s >> m.t;
    cout << intxn(l, m) << '\n';
  }
}

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3573104#1


Measured memory_bytes: 3300
#include <iostream>

using namespace std;
int main(){
	long long i,n,a[51],b[51],ans=0,c;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	while(true){
		c = 0;
		for(i=0;i<n;i++){
			b[i] = 0;
			if(a[i]>=n){
				b[i] = (a[i]-n)/n + 1;
				c += b[i];
			}
		}
		ans += c;
		if(c==0){
			break;
		}
		for(i=0;i<n;i++){
			a[i] = a[i] - b[i]*n + c-b[i];
		}
	}
	cout << ans << endl;
}


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

int n, l=1, r=50000, ans=-1;

int main(){
	cin >> n;
	while (l<=r){
		int mid=(l+r)/2;
		int tmp=(float)mid*1.08;
		if (tmp==n){
			ans=mid;
			break;
		}
		else if (tmp<n) l=mid+1;
		else r=mid-1;
	}
	if (ans==-1) cout << ":(" << "\n";
	else cout << ans << "\n";
}

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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// すべてのマスに入った値を取得
		ArrayList<Integer> all = new ArrayList<Integer>();
		for(int i = 0; i < 9 ; i++){
			all.add(sc.nextInt());
		}
		boolean takahashi = true;
		// test1
		Integer diff1 = all.get(3) - all.get(0);
		Integer diff2 = all.get(4) - all.get(1);
		Integer diff3 = all.get(5) - all.get(2);
		if(diff1 != diff2){
			takahashi = false;
		}else if(diff1 != diff3){
			takahashi = false;
		}
		// test2
		if(takahashi){
			diff1 = all.get(6) - all.get(3);
			diff2 = all.get(7) - all.get(4);
			diff3 = all.get(8) - all.get(5);
			if(diff1 != diff2){
				takahashi = false;
			}else if(diff1 != diff3){
				takahashi = false;
			}
		}
		// test3
		if(takahashi){
			diff1 = all.get(1) - all.get(0);
			diff2 = all.get(4) - all.get(3);
			diff3 = all.get(7) - all.get(6);
			if(diff1 != diff2){
				takahashi = false;
			}else if(diff1 != diff3){
				takahashi = false;
			}
		}
		// test4
		if(takahashi){
			diff1 = all.get(2) - all.get(1);
			diff2 = all.get(5) - all.get(4);
			diff3 = all.get(8) - all.get(7);
			if(diff1 != diff2){
				takahashi = false;
			}else if(diff1 != diff3){
				takahashi = false;
			}
		}
		if(takahashi){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	long long a,b;
	cin >> a >> b;
	if(a<=0 && 0<=b){
		cout << "Zero" << endl;
		return 0;
	}
	if(0<=a){
		cout << "Positive" << endl;
		return 0;
	}
	if((b-a)%2==0){
		cout << "Negative" << endl;
	}else {
		cout << "Positive" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
local n, x = io.read("*n", "*n")
if x == 1 or x == 2 * n - 1 then
  print("No")
elseif n == 2 then
  print("Yes\n1\n2\n3")
else
  print("Yes")
  if x == 2 then
    for i = 1, n - 3 do
      print(i + 4)
    end
    print("4\n1\n2\n3")
    for i = n + 2, 2 * n - 1 do
      print(i)
    end
  else
    for i = 1, n - 2 do
      if i <= x - 3 then
        print(i)
      else
        print(i + 4)
      end
    end
    print(x - 1 .. "\n" .. x .. "\n" .. x + 1 .. "\n" .. x - 2)
    for i = n - 1, 2 * n - 5 do
      if i <= x - 3 then
        print(i)
      else
        print(i + 4)
      end
    end
  end
end


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    long long a[n]; rep(i,n) cin>>a[i];
    long long ans=0;
    while(1){
        long long cnt[n]={},sum=0;
        rep(i,n){
            cnt[i]=a[i]/n;
            sum+=cnt[i];
        }
        // for(auto i:cnt) cout<<i<<" ";
        // cout<<endl;
        bool flg=1;
        rep(i,n){
            a[i]+=sum-cnt[i]*(n+1);
            if(a[i]>n-1) flg=0;
        }
        // for(auto i:a) cout<<i<<" ";
        // cout<<endl;
        ans+=sum;
        if(flg) break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from decimal import Decimal
w,h,x,y = list(map(lambda x:Decimal(int(x)),input().split()))

if x==w/2 and y==h/2:
    print("%s %s" %(w*h/2,1))
else:
    print("%s %s" %(w*h/2,0))


Measured memory_bytes: 5204
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    string str;
    cin >> str;
    
    // calculation
    int sum = 0;
    if (str[0] == 'o') sum++;
    if (str[1] == 'o') sum++;
    if (str[2] == 'o') sum++;
    cout << 700 + sum*100 << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

import itertools
import collections

def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = collections.Counter()
    
    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n //= prime_factor_table[n]
    prime_count[n] += 1
    
    return prime_count

n = int(input())
a = list(map(int,input().split()))

# pairwise coprime -> それぞれがすべて互いに素
# setwise coprime -> 互いに素でないのは混じっているが全体のgcdは1

if gcd_list(a) != 1:
    print("not coprime")
    exit()

pft = prime_factor_table(10**6)
pf = [0]*(10**6+1)

for i in a:
    if i == 1:
        continue
    # print(prime_factor(i, pft).keys())
    for j in prime_factor(i, pft).keys():
        if pf[j] == 1:
            print("setwise coprime")
            exit()
        pf[j] += 1

print("pairwise coprime")

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

FiniteField Solve() {
  int raw_n;
  cin >> raw_n;
  string s;
  cin >> s;
  int n = 2 * raw_n;

  FiniteField ans = 1;
  int stack = 0;
  for (char c : s) {
    if ((stack % 2 == 0 && c == 'B') || (stack % 2 == 1 && c == 'W')) {
      // Open
      stack++;
    } else {
      // Close
      if (stack == 0) return 0;
      ans *= stack;
      stack--;
    }
  }

  if (stack > 0) return 0;

  for (int i = 1; i <= raw_n; i++) {
    ans *= i;
  }
  return ans;
}

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

  cout << Solve().Value() << endl;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
int main(){
  int sum[501][501]={0};
  int N,M,Q,L,R,p,q;
  scanf("%d %d %d",&N,&M,&Q);
  for(int i=0;i<M;i++){scanf("%d %d",&L,&R); sum[L][R]++;}
  for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)
    sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
  for(int i=0;i<Q;i++){
    scanf("%d %d",&p,&q);
    printf("%d\n",sum[q][q]-sum[q][p-1]-sum[p-1][q]+sum[p-1][p-1]);
  }
}


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

long long int N, a, b, x, i;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld%lld", &a, &b);
        x += b - a + 1;
    }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    cout<<min({A*X+B*Y,2*C*max(X,Y),min(X,Y)*2*C+abs(X-Y)*(X>Y?A:B)})<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef tuple<ll, ll, ll> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    FOR(i, 1, 10){
        if(N%i != 0) continue;
        ll j = N/i;
        if(1 <= j && j <= 9){
            cout << "Yes" << endstr; return 0;
        }
    }
    cout << "No" << endstr;
    return 0;
}


Measured memory_bytes: 256
//2020/05/17 15:51:08
// 1%

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

int main()
{
		long long X;
		cin >> X;
		long long  P=100, step=0;
		while(P<X){
			P += (P/100);
			++step;
		}
		
		cout << step ;
		return 0;
}


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

int main() {
    long long N, M; cin >> N >> M;
    vector<long long>A(N), B(N);
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i) >> B.at(i);
    }
    sort(A.begin(), A.end(), greater<long long>());
    sort(B.begin(), B.end(), greater<long long>());
    long long ans = 0;
    for (long long i = 0; i < N; i++) {
        if (B.at(i) > A.at(0)) {
            M -= B.at(i);
            ans++;
        }
        if (M <= 0) {
            cout << ans << endl;
            return 0;
        }
    }
    ans += M / A.at(0);
    if (M % A.at(0) != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

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

    int ans = 0;

    ans += min(n, k) * y;
    ans += max(0, n - k) * x;

    OUT(ans);

    return 0;
}



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

using namespace std;

bool color[100001] = {}, visit[100001] = {};
vector<pair<int, int>> node[100001];

void dfs(int n)
{
    visit[n] = true;
    for (int i = 0; i < node[n].size(); i++)
        if (!visit[node[n][i].first])
        {
            if (node[n][i].second % 2)
                color[node[n][i].first] = !color[n];
            else
                color[node[n][i].first] = color[n];
            dfs(node[n][i].first);
        }
    return;
}

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

    int n, u, v, w;
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        cin >> u >> v >> w;
        node[u].push_back(make_pair(v, w));
        node[v].push_back(make_pair(u, w));
    }
    dfs(1);
    for (int i = 1; i <= n; i++)
        cout << color[i] << '\n';

    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

int N, co[100001], ans = 0;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N;
	F0R(i,N) {
	    int a; cin >> a;
	    co[a] ++;
	}
	FOR(i,1,100000) ans = max(ans,co[i-1]+co[i]+co[i+1]);
	cout << ans;
}

// read!
// ll vs. int!

Measured memory_bytes: 640
class BinSearchTree
  attr_accessor :node
  def initialize()
    @node = {}
  end
  def preorder(n=root())
    arr = []
    return [] if n == nil 
    #root
    arr += [n]
    #left
    arr += preorder(node[n].left)
    #right
    arr += preorder(node[n].right)
    return arr
  end
  def inorder(n=root())
    arr = []
    return [] if n == nil 
    #left
    arr += inorder(node[n].left)
    #root
    arr += [n]
    #right
    arr += inorder(node[n].right)
    return arr
  end
  def root
    #find root
    r = nil
    node.each {|n, value|
      if node[n].parent == -1 then
        r = n
        break
      end
    }
    return r
  end
  def insert(z)
    y = nil
    x = root()
    node[z] = Node.new()
    while x != nil
      y = x
      if z < x
        x = node[x].left
      else
        x = node[x].right
      end
    end
    node[z].parent = y
    if y == nil then
      node[z].parent = -1
    elsif z < y
      node[y].left = z
    else
      node[y].right = z
    end
  end
  def print
    str = inorder().join(" ")
    puts " #{str}"
    str = preorder().join(" ")
    puts " #{str}"
  end
end

class Node
  attr_accessor :parent, :left, :right
  def initialize
    @parent = nil
    @left = nil
    @right = nil
  end
end

n = gets.to_i
tree = BinSearchTree.new()

n.times{
  command, num = gets.split
  case command;
  when "insert"; tree.insert(num.to_i)
  when "print"; tree.print
  end
}

Measured memory_bytes: 128376
#include <iostream>
#include <sstream>
//#include <fstream>

using namespace std;

int main()
{
	const string ope[] = { 
		"North", "East", "West", "South", "Left", "Right"
	};
	const int order[][6] = {
			{ 1, 5, 2, 3, 0, 4 }, // north[];
			{ 3, 1, 0, 5, 4, 2 }, // east[];
			{ 2, 1, 5, 0, 4, 3 }, //west[];
			{ 4, 0, 2, 3, 5, 1 }, //south[];
			{ 0, 3, 1, 4, 2, 5 }, //left[];
			{ 0, 2, 4, 1, 3, 5 } //right[];
	};

//	cut here before submit 
//	freopen ("testcase.dice3", "r", stdin );

	string str = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;

		if (n == 0 ){
			break;
		} // end if

		int i,j,k;
		int dice[] = { 1, 2, 3, 4, 5, 6 };
		int ans[6];

		int res = dice[0];
		for (i = 0; i < n; ++i){
			getline (cin, str );
			stringstream ss (str );
			ss >> str;
			for (j = 0; j < sizeof(ope)/sizeof(ope[0]); ++j){
				if (str == ope[j] ){
					for (k = 0; k < 6; ++k){
						ans[k] = dice[order[j][k]];
					} // end for
					res += ans[0];
					for (k = 0; k < 6; ++k){
						dice[k] = ans[k];
					} // end for
					break;
				} // end if
			} // end for
		} // end for
		cout << res << endl;	
	
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
import math
def main():
    A,B=map(int, input().split())
    X=[]
    for i in range(1,1001):
        if math.floor(i * 0.08) == A:
            X.append(i)
    for x in X:
        if math.floor(x * 0.10) == B:
            print(x)
            return
    print(-1)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>
#include<stdlib.h>
int n;
int p[100001];
int s[100001];
int d[100001];

int Depth(int i) {
  if(p[i] == -1) return 0;
  return Depth(p[i]) + 1;
}

int Height(int i) {
  int j, l;
  l=0;
  for(j = 0; j < n; ++j) {
    if(p[j] == i) {
      int tmp = Height(j)+1;
      if(tmp>l) l=tmp;
    }
  }
  return l;
}
int main() {
  int i,j;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    p[i] = -1;
    s[i] = -1;
    d[i] = 0;
  }
  for(i = 0; i < n; ++i) {
    int id, left, right,k;
    k=0;
    scanf("%d %d %d", &id, &left, &right);
    if(left != -1) {
      p[left] = id;
      s[left] = right;
      ++d[id];
    }
    if(right != -1) {
      p[right] = id;
      s[right] = left;
      ++d[id];
    }
  }

  for(i = 0; i < n; ++i) {
    int fukasa = Depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d\
, height = %d, ",
           i, p[i], s[i], d[i], fukasa, Height(i));
    if(fukasa == 0) {
      printf("root\n");
    } else if(d[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int cnt[128];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N;
	string s;
	cin>>N>>s;
	for(auto c: s) cnt[c]++;
	cout<<(cnt['R']>cnt['B'] ? "Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define endl '\n'

int main()
{
    int n, i, s=0;
    scanf("%d", &n);
    int a[n], b[n];

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

    for(i=0; i<n; i++)
    {
        scanf("%d", &b[i]);
        b[i]=a[i]-b[i];

        if(b[i]>0) s+=b[i];
    }

    printf("%d", s);

    return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
	ll cnt=0;
	for(int i=0; i<N; i++){
		while(A[i]%2==0){
			A[i]/=2;
			cnt++;
		}
	}
	cout << cnt << endl;
    

    return 0;
}


Measured memory_bytes: 384