akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <tuple>
#include <utility>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int64;
typedef pair<int, int> pii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  priority_queue<double, vector<double>, greater<int>> pq;
  for (int i = 0; i < n; ++i) {
    double x;
    cin >> x;
    pq.push(x);
  }
  while (pq.size() > 1) {
    double a = pq.top();
    pq.pop();
    double b = pq.top();
    pq.pop();
    pq.push((a + b) / 2.0);
  }
  cout << pq.top() << '\n';
  return 0;
}



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

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  cout << (int)pow(N, 3) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M, A = 0; cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int s; cin >> s; A += s;
  }
  if(N >= A) cout << N - A << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3620
declare function require(x: string): any

const main = (input: any): void => {
  let [N, K] = input.split('\n')[0].split(' ').map((i: number) => { return Number(i) })
  console.log(K * ((K - 1) ** (N - 1)))
}


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

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int l,r,d,c=0;
  cin>>l>>r>>d;
  rep(i,l,r+1){
    if(i%d==0) c++;
  }
  cout<<c<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	public static int max, target;
	public static int[] nums = {0,1,2,3,4,5,6,7,8,9};

	public static int solve (int sum, int i, int cnt) {
		if (cnt == max) return sum == target ? 1 : 0;
		if (sum > target || i >= nums.length) return 0;
		return solve(sum + nums[i], i + 1, cnt + 1) +
			   solve(sum, i + 1, cnt);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			max = sc.nextInt();
			target = sc.nextInt();
			if (max == 0 && target == 0) break;
			System.out.println(solve(0,0,0));
		}

	}

}

Measured memory_bytes: 18268
DP = {1 => 1, 2 => 2, 3 => 4}

def dp(n)
  if DP[n] == nil
    DP[n] = dp(n-1) + dp(n-2) + dp(n-3)
  else
    DP[n]
  end
end

loop do
  n = gets.to_i
  exit if n == 0
  puts (dp(n)/3650.0).ceil
  next
end

Measured memory_bytes: 6104
/**
 * Created by hiroqn on 13/10/07.
 */

var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main() {
  var temp = input.shift().split(' '),
      n = temp[0],
      m = temp[1],
      edges = [],
      g = [],
      gInv = [],
      dp = [],
      i, j,
      len,
      a, b;
  for (i = 0; i < n; i++) {
    g[i] = [];
    gInv[i] = [];
    dp[i] = 0;
  }

  for (i = 0; i < m; i++) {
    temp = input[i].split(' ');
    a = temp[0] - 1;
    b = temp[1] - 1;
    edges[i] = [a, b];//edges
    g[a].push(b); // make graph
    gInv[b].push(a);
  }
  for (i = 0; i < n; i++) {
    for (j = 0, len = g[i].length; j < len; j++) {
      if (dp[g[i][j]] < dp[i] + 1) {
        dp[g[i][j]] = dp[i] + 1
      }
    }
  }
  var max = Math.max.apply(null, dp),
      nodeList = [],
      level = [],
      hash ={},
      flag = true;
  for (i = 0; i < n; i++) {
    nodeList[i] = max === dp[i];
    level[i] = 0;
  }
  for (i = n - 1; i >= 0; i--) {
    if (!nodeList[i]) {
      continue
    }
    for (j = 0, len = gInv[i].length; j < len; j++) {
      if (dp[gInv[i][j]] + 1 === dp[i]) {
        nodeList[gInv[i][j]] = true;
        level[dp[gInv[i][j]]]++;
        hash[[gInv[i][j],i]] = true;
//        console.log([gInv[i][j],i]);
      }
    }

  }

  for (i = 0; i < m; i++) {
//    console.log(dp[edges[i][0]],level[dp[edges[i][0]]] ,edges[i],hash[[gInv[i][j],i]]);
    if ( hash[edges[i]] && level[dp[edges[i][0]]] === 1) {//nodeList[edges[i][0]] && nodeList[edges[i][1]]

      console.log(i + 1);
      flag = false;
    }
  }
  if (flag) {
    console.log(-1);
  }
}

Measured memory_bytes: 119568
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd( T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint power(lint N, lint P, lint M){if(P==0) return 1;if(P%2==0){lint t = power(N, P/2, M);return t*t % M;}return N * power(N, P-1, M);}
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**/int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int x;
	in(x);
	out(x*x*x);
	return 0;
}



Measured memory_bytes: 3224
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();

        if(x.charAt(0) < y.charAt(0)){
            System.out.println('<');
        }else if(x.charAt(0) > y.charAt(0)){
            System.out.println('>');
        }else{
            System.out.println('=');
        }

    }
}

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

int main(){
  int a, b, c; cin >> a >> b >> c;
  
  int ma = max(max(a, b), c);
  int rem = 3 * ma - (a + b + c);
  
  int ans = 0;
  if(rem % 2 == 0){
    ans = rem / 2;
  }else{
    ans = rem / 2 + 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 200003;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define fr(s,n) for (int i=(int)(s);i<(int)(n);i++)
#define lc cout<<"\n"
//double pi=2*acos(0.0);
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    if(s==t.substr(0,s.size())){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	vector<ll>x,y;
	for(ll i=0;i<a;i++){
		ll now;
		cin>>now;
		x.push_back(now);
	}
	for(ll i=0;i<b;i++){
		ll now;
		cin>>now;
		y.push_back(now);
	}
	x.push_back(-INF);
	y.push_back(-INF);
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	x.push_back(INF);y.push_back(INF);
	for(ll i=0;i<c;i++){
		ll now;
		cin>>now;
		ll sum1=0;
		auto aaa = lower_bound(x.begin(),x.end(),now);
		sum1+=*aaa-now;
		auto aba = lower_bound(y.begin(),y.end(),*aaa);
		auto abb = aba-1;
		sum1+=min(abs(*aaa-*aba),abs(*aaa-*abb));
		
		ll sum2=0;
		auto baa = upper_bound(x.begin(),x.end(),now);baa--;
		sum2+=abs(*baa-now);
		auto bba = lower_bound(y.begin(),y.end(),*baa);
		auto bbb = bba-1;
		sum2+=min(abs(*baa-*bba),abs(*baa-*bbb));	
		
		ll sum3=0;
		auto caa = lower_bound(y.begin(),y.end(),now);
		sum3+=abs(*caa-now);
		auto cba = upper_bound(x.begin(),x.end(),*caa);
		auto cbb = cba-1;
		sum3+=min(abs(*caa-*cba),abs(*caa-*cbb));

		ll sum4=0;
		auto daa = upper_bound(y.begin(),y.end(),now);daa--;
		sum4+=abs(*daa-now);
		auto dba = upper_bound(x.begin(),x.end(),*daa);
		auto dbb = dba-1;
		sum4+=min(abs(*daa-*dba),abs(*daa-*dbb));
		
		//cout << sum1<<sum2<<sum3<<sum4;
		cout << min({sum1,sum2,sum3,sum4})<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3060
package main

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

const abcd = "abcdefghijklnmopqrstuvwxyz"

// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e9

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	s := next.next()
	a := map[int]bool{}
	for i := 0; i < len(s); i++ {
		a[int(s[i])] = true
	}
	var ans byte
	for i := 'a'; i <= 'z'; i++ {
		if !a[int(i)] {
			ans = byte(i)
			break
		}
	}
	if ans != 0 {
		fmt.Println(string(ans))
	} else {
		fmt.Println("None")
	}
}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1152
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        
	        for(int i=0;i<3;i++) {
	        	if(c[i]=='7') {
	        		System.out.println("Yes");
	        		return;
	        	}
	        }
	        
	    	System.out.println("No");
	        
	        	        	        
	 }
}


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

using namespace std;
using ll = long long;

const int N = 1e6 + 5, M = 1e9 + 7;

void solve() {            
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size(); ++i) sum += (s[i] - '0');
    if (sum % 9 == 0) cout << "Yes";
    else cout << "No";    
}

main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 3796
n = gets.to_i
ans = 0
1.upto(n) do |i|
  if i % 2 == 1
    count = 0
    1.upto(i) do |j|
      if i % j == 0
        count += 1
      end
    end
    if count == 8
      ans += 1
    end
  end
end

p ans


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int a,b;cin >> a>> b;
	cout << (a+b+1)/2 << endl;
	return 0;
}

Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int a, b;
  cin >> a >> b;
  cout << a*(a-1)/2 + b*(b-1)/2 << endl;
}

Measured memory_bytes: 256
main = do
  [q,h,s,d] <- map read . words <$> getLine
  n <- readLn
  print (icetea q h s d n)

icetea q h s d n = div n 2 * l2 + mod n 2 * l1
  where
    l1 = min s (min (2*q) h * 2)
    l2 = min (l1 * 2) d

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

using Int = __int128_t;
Int abs128(Int val){return val<0?-val:val;}

ostream &operator<<(ostream &os,Int val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    Int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,Int &val){
  string s;
  is>>s;
  val=0;
  for(Int i=0;i<(Int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}



template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,a;
  cin>>n>>a;
  
  Int ans=n;
  for(Int i=1;i<100;i++){
    auto calc2=[&](Int x){      
      assert(x/i>=2);
      vector<Int> v(i,x/i);
      for(Int j=0;j<x%i;j++) v[j]++;
      Int s=1;
      for(Int j=0;j<i;j++){
	if(s<(n+v[j]-1)/v[j]) s*=v[j];
	else s=n;
	if(s>=n) break;
      }
      return (n+s-1)/s;
    };
    
    auto calc=[&](Int x){
      return i*a+x+calc2(x);
    };
    
    auto best=[&](Int x){
      Int l=0,r=x-2*i+1;
      Int v=calc2(x);
      while(l+1<r){
	Int m=(l+r)>>1;
	if(v==calc2(x-m)) l=m;
	else r=m;
      }
      return x-l;
    };
    
    auto next=[&](Int x){
      Int l=0,r=1e18;
      Int v=calc2(x);
      while(l+1<r){
	Int m=(l+r)>>1;
	if(v==calc2(x+m)) l=m;
	else r=m;
      }
      return best(x+r);
    };
    
    Int l=i*2,r=1e18;    
    l=best(l);
    r=best(r);
    while((l+1<r)&&(calc2(r)+1<calc2(l))){
      chmin(ans,calc(l));
      chmin(ans,calc(r));
      Int m=best((l+r)>>1);
      Int t=next(m);
      chmin(ans,calc(m));
      chmin(ans,calc(t));
      if(calc2(t)+(t-m)==calc2(m))
	for(Int j=m+1;calc2(j)<calc2(j-1);j++) chmin(ans,calc(j));
      if(calc2(t)+(t-m)<calc2(m)) l=m;
      else r=m;
    }
    chmin(ans,calc(l));
    chmin(ans,calc(r));
  }

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


Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int w = sc.nextInt();

//        String str[] = new String[h];

//        for (int i=0; i<h; i++){
//            str[i] = sc.next();
//        }

//        String str2[] = new String[h+2];

//        for (int i=0; i<w+2; i++){
//            str2[0] += "#";
//            str2[h+1] += "#";
//        }
//
//        for (int i=1; i<h+1; i++){
//            str2[i] = "#"+str2[i]+"#";
//        }

        char chr[][] = new char[h][w];
//        while(Arrays.asList(str2).contains('.'))
//        for (int i=1; i<h+1; i++){
//            for (int j=1; j<w+1; j++){
//                chr[i][j] = str[i-1].charAt(j-1);
//            }
//        }

        Queue<int []> queue = new ArrayDeque<int []>();
        for (int i=0; i<h; i++){
            String row = sc.next();
            for (int j=0; j<w; j++){
                chr[i][j] = row.charAt(j);
                if (chr[i][j]=='#'){
                    int start[] = {i, j, 0};
                    queue.add(start);
                }
            }
        }

        int flag[][] = new int[h][w];
        int count = 0;

        int dx[] = {1,0,-1,0};
        int dy[] = {0,1,0,-1};
        while(!queue.isEmpty()){
            int temp[] = queue.remove();
            int y = temp[0];
            int x = temp[1];
            int depth = temp[2];
            for (int i=0; i<4; i++){
                if (0<=y+dy[i] && y+dy[i]<= h-1 && 0<=x+dx[i] && x+dx[i]<=w-1){
                    if (flag[y+dy[i]][x+dx[i]]==0 && chr[y+dy[i]][x+dx[i]]=='.'){
                        flag[y+dy[i]][x+dx[i]]=1;
                        int add_queue[] = {y+dy[i], x+dx[i], depth+1};
                        queue.add(add_queue);
                        count = depth+1;
                    }
                }
            }
        }
        System.out.println(count);
//        while(Arrays.asList(chr).contains('.')){
//            for (int i=1; i<h; i++){
//                for (int j=1; j<w; j++){
//                    if(chr[i][j]=='#'){
//                        chr[i-1][j]='#';
//                        chr[i+1][j]='#';
//                        chr[i][j-1]='#';
//                        chr[i][j+1]='#';
//                    }
//                }
//            }
//            count++;
//        }
//        System.out.println(count);

    }

}



Measured memory_bytes: 73244
#include <stdio.h>

int main(void)
{
	int week,money=100000,i; //千の桁が基準
	int tmp;
	
	scanf("%d",&week);
	for(i=0;i<week;i++)
	{
		money=money*1.05;
		tmp=money%1000; //999以下が出てくるか
		if(tmp>0)
			{
				money=money+1000-tmp;
			}
	}
	printf("%d\n",money);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    int flagA = 0;
    int index = 0;
    while(index<s.size()){
        if(s[index]=='A'){
            flagA++;
        }
        if(index<s.size()-1 && s.substr(index,2)=="BC"){
            index+=2;
            int flagBC = 0;
            while(index<s.size()-1){
                if(s.substr(index,2)=="BC"){
                    flagBC++;
                    index+=2;
                }
                break;
            }
            ans += flagA;
            ans += flagA*flagBC;
            continue;
        }
        if(s[index]!='A'){
            flagA = 0;
        }
        index++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include<ctype.h>
#include<stdio.h>
using namespace std;

int main() {

	char ch[2000];
	scanf("%[^\n]", ch);
	for (int i = 0; ch[i] != '\0'; i++) {
		char c = ch[i];
		if ('a' <= c && c <= 'z') {
			printf("%c", toupper(c));
		}
		else if ('A' <= c && c <= 'Z') {
			printf("%c", tolower(c));
		}
		else {
			printf("%c",c);
		}
	}printf("\n");
		return 0;
}


Measured memory_bytes: 3068
#include <stdio.h>

int main()
{
    int k, a, b,flg=0;

    scanf("%d%d%d", &k, &a, &b);

    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            flg = 1;
        }
    }
    if (flg == 0)
    {
        printf("NG\n");
    }
    else
    {
        printf("OK\n");
    }
    return 0;
}

Measured memory_bytes: 1660
from collections import defaultdict

N,M=map(int,input().split())

Q=[]

for i in range(M):
  P,Y=map(int,input().split())
  Q.append([P,Y,i])
  
Q = sorted(Q,key=lambda x:x[1])
Q = sorted(Q,key=lambda x:x[0])

nowP=Q[0][0]
nownum=0

for l in Q:
  s=str(l[0]).zfill(6)
  if l[0]==nowP:
    nownum+=1
  else:
    nowP=l[0]
    nownum=1
  s+=str(nownum).zfill(6)
  l.append(s)
  
Q = sorted(Q,key=lambda x:x[2])

for l in Q:
  print(l[3])

Measured memory_bytes: 35836
#include<stdio.h>
int main(){
    int n, b[10];
    int a[3][3], ck[3][3];
 
    for(int i = 0 ; i < 3 ; i++ ) {
        scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
    }

    scanf("%d",&n);

    for(int j = 0 ; j < n ; j++ ){
        scanf("%d",&b[j]);
 
        for(int  x = 0 ; x < 3 ; x++ ) {
            for(int z = 0 ; z < 3 ; z++ ){
                if( b[j] == a[x][z] ) {
                    ck[x][z] = 1;
                }
            }
        }
    }

    if( (ck[1][1] == 1 && ck[2][2] == 1 && ck[0][0] == 1  )
    || (ck[2][0] == 1 && ck[1][1] == 1 && ck[0][2] == 1  )
    || (ck[0][0] == 1 && ck[0][1] == 1 && ck[0][2] == 1  )
    || (ck[1][0] == 1 && ck[1][1] == 1 && ck[1][2] == 1  )
    || (ck[2][0] == 1 && ck[2][1] == 1 && ck[2][2] == 1  )
    || (ck[0][0] == 1 && ck[1][0] == 1 && ck[2][0] == 1  )
    || (ck[0][1] == 1 && ck[1][1] == 1 && ck[2][1] == 1  )
    || (ck[0][2] == 1 && ck[1][2] == 1 && ck[2][2] == 1  )
    ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    
    return 0;
}

Measured memory_bytes: 1652
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
using namespace std;
int n;
int fa[100005];
vector<int> V[100005];
int dp[100005];
void dfs(int x){
	vector<int> v;
	v.clear();
	for (int i=0;i<V[x].size();i++){
		dfs(V[x][i]);
		v.push_back(dp[V[x][i]]);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	dp[x]=v.size();
	for (int i=0;i<v.size();i++){
		dp[x]=max(dp[x],v[i]+i+1);
	}
}
int main(){
	cin>>n;
	for (int i=2;i<=n;i++){
		cin>>fa[i];
		V[fa[i]].push_back(i);
	}
	dfs(1);
	cout<<dp[1];
	/*for (int i=1;i<=n;i++){
		cout<<dp[i]<<" ";
	}*/
	return 0;
}

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

int compare_ints(const void *a, const void *b) {
    return *((long long *)a) - *((long long *)b);
}

int main() {
    int n, i;
    long long f, *times, t;
    while (1) {
        scanf("%d", &n);
        if (n < 1) break;
        times = malloc(n * sizeof(long long));
        for (i=0; i<n; i++) {
            scanf(" %lld", &times[i]);
        }
        qsort(times, n, sizeof(long long), compare_ints);
        t = 0;
        f = n - 1;
        for (i=0; i<n-1; i++) {
            t += f * times[i];
            f--;
        }
        printf("%lld\n", t);
        free(times);
    }
    return 0;
}

Measured memory_bytes: 1820
import java.util.Scanner;

class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        System.out.print(a*b+" ");
        System.out.println(2*a+2*b);
    }
}


Measured memory_bytes: 25964
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var oneLine = Console.ReadLine();

                if (oneLine == "0")
                {
                    goto Finish;
                }

                var splitedValue = oneLine.Select(x => int.Parse(x.ToString())).Sum();
                Console.WriteLine(splitedValue);
            }

            Finish:
            return;
        }
    }
}



Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
# define M_PI 3.14159265358979323846
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 4;
const ll MOD = 998244353;
bool ans[2 * N];

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % MOD;
        exponent = exponent >> 1;
        base = (base * base) % MOD;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, MOD - 2);
}

void BFS(int s, vector<int> &d, vector<int> edge[]) {
    d[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto to : edge[v]) {
            if (d[to] == (int)1e9){
                d[to] = d[v] + 1;
                q.push(to);
            }
        }
    }
}

int main(){
    IOS
    string s, t;
    cin>>s>>t;
    int f = 1;
    rep(i, 0, (int)s.size()) if(s[i] != t[i]) f = 0;
    if(f) cout<<"Yes";
    else cout<<"No";
    return 0;   
}

Measured memory_bytes: 3640
while true
	i = gets.chomp.to_i(10)
	break if i == 0
	str = gets.chomp

	i.times do
		str = str.split('').concat(["-"])
		result = ""
		c = str[0]
		len = 0

		until str.empty?
			x = str.shift
			if x == c
				len += 1
			else
				result << "#{len}#{c}"
				c = x
				len = 1
			end
		end

		str = result
	end

	puts str

end

Measured memory_bytes: 10560
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("ip1.txt", "r", stdin);
  freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
  return (a.second < b.second);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int prime(int n) {
  int flag = 1;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {flag = 0; break;}
  }
  return flag;
}
int power(int x, int y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
  else
    return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}

int32_t main()
{
  k_007();
  int r;
  cin >> r;
  long double ans = 2 * pi * r;

  cout << ps(ans, 20) << endl;
}


Measured memory_bytes: 3872
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n;
    vll v(n);
    cin >> v;
    rep(i,0,n)	sum+=v[i];
    map<lli,lli>ma;
    rep(i,0,n)	ma[v[i]]++;
    cin >> t;
    lli count;
    while(t--){
    	cin >> b >> c;
    	if(ma[b]==0){
    		cout<<sum<<endl;
    	}
    	else{
    		count=ma[b];
    		sum-=(count*b);
    		sum+=(count*c);
    		ma[b]=0;
    		ma[c]+=count;
    		cout<<sum<<endl;
    	}
    }
    
    
}













int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

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

using namespace std;

#define ll long long int

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,x;
    cin >> n >> x;

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

    sort(a.begin(),a.end(),greater<ll>());

    vector<ll> invn(n+1,0);
    for(int i = 0; i < n+1; i++){
        invn[i] = mypow((ll)i,MOD-2);
    }

    vector<vector<ll>> dp(n+1,vector<ll>(max(a[0],x)+1,0));

    dp[0][x] = 1;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < max(a[0],x)+1; j++){
            if(j < a[i]){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }else{
                dp[i+1][j%a[i]] += (dp[i][j]*invn[n-i])%MOD;
                dp[i+1][j%a[i]] %= MOD;
                if(i < n-1){
                    dp[i+1][j] += (dp[i][j]*(1 + (MOD - invn[n-i])%MOD))%MOD;
                    dp[i+1][j] %= MOD;
                }
            }
        }
    }

    ll ans = 0;

    ll factorial = 1;
    for(int i = 1; i <= n; i++){
        factorial *= (ll)i;
        factorial %= MOD;
    }

    for(int i = 0; i < max(a[0],x)+1; i++){
        ans += (((dp[n][i]*factorial)%MOD)*(ll)i)%MOD;
        ans %= MOD;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 158592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
int main(){
    lint N,W;
   string s;
   
   cin>>s;
   if(s=="SUN")cout<<7;
     if(s=="MON")cout<<6;
       if(s=="TUE")cout<<5;
         if(s=="WED")cout<<4;
           if(s=="THU")cout<<3;
             if(s=="FRI")cout<<2;
               if(s=="SAT")cout<<1;
   
}

Measured memory_bytes: 256
import array


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


a, b = map(int, input().split())
c = gcd(a, b)
if c != 1:
    prime = array.array('b', [1] * (10 ** 6 + 1))
    index = 2
    while index * index <= 10 ** 6:
        if prime[index] == 1:
            for i in range(index * index, 10 ** 6 + 1, index):
                prime[i] = 0
        index += 1
    prime_list = []
    for i in range(2, 10 ** 6 + 1):
        if prime[i]:
            prime_list.append(i)
    index = 0
    count = 1
    while index < len(prime_list) and c != 1:
        if c % prime_list[index] == 0:
            count += 1
            while c % prime_list[index] == 0:
                c = c // prime_list[index]
        index += 1
    if c != 1:
        count += 1
    print(count)
else:
    print(1)


Measured memory_bytes: 11892
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string,getline
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt,ceil,M_PI, pow
#include <sstream>	//stringstream,getline
#include <numeric>	//gcd
#include <deque>	//deque

using namespace std;

int main() {

	int a;
	string S;
	cin >> a >> S;

	if (a < 3200) {
		cout << "red" << endl;
	}
	else {
		cout << S << endl;
	}

	return 0;

}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<bool> ac(n);
    VI wa(n);
    FOR(i, 0, m) {
        int p; string s; cin >> p >> s;
        --p;
        if (s == "AC")ac[p] = true;
        else if (!ac[p])++wa[p];
    }

    int a = 0, w = 0;
    FOR(i, 0, n) {
        if (ac[i]) {
            ++a;
            w += wa[i];
        }
    }
    cout << a << " " << w << "\n";
}

Measured memory_bytes: 640
double M[12][4096],r,t;D[12],n;
double dfs(p,f){if(M[p][f]<0){
int i=0;
for(M[p][f]=0;i<n;i++)if(!(f&1<<i)&&(t=dfs(i,f|1<<i)+D[p]+D[i]-2*sqrt(D[p]*D[i]),M[p][f]<t))M[p][f]=t;
}return M[p][f];}
main(l,i,j,d){for(;~scanf("%d",&l);puts(d-r>l?"NA":"OK")){
for(d=n=0;getchar()-10;d+=D[n++]*2)scanf("%d",D+n);
for(i=0;i<n;i++)for(j=0;j<1<<n;j++)M[i][j]=-1;
for(r=i=0;i<n;)t=dfs(i++,1<<i),r=r>t?r:t;
}exit(0);}

Measured memory_bytes: 968
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;
 
 
 
int main() {
    int n;
    scanf("%d",&n);
    if(n==25){
    puts("Christmas");
    }else if(n==24){
    puts("Christmas Eve");
    }else if(n==23){
    puts("Christmas Eve Eve");
    }else if(n==22){
    puts("Christmas Eve Eve Eve");
    }
    return 0;
}
 

 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a,b,c,k] <- getIntList
    let ans | a >= k = k
            | a+b >= k = a
            | otherwise = a - (k-a-b)
    print ans

Measured memory_bytes: 3776
import java.util.Scanner;

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

        int[] result = hoge(n, y);
        System.out.printf("%d %d %d\n", result[0], result[1], result[2]);
    }

    private static int[] hoge(int n, int y) {
        int[] result = {-1, -1 ,-1};

        int s = 0;
        for (int i = 0; i <= 2000; i++) {
            for (int j = 0; j <= 2000; j++) {
                s = y - (10000 * i + 5000 * j);
                if (s < 0) {
                    break;
                }
                if (s/1000 == (n-(i+j))) {
                    result[0] = i;
                    result[1] = j;
                    result[2] = s/1000;
                    return result;
                }
            }
        }
        return result;
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;string S;cin>>N>>S;
  vector<bool> X(26,false);
  vector<bool> Y(26,false);
  int m=0;
  for(int i=1; i<N; i++){
    for(int j=0; j<26; j++){X[j]=false;Y[j]=false;}
    for(int x=0; x<i; x++){
      X[S[x]-'a']=true;
    }
    for(int x=i; x<N; x++){
      Y[S[x]-'a']=true;
    }
    int k=0;
    for(int j=0; j<26; j++){
      if(X[j]&&Y[j])k++;
    }
    m=max(m,k);
  }
  cout<<m<<endl;
}

Measured memory_bytes: 256