akhauriyash/Code-Regression huggingface dataset:
from fractions import gcd

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

lcm = A[0]
for i in range(1,len(A)):
    g = gcd(lcm, A[i])
    lcm = lcm * A[i] // g

f = 0
for a in A:
    f += (lcm-1) % a
print(f)
#max_f = 0
#for i in range(lcm):
#    f = 0
#    for a in A:
#        f += i % a
#    print(i, f)
#    max_f = max(max_f, f)
#print(max_f)


Measured memory_bytes: 5476
import math
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
#エンジンは100しかないからN**2でも間に合うはず

ans = 0
for i in range(100):
  x=math.cos(2*math.pi*i/100)
  y=math.sin(2*math.pi*i/100)
  x1 = 0
  y1 = 0
  for j in range(N):  
    if x * A[j][0] + y * A[j][1] >= 0:
      x1 += A[j][0]
      y1 += A[j][1]
  ans1 = (x1 ** 2 + y1 ** 2 ) ** (1/2)
  ans = max(ans, ans1)
  
print(ans)
#print(A)

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

using namespace std;

int main()
{
	int n = 0;
	cin >> n;
	int mas_v = 0, counter = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> mas_v;
		if (mas_v % 2 == 1 && i % 2 == 1)
		{
			counter++;
		}
	}
	cout << counter << endl;
	return 0;
}

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

int main ()
{
    int A1, A2, A3;
    std::cin >> A1 >> A2 >> A3;

    int num = A1 + A2 + A3;
    if (num >= 22) std::cout << "bust" << std::endl;
    if (num <= 21) std::cout << "win" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int main(void){
    int A, P;
    cin >> A >> P;
    int x = A * 3 + P;
    cout << x / 2 << endl;
}



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

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int j = 0; j < n; j++) cin >> a[j];
  
  for (int j = 0; j < k; j++) {
  	vector<int> b(n+1, 0);
 	for (int i = 0; i < n; i++) {
      int l = max(0, i - a[i]);
      int r = min(n, i + a[i]+1);
   	  b[l]++;
      b[r]--;
    }
    for (int i = 1; i < n; i++) b[i] += b[i-1];
    b.pop_back();
    if (a == b) break;
    a = b;
  }
  
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << endl;
}

Measured memory_bytes: 4840
package main

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

type Node struct {
	Value int
	Left *Node
	Right *Node
	Parent *Node
}

func main() {
	var n int
	fmt.Scan(&n)

	var root *Node

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		sc.Scan()
		command := sc.Text()
		switch command {
		case "print":
			printInorder(wr, root)
			wr.WriteString("\n")
			printPreorder(wr, root)
			wr.WriteString("\n")
		case "insert":
			sc.Scan()
			k, _ := strconv.Atoi(sc.Text())
			root = insert(root, k)
		case "find":
			sc.Scan()
			k, _ := strconv.Atoi(sc.Text())
			if find(root, k) {
				wr.WriteString("yes\n")
			} else {
				wr.WriteString("no\n")
			}
			
		default:
			panic("undefined command")
		}
	}
	wr.Flush()
}

func printPreorder(wr *bufio.Writer, node *Node) {
	if node == nil {
		return
	}
	wr.WriteString(" ")
	wr.WriteString(strconv.Itoa(node.Value))
	printPreorder(wr, node.Left)
	printPreorder(wr, node.Right)
}

func printInorder(wr *bufio.Writer, node *Node) {
	if node == nil {
		return
	}
	printInorder(wr, node.Left)
	wr.WriteString(" ")
	wr.WriteString(strconv.Itoa(node.Value))
	printInorder(wr, node.Right)
}

func insert(root *Node, k int) *Node {
	z := &Node{k, nil, nil, nil}
	if root == nil {
		return z
	}
	
	var x, y *Node
	x = root
	for x != nil {
		y = x
		if k < x.Value {
			x = x.Left
		} else {
			x = x.Right
		}
	}

	z.Parent = y
	if k < y.Value {
		y.Left = z
	} else {
		y.Right = z
	}
	return root
}

func find(node *Node, k int) bool {
	if node == nil {
		return false
	} else if node.Value == k {
		return true
	} else if k < node.Value {
		return find(node.Left, k)
	} else {
		return find(node.Right, k)
	}
}



Measured memory_bytes: 22412
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 7; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            System.out.println(a - b);
        }   
    }
}



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

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void test_case() {
	
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t; 
	cin >> t;
    cout << !t;
	return 0;
}



Measured memory_bytes: 3684
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n, qn;
string s;
int sum[MAXN];

int main() { 

  scanf("%d %d\n", &n, &qn);
  getline(cin, s);

  for (int i = 0; i < n; i++) {
    if (i + 1 < n && s[i] == 'A' && s[i + 1] == 'C') {
      sum[i] = 1;
    }
    if (i > 0) {
      sum[i] += sum[i - 1];
    }
  }

  for (int i = 0; i < qn; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    l--; r--;
    int ans = 0;
    if (r - 1 >= l) {
      ans += sum[r - 1];
    }
    if (l > 0) {
      ans -= sum[l - 1];
    }
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 1536
// Author : heyuhhh
// Created Time : 2020/09/13 20:01:33
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a > b) swap(a, b);
    if (c > d) swap(c, d);
    ll res = max({a * c, b * d, a * d, b * c});
    cout << res << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int n,x,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		ans+=x;
		ans%=2;
	}
	if(ans)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	return 0;
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    if(s.length()!=t.length()){
    	cout << "No"; return 0;
    }
    if(s==t){
    	return cout << "Yes", 0;
    }
    for(int i=1; i<s.length(); i++){
    	s=s.substr(1)+s[0];
    	if(s==t){
    		return cout << "Yes", 0;
    	}
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int n = Integer.parseInt(scanner.nextLine());
    int k = Integer.parseInt(scanner.nextLine());
    int x = Integer.parseInt(scanner.nextLine());
    int y = Integer.parseInt(scanner.nextLine());
    
    if(n>=k){
      System.out.println(k*x + (n-k)*y);
    }
    else{
      System.out.println(n*x);
    }
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int r, c, sum;
        int[][] table;
        Scanner sc = new Scanner(System.in);
        r = sc.nextInt();
        c = sc.nextInt();
        table = new int[r + 1][c + 1];
        for (int i = 0; i < r; i++) {
            sum = 0;
            for (int j = 0; j < c; j++) {
                table[i][j] = sc.nextInt();
                sum += table[i][j];
            }
            table[i][c] = sum;
        }

        for (int i = 0; i < c + 1; i++) 
                table[r][i] = 0;

        for (int i = 0; i < r + 1; i++) {
            for (int j = 0; j < c + 1; j++) {
                System.out.print(table[i][j]);
                table[r][j] += table[i][j];
                if (j != c)
                    System.out.print(" ");
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 40824
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        long minSum = Long.MAX_VALUE;
        boolean isOdd = n % 2 == 1;

        if (isOdd) {
            for (long i = 1; i * i <= n; i += 2) {
                if (n % i == 0) {
                    long sum = n / i + i;
                    if (minSum > sum) {
                        minSum = sum;
                    }
                }
            }
        } else {
            for (long i = 1; i * i <= n; i++) {
                if (n % i == 0) {
                    long sum = n / i + i;
                    if (minSum > sum) {
                        minSum = sum;
                    }
                }
            }
        }

        System.out.println(minSum - 2);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n,k,i=0,s=0;
  cin>>n>>k;
  vector<int> V(n);
  for(i=0;i<n;i++)
    cin>>V[i];
  sort(V.begin(),V.end());
  i=0;
  while(k--)
  {
  	s+=V[i];
  	++i;
  }
  cout<<s;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int n; cin >> n;
    vi ans(n+1);
    repa(x, 1, 101) repa(y, 1, 101) repa(z, 1, 101) {
        int k = x * x + y * y + z * z + x * y + y * z + x * z;
        if(k <= n) ans[k]++;
    }
    repa(i, 1, n+1) cout << ans[i] << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3588
#include<stdio.h>

int d[10]={0};

int han(int k){
	int a;
	while(k>0){
		a=k%10;
		if(d[a]==1) return 0;
		k=(k-a)/10;
	}
	return 1;
}

int main(){
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(int j=1;j<=k;j++){
		scanf("%d",&i);
		d[i]=1;
	}
	
	for(int j=n;;j++){
		if(han(j)==1){ 
			printf("%d",j);
			return 0;
		}
	}

}

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

#define rep(i,a,b) for(int i=(a);i<(b);i++)

int main() {
	for (int n; cin >> n && n;) {
		vector<string> f(n);

		rep(i, 0, n)cin >> f[i];

		int cnt = 0;
		bool l = false, r = false;
		bool u = false;
		rep(i, 0, n) {
			if (f[i] == "lu")
				l = true;
			if (f[i] == "ld")
				l = false;
			if (f[i] == "ru")
				r = true;
			if (f[i] == "rd")
				r = false;
			if (!u && l && r) {
				cnt++;
				u = true;
			}
			else if (u && !l && !r) {
				cnt++;
				u = false;
			}
		}
		cout << cnt << endl;
	}
}


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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,r,l) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll INF = LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MAXN = 1e5+20;
const double EPS= 1e-10;

int n, m, u, v;
vector<int> g[MAXN];
bool seen[MAXN];
int maxi= 0;
int memo[MAXN];

void dfs(int u, int l){
    seen[u]= true;
    forn(i,g[u].size()){
        int k= g[u][i];
        if(!seen[k]) dfs(k,l+1);
        memo[u] = max(memo[u],1 + memo[k]);
    }
    maxi= max(maxi, memo[u]);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<< setprecision(2)<< fixed;
    cin>> n>> m;
    forn(i,m){
        cin>> u>> v;
        g[u-1].pb(v-1);
    }
    forn(i,n){
        if(!seen[i]) dfs(i,0);
    }
    cout<< maxi<<el;
}



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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define MAGIC0
mt19937 rnd(time(0)); //rnd()

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e5 + 7;
const double PI = acos(-1.);
const double EPS = 1e-8;
const int MOD = 998244353;

int main()
{
//	freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	VI x(4);
	FOR(i, 0, 4)
	{
		cin >> x[i];
	}
	sort(ALL(x));
	if (x[0] == 1 && x[1] == 4 && x[2] == 7 && x[3] == 9)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}
// 2 12 216 5280 190800 9344160


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var result uint64
	fmt.Scanf("%d", &n)
	arr := make([]uint64, n)
	for i:=0; i<n; i++ {
		fmt.Scanf("%d", &arr[i])
	}
	sort.Slice(arr, func(i, j int) bool {
		return arr[i] < arr[j]
	})
	result = 1
	toobig := false
	for _,value := range arr {
		if value == 0 {
			fmt.Printf("%d", 0)
			return
		}
		if result > 1e18/value {
			toobig = true
		}
		result *= value
	}
	if toobig || result > 1e18 {
		fmt.Printf("-1")
	} else {
		fmt.Printf("%d", result)
	}
}


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

int main(){
  
  int n,d;
  cin >>n>>d;
  int x[n][d];
  for(int i=0; i<n; i++){
  	for(int j=0; j<d; j++){
    	cin >> x[i][j];
    }
  }
  
  int sum=0,count=0;
  for(int i=0; i<n-1; i++){
  	for(int j=i+1; j<n; j++){
    	
    	for(int k=0;k<d; k++){
      		sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      	}
      //cout <<sum <<floor(sqrt(sum))<< endl;
      if(floor(sqrt(sum))*floor(sqrt(sum))==sum) count++;
      sum=0;
    }
  }

  cout << count << endl;
  
}


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

int main(){
    int a[100][100],b[100],c[100],n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
        c[i]+=a[i][j]*b[j];
        }
    }
    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }
    
    
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;



int main(){
 ll n,m,k;
 cin>>n>>m>>k;
 vector< vector<mp> > g(n);
 vector<mp> edge(m);
 vector<ll> leng(m);
 for(ll i=0;i<m;i++){
  ll u,v,c;
  cin>>u>>v>>c;
  u--,v--;
  edge[i] = mp(u,v);
  leng[i] = c;
  g[u].push_back( mp(c,v) );
  g[v].push_back( mp(c,u) );
 }
 
 vector<ll> res(n,inf);
 priority_queue<mp,vector<mp>,greater<mp> > q;

 for(ll i=0;i<k;i++){
  ll s;
  cin>>s;
  s--;
  q.push(mp(0,s) );
 }


 while( !q.empty() ){
  mp now = q.top();
  q.pop();
  ll nn = now.second;
  ll cost = now.first;
  if( res[nn] != inf ) continue;
  res[nn] = cost;
  for(ll i=0;i<g[nn].size();i++){
   ll next = g[nn][i].second;
   ll nec = cost + g[nn][i].first;
   if( res[next] != inf ) continue;
   q.push( mp( nec , next ) );
  }
 }

 ll ans = 0;
 for(auto i:res)  ans = max( ans , i );
 for(ll i=0;i<m;i++){
  ans = max( ans , ( res[edge[i].first] + res[edge[i].second] + 1  + leng[i] )/2 );
 }
 cout<<ans<<endl;




    return 0;
}



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

int main()
{
	while(true)
	{
		int n,m;
		scanf("%d %d", &n, &m);
		if(n==0 && m==0) break;
		int in;
		long long scores[n]={0};
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				scanf("%d", &in);
				scores[j]+=in;
			}
		}
		long long highest=-1;
		for(int i=0;i<n;i++) if(scores[i]>highest) highest = scores[i];
		printf("%lld\n", highest);
	}	
	return 0;
}



Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const int mod = 998244353;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	bitset<300100> can;
	can.set(0);
	for(int i = 0; i <= n; i++) {
		if(can.test(i)) {
			for(int j = 0; j < 6; j++)
				can.set(i+j+100);
		}
	}
	cout << can.test(n);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int left = 0, right = 0;
  for (char c : s) {
    if (c == 'E') right++;
  }

  int ans = 1001001001;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'E') right--;
    if (i > 0 && s[i - 1] == 'W') left++;
    ans = min(ans, right + left);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3936
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.07.07 20:59:42
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    int ret1 = a * n;
    int ret2 = b;
    if (ret1 > ret2) {
        printf("%d\n", ret2);
    } else {
        printf("%d\n", ret1);
    }

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#ifdef DBG_MACRO_NO_WARNING
#include <dbg.h>
#endif
#include <bits/stdc++.h>
#define all(c) c.begin(), c.end()
#define isz(c) (int)c.size()

using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

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

    vector<ii> d(n);

    for (auto &[f, s] : d)
        cin >> f >> s;

    int cnt = 0;
    for (auto [f, s] : d)
    {
        if (f == s)
        {
            cnt++;
        }
        else
        {
            if (cnt >= 3)
            {
                cout << "Yes" << endl;
                return 0;
            }
            cnt = 0;
        }
    }

    if (cnt >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3636
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64
    }
    println!("{}", if B%A==0{A+B}else{B-A});
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        scanner.close();

        int price = N * 800;
        int refund = N / 15 * 200;

        System.out.println(price - refund);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef pair<int,int> P;

struct Graph{
  Graph(int n):E(n),d(n){};
  vector<vector<P>>E;
  vector<int>d;
  void add_edge(int a,int b,int c){
    E[a].push_back({b,c});
  }
  bool bellmanFord(int s){
    int sz=d.size();
    fill(d.begin(),d.end(),INF);
    d[s]=0;
    for(int i=0;i<sz;++i)
      for(int j=0;j<sz;++j)
        for(P& p:E[j])
          if(d[j]!=INF&&d[j]+p.second<d[p.first]){
            d[p.first]=d[j]+p.second;
            if(i==sz-1)return false;
          }
    return true;
  }
};

main(){
  int n,a,b,c,x,y,z,g;
  while(cin>>n,n){
    Graph E(10);
    x=0,z=1e9;
    for(int i=0;i++<n;x=max(x,max(a,b)),E.add_edge(a,b,c),E.add_edge(b,a,c))cin>>a>>b>>c;
    for(int i=0;i<=x;++i){
      E.bellmanFord(i);
      y=0;
      for(int j=0;j<=x;++j)y+=E.d[j];
      if(y<z)z=y,g=i;
    }
    cout<<g<<' '<<z<<endl;
  }
}

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

int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  if(b-a-2*k<0){
    fr(i,b-a+1) cout<<a+i<<endl;
    return 0;
  }
  fr(i,k) cout<<a+i<<endl;
  fr(i,k) cout<<b-k+1+i<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	vector<int> v;
	v.push_back(a);
	v.push_back(b); 
	v.push_back(c);
	sort(v.begin(),v.end());
	if(v[0]==v[1] && v[1]!=v[2])
		cout<<"Yes";
	else if(v[0]!=v[1] && v[1]==v[2])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
R = [x for x in input().split()]#リスト内包表記
R2=R.copy()

def selected_sort(a,n):
    for i in range(0,n-1):#一個前までやれば全てソートが完了する
        minj=i#未ソート部の先頭をminとみなす
        for j in range(i,n):
            if a[j][1]<a[minj][1]:#
                minj=j#最小インデックスの更新
                judge=True#インデックスが更新されたかどうかの判定
        a[i],a[minj]=a[minj],a[i]#最小値と未ソートの先頭をswap
    print(*a)

def bubble_sort(r,n):
    flag=True
    i=0
    count=0
    while flag:
        flag=False
        for i in range(n-1,i,-1):#iは1でとまらないとi-1が-1となってしまう
            if r[i][1]<r[i-1][1]:
                r[i],r[i-1]=r[i-1],r[i]#swap
                count+=1
                flag=True#入れ替える条件があって初めてtrueになる
    print(*r)

def isStable(a,b):
    if R==R2:
        print("Stable")
    else:
        print("Not stable")


bubble_sort(R,n)
print("Stable")

selected_sort(R2,n)
isStable(R,R2)



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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep2(i,a,b) for(ll i=a; i<=b; i++)
#define drep2(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
using ll = long long;

ll calc(ll n)
{
//  ll ans = 0;
//  rep2(i,1,n) {
//    ans += i * (i+1) / 2;
//  }
//  return ans;
  //return  n*(n+1)*(2*n+1)/12 + n*(n+1)/4;
  return n * (n+1) / 2;
}

ll getl(vector<ll> a, ll index, ll* dp, int N) 
{
  if (index == 0) {
    dp[index] = 0;
    return 0;
  } else if (index == 1) {
  }
}

int main()
{
  int N;
  cin >> N;
  vector<ll> a(N);
  rep(i,N)
    cin >> a[i];


  vector<ll> cum(N);
  cum[0] = a[0];

  ll numzero = 0;
  map<ll, ll> aaa;

  rep2(i, 1, N-1)
    cum[i] = cum[i-1]+a[i];
  rep(i,N) {
    //cout << cum[i] << endl;;
  }
  //cout << endl;

  rep(i,N) {
    aaa[ cum[i] ]++;
  }

  ll ans = 0;
  for (auto c : aaa) {
    if (c.first  == 0) {
      ans += calc(c.second);
    }
    else if (c.second > 1) {
      ans += calc(c.second-1);
    }
  }
  cout << ans << endl;


}

Measured memory_bytes: 15872
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        for (int i=l;i<=r;i++){
            if (i%d==0)ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
#define MAX 1000000
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	long long d,x,y;
	cin>>d;
	int ans = 0;
	while(n--)
	{
		cin>>x>>y;
		if(x*x+y*y<=d*d)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int C[110000];

int main(){
  int N,Q,a;
  ll K;
  cin>>N>>K>>Q;

  for(int i=0;i<Q;i++){
    cin>>a;
    C[a]++;
  }

  for(int i=1;i<=N;i++){
    if(K-Q+C[i]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i <= n - 1; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		a[n-1] = a[n-1]/2;
		int sum=0;
		for (int i = 0; i <= n - 1; i++) {
			sum+=a[i];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int k, x;
  	cin >> k >> x;
  	for (int i = -1000000; i <= 1000000; i++)
		if(abs(i - x) < k)
        	cout << i << " ";
  	cout << endl;
  	return 0;
} 

Measured memory_bytes: 256
import math

num = list(map(int,input().split()))
left = 4*num[0]*num[1]
right = (num[2]-num[1]-num[0])**2
judge = num[2] - num[0] - num[1]
sign = 1
if judge <= 0:
  sign = 0

if (left < right) and sign == 1:
  ans = 'Yes'
else:
  ans = 'No'
  
print(ans)

Measured memory_bytes: 3064
n = gets().to_i
a = Array.new(n+1,0)
for i in 1..n
	a[i] = gets().to_i
end

count = 0
j = a[1]
stop = 0
if j==2
	count = 1
	stop = 1
end
while stop==0
	j = a[j]
	if j == 2
		count+= 1
		stop = 1
	end
	count += 1
	if count > n
		count = -1
		stop = 1
	end
end

print(count,"\n")

Measured memory_bytes: 2812
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct edge{
  int v,w;
};

vector<int> minimum_spanning_arborescence(const vector<vector<edge> > &G,int root){
  const int INF=1<<29;
  const int N=G.size();
  // cout<<"N = "<<N<<endl;
  // for(int i=0;i<N;i++){
  //   for(auto e:G[i]){
  //     cout<<i<<' '<<e.v<<' '<<e.w<<endl;
  //   }
  // }

  vector<int> prev(N,-1),weight(N,INF);
  for(int i=0;i<N;i++){
    for(auto e:G[i]){
      if(e.v!=root&&e.w<weight[e.v]){
	weight[e.v]=e.w;
	prev[e.v]=i;
      }
    }
  }
  vector<int> check(N,N);
  vector<int> cycle;
  vector<char> in_cycle(N);
  for(int i=0;i<N;i++){
    for(int j=i;j>=0;){
      if(check[j]<i)break;
      if(check[j]==i){
	for(int k=j;;){
	  cycle.push_back(k);
	  in_cycle[k]=true;
	  k=prev[k];
	  if(k==j)goto found;
	}
      }
      check[j]=i;
      j=prev[j];
    }
  }
  return prev;
 found:
  int nN=N-cycle.size()+1;
  vector<int> newv(N),oldv(N);
  for(int i=0,idx=0;i<N;i++){
    if(!in_cycle[i]){
      oldv[idx]=i;
      newv[i]=idx++;
    }else{
      newv[i]=nN-1;
    }
  }
  vector<vector<edge> > nG(nN);
  vector<int> in(N,-1),out(N,-1);
  vector<int> in_val(N,INF),out_val(N,INF);
  for(int i=0;i<N;i++){
    for(auto e:G[i]){
      int nc=e.w-weight[e.v];
      if(!in_cycle[i]){
	if(!in_cycle[e.v]){
	  nG[newv[i]].push_back({newv[e.v],nc});
	}else{
	  if(nc<in_val[i]){
	    in_val[i]=nc;
	    in[i]=e.v;
	  }
	}
      }else{
	if(!in_cycle[e.v]){
	  if(nc<out_val[e.v]){
	    out_val[e.v]=nc;
	    out[e.v]=i;
	  }
	}
      }
    }
  }
  for(int i=0;i<N;i++){
    if(in_val[i]<INF){
      nG[newv[i]].push_back({nN-1,in_val[i]});
    }
    if(out_val[i]<INF){
      nG[nN-1].push_back({newv[i],out_val[i]});
    }
  }
  auto r=minimum_spanning_arborescence(nG,newv[root]);
  vector<int> rv(N);
  for(int i=0;i<nN-1;i++){
    if(r[i]<0){
      rv[oldv[i]]=r[i];
    }else if(r[i]<nN-1){
      rv[oldv[i]]=oldv[r[i]];
    }else{
      rv[oldv[i]]=out[oldv[i]];
    }
  }
  int v_into_cycle=oldv[r[nN-1]];
  int v_in_cycle=in[v_into_cycle];
  rv[v_in_cycle]=v_into_cycle;
  int x=prev[v_in_cycle];
  for(int i=0;i<cycle.size()-1;i++){
    rv[x]=prev[x];
    x=prev[x];
  }
  return rv;
}

int main(){
  int V,E,r;
  cin>>V>>E>>r;
  vector<vector<edge> > G(V);
  for(int i=0;i<E;i++){
    int s,t,w;
    cin>>s>>t>>w;
    G[s].push_back({t,w});
  }
  auto msa=minimum_spanning_arborescence(G,r);
  for(auto e:msa){
    //    cout<<e<<endl;
  }
  int ans=0;
  for(int i=0;i<G.size();i++){
    for(auto e:G[i]){
      if(msa[e.v]==i){
	ans+=e.w;
      }
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e5+5;
const int mxM = 1e5+5;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif


    int n;
    cin>>n;
    
    vvi dp(n+1,vi(3));
    vvi c(n+1,vi(3));

    for(int i=0;i<n;i++){
        cin>>c[i][0]>>c[i][1]>>c[i][2];    
    }

    //the only important thing here is what activity out of three(0,1,2) we did on the last day.hence
    //dp[i][j] = total cost such that we did activity j on day i. 


    for(int i=0;i<3;i++) dp[0][i] = c[0][i];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k) dp[i][k] = max(dp[i][k],dp[i-1][j] + c[i][k]);
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 14028
#include <iostream>
#include <stdio.h>

#define PI 3.14159265359
using namespace std;


int main(){

	double r;
	double S, L;

	cin >> r;

	S = PI*r*r;
	L = 2 * PI*r;

	printf("%.8lf", S);
	cout << " ";
	printf("%.8lf\n", L);



	return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


int main() {
    // input
    ll K, A, B;
    cin >> K >> A >> B;

    // process
    ll biscuit = 1;

    if (A + 2 >= B) {
        biscuit += K;
    } else {
        biscuit = A;
        K -= A - 1;
        if (K % 2 == 0) {
            biscuit += (B - A) * K / 2;
        } else if (K % 2 == 1 && K > 2) {
            biscuit += (B - A) * (K - 1) / 2;
            biscuit++;
        } else {
            biscuit++;
        }
    }

    cout << biscuit << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int BASE = 1000000007;
	int N,M;

	private void solve() {
		// input

		Scanner io = new Scanner(System.in);
		N = io.nextInt();
		M = io.nextInt();
		int pat = (Math.abs(N-M)>1)? 0 : 
					(Math.abs(N-M)==1)? 1 : 2; 

		System.out.println((fuc(N)*fuc(M)*pat)%BASE);
	}
	
	private long fuc(long n){
		long ans = 1;
		for(long i=n;i>0;i--){
			ans = (ans * i)%BASE;
		}
		return ans;
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 21844
using System;
class Program
{
    static void Main(string[] args)
    {
        // 解
        int ans = 0;

        // 入力
        string[] inp = Console.ReadLine().Split(' ');
        int a = int.Parse(inp[0]);
        int b = int.Parse(inp[1]);
        int c = int.Parse(inp[2]);

        int cnt = 0;
        for (int i = 100; i >= 1; i--)
        {
            if ((a % i == 0) && (b % i == 0))
            {
                cnt++;
            }
            if (cnt == c)
            {
                ans = i;
                break;
            }
        }
        //出力
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
use proconio::fastout;
use proconio::input;
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input!(n: usize, town: [(Usize1, Usize1); n]);

    let mut idx = vec![0; n];
    for i in 0..n {
        idx[town[i].0] = i
    }

    let mut col = vec![0; n];
    let mut siz = vec![0; n];
    let mut cnt = 0;
    let mut min = n + 1;
    for i in 0..n {
        let (_, y) = town[idx[i]];
        if min == n - i {
            cnt += 1;
        }
        min = min.min(y);
        col[idx[i]] = cnt;
        siz[cnt] += 1;
    }

    for i in 0..n {
        println!("{}", siz[col[i]])
    }
}


Measured memory_bytes: 11044
#include<bits/stdc++.h>
#define N 500009
using namespace std;

int n,pw[9],a[N],b[N]; char ch[N];
bool check(int x){
	int i,k=0,now=0;
	for (i=1; i<=n+k; i++) a[i]=b[i];
	for (i=x; i; i/=10) k++;
	for (i=1; i<k; i++) now+=pw[i-1]*a[i];
	for (i=k; i<=n+k; i++){
		now=now+pw[k-1]*a[i];
		for (; now<0; now+=pw[k]) a[i+1]--;
		if (x%10>=now%10) x=x/10*10+now%10;
		else{
			if (x<10) return 0;
			x=(x/10-1)*10+now%10;
		}
		now=(now-x)/10;
	}
	return 1;
}
int main(){
	scanf("%s",ch+1); n=strlen(ch+1);
	int i;
	for (i=pw[0]=1; i<=7; i++) pw[i]=pw[i-1]*10;
	for (i=1; i<=n; i++) b[i]=ch[n-i+1]-'0';
	int l=1,r=n*9,mid;
	while (l<r){
		mid=l+r>>1;
		if (check(mid)) r=mid; else l=mid+1;
	}
	printf("%d\n",(l-1)/9+1);
	return 0;
}


Measured memory_bytes: 4736
using System;
using System.Text;

namespace ALDS1_4_C {
    class Problem {
        bool[] _memo = new bool[244140625];

        public void Run() {
            int n = int.Parse(Console.ReadLine());
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < n; i++) {
                string[] input = Console.ReadLine().Split(' ');
                if (input[0][0] == 'i')
                    Insert(input[1]);
                else
                    sb.AppendLine(Find(input[1]) ? "yes" : "no");
            }
            Console.Write(sb);
        }

        private void Insert(string source) {
            _memo[Convert(source)] = true;
        }
        private bool Find(string source) {
            return _memo[Convert(source)];
        }

        private int Convert(string source) {
            int ret = 0;
            for (int i = 0; i < source.Length; i++) {
                ret = ret * 5 + CharToInt(source[i]);
            }
            return ret;
        }

        private int CharToInt(char ch) {
            switch (ch) {
                case 'A':
                    return 1;
                case 'C':
                    return 2;
                case 'G':
                    return 3;
                case 'T':
                    return 4;
            }
            return -1;
        }
    }

    class Program {
        static void Main(string[] args) {
            Problem p = new Problem();
            p.Run();
        }
    }
}

Measured memory_bytes: 374368
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  string s,t;
  for(int i=0;i<n/2;i++){
    char c;
    cin>>c;
    s.push_back(c);
  }
  for(int i=n/2;i<n;i++){
    char c;
    cin>>c;
    t.push_back(c);
  }
  cout<<(s==t?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#define STACK_SIZE 1024
using namespace std;

struct Stack{
    Stack(int stack_size){
        ptr=0;
        stack = new long long[stack_size];
    };
    ~Stack(){
		delete[] stack;
	};

    bool isEmpty(){
        return ptr==0;
    };

    int Size(){
        return ptr;
    };

    void push_back(long long data){
        if(ptr<STACK_SIZE){
            stack[ptr++]=data;
        }
    };

    int pop_back(){
        if(isEmpty()){
            return -1;
        }
        return stack[--ptr];
        
    };
    private:
    int ptr;
    long long *stack;
};

int main(){
    Stack stack(STACK_SIZE);
    while(1) {
        string s;
        cin >> s;
        if (cin.eof()) break;
        if (s[0] == '+') {
            int b = stack.pop_back();
            int a = stack.pop_back();
            stack.push_back(a + b);
        }else if (s[0] == '-') {
            int b = stack.pop_back();
            int a = stack.pop_back();
            stack.push_back(a - b);
        }else if (s[0] == '*') {
            int b = stack.pop_back();
            int a = stack.pop_back();
            stack.push_back(a * b);
        } else{
            stack.push_back(atoi(s.c_str()));
        }
    }
    long long ans = stack.pop_back();
    cout << ans <<endl;
}



Measured memory_bytes: 3188
function main(arg) {
	arg = arg.trim().split('\n');
  	var v = arg[1].split(' ').map(str => parseInt(str, 10)),
        n = arg[0],
        out = 0;
    v = v.sort(function(a, b) {
      return a - b
    });
    out = (v[0] + v[1])/2
  	if (n-1 === 1) {
    	console.log(out);
    } else{
      for (var i = 2; i < n; i++) {
        out += v[i];
        out /= 2;
      }
      console.log(out);
    }
}

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

Measured memory_bytes: 7500
#include<stdio.h>

int main(void){

	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a<b){
	printf("a < b\n");
	}
	else if(a==b){
	printf("a == b\n");
	}
	else{
	printf("a > b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int Num[11];

int N, K;
int Flag;
int Min;

void DFS(int d, int s);

int main(void) {
	int i, tmp, m, min;

	Min = 987654321;
	scanf("%d %d", &N, &K);
	for (i = 0; i < 10; i++) {
		scanf("%d", &tmp);
		Num[tmp] = 1;
	}
	
	for (m = 1; Num[m]; m++);

	if (Num[0] == 0) min = m * 10000;
	else min = (m * 10000) + (m * 1000) + (m * 100) + (m * 10) + m;

	DFS(1, 0);

	if (Min != 987654321) printf("%d\n", Min);
	else printf("%d\n", min);
	
	return 0;
}

void DFS(int d, int s) {
	int i;
	
	if (Flag || s >= Min || d > 4) return;

	s *= 10;
	for (i = 0; i < 10; i++)
	{
		if (Num[i]) continue;
		s += i;
		if (s == N) { Flag = 1; Min = s; return; }
		else if (s > N && s < Min) Min = s;
		DFS(d + 1, s);
		s -= i;
	}
}

Measured memory_bytes: 128
N = int(input())
b = [int(s) for s in input().split()]
a = int(0)

if N == 1 or N == 2:
  print("0")
else:
  for i in range(N-2):
    for k in range(int(i)+1, N-1):
      for h in range(int(k)+1, N):
        if b[i] != b[k] and b[i] != b[h] and b[k] != b[h]:
          if b[i] + b[k] + b[h] - max([b[i], b[k], b[h]]) > max([b[i], b[k], b[h]]):
            a = a+1
          else:
            pass
        else:
          pass
  print(a)

Measured memory_bytes: 9176
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
 *
 * @author anand.oza
 */
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);
        AFairness solver = new AFairness();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFairness {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong(), b = in.nextLong(), c = in.nextLong();
            long k = in.nextLong();

            long answer = a - b;
            if (k % 2 == 1) {
                answer *= -1;
            }

            out.println(answer);
        }

    }

    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 long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

int main() {
  int a, b, t;
  cin >> a >> b;
  t = min(a, b);
  if(t == a) {
    for(int i = 0;i < b;++i) {
      cout << a;
    }
  } else {
    for(int i = 0;i < a;++i) {
      cout << b;
    }
  }
}

Measured memory_bytes: 3560
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
long long a[300007];
int num[300007][67];
long long sum0[67],sum1[67],presolve[67];
const long long mod = 1e9+7;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    for(int i=1;i<=n;++i){
        long long temp=a[i];
        int cnt=0;
        while(temp){
            if(temp&1)
                num[i][cnt]=1;
            ++cnt;
            temp/=2;
        }
    }
    long long ans=0;
    for(int i=1;i<=n;++i){
        for(int k=0;k<=60;++k){
            if(num[i][k]==0)
                ++sum0[k];
            else
                ++sum1[k];
        }
    }
    long long x=1;
    presolve[0]=1;
    for(int i=1;i<=60;++i){
        x*=2;
        presolve[i]=x;
    }
    for(int i=0;i<=60;++i){
        ans+=(((sum0[i]*sum1[i])%mod)*(presolve[i]%mod))%mod;
        ans%=mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 81152